From 640a60169b0247924bb168af4fbdf193782f2757 Mon Sep 17 00:00:00 2001 From: Doug McLain Date: Fri, 15 Feb 2008 22:27:48 +0000 Subject: [PATCH] Trackfaders git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3068 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/SConscript | 20 +-- gtk2_ardour/editor_mixer.cc | 1 - gtk2_ardour/editor_route_list.cc | 1 + gtk2_ardour/icons/fader_belt_h.png | Bin 0 -> 3320 bytes gtk2_ardour/route_time_axis.cc | 76 +++++++++-- gtk2_ardour/route_time_axis.h | 13 ++ gtk2_ardour/time_axis_view.cc | 9 +- libs/gtkmm2ext/gtkmm2ext/pixfader.h | 18 ++- libs/gtkmm2ext/gtkmm2ext/slider_controller.h | 2 +- libs/gtkmm2ext/pixfader.cc | 127 ++++++++++++------- libs/gtkmm2ext/slider_controller.cc | 8 +- 11 files changed, 196 insertions(+), 79 deletions(-) create mode 100644 gtk2_ardour/icons/fader_belt_h.png diff --git a/gtk2_ardour/SConscript b/gtk2_ardour/SConscript index cfeff7a1aa..a317a6c550 100644 --- a/gtk2_ardour/SConscript +++ b/gtk2_ardour/SConscript @@ -357,13 +357,13 @@ else: } else: font_sizes = { - 'TINY' : '6', - 'SMALLER' : '8', - 'SMALL' : '9', - 'NORMAL' : '10', - 'BIG' : '14', - 'BIGGER' : '16', - 'LARGE' : '18', + 'TINY' : '5', + 'SMALLER' : '6', + 'SMALL' : '7', + 'NORMAL' : '7', + 'BIG' : '8', + 'BIGGER' : '10', + 'LARGE' : '12', 'LARGER' : '24', 'HUGER' : '34', 'MASSIVE' : '60' @@ -464,9 +464,9 @@ env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), ardour_ env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'ardour2_ui_default.conf')) env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'ardour.menus')) env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'ardour-sae.menus')) -env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'ergonomic-us.bindings')) -env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'mnemonic-us.bindings')) -env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'SAE-de.bindings')) +env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'ardour.bindings')) +env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'ardour-sae-ansi.bindings')) +env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'ardour-sae-de.bindings')) # data files env.Alias('install', env.Install(os.path.join(install_prefix, 'share', 'ardour2'), 'splash.png')) env.Alias('install', env.Install(os.path.join(install_prefix, 'share', 'ardour2', 'pixmaps'), pixmap_files)) diff --git a/gtk2_ardour/editor_mixer.cc b/gtk2_ardour/editor_mixer.cc index 8b60d73f69..fc4269f85e 100644 --- a/gtk2_ardour/editor_mixer.cc +++ b/gtk2_ardour/editor_mixer.cc @@ -338,7 +338,6 @@ Editor::session_going_away () editor_mixer_button.set_active(false); editor_mixer_button.set_sensitive(false); /* clear tempo/meter rulers */ - remove_metric_marks (); hide_measures (); clear_marker_display (); diff --git a/gtk2_ardour/editor_route_list.cc b/gtk2_ardour/editor_route_list.cc index ff9d55f3f8..9749c1b0c6 100644 --- a/gtk2_ardour/editor_route_list.cc +++ b/gtk2_ardour/editor_route_list.cc @@ -77,6 +77,7 @@ Editor::handle_new_route (Session::RouteList& routes) if (atv->route()->order_key(N_("editor")) == -1) { atv->route()->set_order_key (N_("editor"), route_display_model->children().size()-1); } + atv->effective_gain_display (); } tv->set_old_order_key (route_display_model->children().size() - 1); diff --git a/gtk2_ardour/icons/fader_belt_h.png b/gtk2_ardour/icons/fader_belt_h.png new file mode 100644 index 0000000000000000000000000000000000000000..3525767560b6acda6d84d2efaa0a5d658aa10d57 GIT binary patch literal 3320 zcmVPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iO7+ z5FQ6c8GhIR000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}000bANkl7Xxlb>GM|NlkbcPcKJb#P)ZQ+a}P36{Sj zK@jenz#QfegBS&gFu5+))$yn6x7_2BCe%)>_Fxv1dEL#79QGS7avaH~xUBkvfvFZ={kRC+?_y_rZ+vpw zH`AG|UnBoH>iZ4{oyZLVnSn-cW&n+w;#vE!KSFF5a=VO9!mPiW44@$#bi_u5&Hx(i znOUx-O~=TL+$aXW9kvPI=tJyux4(m8;6UJp*POAeVeQkBFi+!FmG{tdo91SwKL|a#qI4CvQ9)~Ss?TI46D_( z^v#T%Gje7u<}FsYOXLQ~nbBmK(DV5Wx3|~w8?0EsVEwIKCuP$99=pjvnzy+9z6{to zGv@OdzTaL4Y*>G5w+XNKD{VI`=LVS1Tio6*Wzl8PIfF5ux1w*u+9nHnKA+)sbzK&H z)`dQ#8NQodYBwMw&0DNiOBv5>?d)UrG(F~nle4L(@?x0b_O{|M7~qVyeUEYbL)W^_ zB4)JRdyM0KZHJt&ZTB7z*3JNN1{i4D-(Vbn=qzL~%YR+_9@~feN)}j7qqhBk?f63` zDJv^b{Bit;SfA~5%ILJeZA!0||6KK@pMLr)vs>{gwIBw@?PEB~7efmWFpiIvu``es zEdXn;yGu$f2*5Z#8M_An45lL5#c_Nnshs1u4?A!gR4=u&?cj?d z&y(|Syd9qER;~770Nc$YK)~gq)7`U*2{Zs@<<^bvCekMUfRRpvZmNIxX4po2b95VBOo^v1sQCt= z&BiifnS<=bMk-^F+jJ{njU(h4&drwhgIp$njcY<){`yPxQQd?iR{xrh{b^6Rh^f$K zA}RqdR%MDm z>|d!Y0~nQ>+R$my3AG;gAuhI9^k8P`@6t6XbxNW4VM85K9oGdqRWH}Br_-?Lg!&p) z)}e<*2Y|30cYy*eRIhQ|mo}3}DC@pP2@%`jg1o~*+?jF0w2_pNe7?ZRkJo|g8{2|?Y zM*23abgWRd)MC9}7An9b4-Z3!)%qrepqYiLeHUsfG6+!|Qit{TrQⅈ4pNGpEa~E z_lDGBwO&>_sRj~?dmXS@Ptw)uCSWs5uw}Kr4%n-9~*X0Ve-sVNDyOsT_az0?qR zmSxB)r;c08EKIL!LDfx)jmnzc)IA_&6zla(r8;`gRRhmE>BI=2XD z`wMIzHcA~OXD881!6_MrSIU2``qJmme{?BPAf;X@*{)Qv0E}ViL4-hML;uabW^_s0 z85p<6{e?R2!p1bDUMT2h7dE_r<93}i^cppd_yNZymlva73nxiAgDs32j#dkO)y{w3r77x~XoU;6y{4{SvOq^sJ~BeE0560$t0R8gml z7?T1f4ktbwj zJUUS`R^RuFb0v;I#xMv@ zi69=dJt=jxtwM_!YLt}&y&DFltPY#AoQ!L0S8OggHvt<;SxYq4(HhZrS*WAkEmYRO z&I2&ag@TrdV3x#j8cZIQGHWzD^;oTLq&Nb#Fe43paTyNGQg>j{@4F?kn@U-OW~=oQ z2UZtAiw{!jojm2`pzUTDAMQ&u*y^QvZO>{iBV}EGf$?DzXtnI*GmP7NHK&hu&Xgi% z9aHt@LCZUdoZSt^1p*1zpG$N0unvGWZm>tILu2lCl85lka1>I_U zqkCXlR0^71I&SKa=R?!;?Ej9FF!ciSqdj#K6PuDVzlr=ef8xB2No2*KrF)oPh{>x=Un=ig=r@}xi?Fd)Bz99?=#u6`zqw1D(GV3gND8dLyyy!%PxRT0zCA>67~ZX!H8{N)C&WIog-}dtk9g{QMi`o6QT7Y_PGMWZ^EJ$)L4 zm^iYvs*Hm8aOng9$OoZ_^wPB zhw@<+xKHqS@<~*|@ws3XCLr?BF!F)LE95^{eg6&AgEs RouteTimeAxisView::slider; + +int +RouteTimeAxisView::setup_slider_pix () +{ + slider = ::get_icon ("fader_belt_h"); + return 0; +} RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr rt, Canvas& canvas) : AxisView(sess), @@ -94,9 +104,14 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh size_button (_("h")), // height automation_button (_("a")), visual_button (_("v")), - lm (rt, sess) - + lm (rt, sess), + gain_slider (0), + gain_adjustment (0.781787, 0.0, 1.0, 0.01, 0.1) { + if (slider == 0) { + setup_slider_pix (); + } + lm.set_no_show_all(); lm.setup_meters(50); _has_state = true; @@ -109,6 +124,8 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh destructive_track_mode_item = 0; normal_track_mode_item = 0; + gain_slider = manage (new HSliderController (slider, &gain_adjustment, _route->gain_control(), false)); + ignore_toggle = false; edit_group_button.set_name ("TrackGroupButton"); @@ -150,7 +167,7 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false); rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release)); - controls_table.attach (*rec_enable_button, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); + controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); ARDOUR_UI::instance()->tooltips().set_tip(*rec_enable_button, _("Record")); } @@ -160,10 +177,11 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh _route->input_changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed)); _route->output_changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed)); - controls_table.attach (*mute_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); - controls_table.attach (*solo_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); + controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); + controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); - controls_table.attach (edit_group_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); + controls_table.attach (edit_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); + controls_table.attach (*gain_slider, 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0); ARDOUR_UI::instance()->tooltips().set_tip(*solo_button,_("Solo")); ARDOUR_UI::instance()->tooltips().set_tip(*mute_button,_("Mute")); @@ -187,11 +205,11 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh } else { - controls_table.attach (automation_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND); + controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND); } if (is_track() && track()->mode() == ARDOUR::Normal) { - controls_table.attach (playlist_button, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND); + controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND); } y_position = -1; @@ -213,6 +231,15 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh editor.ZoomChanged.connect (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit)); ColorsChanged.connect (mem_fun (*this, &RouteTimeAxisView::color_handler)); + + gain_slider->signal_button_press_event().connect (mem_fun(*this, &RouteTimeAxisView::start_gain_touch)); + gain_slider->signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::end_gain_touch)); + gain_slider->set_name ("TrackGainFader"); + + gain_adjustment.signal_value_changed().connect (mem_fun(*this, &RouteTimeAxisView::gain_adjusted)); + _route->gain_changed.connect (mem_fun(*this, &RouteTimeAxisView::gain_changed)); + + gain_slider->show_all(); } RouteTimeAxisView::~RouteTimeAxisView () @@ -1862,3 +1889,36 @@ RouteTimeAxisView::io_changed (IOChange change, void *src) { reset_meter (); } + +gint +RouteTimeAxisView::start_gain_touch (GdkEventButton* ev) +{ + _route->start_gain_touch (); + return FALSE; +} + +gint +RouteTimeAxisView::end_gain_touch (GdkEventButton* ev) +{ + _route->end_gain_touch (); + return FALSE; +} + +void +RouteTimeAxisView::gain_adjusted () +{ + _route->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this); +} + +void +RouteTimeAxisView::gain_changed (void *src) +{ + Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::effective_gain_display)); +} + +void +RouteTimeAxisView::effective_gain_display () +{ + gfloat value = gain_to_slider_position (_route->effective_gain()); + gain_adjustment.set_value (value); +} diff --git a/gtk2_ardour/route_time_axis.h b/gtk2_ardour/route_time_axis.h index 4159969073..211ab8c2ce 100644 --- a/gtk2_ardour/route_time_axis.h +++ b/gtk2_ardour/route_time_axis.h @@ -27,8 +27,10 @@ #include #include #include +#include #include +#include #include #include @@ -108,6 +110,7 @@ public: void clear_meter (); void io_changed (ARDOUR::IOChange, void *); void meter_changed (void *); + void effective_gain_display (); protected: friend class StreamView; @@ -255,6 +258,16 @@ protected: void post_construct (); LevelMeter lm; + + Gtkmm2ext::HSliderController *gain_slider; + Gtk::Adjustment gain_adjustment; + static Glib::RefPtr slider; + static int setup_slider_pix (); + void gain_adjusted(); + + gint start_gain_touch (GdkEventButton*); + gint end_gain_touch (GdkEventButton*); + void gain_changed (void *); }; #endif /* __ardour_route_time_axis_h__ */ diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index ecfeccff59..316d46e113 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -72,7 +72,7 @@ bool TimeAxisView::need_size_info = true; TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisView* rent, Canvas& canvas) : AxisView (sess), editor (ed), - controls_table (2, 7) + controls_table (2, 8) { if (need_size_info) { compute_controls_size_info (); @@ -126,7 +126,7 @@ TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisVie controls_table.set_col_spacings (0); controls_table.set_homogeneous (true); - controls_table.attach (name_hbox, 0, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 3, 0); + controls_table.attach (name_hbox, 0, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 3, 0); controls_table.show_all (); controls_table.set_no_show_all (); @@ -146,6 +146,7 @@ TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisVie controls_frame.add (controls_hbox); controls_frame.set_name ("TimeAxisViewControlsBaseUnselected"); + controls_vbox.set_name ("TimeAxisViewControlsBaseUnselected"); controls_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT); ColorsChanged.connect (mem_fun (*this, &TimeAxisView::color_handler)); @@ -562,7 +563,7 @@ TimeAxisView::set_selected (bool yn) if (_selected) { controls_ebox.set_name (controls_base_selected_name); controls_frame.set_name (controls_base_selected_name); - + controls_vbox.set_name (controls_base_selected_name); /* propagate any existing selection, if the mode is right */ if (editor.current_mouse_mode() == Editing::MouseRange && !editor.get_selection().time.empty()) { @@ -572,7 +573,7 @@ TimeAxisView::set_selected (bool yn) } else { controls_ebox.set_name (controls_base_unselected_name); controls_frame.set_name (controls_base_unselected_name); - + controls_vbox.set_name (controls_base_unselected_name); hide_selection (); /* children will be set for the yn=true case. but when deselecting diff --git a/libs/gtkmm2ext/gtkmm2ext/pixfader.h b/libs/gtkmm2ext/gtkmm2ext/pixfader.h index 5d0476681b..519e1c9e1e 100644 --- a/libs/gtkmm2ext/gtkmm2ext/pixfader.h +++ b/libs/gtkmm2ext/gtkmm2ext/pixfader.h @@ -30,7 +30,7 @@ namespace Gtkmm2ext { class PixFader : public Gtk::DrawingArea { public: - PixFader (Glib::RefPtr belt_image, Gtk::Adjustment& adjustment); + PixFader (Glib::RefPtr belt_image, Gtk::Adjustment& adjustment, int orientation); virtual ~PixFader (); protected: @@ -44,23 +44,29 @@ class PixFader : public Gtk::DrawingArea { bool on_motion_notify_event (GdkEventMotion*); bool on_scroll_event (GdkEventScroll* ev); - private: + enum Orientation { + VERT=1, + HORIZ=2, + }; + + private: Glib::RefPtr pixbuf; - gint pixheight; + int span, girth; + int _orien; GdkRectangle view; GdkWindow* grab_window; - double grab_y; + double grab_loc; double grab_start; int last_drawn; bool dragging; float default_value; - int unity_y; + int unity_loc; void adjustment_changed (); - int display_height (); + int display_span (); static int fine_scale_modifier; static int extra_fine_scale_modifier; diff --git a/libs/gtkmm2ext/gtkmm2ext/slider_controller.h b/libs/gtkmm2ext/gtkmm2ext/slider_controller.h index 74ff36816b..60c8eef660 100644 --- a/libs/gtkmm2ext/gtkmm2ext/slider_controller.h +++ b/libs/gtkmm2ext/gtkmm2ext/slider_controller.h @@ -38,7 +38,7 @@ class SliderController : public Gtkmm2ext::PixFader { public: SliderController (Glib::RefPtr image, - Gtk::Adjustment* adj, + Gtk::Adjustment* adj, int orientation, PBD::Controllable&, bool with_numeric = true); diff --git a/libs/gtkmm2ext/pixfader.cc b/libs/gtkmm2ext/pixfader.cc index 81560cd06a..72eb597475 100644 --- a/libs/gtkmm2ext/pixfader.cc +++ b/libs/gtkmm2ext/pixfader.cc @@ -35,21 +35,28 @@ int PixFader::fine_scale_modifier = GDK_CONTROL_MASK; int PixFader::extra_fine_scale_modifier = GDK_MOD1_MASK; -PixFader::PixFader (Glib::RefPtr belt, Gtk::Adjustment& adj) +PixFader::PixFader (Glib::RefPtr belt, Gtk::Adjustment& adj, int orientation) + : adjustment (adj), - pixbuf (belt) + pixbuf (belt), + _orien(orientation) { dragging = false; default_value = adjustment.get_value(); last_drawn = -1; - pixheight = pixbuf->get_height(); view.x = 0; view.y = 0; - view.width = pixbuf->get_width(); - view.height = pixheight / 2; - unity_y = (int) rint (view.height - (default_value * view.height)) - 1; + if (orientation == 1) { + view.width = girth = pixbuf->get_width(); + view.height = span = pixbuf->get_height() / 2; + unity_loc = (int) rint (view.height - (default_value * view.height)) - 1; + } else { + view.width = span = pixbuf->get_width () / 2; + view.height = girth = pixbuf->get_height(); + unity_loc = (int) rint (default_value * view.width) - 1; + } add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK|Gdk::SCROLL_MASK); @@ -65,28 +72,37 @@ bool PixFader::on_expose_event (GdkEventExpose* ev) { GdkRectangle intersection; - int dh = display_height (); - int offset_into_pixbuf = (int) floor (view.height / ((float) view.height / dh)); + int srcx, srcy, ds = display_span (); + int offset_into_pixbuf = (int) floor (span / ((float) span / ds)); Glib::RefPtr fg_gc (get_style()->get_fg_gc(get_state())); if (gdk_rectangle_intersect (&view, &ev->area, &intersection)) { + if (_orien == VERT) { + srcx = intersection.x; + srcy = offset_into_pixbuf + intersection.y; + } else { + srcx = offset_into_pixbuf + intersection.x; + srcy = intersection.y; + } get_window()->draw_pixbuf (fg_gc, pixbuf, - intersection.x, offset_into_pixbuf + intersection.y, + srcx, srcy, intersection.x, intersection.y, intersection.width, intersection.height, Gdk::RGB_DITHER_NONE, 0, 0); - get_window()->draw_line (get_style()->get_bg_gc(STATE_ACTIVE), 0, 0, view.width - 1, 0); /* top */ + get_window()->draw_line (get_style()->get_bg_gc(STATE_ACTIVE), 0, 0, view.width - 1, 0); /* top */ get_window()->draw_line (get_style()->get_bg_gc(STATE_ACTIVE), 0, 0, 0, view.height - 1); /* left */ get_window()->draw_line (get_style()->get_bg_gc(STATE_NORMAL), view.width - 1, 0, view.width - 1, view.height - 1); /* right */ get_window()->draw_line (get_style()->get_bg_gc(STATE_NORMAL), 0, view.height - 1, view.width - 1, view.height - 1); /* bottom */ } /* always draw the line */ - - get_window()->draw_line (fg_gc, 1, unity_y, view.width - 2, unity_y); - - last_drawn = dh; + if (_orien == VERT) { + get_window()->draw_line (fg_gc, 1, unity_loc, girth - 2, unity_loc); + } else { + get_window()->draw_line (fg_gc, unity_loc, 1, unity_loc, girth - 2); + } + last_drawn = ds; return true; } @@ -104,8 +120,8 @@ PixFader::on_button_press_event (GdkEventButton* ev) case 1: case 2: add_modal_grab(); - grab_y = ev->y; - grab_start = ev->y; + grab_loc = (_orien == VERT) ? ev->y : ev->x; + grab_start = (_orien == VERT) ? ev->y : ev->x; grab_window = ev->window; dragging = true; break; @@ -120,15 +136,17 @@ PixFader::on_button_press_event (GdkEventButton* ev) bool PixFader::on_button_release_event (GdkEventButton* ev) { - double fract; - + double fract, ev_pos; + + (_orien == VERT) ? ev_pos = ev->y : ev->x; + switch (ev->button) { case 1: if (dragging) { remove_modal_grab(); dragging = false; - if (ev->y == grab_start) { + if (ev_pos == grab_start) { /* no motion - just a click */ @@ -136,7 +154,7 @@ PixFader::on_button_release_event (GdkEventButton* ev) adjustment.set_value (default_value); } else if (ev->state & fine_scale_modifier) { adjustment.set_value (adjustment.get_lower()); - } else if (ev->y < view.height - display_height()) { + } else if (ev_pos < span - display_span()) { /* above the current display height, remember X Window coords */ adjustment.set_value (adjustment.get_value() + adjustment.get_step_increment()); } else { @@ -152,7 +170,7 @@ PixFader::on_button_release_event (GdkEventButton* ev) remove_modal_grab(); dragging = false; - fract = 1.0 - (ev->y / view.height); // inverted X Window coordinates, grrr + fract = 1.0 - (ev_pos / span); // inverted X Window coordinates, grrr fract = min (1.0, fract); fract = max (0.0, fract); @@ -183,18 +201,34 @@ PixFader::on_scroll_event (GdkEventScroll* ev) scale = 0.25; } - switch (ev->direction) { + if (_orien == VERT) { + switch (ev->direction) { - case GDK_SCROLL_UP: - /* wheel up */ - adjustment.set_value (adjustment.get_value() + (adjustment.get_page_increment() * scale)); - break; - case GDK_SCROLL_DOWN: - /* wheel down */ - adjustment.set_value (adjustment.get_value() - (adjustment.get_page_increment() * scale)); - break; - default: - break; + case GDK_SCROLL_UP: + /* wheel up */ + adjustment.set_value (adjustment.get_value() + (adjustment.get_page_increment() * scale)); + break; + case GDK_SCROLL_DOWN: + /* wheel down */ + adjustment.set_value (adjustment.get_value() - (adjustment.get_page_increment() * scale)); + break; + default: + break; + } + } else { + switch (ev->direction) { + + case GDK_SCROLL_RIGHT: + /* wheel right */ + adjustment.set_value (adjustment.get_value() + (adjustment.get_page_increment() * scale)); + break; + case GDK_SCROLL_LEFT: + /* wheel left */ + adjustment.set_value (adjustment.get_value() - (adjustment.get_page_increment() * scale)); + break; + default: + break; + } } return false; } @@ -203,12 +237,11 @@ bool PixFader::on_motion_notify_event (GdkEventMotion* ev) { if (dragging) { - double fract; - double delta; - double scale; - + double fract, delta, scale, ev_pos; + (_orien == VERT) ? ev_pos = ev->y : ev_pos = ev->x; + cerr << "PixFader::on_motion_notify_event() called x:y = " << ev->x << ":" << ev->y; if (ev->window != grab_window) { - grab_y = ev->y; + grab_loc = ev_pos; grab_window = ev->window; return true; } @@ -222,20 +255,23 @@ PixFader::on_motion_notify_event (GdkEventMotion* ev) } else { scale = 1.0; } + cerr << " ev_pos=" << ev_pos << " grab_loc=" << grab_loc; + delta = ev_pos - grab_loc; + grab_loc = ev_pos; - delta = ev->y - grab_y; - grab_y = ev->y; - - fract = (delta / view.height); + fract = (delta / span); fract = min (1.0, fract); fract = max (-1.0, fract); // X Window is top->bottom for 0..Y - fract = -fract; + if (_orien == VERT) { + fract = -fract; + } adjustment.set_value (adjustment.get_value() + scale * fract * (adjustment.get_upper() - adjustment.get_lower())); + cerr << " adj=" << adjustment.get_value() << " fract=" << fract << " delta=" << delta << " scale=" << scale << endl; } return true; @@ -244,14 +280,15 @@ PixFader::on_motion_notify_event (GdkEventMotion* ev) void PixFader::adjustment_changed () { - if (display_height() != last_drawn) { + if (display_span() != last_drawn) { queue_draw (); } } int -PixFader::display_height () +PixFader::display_span () { float fract = (adjustment.get_upper() - adjustment.get_value ()) / ((adjustment.get_upper() - adjustment.get_lower())); - return (int) floor (view.height * (1.0 - fract)); + return (_orien == VERT) ? (int)floor (span * (1.0 - fract)) : (int)floor (span * fract); } + diff --git a/libs/gtkmm2ext/slider_controller.cc b/libs/gtkmm2ext/slider_controller.cc index 3e2b42f409..93dfb27ae2 100644 --- a/libs/gtkmm2ext/slider_controller.cc +++ b/libs/gtkmm2ext/slider_controller.cc @@ -29,11 +29,11 @@ using namespace Gtkmm2ext; using namespace PBD; SliderController::SliderController (Glib::RefPtr image, - Gtk::Adjustment *adj, + Gtk::Adjustment *adj, int orientation, Controllable& c, bool with_numeric) - : PixFader (image, *adj), + : PixFader (image, *adj, orientation), binding_proxy (c), spin (*adj, 0, 2) { @@ -63,7 +63,7 @@ VSliderController::VSliderController (Glib::RefPtr image, Controllable& control, bool with_numeric) - : SliderController (image, adj, control, with_numeric) + : SliderController (image, adj, VERT, control, with_numeric) { if (with_numeric) { spin_frame.add (spin); @@ -79,7 +79,7 @@ HSliderController::HSliderController (Glib::RefPtr image, Controllable& control, bool with_numeric) - : SliderController (image, adj, control, with_numeric) + : SliderController (image, adj, HORIZ, control, with_numeric) { if (with_numeric) { spin_frame.add (spin);