From ff50b3780ab688371f1a0f7cb25c92da9b9712d5 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 4 Jul 2016 00:19:13 +0200 Subject: Replace Gtk::ToggleButton with ArdourButton in Generic Plugin GUI --- gtk2_ardour/automation_controller.cc | 4 ++ gtk2_ardour/generic_pluginui.cc | 98 ++++++++--------------------------- gtk2_ardour/plugin_ui.h | 4 +- gtk2_ardour/themes/dark-ardour.colors | 2 + 4 files changed, 28 insertions(+), 80 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/automation_controller.cc b/gtk2_ardour/automation_controller.cc index f8e14595ba..cd76163c6c 100644 --- a/gtk2_ardour/automation_controller.cc +++ b/gtk2_ardour/automation_controller.cc @@ -90,6 +90,10 @@ AutomationController::AutomationController(boost::shared_ptr but->set_controllable(ac); but->signal_clicked.connect( sigc::mem_fun(*this, &AutomationController::toggled)); + const bool active = _adjustment->get_value() >= 0.5; + if (but->get_active() != active) { + but->set_active(active); + } _widget = but; } else if (use_knob) { ArdourKnob* knob = manage (new ArdourKnob (ArdourKnob::default_elements, ArdourKnob::Detent)); diff --git a/gtk2_ardour/generic_pluginui.cc b/gtk2_ardour/generic_pluginui.cc index cba2cc24d9..75efd30e50 100644 --- a/gtk2_ardour/generic_pluginui.cc +++ b/gtk2_ardour/generic_pluginui.cc @@ -340,11 +340,7 @@ GenericPluginUI::build () for (i = 0; i < control_uis.size(); ++i) { ControlUI* cui = control_uis[i]; - if (cui->controller || cui->clickbox || cui->combo) { - // Get all of the controls into a list, so that - // we can lay them out a bit more nicely later. - cui_controls_list.push_back(cui); - } else if (cui->button || cui->file_button) { + if (cui->button || cui->file_button) { if (!is_scrollable && button_row == button_rows) { button_row = 0; @@ -358,6 +354,11 @@ GenericPluginUI::build () FILL|EXPAND, FILL); button_row++; + } else if (cui->controller || cui->clickbox || cui->combo) { + // Get all of the controls into a list, so that + // we can lay them out a bit more nicely later. + cui_controls_list.push_back(cui); + } else if (cui->display) { output_table.attach (*cui, output_col, output_col + 1, output_row, output_row+1, @@ -501,7 +502,7 @@ GenericPluginUI::ControlUI::ControlUI (const Evoral::Parameter& p) ignore_change = 0; display = 0; - button = 0; + button = false; clickbox = 0; meterinfo = 0; } @@ -633,39 +634,6 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter& param, return control_ui; } - if (desc.toggled) { - - /* Build a button */ - - control_ui->button = manage (new ToggleButton ()); - control_ui->button->set_name ("PluginEditorButton"); - control_ui->button->set_size_request (20, 20); - - control_ui->pack_start (control_ui->label, true, true); - control_ui->pack_start (*control_ui->button, false, true); - control_ui->pack_start (control_ui->automate_button, false, false); - - if (mcontrol->flags () & Controllable::NotAutomatable) { - control_ui->automate_button.set_sensitive (false); - set_tooltip(control_ui->automate_button, _("This control cannot be automated")); - } else { - control_ui->automate_button.signal_clicked().connect (bind (mem_fun(*this, &GenericPluginUI::astate_clicked), control_ui)); - mcontrol->alist()->automation_state_changed.connect (control_connections, invalidator (*this), boost::bind (&GenericPluginUI::automation_state_changed, this, control_ui), gui_context()); - } - - control_ui->button->signal_clicked().connect (sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::control_port_toggled), control_ui)); - - mcontrol->Changed.connect (control_connections, invalidator (*this), boost::bind (&GenericPluginUI::toggle_parameter_changed, this, control_ui), gui_context()); - - if (value > 0.5){ - control_ui->button->set_active(true); - } - - automation_state_changed (control_ui); - - return control_ui; - } - if (desc.datatype == Variant::PATH) { /* Build a file selector button */ @@ -703,7 +671,7 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter& param, Adjustment* adj = control_ui->controller->adjustment(); - if (desc.integer_step) { + if (desc.integer_step && !desc.toggled) { control_ui->clickbox = new ClickBox (adj, "PluginUIClickBox", true); Gtkmm2ext::set_size_request_to_display_given_text (*control_ui->clickbox, "g9999999", 2, 2); if (desc.unit == ParameterDescriptor::MIDI_NOTE) { @@ -711,6 +679,8 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter& param, } else { control_ui->clickbox->set_printer (sigc::bind (sigc::mem_fun (*this, &GenericPluginUI::integer_printer), control_ui)); } + } else if (desc.toggled) { + control_ui->controller->set_size_request (req.height, req.height); } else { //sigc::slot pslot = sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::print_parameter), (uint32_t) port_index); @@ -727,7 +697,16 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter& param, */ control_ui->pack_start (control_ui->label, true, true); - if (desc.integer_step) { + + if (desc.toggled) { + control_ui->button = true; + ArdourButton* but = dynamic_cast(control_ui->controller->widget ()); + assert (but); + but->set_name ("pluginui toggle"); + update_control_display(control_ui); + } + + if (desc.integer_step && !desc.toggled) { control_ui->pack_start (*control_ui->clickbox, false, false); } else { control_ui->pack_start (*control_ui->controller, false, false); @@ -863,22 +842,6 @@ GenericPluginUI::set_automation_state (AutoState state, ControlUI* cui) insert->set_parameter_automation_state (cui->parameter(), state); } -void -GenericPluginUI::toggle_parameter_changed (ControlUI* cui) -{ - float val = cui->control->get_value(); - - if (!cui->ignore_change) { - if (val > 0.5) { - cui->button->set_active (true); - cui->button->set_name ("PluginEditorButton-active"); - } else { - cui->button->set_active (false); - cui->button->set_name ("PluginEditorButton"); - } - } -} - void GenericPluginUI::ui_parameter_changed (ControlUI* cui) { @@ -907,12 +870,7 @@ GenericPluginUI::update_control_display (ControlUI* cui) } } } else if (cui->button) { - - if (val > 0.5) { - cui->button->set_active (true); - } else { - cui->button->set_active (false); - } + // AutomationController handles this } if( cui->controller ) { @@ -931,20 +889,6 @@ GenericPluginUI::update_control_display (ControlUI* cui) cui->ignore_change--; } -void -GenericPluginUI::control_port_toggled (ControlUI* cui) -{ - cui->ignore_change++; - const bool active = cui->button->get_active(); - if (active) { - cui->button->set_name ("PluginEditorButton-active"); - } else { - cui->button->set_name ("PluginEditorButton"); - } - insert->automation_control (cui->parameter())->set_value (active, Controllable::NoGroup); - cui->ignore_change--; -} - void GenericPluginUI::control_combo_changed (ControlUI* cui) { diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h index d2e5e21cca..ca855d0571 100644 --- a/gtk2_ardour/plugin_ui.h +++ b/gtk2_ardour/plugin_ui.h @@ -246,10 +246,10 @@ class GenericPluginUI : public PlugUIBase, public Gtk::VBox Gtk::ComboBoxText* combo; boost::shared_ptr scale_points; - Gtk::ToggleButton* button; boost::shared_ptr controller; Gtkmm2ext::ClickBox* clickbox; Gtk::Label label; + bool button; bool update_pending; char ignore_change; Gtk::Button automate_button; @@ -282,9 +282,7 @@ class GenericPluginUI : public PlugUIBase, public Gtk::VBox bool is_input); void ui_parameter_changed (ControlUI* cui); - void toggle_parameter_changed (ControlUI* cui); void update_control_display (ControlUI* cui); - void control_port_toggled (ControlUI* cui); void control_combo_changed (ControlUI* cui); void astate_clicked (ControlUI*); diff --git a/gtk2_ardour/themes/dark-ardour.colors b/gtk2_ardour/themes/dark-ardour.colors index fe698923b6..814613b99b 100644 --- a/gtk2_ardour/themes/dark-ardour.colors +++ b/gtk2_ardour/themes/dark-ardour.colors @@ -337,6 +337,8 @@ + + -- cgit v1.2.3