From 316fca72dbad5bae530816714de52eadc9d7f243 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 26 Mar 2010 21:24:17 +0000 Subject: [PATCH] lots of work to hide prelight from most buttons, etc. etc. etc; increase range of solo boost knob; theme RC files changes need propagating to the light theme, sigh git-svn-id: svn://localhost/ardour2/branches/3.0@6799 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour3_ui_dark.rc.in | 34 +++-- gtk2_ardour/ardour_ui.cc | 5 - gtk2_ardour/canvas-note-event.cc | 2 + gtk2_ardour/midi_region_view.cc | 7 +- gtk2_ardour/monitor_section.cc | 42 ++---- gtk2_ardour/route_ui.cc | 8 +- libs/gtkmm2ext/gtkmm2ext/stateful_button.h | 32 +++-- libs/gtkmm2ext/stateful_button.cc | 155 ++++++++++++++++++++- 8 files changed, 223 insertions(+), 62 deletions(-) diff --git a/gtk2_ardour/ardour3_ui_dark.rc.in b/gtk2_ardour/ardour3_ui_dark.rc.in index 2ec1f56eee..5fd7696bc8 100644 --- a/gtk2_ardour/ardour3_ui_dark.rc.in +++ b/gtk2_ardour/ardour3_ui_dark.rc.in @@ -268,12 +268,14 @@ style "gain_fader" style "track_rec_enable_button" = "small_button" { + fg[ACTIVE] = { 0.0, 0.0, 0.0 } + bg[ACTIVE] = { 1.0, 0.0, 0.0 } } style "track_rec_enable_button_active" = "small_button" { - fg[SELECTED] = { 0.0, 0.0, 0.0 } fg[ACTIVE] = { 0.0, 0.0, 0.0 } + fg[SELECTED] = { 0.0, 0.0, 0.0 } fg[PRELIGHT] = { 0.0, 0.0, 0.0 } fg[NORMAL] = { 0.0, 0.0, 0.0 } @@ -319,6 +321,8 @@ style "mixer_track_rec_enable_button_active" = "track_rec_enable_button_active" style "solo_button" = "small_button" { + bg[ACTIVE] = { 0.66, 0.97, 0.19 } # solo + fg[ACTIVE] = { 0, 0, 0 } } style "solo_button_alternate" = "small_button" @@ -368,8 +372,16 @@ style "mixer_solo_button_active" = "solo_button_active" ythickness = 0 } +style "monitor_section_button" = "small_button" +{ + bg[ACTIVE] = { 1.0, 0, 0 } + fg[ACTIVE] = { 0, 0, 0 } +} + style "mute_button" = "small_button" { + bg[ACTIVE] = { 0.90, 0.89, 0.73 } + fg[ACTIVE] = { 0, 0, 0 } } style "mute_button_alternate" = "small_button" @@ -398,6 +410,13 @@ style "mute_button_active" = "small_button" fg[PRELIGHT] = { 0, 0, 0 } } +style "mixer_mute_button" = "mute_button" +{ + font_name = "@FONT_SMALLER@" + xthickness = 0 + ythickness = 0 +} + style "mixer_mute_button_alternate" = "mute_button_alternate" { font_name = "@FONT_SMALLER@" @@ -419,12 +438,6 @@ style "multiline_combo" = "small_button" ythickness = 0 } -style "mixer_mute_button" = "mute_button" -{ - font_name = "@FONT_SMALLER@" - xthickness = 0 - ythickness = 0 -} style "track_loop_button" = "small_button" { @@ -449,6 +462,8 @@ style "time_button" = "default_button" style "transport_button" { + bg[ACTIVE] = { 0.50, 1.0, 0.50 } + fg[ACTIVE] = { 0, 0, 0 } } style "transport_button_active" @@ -466,6 +481,7 @@ style "transport_button_active" style "transport_rec_button" { + bg[ACTIVE] = { 1.0, 0, 0 } } style "transport_rec_button_active" @@ -1413,7 +1429,7 @@ widget "*MixerCommentButton*" style:highest "very_small_button" widget "*MixerMonoButton*" style:highest "very_small_button" widget "*EditGroupButton" style:highest "very_small_button" widget "*EditGroupButtonLabel" style:highest "very_small_button" -widget "*TransportButton" style:highest "transport_rec_button" +widget "*TransportButton" style:highest "transport_button" widget "*TransportButton-active" style:highest "transport_button_active" widget "*TransportSyncButton" style:highest "transport_button" widget "*TransportSyncButton*" style:highest "transport_button" @@ -1581,6 +1597,8 @@ widget "*MixerStripSelectedFrame" style:highest "selected_strip_frame" widget "*MixerStripFrame" style:highest "base_frame" widget "*HWMonitorButton" style:highest "red_when_active" widget "*HWMonitorButton*" style:highest "red_when_active" +widget "*MonitorSectionButton" style:highest "monitor_section_button" +widget "*MonitorSectionButton*" style:highest "monitor_section_button" widget "*BypassButton" style:highest "red_when_active" widget "*BypassButton*" style:highest "red_when_active" widget "*TransportSoloAlert" style:highest "flashing_alert" diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 4fc36dd0e8..d2ddc0d30c 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -1532,8 +1532,6 @@ ARDOUR_UI::transport_roll () if (!rolling) { _session->request_transport_speed (1.0f); } - - map_transport_state (); } void @@ -1593,8 +1591,6 @@ ARDOUR_UI::toggle_roll (bool with_abort, bool roll_out_of_bounded_mode) _session->request_transport_speed (1.0f); } } - - map_transport_state (); } void @@ -1768,7 +1764,6 @@ ARDOUR_UI::map_transport_state () play_selection_button.set_visual_state (0); auto_loop_button.set_visual_state (0); } - } void diff --git a/gtk2_ardour/canvas-note-event.cc b/gtk2_ardour/canvas-note-event.cc index 958ba3e29a..7fdb931ba9 100644 --- a/gtk2_ardour/canvas-note-event.cc +++ b/gtk2_ardour/canvas-note-event.cc @@ -53,6 +53,8 @@ CanvasNoteEvent::CanvasNoteEvent(MidiRegionView& region, Item* item, CanvasNoteEvent::~CanvasNoteEvent() { + cerr << "Destroying CNE @ " << this << endl; + if (_text) { _text->hide(); delete _text; diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index aec77df8c0..dc70e37a36 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -1757,6 +1757,7 @@ MidiRegionView::add_to_selection (CanvasNoteEvent* ev) } if (_selection.insert (ev).second) { + cerr << "Added CNE to selection, size now " << _selection.size() << endl; ev->selected (true); play_midi_note ((ev)->note()); } @@ -2475,8 +2476,12 @@ MidiRegionView::selection_as_cut_buffer () const { Notes notes; + cerr << "Convert selection of " << _selection.size() << " into a cut buffer\n"; + for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) { - notes.insert (boost::shared_ptr (new NoteType (*((*i)->note().get())))); + NoteType* n = (*i)->note().get(); + cerr << "CNE's note is " << n << endl; + notes.insert (boost::shared_ptr (new NoteType (*n))); } MidiCutBuffer* cb = new MidiCutBuffer (trackview.session()); diff --git a/gtk2_ardour/monitor_section.cc b/gtk2_ardour/monitor_section.cc index e85bbf13ff..9dff4b101b 100644 --- a/gtk2_ardour/monitor_section.cc +++ b/gtk2_ardour/monitor_section.cc @@ -31,37 +31,16 @@ Glib::RefPtr MonitorSection::monitor_actions; Glib::RefPtr MonitorSection::big_knob_pixbuf; Glib::RefPtr MonitorSection::little_knob_pixbuf; -static bool -fixup_prelight (GdkEventCrossing* /* ignored */, GtkWidget* widget) -{ - GtkRcStyle* style = gtk_rc_style_copy (gtk_widget_get_modifier_style (widget)); - int current = gtk_widget_get_state (widget); - - style->fg[GTK_STATE_PRELIGHT] = style->fg[current]; - style->bg[GTK_STATE_PRELIGHT] = style->bg[current]; - - gtk_widget_modify_style(widget, style); - g_object_unref(style); - - return false; -} - -static void -block_prelight (Gtk::Widget& w) -{ - w.signal_enter_notify_event().connect (sigc::bind (sigc::ptr_fun (fixup_prelight), w.gobj()), false); -} - MonitorSection::MonitorSection (Session* s) : AxisView (s) , RouteUI (s) , main_table (2, 3) , _tearoff (0) - , gain_adjustment (1.0, 0.0, 1.0, 0.01, 0.1) + , gain_adjustment (0.781787, 0.0, 1.0, 0.01, 0.1) // initial value is unity gain , gain_control (0) , dim_adjustment (0.2, 0.0, 1.0, 0.01, 0.1) , dim_control (0) - , solo_boost_adjustment (1.0, 1.0, 2.0, 0.01, 0.1) + , solo_boost_adjustment (1.0, 1.0, 3.0, 0.01, 0.1) , solo_boost_control (0) , solo_cut_adjustment (0.0, 0.0, 1.0, 0.01, 0.1) , solo_cut_control (0) @@ -111,7 +90,6 @@ MonitorSection::MonitorSection (Session* s) rude_solo_button.set_name ("TransportSoloAlert"); rude_solo_button.show (); - block_prelight (rude_solo_button); ARDOUR_UI::Blink.connect (sigc::mem_fun (*this, &MonitorSection::solo_blink)); rude_solo_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MonitorSection::cancel_solo), false); @@ -196,6 +174,8 @@ MonitorSection::MonitorSection (Session* s) act->connect_proxy (mono_button); } + cut_all_button.set_name (X_("MixerMuteButton")); + cut_all_button.unset_flags (Gtk::CAN_FOCUS); cut_all_button.set_size_request (50,50); cut_all_button.show (); @@ -205,6 +185,11 @@ MonitorSection::MonitorSection (Session* s) bbox->pack_start (mono_button, true, true); bbox->pack_start (dim_all_button, true, true); + dim_all_button.set_name (X_("MonitorSectionButton")); + dim_all_button.unset_flags (Gtk::CAN_FOCUS); + mono_button.set_name (X_("MonitorSectionButton")); + mono_button.unset_flags (Gtk::CAN_FOCUS); + lower_packer.set_spacing (12); lower_packer.pack_start (*bbox, false, false); lower_packer.pack_start (cut_all_button, false, false); @@ -309,16 +294,17 @@ MonitorSection::ChannelButtonSet::ChannelButtonSet () cut.set_name (X_("MixerMuteButton")); dim.set_name (X_("MixerMuteButton")); solo.set_name (X_("MixerSoloButton")); + invert.set_name (X_("MonitorSectionButton")); gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (cut.gobj()), false); gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (dim.gobj()), false); gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (invert.gobj()), false); gtk_activatable_set_use_action_appearance (GTK_ACTIVATABLE (solo.gobj()), false); - block_prelight (cut); - block_prelight (dim); - block_prelight (solo); - block_prelight (invert); + cut.unset_flags (Gtk::CAN_FOCUS); + dim.unset_flags (Gtk::CAN_FOCUS); + solo.unset_flags (Gtk::CAN_FOCUS); + invert.unset_flags (Gtk::CAN_FOCUS); } void diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index bdbdd11591..62dbd3f2d9 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -109,14 +109,14 @@ RouteUI::init () multiple_solo_change = false; mute_button = manage (new BindableToggleButton ()); - mute_button->set_self_managed (true); + // mute_button->set_self_managed (true); mute_button->set_name ("MuteButton"); mute_button->add (mute_button_label); mute_button_label.show (); UI::instance()->set_tip (mute_button, _("Mute this track"), ""); solo_button = manage (new BindableToggleButton ()); - solo_button->set_self_managed (true); + // solo_button->set_self_managed (true); solo_button->set_name ("SoloButton"); solo_button->add (solo_button_label); solo_button_label.show (); @@ -125,14 +125,14 @@ RouteUI::init () rec_enable_button = manage (new BindableToggleButton ()); rec_enable_button->set_name ("RecordEnableButton"); - rec_enable_button->set_self_managed (true); + // rec_enable_button->set_self_managed (true); rec_enable_button->add (rec_enable_button_label); rec_enable_button_label.show (); UI::instance()->set_tip (rec_enable_button, _("Enable recording on this track"), ""); show_sends_button = manage (new BindableToggleButton ("")); show_sends_button->set_name ("SendAlert"); - show_sends_button->set_self_managed (true); + // show_sends_button->set_self_managed (true); UI::instance()->set_tip (show_sends_button, _("make mixer strips show sends to this bus"), ""); _session->SoloChanged.connect (_session_connections, boost::bind (&RouteUI::solo_changed_so_update_mute, this), gui_context()); diff --git a/libs/gtkmm2ext/gtkmm2ext/stateful_button.h b/libs/gtkmm2ext/gtkmm2ext/stateful_button.h index 1ba8ddf6f5..b69dba83fc 100644 --- a/libs/gtkmm2ext/gtkmm2ext/stateful_button.h +++ b/libs/gtkmm2ext/gtkmm2ext/stateful_button.h @@ -40,42 +40,52 @@ class StateButton int visual_state; bool _self_managed; bool _is_realized; + bool style_changing; + Gtk::StateType state_before_prelight; + bool is_toggle; - virtual std::string get_widget_name() const = 0; - virtual void set_widget_name (const std::string&) = 0; - virtual int get_widget_state() = 0; + virtual std::string get_widget_name() const = 0; + virtual void set_widget_name (const std::string& name) = 0; + virtual Gtk::Widget* get_child_widget () = 0; + + void avoid_prelight_on_style_changed (const Glib::RefPtr& style, GtkWidget* widget); + void avoid_prelight_on_state_changed (Gtk::StateType old_state, GtkWidget* widget); }; class StatefulToggleButton : public StateButton, public Gtk::ToggleButton { public: - StatefulToggleButton() {} - explicit StatefulToggleButton(const std::string &label) : Gtk::ToggleButton (label) {} + StatefulToggleButton(); + explicit StatefulToggleButton(const std::string &label); ~StatefulToggleButton() {} protected: void on_realize (); void on_toggled (); + void on_style_changed (const Glib::RefPtr& style); + void on_state_changed (Gtk::StateType old_state); + Gtk::Widget* get_child_widget (); std::string get_widget_name() const { return get_name(); } void set_widget_name (const std::string& name); - int get_widget_state() { return get_state(); } }; class StatefulButton : public StateButton, public Gtk::Button { public: - StatefulButton() {} - explicit StatefulButton(const std::string &label) : Gtk::Button (label) {} + StatefulButton(); + explicit StatefulButton(const std::string &label); virtual ~StatefulButton() {} - + protected: void on_realize (); - + void on_style_changed (const Glib::RefPtr& style); + void on_state_changed (Gtk::StateType old_state); + + Gtk::Widget* get_child_widget (); std::string get_widget_name() const { return get_name(); } void set_widget_name (const std::string& name); - int get_widget_state() { return get_state(); } }; }; diff --git a/libs/gtkmm2ext/stateful_button.cc b/libs/gtkmm2ext/stateful_button.cc index a4503ed863..ea6abdac43 100644 --- a/libs/gtkmm2ext/stateful_button.cc +++ b/libs/gtkmm2ext/stateful_button.cc @@ -20,6 +20,7 @@ #include #include + #include #include @@ -29,9 +30,14 @@ using namespace Glib; using namespace Gtkmm2ext; using namespace std; -StateButton::StateButton () : visual_state (0), _self_managed (false), _is_realized (false) +StateButton::StateButton () + : visual_state (0) + , _self_managed (false) + , _is_realized (false) + , style_changing (false) + , state_before_prelight (Gtk::STATE_NORMAL) + , is_toggle (false) { - } void @@ -55,8 +61,9 @@ StateButton::set_visual_state (int n) /* relax */ break; case 1: - name += "-active"; + name += "-active"; break; + case 2: name += "-alternate"; break; @@ -67,8 +74,94 @@ StateButton::set_visual_state (int n) visual_state = n; } +void +StateButton::avoid_prelight_on_style_changed (const Glib::RefPtr& /* old_style */, GtkWidget* widget) +{ + /* don't go into an endless recursive loop if we're changing + the style in response to an existing style change. + */ + + if (style_changing) { + return; + } + + if (gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT) { + + /* avoid PRELIGHT: make sure that the prelight colors in this new style match + the colors of the new style in whatever state we were in + before we switched to prelight. + */ + + GtkRcStyle* rcstyle = gtk_widget_get_modifier_style (widget); + GtkStyle* style = gtk_widget_get_style (widget); + + rcstyle->fg[GTK_STATE_PRELIGHT] = style->fg[state_before_prelight]; + rcstyle->bg[GTK_STATE_PRELIGHT] = style->bg[state_before_prelight]; + rcstyle->color_flags[GTK_STATE_PRELIGHT] = (GtkRcFlags) (GTK_RC_FG|GTK_RC_BG); + + style_changing = true; + g_object_ref (rcstyle); + gtk_widget_modify_style (widget, rcstyle); + + Widget* child = get_child_widget(); + if (child) { + gtk_widget_modify_style (GTK_WIDGET(child->gobj()), rcstyle); + } + + g_object_unref (rcstyle); + style_changing = false; + } +} + +void +StateButton::avoid_prelight_on_state_changed (Gtk::StateType old_state, GtkWidget* widget) +{ + GtkStateType state = gtk_widget_get_state (widget); + + if (state == GTK_STATE_PRELIGHT) { + + state_before_prelight = old_state; + + + /* avoid PRELIGHT when currently ACTIVE: + if we just went into PRELIGHT, make sure that the colors + match those of whatever state we were in before. + */ + + GtkRcStyle* rcstyle = gtk_widget_get_modifier_style (widget); + GtkStyle* style = gtk_widget_get_style (widget); + + rcstyle->fg[GTK_STATE_PRELIGHT] = style->fg[old_state]; + rcstyle->bg[GTK_STATE_PRELIGHT] = style->bg[old_state]; + rcstyle->color_flags[GTK_STATE_PRELIGHT] = (GtkRcFlags) (GTK_RC_FG|GTK_RC_BG); + + g_object_ref (rcstyle); + gtk_widget_modify_style (widget, rcstyle); + + Widget* child = get_child_widget (); + + if (child) { + gtk_widget_modify_style (GTK_WIDGET(child->gobj()), rcstyle); + } + + g_object_unref (rcstyle); + + } +} + /* ----------------------------------------------------------------- */ +StatefulToggleButton::StatefulToggleButton () +{ + is_toggle = true; +} + +StatefulToggleButton::StatefulToggleButton (const std::string& label) + : ToggleButton (label) +{ + is_toggle = true; +} + void StatefulToggleButton::on_realize () { @@ -94,13 +187,34 @@ StatefulToggleButton::on_toggled () { if (!_self_managed) { if (get_active()) { - set_visual_state (1); + set_state (Gtk::STATE_ACTIVE); } else { - set_visual_state (0); + set_state (Gtk::STATE_NORMAL); } } } + +void +StatefulToggleButton::on_style_changed (const Glib::RefPtr& style) +{ + avoid_prelight_on_style_changed (style, GTK_WIDGET(gobj())); + Button::on_style_changed (style); +} + +void +StatefulToggleButton::on_state_changed (Gtk::StateType old_state) +{ + avoid_prelight_on_state_changed (old_state, GTK_WIDGET(gobj())); + Button::on_state_changed (old_state); +} + +Widget* +StatefulToggleButton::get_child_widget () +{ + return get_child(); +} + void StatefulToggleButton::set_widget_name (const std::string& name) { @@ -112,6 +226,37 @@ StatefulToggleButton::set_widget_name (const std::string& name) } } +/*--------------------------------------------- */ + +StatefulButton::StatefulButton () +{ +} + +StatefulButton::StatefulButton (const std::string& label) + : Button (label) +{ +} + +void +StatefulButton::on_style_changed (const Glib::RefPtr& style) +{ + avoid_prelight_on_style_changed (style, GTK_WIDGET(gobj())); + Button::on_style_changed (style); +} + +void +StatefulButton::on_state_changed (Gtk::StateType old_state) +{ + avoid_prelight_on_state_changed (old_state, GTK_WIDGET(gobj())); + Button::on_state_changed (old_state); +} + +Widget* +StatefulButton::get_child_widget () +{ + return get_child(); +} + void StatefulButton::set_widget_name (const std::string& name) {