Various UI tweaks.
authorBen Loftis <ben@harrisonconsoles.com>
Tue, 29 Jul 2014 21:40:19 +0000 (16:40 -0500)
committerBen Loftis <ben@harrisonconsoles.com>
Tue, 29 Jul 2014 21:40:19 +0000 (16:40 -0500)
Refactor comments dialog into Route_UI so it can be shared by tracks and strips.
Make Color and Comments selections consistent in the menus
Refine the color displays at the top of each mixer strip
Correctly color the number displays on tracks

gtk2_ardour/mixer_strip.cc
gtk2_ardour/mixer_strip.h
gtk2_ardour/route_time_axis.cc
gtk2_ardour/route_ui.cc
gtk2_ardour/route_ui.h

index 1b6a6558dff973de88c724e06a88ee7144c979a4..7b91611cb018f2506668ff2897534842c6be1a36 100644 (file)
@@ -145,7 +145,6 @@ MixerStrip::init ()
        route_ops_menu = 0;
        ignore_comment_edit = false;
        ignore_toggle = false;
-       comment_window = 0;
        comment_area = 0;
        _width_owner = 0;
        spacer = 0;
@@ -285,35 +284,32 @@ MixerStrip::init ()
        Gtkmm2ext::set_size_request_to_display_given_text (group_button, "Grp", 2, 2);
 
        _comment_button.set_name (X_("mixer strip button"));
-       _comment_button.signal_clicked.connect (sigc::mem_fun (*this, &MixerStrip::toggle_comment_editor));
+       _comment_button.signal_clicked.connect (sigc::mem_fun (*this, &RouteUI::toggle_comment_editor));
 
        global_vpacker.set_border_width (0);
        global_vpacker.set_spacing (0);
 
        width_button.set_name ("mixer strip button");
        hide_button.set_name ("mixer strip button");
-       top_event_box.set_name ("mixer strip button");
 
        width_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::width_button_pressed), false);
        hide_button.signal_clicked.connect (sigc::mem_fun(*this, &MixerStrip::hide_clicked));
 
+       width_hide_box.set_border_width (2);
+       width_hide_box.set_spacing (2);
        width_hide_box.pack_start (width_button, false, true);
-       width_hide_box.pack_start (top_event_box, true, true);
+       width_hide_box.pack_start (number_label, true, true);
        width_hide_box.pack_end (hide_button, false, true);
 
        number_label.set_text ("-");
        number_label.set_no_show_all ();
        number_label.set_name ("tracknumber label");
        number_label.set_fixed_colors (0x80808080, 0x80808080);
-       number_label.set_elements (ArdourButton::Element(ArdourButton::Body | ArdourButton::Text));
        number_label.set_alignment (.5, .5);
-       top_event_box.add (number_label);
-
-       whvbox.pack_start (width_hide_box, true, true);
 
        global_vpacker.set_spacing (2);
        if (!ARDOUR::Profile->get_trx()) {
-               global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
+               global_vpacker.pack_start (width_hide_box, Gtk::PACK_SHRINK);
                global_vpacker.pack_start (button_table, Gtk::PACK_SHRINK);
                global_vpacker.pack_start (processor_box, true, true);
        }
@@ -352,7 +348,7 @@ MixerStrip::init ()
 
        /* ditto for this button and busses */
 
-       number_label.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::name_button_button_press), false);
+       number_label.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::number_button_button_press), false);
        name_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::name_button_button_press), false);
        group_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::select_route_group), false);
 
@@ -416,7 +412,6 @@ MixerStrip::~MixerStrip ()
 
        delete input_selector;
        delete output_selector;
-       delete comment_window;
 }
 
 bool
@@ -625,7 +620,7 @@ MixerStrip::set_route (boost::shared_ptr<Route> rt)
                audio_track()->DiskstreamChanged.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::diskstream_changed, this), gui_context());
        }
 
-       _route->comment_changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::comment_changed, this, _1), gui_context());
+       _route->comment_changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::setup_comment_button, this), gui_context());
        _route->PropertyChanged.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::property_changed, this, _1), gui_context());
 
        set_stuff_from_route ();
@@ -665,10 +660,8 @@ MixerStrip::set_route (boost::shared_ptr<Route> rt)
        gpm.gain_display.show ();
        gpm.peak_display.show ();
 
-       top_event_box.show();
        width_button.show();
        width_hide_box.show();
-       whvbox.show ();
        global_frame.show();
        global_vpacker.show();
        button_table.show();
