From 2af7bae65d105277872e13b9952c96e22f79651b Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 28 Oct 2009 19:56:00 +0000 Subject: [PATCH] key stroke (left/right arrow) and wheel (left/right, shift-down/up) scrolling in mixer window git-svn-id: http://subversion.ardour.org/svn/ardour2/ardour2/branches/2.0-ongoing@5958 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/mixer_ui.cc | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ gtk2_ardour/mixer_ui.h | 3 +++ 2 files changed, 61 insertions(+) diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index a02466100..e2946f823 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -1478,8 +1478,66 @@ Mixer_UI::pane_allocation_handler (Allocation& alloc, Gtk::Paned* which) } } +void +Mixer_UI::scroll_left () +{ + Adjustment* adj = scroller.get_hscrollbar()->get_adjustment(); + /* stupid GTK: can't rely on clamping across versions */ + scroller.get_hscrollbar()->set_value (max (adj->get_lower(), adj->get_value() - adj->get_step_increment())); +} + +void +Mixer_UI::scroll_right () +{ + Adjustment* adj = scroller.get_hscrollbar()->get_adjustment(); + /* stupid GTK: can't rely on clamping across versions */ + scroller.get_hscrollbar()->set_value (min (adj->get_upper(), adj->get_value() + adj->get_step_increment())); +} + bool Mixer_UI::on_key_press_event (GdkEventKey* ev) { + switch (ev->keyval) { + case GDK_Left: + scroll_left (); + return true; + + case GDK_Right: + scroll_right (); + return true; + + default: + break; + } + return key_press_focus_accelerator_handler (*this, ev); } + +bool +Mixer_UI::on_scroll_event (GdkEventScroll* ev) +{ + switch (ev->direction) { + case GDK_SCROLL_LEFT: + scroll_left (); + return true; + case GDK_SCROLL_UP: + if (ev->state & Keyboard::TertiaryModifier) { + scroll_left (); + return true; + } + return false; + + case GDK_SCROLL_RIGHT: + scroll_right (); + return true; + + case GDK_SCROLL_DOWN: + if (ev->state & Keyboard::TertiaryModifier) { + scroll_right (); + return true; + } + return false; + } + + return false; +} diff --git a/gtk2_ardour/mixer_ui.h b/gtk2_ardour/mixer_ui.h index 1c5ecda85..809e7a759 100644 --- a/gtk2_ardour/mixer_ui.h +++ b/gtk2_ardour/mixer_ui.h @@ -113,12 +113,15 @@ class Mixer_UI : public Gtk::Window void get_window_pos_and_size (); bool on_key_press_event (GdkEventKey*); + bool on_scroll_event (GdkEventScroll*); void pane_allocation_handler (Gtk::Allocation&, Gtk::Paned*); list strips; bool strip_scroller_button_release (GdkEventButton*); + void scroll_left (); + void scroll_right (); void add_strip (ARDOUR::Session::RouteList&); void remove_strip (MixerStrip *); -- 2.11.4.GIT