Make buttons in track headers behave more like Gtk::MenuToolButton
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Thu, 18 Aug 2016 08:42:43 +0000 (10:42 +0200)
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Thu, 18 Aug 2016 11:24:00 +0000 (13:24 +0200)
Make their popup menus show attached, and on mouse down, but keep the
context menu behavior on middle- and right-click for the group button
that reacted to those (probably an oversight but some users might have
got the habit of right-clicking).

This also makes the group deletion on Ctrl+click happen on mouse down
instead of mouse up which is not a great difference and avoids
complicating the code.

gtk2_ardour/route_time_axis.cc
gtk2_ardour/route_time_axis.h

index 9bf84f8b13e0ce4ce80e05146bbbe54a20821cf9..7e4d4b234aaa352259f80f9a4dfe448780e946cb 100644 (file)
@@ -178,9 +178,9 @@ RouteTimeAxisView::set_route (boost::shared_ptr<Route> rt)
        playlist_button.set_name ("route button");
        automation_button.set_name ("route button");
 
-       route_group_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::route_group_click), false);
-       playlist_button.signal_clicked.connect (sigc::mem_fun(*this, &RouteTimeAxisView::playlist_click));
-       automation_button.signal_clicked.connect (sigc::mem_fun(*this, &RouteTimeAxisView::automation_click));
+       route_group_button.signal_button_press_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::route_group_click), false);
+       playlist_button.signal_button_press_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::playlist_click), false);
+       automation_button.signal_button_press_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::automation_click), false);
 
        if (is_track()) {
 
@@ -379,7 +379,7 @@ RouteTimeAxisView::setup_processor_menu_and_curves ()
        _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
 }
 
-gint
+bool
 RouteTimeAxisView::route_group_click (GdkEventButton *ev)
 {
        if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
@@ -393,9 +393,15 @@ RouteTimeAxisView::route_group_click (GdkEventButton *ev)
        r.push_back (route ());
 
        route_group_menu->build (r);
-       route_group_menu->menu()->popup (ev->button, ev->time);
+       if (ev->button == 1) {
+               Gtkmm2ext::anchored_menu_popup(route_group_menu->menu(),
+                                              &route_group_button,
+                                              "", 1, ev->time);
+       } else {
+               route_group_menu->menu()->popup (ev->button, ev->time);
+       }
 
-       return false;
+       return true;
 }
 
 void
@@ -472,20 +478,31 @@ RouteTimeAxisView::take_name_changed (void *src)
        }
 }
 
-void
-RouteTimeAxisView::playlist_click ()
+bool
+RouteTimeAxisView::playlist_click (GdkEventButton *ev)
 {
+       if (ev->button != 1) {
+               return true;
+       }
+
        build_playlist_menu ();
        conditionally_add_to_selection ();
-       playlist_action_menu->popup (1, gtk_get_current_event_time());
+       Gtkmm2ext::anchored_menu_popup(playlist_action_menu, &playlist_button,
+                                      "", 1, ev->time);
+       return true;
 }
 
-void
-RouteTimeAxisView::automation_click ()
+bool
+RouteTimeAxisView::automation_click (GdkEventButton *ev)
 {
+       if (ev->button != 1) {
+               return true;
+       }
+
        conditionally_add_to_selection ();
        build_automation_action_menu (false);
-       automation_action_menu->popup (1, gtk_get_current_event_time());
+       Gtkmm2ext::anchored_menu_popup(automation_action_menu, &automation_button,
+                                      "", 1, ev->time);
 }
 
 void
index 0634890e515b6f33b84d3d0063d272eb867c966b..825a286360f50c4ccb9c0eda06845e404a4fa283 100644 (file)
@@ -183,7 +183,7 @@ protected:
 
        void update_diskstream_display ();
 
-       gint route_group_click  (GdkEventButton *);
+       bool route_group_click  (GdkEventButton *);
 
        void processors_changed (ARDOUR::RouteProcessorChange);
 
@@ -227,13 +227,13 @@ protected:
 
        void set_align_choice (Gtk::RadioMenuItem*, ARDOUR::AlignChoice, bool apply_to_selection = false);
 
-       void         playlist_click ();
+       bool         playlist_click (GdkEventButton *);
        void         show_playlist_selector ();
        void         playlist_changed ();
 
        void rename_current_playlist ();
 
-       void         automation_click ();
+       bool         automation_click (GdkEventButton *);
 
        virtual void show_all_automation (bool apply_to_selection = false);
        virtual void show_existing_automation (bool apply_to_selection = false);