@@ -1447,79 +1440,6 @@ MixerStrip::setup_comment_button ()
                );
 }
 
-void
-MixerStrip::comment_editor_done_editing ()
-{
-       string const str = comment_area->get_buffer()->get_text();
-       if (str == _route->comment ()) {
-               return;
-       }
-
-       _route->set_comment (str, this);
-       setup_comment_button ();
-}
-
-void
-MixerStrip::toggle_comment_editor ()
-{
-       if (ignore_toggle) {
-               return;
-       }
-
-       if (comment_window && comment_window->is_visible ()) {
-               comment_window->hide ();
-       } else {
-               open_comment_editor ();
-       }
-}
-
-void
-MixerStrip::open_comment_editor ()
-{
-       if (comment_window == 0) {
-               setup_comment_editor ();
-       }
-
-       string title;
-       title = _route->name();
-       title += _(": comment editor");
-
-       comment_window->set_title (title);
-       comment_window->present();
-}
-
-void
-MixerStrip::setup_comment_editor ()
-{
-       comment_window = new ArdourWindow (""); // title will be reset to show route
-       comment_window->set_skip_taskbar_hint (true);
-       comment_window->signal_hide().connect (sigc::mem_fun(*this, &MixerStrip::comment_editor_done_editing));
-       comment_window->set_default_size (400, 200);
-
-       comment_area = manage (new TextView());
-       comment_area->set_name ("MixerTrackCommentArea");
-       comment_area->set_wrap_mode (WRAP_WORD);
-       comment_area->set_editable (true);
-       comment_area->get_buffer()->set_text (_route->comment());
-       comment_area->show ();
-
-       comment_window->add (*comment_area);
-}
-
-void
-MixerStrip::comment_changed (void *src)
-{
-       ENSURE_GUI_THREAD (*this, &MixerStrip::comment_changed, src)
-
-       if (src != this) {
-               ignore_comment_edit = true;
-               if (comment_area) {
-                       comment_area->get_buffer()->set_text (_route->comment());
-               }
-               ignore_comment_edit = false;
-       }
-}
-
 bool
 MixerStrip::select_route_group (GdkEventButton *ev)
 {
@@ -1572,7 +1492,6 @@ void
 MixerStrip::route_color_changed ()
 {
        name_button.modify_bg (STATE_NORMAL, color());
-       top_event_box.modify_bg (STATE_NORMAL, color());
        number_label.set_fixed_colors (gdk_color_to_rgba (color()), gdk_color_to_rgba (color()));
        reset_strip_style ();
 }
@@ -1592,7 +1511,9 @@ MixerStrip::build_route_ops_menu ()
 
        MenuList& items = route_ops_menu->items();
 
-       items.push_back (MenuElem (_("Comments..."), sigc::mem_fun (*this, &MixerStrip::open_comment_editor)));
+       items.push_back (MenuElem (_("Color..."), sigc::mem_fun (*this, &RouteUI::choose_color)));
+
+       items.push_back (MenuElem (_("Comments..."), sigc::mem_fun (*this, &RouteUI::open_comment_editor)));
        if (!_route->is_master()) {
                items.push_back (MenuElem (_("Save As Template..."), sigc::mem_fun(*this, &RouteUI::save_as_template)));
        }
@@ -1642,6 +1563,20 @@ MixerStrip::name_button_button_press (GdkEventButton* ev)
        return false;
 }
 
+gboolean
+MixerStrip::number_button_button_press (GdkEventButton* ev)
+{
+       if (  ev->button == 3 ) {
+               list_route_operations ();
+
+               /* do not allow rename if the track is record-enabled */
+               rename_menu_item->set_sensitive (!_route->record_enabled());
+               route_ops_menu->popup (1, ev->time);
+       }
+
+       return false;
+}
+
 void
 MixerStrip::list_route_operations ()
 {
@@ -1685,18 +1620,15 @@ MixerStrip::name_changed ()
                        const int64_t track_number = _route->track_number ();
                        if (track_number == 0) {
                                number_label.set_text ("-");
-                               number_label.hide();
                        } else {
                                number_label.set_text (PBD::to_string (abs(_route->track_number ()), std::dec));
-                               number_label.show();
                        }
                } else {
-                       number_label.hide();
+                       number_label.set_text ("");
                }
                name_button.set_text (_route->name());
                break;
        case Narrow:
