size-based scrolling and right-click pages for editor notebook
[ardour.git] / gtk2_ardour / plugin_ui.cc
index 7d1047beb27b783d362182c3cf52d1d8d9ee5762..958654dab5de976a218f7eb7cedf4812a3e93633 100644 (file)
@@ -75,7 +75,7 @@ PluginUIWindow::PluginUIWindow (AudioEngine &engine, PluginInsert& insert, bool
                        VSTPluginUI* vpu = new VSTPluginUI (insert, *vp);
                        
                        _pluginui = vpu;
-                       add (*vpu);
+                       get_vbox()->add (*vpu);
                        vpu->package (*this);
                        
                } else {
@@ -92,10 +92,10 @@ PluginUIWindow::PluginUIWindow (AudioEngine &engine, PluginInsert& insert, bool
                PluginUI*  pu  = new PluginUI (engine, insert, scrollable);
                
                _pluginui = pu;
-               add (*pu);
+               get_vbox()->add (*pu);
                
-               map_event.connect (mem_fun (*pu, &PluginUI::start_updating));
-               unmap_event.connect (mem_fun (*pu, &PluginUI::stop_updating));
+               signal_map_event().connect (mem_fun (*pu, &PluginUI::start_updating));
+               signal_unmap_event().connect (mem_fun (*pu, &PluginUI::stop_updating));
        }
 
        set_position (Gtk::WIN_POS_MOUSE);
@@ -121,6 +121,9 @@ PluginUI::PluginUI (AudioEngine &engine, PluginInsert& pi, bool scrollable)
          engine(engine),
          button_table (initial_button_rows, initial_button_cols),
          output_table (initial_output_rows, initial_output_cols),
+         hAdjustment(0.0, 0.0, 0.0),
+         vAdjustment(0.0, 0.0, 0.0),
+         scroller_view(hAdjustment, vAdjustment),
          automation_menu (0),
          is_scrollable(scrollable)
 {
@@ -230,9 +233,6 @@ PluginUI::build (AudioEngine &engine)
        frame->add (*box);
        hpacker.pack_start(*frame, true, true);
 
-       box->set_border_width (5);
-       box->set_spacing (1);
-       
        /* find all ports. build control elements for all appropriate control ports */
 
        for (i = 0; i < plugin.parameter_count(); ++i) {
@@ -473,11 +473,11 @@ PluginUI::build_control_ui (AudioEngine &engine, guint32 port_index, MIDI::Contr
                        
                        if (defaults && defaults->count > 0)    {
                                
-                               control_ui->combo = new Gtk::Combo;
-                               control_ui->combo->set_value_in_list(true, false);
+                               control_ui->combo = new Gtk::ComboBoxText;
+                               //control_ui->combo->set_value_in_list(true, false);
                                set_popdown_strings (*control_ui->combo, setup_scale_values(port_index, control_ui));
-                               control_ui->combo->signal_unmap_event().connect( mem_fun(*this, &PluginUI::control_combo_changed), control_ui);
-                               plugin.ParameterChanged.connect (bind (mem_fun(*this, &PluginUI::parameter_changed), control_ui));
+                               control_ui->combo->signal_changed().connect (bind (mem_fun(*this, &PluginUI::control_combo_changed), control_ui));
+                               plugin.ParameterChanged.connect (bind (mem_fun (*this, &PluginUI::parameter_changed), control_ui));
                                control_ui->pack_start(control_ui->label, true, true);
                                control_ui->pack_start(*control_ui->combo, false, true);
                                
@@ -550,9 +550,6 @@ PluginUI::build_control_ui (AudioEngine &engine, guint32 port_index, MIDI::Contr
                        control_ui->control->set_style (BarController::LeftToRight);
                        control_ui->control->set_use_parent (true);
 
-                       control_ui->control->get_spin_button().signal_focus_in_event().connect (mem_fun(*this, &PluginUI::entry_focus_event));
-                       control_ui->control->get_spin_button().signal_focus_out_event().connect (mem_fun(*this, &PluginUI::entry_focus_event));
-
                        control_ui->control->StartGesture.connect (bind (mem_fun(*this, &PluginUI::start_touch), control_ui));
                        control_ui->control->StopGesture.connect (bind (mem_fun(*this, &PluginUI::stop_touch), control_ui));
                        
@@ -746,8 +743,8 @@ PluginUI::control_port_toggled (ControlUI* cui)
        }
 }
 
-gint
-PluginUI::control_combo_changed (GdkEventAny* ignored, ControlUI* cui)
+void
+PluginUI::control_combo_changed (ControlUI* cui)
 {
        if (!cui->ignore_change) {
                string value = cui->combo->get_active_text();
@@ -755,7 +752,6 @@ PluginUI::control_combo_changed (GdkEventAny* ignored, ControlUI* cui)
                insert.set_parameter (cui->port_index, mapping[value]);
        }
 
-       return FALSE;
 }
 
 void
@@ -767,17 +763,6 @@ PluginUIWindow::plugin_going_away (ARDOUR::Redirect* ignored)
        delete_when_idle (this);
 }
 
-gint
-PluginUI::entry_focus_event (GdkEventFocus* ev)
-{
-       if (ev->in) {
-               ARDOUR_UI::instance()->allow_focus (true);
-       } else {
-               ARDOUR_UI::instance()->allow_focus (false);
-       }
-       return TRUE;
-}
-
 void
 PluginUI::redirect_active_changed (Redirect* r, void* src)
 {
@@ -786,24 +771,24 @@ PluginUI::redirect_active_changed (Redirect* r, void* src)
        bypass_button.set_active (!r->active());
 }
 
-gint
-PluginUI::start_updating (GdkEventAny *ev)
+bool
+PluginUI::start_updating (GdkEventAny* ignored)
 {
        if (output_controls.size() > 0 ) {
                screen_update_connection.disconnect();
                screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect 
                        (mem_fun(*this, &PluginUI::output_update));
        }
-       return FALSE;
+       return false;
 }
 
-gint 
-PluginUI::stop_updating (GdkEventAny *ev)
+bool
+PluginUI::stop_updating (GdkEventAny* ignored)
 {
        if (output_controls.size() > 0 ) {
                screen_update_connection.disconnect();
        }
-       return FALSE;
+       return false;
 }
 
 void
@@ -840,10 +825,10 @@ PluginUI::output_update ()
        }
 }
 
-list<string> 
+vector<string> 
 PluginUI::setup_scale_values(guint32 port_index, ControlUI* cui)
 {
-       list<string> enums;
+       vector<string> enums;
        LadspaPlugin* lp = dynamic_cast<LadspaPlugin*> (&plugin);
 
        cui->combo_map = new std::map<string, float>;
@@ -869,12 +854,10 @@ PlugUIBase::PlugUIBase (PluginInsert& pi)
          save_button(_("save")),
          bypass_button (_("bypass"))
 {
-       combo.set_value_in_list(true,true);
-       combo.set_use_arrows(true);
-       combo.set_use_arrows_always(true);
+        //combo.set_use_arrows_always(true);
        set_popdown_strings (combo, plugin.get_presets());
        combo.set_active_text ("");
-       combo.signal_unmap_event().connect(mem_fun(*this, &PlugUIBase::setting_selected));
+       combo.signal_changed().connect(mem_fun(*this, &PlugUIBase::setting_selected));
 
        save_button.set_name ("PluginSaveButton");
        save_button.signal_clicked().connect(mem_fun(*this, &PlugUIBase::save_plugin_setting));
@@ -883,8 +866,8 @@ PlugUIBase::PlugUIBase (PluginInsert& pi)
        bypass_button.signal_toggled().connect (mem_fun(*this, &PlugUIBase::bypass_toggled));
 }
 
-gint
-PlugUIBase::setting_selected(GdkEventAny* ignored)
+void
+PlugUIBase::setting_selected()
 {
        if (combo.get_active_text().length() > 0) {
                if (!plugin.load_preset(combo.get_active_text())) {
@@ -892,7 +875,6 @@ PlugUIBase::setting_selected(GdkEventAny* ignored)
                }
        }
 
-       return FALSE;
 }
 
 void
@@ -904,7 +886,7 @@ PlugUIBase::save_plugin_setting ()
        prompter.show_all();
 
        switch (prompter.run ()) {
-       case GTK_RESPONSE_ACCEPT:
+       case Gtk::RESPONSE_ACCEPT:
 
                string name;