lots of work to hide prelight from most buttons, etc. etc. etc; increase range of...
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 26 Mar 2010 21:24:17 +0000 (21:24 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 26 Mar 2010 21:24:17 +0000 (21:24 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@6799 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour3_ui_dark.rc.in
gtk2_ardour/ardour_ui.cc
gtk2_ardour/canvas-note-event.cc
gtk2_ardour/midi_region_view.cc
gtk2_ardour/monitor_section.cc
gtk2_ardour/route_ui.cc
libs/gtkmm2ext/gtkmm2ext/stateful_button.h
libs/gtkmm2ext/stateful_button.cc

index 2ec1f56eeea348e9bca723e19d1bcea23c9b771e..5fd7696bc82bb17ac97e4eece85c97e854a5faaa 100644 (file)
@@ -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,34 +410,35 @@ style "mute_button_active" = "small_button"
        fg[PRELIGHT] = { 0, 0, 0 }
 }
 
-style "mixer_mute_button_alternate" = "mute_button_alternate"
+style "mixer_mute_button" = "mute_button"
 {
        font_name = "@FONT_SMALLER@"
        xthickness = 0
        ythickness = 0
 }
 
-style "mixer_mute_button_active" = "mute_button_active"
+style "mixer_mute_button_alternate" = "mute_button_alternate"
 {
        font_name = "@FONT_SMALLER@"
        xthickness = 0
        ythickness = 0
 }
 
-style "multiline_combo" = "small_button"
+style "mixer_mute_button_active" = "mute_button_active"
 {
-       font_name = "@FONT_NORMAL@"
+       font_name = "@FONT_SMALLER@"
        xthickness = 0
        ythickness = 0
 }
 
-style "mixer_mute_button" = "mute_button"
+style "multiline_combo" = "small_button"
 {
-       font_name = "@FONT_SMALLER@"
+       font_name = "@FONT_NORMAL@"
        xthickness = 0
        ythickness = 0
 }
 
+
 style "track_loop_button" = "small_button"
 {
        bg[ACTIVE] = { 1.0, 0.98, 0.53 }
@@ -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"
index 4fc36dd0e8bf8cfc92d32a2191b5eae9e36c7c72..d2ddc0d30c0c90361cd8dfb2a61f828216742c10 100644 (file)
@@ -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
index 958ba3e29aa699836acdc00ad4227894d355cdad..7fdb931ba9fa9e31a70debca4752b45fbac5025b 100644 (file)
@@ -53,6 +53,8 @@ CanvasNoteEvent::CanvasNoteEvent(MidiRegionView& region, Item* item,
 
 CanvasNoteEvent::~CanvasNoteEvent()
 {
+        cerr << "Destroying CNE @ " << this << endl;
+
        if (_text) {
                _text->hide();
                delete _text;
index aec77df8c08a35146a47cc15023ab75177d444ea..dc70e37a369c07efcc2cb7660c4ff7f4e970c8f9 100644 (file)
@@ -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<NoteType> (new NoteType (*((*i)->note().get()))));
+                NoteType* n = (*i)->note().get();
+                cerr << "CNE's note is " << n << endl;
+               notes.insert (boost::shared_ptr<NoteType> (new NoteType (*n)));
        }
 
        MidiCutBuffer* cb = new MidiCutBuffer (trackview.session());
index e85bbf13ff09cefcab51d66e0f255aef26adc5c4..9dff4b101bbaee41747680eb49ad957edfa93718 100644 (file)
@@ -31,37 +31,16 @@ Glib::RefPtr<ActionGroup> MonitorSection::monitor_actions;
 Glib::RefPtr<Gdk::Pixbuf> MonitorSection::big_knob_pixbuf;
 Glib::RefPtr<Gdk::Pixbuf> 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
index bdbdd11591563b860589b568e49c57447907138b..62dbd3f2d9ed988e11882122e0414a05b56334e3 100644 (file)
@@ -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());
index 1ba8ddf6f50bd67d69682f5cbd0ceb43d503485a..b69dba83fce7abb3c7112fa59910a7df79bd1ae5 100644 (file)
@@ -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<Gtk::Style>& 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<Gtk::Style>& 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<Gtk::Style>& 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(); }
 };
 
 };
index a4503ed863c033570d3a317690752bc8ea4a43f9..ea6abdac430f0f6bbbe9c1be2e4a254675d21c96 100644 (file)
@@ -20,6 +20,7 @@
 #include <string>
 #include <iostream>
 
+
 #include <gtkmm/main.h>
 
 #include <gtkmm2ext/stateful_button.h>
@@ -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<Gtk::Style>& /* 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<Gtk::Style>& 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<Gtk::Style>& 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)
 {