-               number_label.hide();
                if (_session->config.get_track_name_number()) {
                        name_button.set_markup(track_number_to_string (_route->track_number (), " ",
                                                PBD::short_version (_route->name (), 5)));
index f7c7977a535914ffbd8818d491b760ffed2e60fc..517cab08583959c25b98cdd2149b12793d8501e5 100644 (file)
@@ -158,8 +158,6 @@ class MixerStrip : public RouteUI, public Gtk::EventBox
        ArdourButton         width_button;
        ArdourButton         number_label;
        Gtk::HBox           width_hide_box;
-       Gtk::VBox           whvbox;
-       Gtk::EventBox       top_event_box;
        Gtk::EventBox*      spacer;
 
        void hide_clicked();
@@ -201,14 +199,8 @@ class MixerStrip : public RouteUI, public Gtk::EventBox
 
        ArdourButton   name_button;
 
-       ArdourWindow*  comment_window;
-       Gtk::TextView* comment_area;
        ArdourButton   _comment_button;
 
-       void comment_editor_done_editing ();
-       void setup_comment_editor ();
-       void open_comment_editor ();
-       void toggle_comment_editor ();
        void setup_comment_button ();
 
        ArdourButton   group_button;
@@ -255,13 +247,9 @@ class MixerStrip : public RouteUI, public Gtk::EventBox
        Gtk::Menu* route_ops_menu;
        void build_route_ops_menu ();
        gboolean name_button_button_press (GdkEventButton*);
+       gboolean number_button_button_press (GdkEventButton*);
        void list_route_operations ();
 
-       gint comment_key_release_handler (GdkEventKey*);
-       void comment_changed (void *src);
-       void comment_edited ();
-       bool ignore_comment_edit;
-
        bool select_route_group (GdkEventButton *);
        void route_group_changed ();
 
index e524fde94a7e210ad3f92f7c9930f937022a3200..17fe8e7709b0a8f69270eb7abf796e556dadde1a 100644 (file)
@@ -108,7 +108,6 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session* sess, ArdourCan
        , gm (sess, true, 125, 18)
        , _ignore_set_layer_display (false)
 {
-       number_label.set_corner_radius(2);
        number_label.set_name("tracknumber label");
        number_label.set_alignment(.5, .5);
 
@@ -149,7 +148,8 @@ RouteTimeAxisView::set_route (boost::shared_ptr<Route> rt)
        }
 
        mute_changed (0);
-        update_solo_display ();
+       update_solo_display ();
+       route_color_changed();
 
        timestretch_rect = 0;
        no_redraw = false;
@@ -365,7 +365,6 @@ RouteTimeAxisView::update_track_number_visibility ()
                show_label = false;
        }
 
-       //if (show_label == number_label.is_visible()) { return; }
        if (number_label.get_parent()) {
                controls_table.remove (number_label);
        }
@@ -480,6 +479,8 @@ RouteTimeAxisView::build_display_menu ()
 
        items.push_back (MenuElem (_("Color..."), sigc::mem_fun (*this, &RouteUI::choose_color)));
 
+       items.push_back (MenuElem (_("Comments..."), sigc::mem_fun (*this, &RouteUI::open_comment_editor)));
+
        if (_size_menu) {
                detach_menu (*_size_menu);
        }
@@ -961,6 +962,8 @@ RouteTimeAxisView::route_color_changed ()
        if (_view) {
                _view->apply_color (color(), StreamView::RegionColor);
        }
+
+       number_label.set_fixed_colors (gdk_color_to_rgba (color()), gdk_color_to_rgba (color()));
 }
 
 void
index 7802a0dd7b2ea6180b6ecd1d8d9089b7653aaf93..0de1f81dac103a27750f0ae326f525e4ff7f0ef6 100644 (file)
@@ -71,6 +71,7 @@ RouteUI::RouteUI (ARDOUR::Session* sess)
        , solo_menu(0)
        , sends_menu(0)
        , record_menu(0)
+       , comment_window(0)
        , _invert_menu(0)
 {
        if (sess) init ();
@@ -86,6 +87,7 @@ RouteUI::~RouteUI()
        delete sends_menu;
         delete record_menu;
        delete _invert_menu;
+       delete comment_window;
 }
 
 void
@@ -216,6 +218,8 @@ RouteUI::set_route (boost::shared_ptr<Route> rp)
        _route->active_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::route_active_changed, this), gui_context());
        _route->mute_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::mute_changed, this, _1), gui_context());
 
