summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorBen Loftis <ben@harrisonconsoles.com>2017-07-18 10:37:35 -0500
committerBen Loftis <ben@harrisonconsoles.com>2017-07-18 10:37:35 -0500
commitea05241771816e69857759f59d6ae0d0d2d8bf38 (patch)
tree9e8d78ba066b9cef100367c6fa5f73a9f359b306 /gtk2_ardour
parent8c6d78c188298369e28adc19e577664d9f15567c (diff)
Editor Summary: Changes to behavior
* Remove up/down buttons. * Allow the summary to shrink smaller. * Vertical drag results in zoom. * Scroll-wheel results in zoom. * Tweak mouse cursor to better indicate behaviors. * ToDo: refactor the zooming code.
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor.cc32
-rw-r--r--gtk2_ardour/editor_summary.cc131
-rw-r--r--gtk2_ardour/editor_summary.h8
3 files changed, 124 insertions, 47 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 6a20d81316..712e1a8f1f 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -684,33 +684,21 @@ Editor::Editor ()
editor_summary_pane.set_check_divider_position (true);
editor_summary_pane.add (edit_packer);
- Button* summary_arrows_left_left = manage (new Button);
- summary_arrows_left_left->add (*manage (new Arrow (ARROW_LEFT, SHADOW_NONE)));
- summary_arrows_left_left->signal_pressed().connect (sigc::hide_return (sigc::bind (sigc::mem_fun (*this, &Editor::scroll_press), LEFT)));
- summary_arrows_left_left->signal_released().connect (sigc::mem_fun (*this, &Editor::scroll_release));
+ Button* summary_arrow_left = manage (new Button);
+ summary_arrow_left->add (*manage (new Arrow (ARROW_LEFT, SHADOW_NONE)));
+ summary_arrow_left->signal_pressed().connect (sigc::hide_return (sigc::bind (sigc::mem_fun (*this, &Editor::scroll_press), LEFT)));
+ summary_arrow_left->signal_released().connect (sigc::mem_fun (*this, &Editor::scroll_release));
- Button* summary_arrows_left_right = manage (new Button);
- summary_arrows_left_right->add (*manage (new Arrow (ARROW_RIGHT, SHADOW_NONE)));
- summary_arrows_left_right->signal_pressed().connect (sigc::hide_return (sigc::bind (sigc::mem_fun (*this, &Editor::scroll_press), RIGHT)));
- summary_arrows_left_right->signal_released().connect (sigc::mem_fun (*this, &Editor::scroll_release));
+ Button* summary_arrow_right = manage (new Button);
+ summary_arrow_right->add (*manage (new Arrow (ARROW_RIGHT, SHADOW_NONE)));
+ summary_arrow_right->signal_pressed().connect (sigc::hide_return (sigc::bind (sigc::mem_fun (*this, &Editor::scroll_press), RIGHT)));
+ summary_arrow_right->signal_released().connect (sigc::mem_fun (*this, &Editor::scroll_release));
VBox* summary_arrows_left = manage (new VBox);
- summary_arrows_left->pack_start (*summary_arrows_left_left);
- summary_arrows_left->pack_start (*summary_arrows_left_right);
-
- Button* summary_arrows_right_up = manage (new Button);
- summary_arrows_right_up->add (*manage (new Arrow (ARROW_UP, SHADOW_NONE)));
- summary_arrows_right_up->signal_pressed().connect (sigc::hide_return (sigc::bind (sigc::mem_fun (*this, &Editor::scroll_press), UP)));
- summary_arrows_right_up->signal_released().connect (sigc::mem_fun (*this, &Editor::scroll_release));
-
- Button* summary_arrows_right_down = manage (new Button);
- summary_arrows_right_down->add (*manage (new Arrow (ARROW_DOWN, SHADOW_NONE)));
- summary_arrows_right_down->signal_pressed().connect (sigc::hide_return (sigc::bind (sigc::mem_fun (*this, &Editor::scroll_press), DOWN)));
- summary_arrows_right_down->signal_released().connect (sigc::mem_fun (*this, &Editor::scroll_release));
+ summary_arrows_left->pack_start (*summary_arrow_left);
VBox* summary_arrows_right = manage (new VBox);
- summary_arrows_right->pack_start (*summary_arrows_right_up);
- summary_arrows_right->pack_start (*summary_arrows_right_down);
+ summary_arrows_right->pack_start (*summary_arrow_right);
Frame* summary_frame = manage (new Frame);
summary_frame->set_shadow_type (Gtk::SHADOW_ETCHED_IN);
diff --git a/gtk2_ardour/editor_summary.cc b/gtk2_ardour/editor_summary.cc
index cab0f25dfc..72115d61f2 100644
--- a/gtk2_ardour/editor_summary.cc
+++ b/gtk2_ardour/editor_summary.cc
@@ -50,10 +50,12 @@ EditorSummary::EditorSummary (Editor* e)
_x_scale (1),
_track_height (16),
_last_playhead (-1),
+ _begin_dragging (false),
_move_dragging (false),
_moved (false),
_view_rectangle_x (0, 0),
_view_rectangle_y (0, 0),
+ _zoom_trim_dragging (false),
_zoom_dragging (false),
_old_follow_playhead (false),
_image (0),
@@ -242,8 +244,9 @@ EditorSummary::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle
}
int32_t width = _view_rectangle_x.second - _view_rectangle_x.first;
+ std::min(8, width);
int32_t height = _view_rectangle_y.second - _view_rectangle_y.first;
- cairo_rectangle (cr, _view_rectangle_x.first, _view_rectangle_y.first, width, height);
+ cairo_rectangle (cr, _view_rectangle_x.first, 0, width, get_height ());
cairo_set_source_rgba (cr, 1, 1, 1, 0.15);
cairo_fill (cr);
@@ -327,9 +330,9 @@ EditorSummary::set_overlays_dirty (int x, int y, int w, int h)
void
EditorSummary::on_size_request (Gtk::Requisition *req)
{
- /* Use a dummy, small width and the actual height that we want */
- req->width = 64;
- req->height = 32;
+ /* The left/right buttons will determine our height */
+ req->width = -1;
+ req->height = -1;
}
@@ -416,14 +419,15 @@ EditorSummary::on_button_press_event (GdkEventButton* ev)
_start_editor_x = xr;
_start_mouse_x = ev->x;
+ _start_mouse_y = ev->y;
_start_position = get_position (ev->x, ev->y);
if (_start_position != INSIDE && _start_position != TO_LEFT_OR_RIGHT) {
- /* start a zoom drag */
+ /* start a zoom_trim drag */
- _zoom_position = get_position (ev->x, ev->y);
- _zoom_dragging = true;
+ _zoom_trim_position = get_position (ev->x, ev->y);
+ _zoom_trim_dragging = true;
_editor->_dragging_playhead = true;
_editor->set_follow_playhead (false);
@@ -445,16 +449,9 @@ EditorSummary::on_button_press_event (GdkEventButton* ev)
} else {
- /* start a move drag */
-
- /* get the editor's state in case we are suspending updates */
- get_editor (&_pending_editor_x, &_pending_editor_y);
- _pending_editor_changed = false;
-
- _move_dragging = true;
- _moved = false;
- _editor->_dragging_playhead = true;
- _editor->set_follow_playhead (false);
+ /* start a move or zoom drag */
+ /* won't know which one until the mouse moves */
+ _begin_dragging = true;
}
return true;
@@ -466,7 +463,7 @@ EditorSummary::on_button_press_event (GdkEventButton* ev)
bool
EditorSummary::suspending_editor_updates () const
{
- return (!UIConfiguration::instance().get_update_editor_during_summary_drag () && (_zoom_dragging || _move_dragging));
+ return (!UIConfiguration::instance().get_update_editor_during_summary_drag () && (_zoom_dragging || _zoom_trim_dragging || _move_dragging));
}
/** Fill in x and y with the editor's current viewable area in summary coordinates */
@@ -568,11 +565,29 @@ EditorSummary::on_motion_notify_event (GdkEventMotion* ev)
} else if (_zoom_dragging) {
+ //ToDo: refactor into summary_zoom_in/out(
+ //ToDo: protect the case where the editor position is small, and results in offsetting the position
+
+ double const dy = ev->y - _zoom_last_y;
+
+ pair<double, double> xn;
+ get_editor (&xn);
+
+ xn.first -= dy;
+ xn.second += dy;
+
+ set_overlays_dirty ();
+ set_editor_x (xn);
+
+ _zoom_last_y = ev->y;
+
+ } else if (_zoom_trim_dragging) {
+
double const dx = ev->x - _start_mouse_x;
- if (_zoom_position == LEFT) {
+ if (_zoom_trim_position == LEFT) {
xr.first += dx;
- } else if (_zoom_position == RIGHT) {
+ } else if (_zoom_trim_position == RIGHT) {
xr.second += dx;
} else {
assert (0);
@@ -580,11 +595,52 @@ EditorSummary::on_motion_notify_event (GdkEventMotion* ev)
}
set_overlays_dirty ();
- set_cursor (_zoom_position);
+ set_cursor (_zoom_trim_position);
set_editor (xr);
+ } else if (_begin_dragging) {
+
+ double const dx = ev->x - _start_mouse_x;
+ double const dy = ev->y - _start_mouse_y;
+
+ if ( fabs(dx) > fabs(dy) ) {
+
+ /* initiate a move drag */
+
+ /* get the editor's state in case we are suspending updates */
+ get_editor (&_pending_editor_x, &_pending_editor_y);
+ _pending_editor_changed = false;
+
+ _move_dragging = true;
+ _moved = false;
+ _editor->_dragging_playhead = true;
+ _editor->set_follow_playhead (false);
+
+ get_window()->set_cursor (*_editor->_cursors->expand_left_right);
+
+ _begin_dragging = false;
+
+ } else if ( fabs(dy) > fabs(dx) ) {
+
+ /* initiate a zoom drag */
+
+ /* get the editor's state in case we are suspending updates */
+ get_editor (&_pending_editor_x, &_pending_editor_y);
+ _pending_editor_changed = false;
+
+ //_zoom_position = get_position (ev->x, ev->y);
+ _zoom_dragging = true;
+ _zoom_last_y = ev->y;
+ _editor->_dragging_playhead = true;
+ _editor->set_follow_playhead (false);
+
+ get_window()->set_cursor (*_editor->_cursors->expand_up_down);
+
+ _begin_dragging = false;
+ }
+
} else {
- set_cursor (get_position (ev->x, ev->y));
+ set_cursor ( INSIDE );
}
return true;
@@ -596,6 +652,7 @@ EditorSummary::on_button_release_event (GdkEventButton*)
bool const was_suspended = suspending_editor_updates ();
_move_dragging = false;
+ _zoom_trim_dragging = false;
_zoom_dragging = false;
_editor->_dragging_playhead = false;
_editor->set_follow_playhead (_old_follow_playhead, false);
@@ -616,7 +673,34 @@ EditorSummary::on_scroll_event (GdkEventScroll* ev)
double x = xr.first;
switch (ev->direction) {
- case GDK_SCROLL_UP:
+ case GDK_SCROLL_UP: {
+ //ToDo: use function summary_zoom_in/out
+
+ pair<double, double> xn;
+ get_editor (&xn);
+
+ xn.first -= 2;
+ xn.second += 2;
+
+ set_overlays_dirty ();
+ set_editor_x (xn);
+
+ return true;
+ } break;
+
+ case GDK_SCROLL_DOWN: {
+ pair<double, double> xn;
+ get_editor (&xn);
+
+ xn.first += 2;
+ xn.second -= 2;
+
+ set_overlays_dirty ();
+ set_editor_x (xn);
+
+ return true;
+ } break;
+
case GDK_SCROLL_LEFT:
if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomHorizontalModifier)) {
_editor->temporal_zoom_step (false);
@@ -629,7 +713,6 @@ EditorSummary::on_scroll_event (GdkEventScroll* ev)
return true;
}
break;
- case GDK_SCROLL_DOWN:
case GDK_SCROLL_RIGHT:
if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomHorizontalModifier)) {
_editor->temporal_zoom_step (true);
diff --git a/gtk2_ardour/editor_summary.h b/gtk2_ardour/editor_summary.h
index 7e6b5a0bdd..d237746b9e 100644
--- a/gtk2_ardour/editor_summary.h
+++ b/gtk2_ardour/editor_summary.h
@@ -95,9 +95,12 @@ private:
std::pair<double, double> _start_editor_x;
double _start_mouse_x;
+ double _start_mouse_y;
Position _start_position;
+ bool _begin_dragging;
+
bool _move_dragging;
bool _moved;
std::pair<double, double> _view_rectangle_x;
@@ -107,8 +110,11 @@ private:
std::pair<double, double> _pending_editor_y;
bool _pending_editor_changed;
+ bool _zoom_trim_dragging;
+ Position _zoom_trim_position;
+
bool _zoom_dragging;
- Position _zoom_position;
+ double _zoom_last_y;
bool _old_follow_playhead;
cairo_surface_t* _image;