X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmono_panner.cc;h=daec1eede1c8f8bcc5c04681885637dabd03b414;hb=90ea64d1fc9e64347aca9df8c64ff0aeb674410d;hp=5764c4c137d4c5a0c461a0e7d916fd90d4d770af;hpb=6e79521e8b7709458b8ee093e2d0dc6440ffea2c;p=ardour.git diff --git a/gtk2_ardour/mono_panner.cc b/gtk2_ardour/mono_panner.cc index 5764c4c137..daec1eede1 100644 --- a/gtk2_ardour/mono_panner.cc +++ b/gtk2_ardour/mono_panner.cc @@ -31,14 +31,15 @@ #include "gtkmm2ext/gtk_ui.h" #include "gtkmm2ext/keyboard.h" #include "gtkmm2ext/utils.h" +#include "gtkmm2ext/persistent_tooltip.h" -#include "ardour/panner.h" -#include "ardour/panner.h" #include "ardour/pannable.h" +#include "ardour/panner.h" #include "ardour_ui.h" #include "global_signals.h" #include "mono_panner.h" +#include "mono_panner_editor.h" #include "rgb_macros.h" #include "utils.h" @@ -59,12 +60,12 @@ bool MonoPanner::have_colors = false; MonoPanner::MonoPanner (boost::shared_ptr panner) : PannerInterface (panner) , position_control (_panner->pannable()->pan_azimuth_control) - , dragging (false) , drag_start_x (0) , last_drag_x (0) , accumulated_delta (0) , detented (false) , position_binder (position_control) + , _dragging (false) { if (!have_colors) { set_colors (); @@ -74,6 +75,8 @@ MonoPanner::MonoPanner (boost::shared_ptr panner) position_control->Changed.connect (connections, invalidator(*this), boost::bind (&MonoPanner::value_change, this), gui_context()); ColorsChanged.connect (sigc::mem_fun (*this, &MonoPanner::color_handler)); + + set_tooltip (); } MonoPanner::~MonoPanner () @@ -82,12 +85,8 @@ MonoPanner::~MonoPanner () } void -MonoPanner::set_drag_data () +MonoPanner::set_tooltip () { - if (!_drag_data_label) { - return; - } - double pos = position_control->get_value(); // 0..1 /* We show the position of the center of the image relative to the left & right. @@ -99,10 +98,10 @@ MonoPanner::set_drag_data () */ char buf[64]; - snprintf (buf, sizeof (buf), "L:%3d R:%3d", + snprintf (buf, sizeof (buf), _("L:%3d R:%3d"), (int) rint (100.0 * (1.0 - pos)), (int) rint (100.0 * pos)); - _drag_data_label->set_markup (buf); + _tooltip.set_tip (buf); } bool @@ -248,10 +247,15 @@ MonoPanner::on_expose_event (GdkEventExpose*) bool MonoPanner::on_button_press_event (GdkEventButton* ev) { + if (PannerInterface::on_button_press_event (ev)) { + return true; + } + drag_start_x = ev->x; last_drag_x = ev->x; - dragging = false; + _dragging = false; + _tooltip.target_stop_drag (); accumulated_delta = 0; detented = false; @@ -286,7 +290,8 @@ MonoPanner::on_button_press_event (GdkEventButton* ev) position_control->set_value (0.5); } - dragging = false; + _dragging = false; + _tooltip.target_stop_drag (); } else if (ev->type == GDK_BUTTON_PRESS) { @@ -295,7 +300,8 @@ MonoPanner::on_button_press_event (GdkEventButton* ev) return true; } - dragging = true; + _dragging = true; + _tooltip.target_start_drag (); StartGesture (); } @@ -305,18 +311,19 @@ MonoPanner::on_button_press_event (GdkEventButton* ev) bool MonoPanner::on_button_release_event (GdkEventButton* ev) { + if (PannerInterface::on_button_release_event (ev)) { + return true; + } + if (ev->button != 1) { return false; } - dragging = false; + _dragging = false; + _tooltip.target_stop_drag (); accumulated_delta = 0; detented = false; - if (_drag_data_window) { - _drag_data_window->hide (); - } - if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) { _panner->reset (); } else { @@ -358,12 +365,10 @@ MonoPanner::on_scroll_event (GdkEventScroll* ev) bool MonoPanner::on_motion_notify_event (GdkEventMotion* ev) { - if (!dragging) { + if (!_dragging) { return false; } - show_drag_data_window (); - int w = get_width(); double delta = (ev->x - last_drag_x) / (double) w; @@ -407,10 +412,6 @@ MonoPanner::on_key_press_event (GdkEventKey* ev) step = one_degree * 5.0; } - /* up/down control width because we consider pan position more "important" - (and thus having higher "sense" priority) than width. - */ - switch (ev->keyval) { case GDK_Left: pv -= step; @@ -420,6 +421,10 @@ MonoPanner::on_key_press_event (GdkEventKey* ev) pv += step; position_control->set_value (pv); break; + case GDK_0: + case GDK_KP_0: + position_control->set_value (0.0); + break; default: return false; } @@ -445,3 +450,8 @@ MonoPanner::color_handler () queue_draw (); } +PannerEditor* +MonoPanner::editor () +{ + return new MonoPannerEditor (this); +}