+       _route->comment_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::comment_changed, this, _1), gui_context());
+
        _route->solo_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_solo_display, this), gui_context());
        _route->solo_safe_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_solo_display, this), gui_context());
        _route->listen_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_solo_display, this), gui_context());
@@ -1383,8 +1387,7 @@ RouteUI::toggle_solo_safe (Gtk::CheckMenuItem* check)
        _route->set_solo_safe (check->get_active(), this);
 }
 
-/** Ask the user to choose a colour, and then set all selected tracks
- *  to that colour.
+/** Ask the user to choose a colour, and then apply that color to my route
  */
 void
 RouteUI::choose_color ()
@@ -1393,9 +1396,7 @@ RouteUI::choose_color ()
        Gdk::Color const color = Gtkmm2ext::UI::instance()->get_color (_("Color Selection"), picked, &_color);
 
        if (picked) {
-               ARDOUR_UI::instance()->the_editor().get_selection().tracks.foreach_route_ui (
-                       boost::bind (&RouteUI::set_color, _1, color)
-                       );
+               set_color(color);
        }
 }
 
@@ -1580,6 +1581,79 @@ RouteUI::property_changed (const PropertyChange& what_changed)
        }
 }
 
+void
+RouteUI::toggle_comment_editor ()
+{
+//     if (ignore_toggle) {
+//             return;
+//     }
+
+       if (comment_window && comment_window->is_visible ()) {
+               comment_window->hide ();
+       } else {
+               open_comment_editor ();
+       }
+}
+
+
+void
+RouteUI::open_comment_editor ()
+{
+       if (comment_window == 0) {
+               setup_comment_editor ();
+       }
+
+       string title;
+       title = _route->name();
+       title += _(": comment editor");
+
+       comment_window->set_title (title);
+       comment_window->present();
+}
+
+void
+RouteUI::setup_comment_editor ()
+{
+       comment_window = new ArdourWindow (""); // title will be reset to show route
+       comment_window->set_skip_taskbar_hint (true);
+       comment_window->signal_hide().connect (sigc::mem_fun(*this, &MixerStrip::comment_editor_done_editing));
+       comment_window->set_default_size (400, 200);
+
+       comment_area = manage (new TextView());
+       comment_area->set_name ("MixerTrackCommentArea");
+       comment_area->set_wrap_mode (WRAP_WORD);
+       comment_area->set_editable (true);
+       comment_area->get_buffer()->set_text (_route->comment());
+       comment_area->show ();
+
+       comment_window->add (*comment_area);
+}
+
+void
+RouteUI::comment_changed (void *src)
+{
+       ENSURE_GUI_THREAD (*this, &MixerStrip::comment_changed, src)
+
+       if (src != this) {
+               ignore_comment_edit = true;
+               if (comment_area) {
+                       comment_area->get_buffer()->set_text (_route->comment());
+               }
+               ignore_comment_edit = false;
+       }
+}
+
+void
+RouteUI::comment_editor_done_editing ()
+{
+       string const str = comment_area->get_buffer()->get_text();
+       if (str == _route->comment ()) {
+               return;
+       }
+
+       _route->set_comment (str, this);
+}
+
 void
 RouteUI::set_route_active (bool a, bool apply_to_selection)
 {
index 245101f61627b2cb8a72bcbb2fc8b7b3767313b1..9c2c6618acc3eeb51b940cd44b4ddd0446c154ab 100644 (file)
@@ -25,6 +25,8 @@
 #include "pbd/xml++.h"
 #include "pbd/signals.h"
 
+#include <gtkmm/textview.h>
+
 #include "gtkmm2ext/widget_state.h"
 
 #include "ardour/ardour.h"
@@ -51,6 +53,7 @@ namespace Gtk {
 
 class BindableToggleButton;
 class ArdourButton;
+class ArdourWindow;
 
 class RouteUI : public virtual AxisView
 {
@@ -227,7 +230,21 @@ class RouteUI : public virtual AxisView
         */
        static PBD::Signal1<void, boost::shared_ptr<ARDOUR::Route> > BusSendDisplayChanged;
 
+       void comment_editor_done_editing ();
+       void setup_comment_editor ();
+       void open_comment_editor ();
+       void toggle_comment_editor ();
+
+       gint comment_key_release_handler (GdkEventKey*);
+       void comment_changed (void *src);
+       void comment_edited ();
+       bool ignore_comment_edit;
+
    protected:
+
+       ArdourWindow*  comment_window;
+       Gtk::TextView* comment_area;
+
        PBD::ScopedConnectionList route_connections;
        bool self_destruct;