- drag_start_x = ev->x;
- last_drag_x = ev->x;
-
- dragging_position = false;
- dragging_left = false;
- dragging_right = false;
- dragging = false;
- accumulated_delta = 0;
- detented = false;
-
- /* Let the binding proxies get first crack at the press event
- */
-
- if (ev->y < 20) {
- if (position_binder.button_press_handler (ev)) {
- return true;
- }
- } else {
- if (width_binder.button_press_handler (ev)) {
- return true;
- }
- }
-
- if (ev->button != 1) {
- return false;
- }
-
- if (ev->type == GDK_2BUTTON_PRESS) {
- int width = get_width();
-
- if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
- /* handled by button release */
- return true;
- }
-
- if (ev->y < 20) {
-
- /* upper section: adjusts position, constrained by width */
-
- const double w = fabs (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 {
- 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);
- } else {
- 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 (max_width); // reset width to 100%
- } else if (ev->x > 2*width/3) {
- /* right side dbl click */
- width_control->set_value (-max_width); // reset width to inverted 100%
- } else {
- /* center dbl click */
- width_control->set_value (0); // collapse width to 0%
- }
- }
-
- dragging = false;
-
- } else if (ev->type == GDK_BUTTON_PRESS) {
-
- if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
- /* handled by button release */
- return true;
- }
-
- if (ev->y < 20) {
- /* top section of widget is for position drags */
- dragging_position = true;
- StartPositionGesture ();
- } else {
- /* lower section is for dragging width */
-
- double pos = position_control->get_value (); /* 0..1 */
- double swidth = width_control->get_value (); /* -1..+1 */
- double fswidth = fabs (swidth);
- int usable_width = get_width() - lr_box_size;
- double center = (lr_box_size/2.0) + (usable_width * pos);
- int left = lrint (center - (fswidth * usable_width / 2.0)); // center of leftmost box
- int right = lrint (center + (fswidth * usable_width / 2.0)); // center of rightmost box
- const int half_box = lr_box_size/2;
-
- if (ev->x >= (left - half_box) && ev->x < (left + half_box)) {
- if (swidth < 0.0) {
- dragging_right = true;
- } else {
- dragging_left = true;
- }
- } else if (ev->x >= (right - half_box) && ev->x < (right + half_box)) {
- if (swidth < 0.0) {
- dragging_left = true;
- } else {
- dragging_right = true;
- }
- }
- StartWidthGesture ();
- }
-
- dragging = true;
- }
-
- return true;
+ drag_start_x = ev->x;
+ last_drag_x = ev->x;
+
+ dragging_position = false;
+ dragging_left = false;
+ dragging_right = false;
+ _dragging = false;
+ accumulated_delta = 0;
+ detented = false;
+
+ /* Let the binding proxies get first crack at the press event
+ */
+
+ if (ev->y < 20) {
+ if (position_binder.button_press_handler (ev)) {
+ return true;
+ }
+ } else {
+ if (width_binder.button_press_handler (ev)) {
+ return true;
+ }
+ }
+
+ if (ev->button != 1) {
+ return false;
+ }
+
+ if (ev->type == GDK_2BUTTON_PRESS) {
+ int width = get_width();
+
+ if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
+ /* handled by button release */
+ return true;
+ }
+
+ if (ev->y < 20) {
+
+ /* upper section: adjusts position, constrained by width */
+
+ const double w = fabs (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 {
+ 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);
+ } else {
+ 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 (max_width); // reset width to 100%
+ } else if (ev->x > 2*width/3) {
+ /* right side dbl click */
+ width_control->set_value (-max_width); // reset width to inverted 100%
+ } else {
+ /* center dbl click */
+ width_control->set_value (0); // collapse width to 0%
+ }
+ }
+
+ _dragging = false;
+
+ } else if (ev->type == GDK_BUTTON_PRESS) {
+
+ if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
+ /* handled by button release */
+ return true;
+ }
+
+ show_drag_data_window ();
+
+ if (ev->y < 20) {
+ /* top section of widget is for position drags */
+ dragging_position = true;
+ StartPositionGesture ();
+ } else {
+ /* lower section is for dragging width */
+
+ double pos = position_control->get_value (); /* 0..1 */
+ double swidth = width_control->get_value (); /* -1..+1 */
+ double fswidth = fabs (swidth);
+ int usable_width = get_width() - lr_box_size;
+ double center = (lr_box_size/2.0) + (usable_width * pos);
+ int left = lrint (center - (fswidth * usable_width / 2.0)); // center of leftmost box
+ int right = lrint (center + (fswidth * usable_width / 2.0)); // center of rightmost box
+ const int half_box = lr_box_size/2;
+
+ if (ev->x >= (left - half_box) && ev->x < (left + half_box)) {
+ if (swidth < 0.0) {
+ dragging_right = true;
+ } else {
+ dragging_left = true;
+ }
+ } else if (ev->x >= (right - half_box) && ev->x < (right + half_box)) {
+ if (swidth < 0.0) {
+ dragging_left = true;
+ } else {
+ dragging_right = true;
+ }
+ }
+ StartWidthGesture ();
+ }
+
+ _dragging = true;
+ }
+
+ return true;