summaryrefslogtreecommitdiff
path: root/gtk2_ardour/stereo_panner.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-12-30 19:58:36 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-12-30 19:58:36 +0000
commitf151d8231d6fcaa4a7ecf260179b71317681b41f (patch)
tree6bef6feb5d7c7a291ae665baacdacb214fb9d3a2 /gtk2_ardour/stereo_panner.cc
parent742cb78a917915c9e5a2b350a74ed92de956124e (diff)
better dbl click behaviour for stereo panner: width max is constrained by position; pos max is constrained by width
git-svn-id: svn://localhost/ardour2/branches/3.0@8393 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/stereo_panner.cc')
-rw-r--r--gtk2_ardour/stereo_panner.cc44
1 files changed, 33 insertions, 11 deletions
diff --git a/gtk2_ardour/stereo_panner.cc b/gtk2_ardour/stereo_panner.cc
index 073a52ce3b..86cb794f7b 100644
--- a/gtk2_ardour/stereo_panner.cc
+++ b/gtk2_ardour/stereo_panner.cc
@@ -294,6 +294,10 @@ StereoPanner::on_button_press_event (GdkEventButton* ev)
accumulated_delta = 0;
detented = false;
+ if (ev->button != 1) {
+ return false;
+ }
+
if (ev->type == GDK_2BUTTON_PRESS) {
int width = get_width();
@@ -303,32 +307,46 @@ StereoPanner::on_button_press_event (GdkEventButton* ev)
}
if (ev->y < 20) {
- /* lower section: adjusts position, constrained by width */
+
+ /* upper section: adjusts position, constrained by width */
- if (ev->x >= width/2 - 10 && ev->x <= width/2 + 10) {
- /* double click near center, reset position to center */
- position_control->set_value (0.5);
- } else {
- if (ev->x < width/2) {
- /* double click on left, collapse to hard left */
+ const double w = width_control->get_value ();
+ const double max_pos = 1.0 - (w/2.0);
+ const double min_pos = w/2.0;
+
+ if (ev->x <= width/3) {
+ /* left side dbl click */
+ if (Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier)) {
+ /* 2ndary-double click on left, collapse to hard left */
width_control->set_value (0);
position_control->set_value (0);
} else {
- /* double click on right, collapse to hard right */
+ position_control->set_value (min_pos);
+ }
+ } else if (ev->x > 2*width/3) {
+ if (Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier)) {
+ /* 2ndary-double click on right, collapse to hard right */
width_control->set_value (0);
position_control->set_value (1.0);
}
+ position_control->set_value (max_pos);
+ } else {
+ position_control->set_value (0.5);
}
} else {
+
/* lower section: adjusts width, constrained by position */
+ const double p = position_control->get_value ();
+ const double max_width = 2.0 * min ((1.0 - p), p);
+
if (ev->x <= width/3) {
/* left side dbl click */
- width_control->set_value (1.0); // reset width to 100%
+ width_control->set_value (max_width); // reset width to 100%
} else if (ev->x > 2*width/3) {
/* right side dbl click */
- width_control->set_value (-1.0); // reset width to inverted 100%
+ width_control->set_value (-max_width); // reset width to inverted 100%
} else {
/* center dbl click */
width_control->set_value (0); // collapse width to 0%
@@ -376,6 +394,10 @@ StereoPanner::on_button_press_event (GdkEventButton* ev)
bool
StereoPanner::on_button_release_event (GdkEventButton* ev)
{
+ if (ev->button != 1) {
+ return false;
+ }
+
dragging = false;
dragging_position = false;
dragging_left = false;
@@ -493,7 +515,7 @@ StereoPanner::on_motion_notify_event (GdkEventMotion* ev)
/* have we pulled far enough to escape ? */
- if (fabs (accumulated_delta) >= 0.1) {
+ if (fabs (accumulated_delta) >= 0.025) {
width_control->set_value (current_width + accumulated_delta);
detented = false;
accumulated_delta = false;