Add option to zoom using button press in the time rulers and dragging vertically

This is a common operation used for zooming in other DAWs like Ableton Live and
Cubase. To support such a usage pattern without changing the existing behaviour
of the ruler area I've made it an option that is false by default.

The behaviour of RulerDragZoom is intentionally different than a CursorDrag
that occurs in the rest of the ruler area in that it doesn't follow the snap to
grid setting and no locate related stuff occurs until button release.

There are some issues with responsiveness with more than a few hundred regions
or a large amount of MIDI events/notes.

Implements feature #6768
This commit is contained in:
Tim Mayberry 2016-02-09 20:39:27 +10:00
parent 37a7d87786
commit dac2d41ee2
6 changed files with 91 additions and 0 deletions

View File

@ -2272,6 +2272,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
friend class ControlPointDrag;
friend class LineDrag;
friend class RubberbandSelectDrag;
friend class RulerZoomDrag;
friend class EditorRubberbandSelectDrag;
friend class TimeFXDrag;
friend class ScrubDrag;

View File

@ -1078,6 +1078,18 @@ Editor::canvas_ruler_event (GdkEvent *event, ArdourCanvas::Item* item, ItemType
return handled;
}
switch (event->type) {
case GDK_BUTTON_PRESS:
if (UIConfiguration::instance ().get_use_time_rulers_to_zoom_with_vertical_drag () &&
Keyboard::no_modifier_keys_pressed (&event->button) && event->button.button == 1) {
_drags->set(new RulerZoomDrag(this, item), event);
return true;
}
break;
default:
break;
}
return typed_event (item, event, type);
}

View File

@ -6447,3 +6447,56 @@ void
RegionCutDrag::aborted (bool)
{
}
RulerZoomDrag::RulerZoomDrag (Editor* e, ArdourCanvas::Item* item)
: Drag (e, item, true)
{
}
void
RulerZoomDrag::start_grab (GdkEvent* event, Gdk::Cursor* c)
{
Drag::start_grab (event, c);
framepos_t where = _editor->canvas_event_sample(event);
_editor->_dragging_playhead = true;
_editor->playhead_cursor->set_position (where);
}
void
RulerZoomDrag::motion (GdkEvent* event, bool)
{
framepos_t where = _editor->canvas_event_sample(event);
_editor->playhead_cursor->set_position (where);
const double movement_limit = 20.0;
const double scale = 1.08;
const double y_delta = last_pointer_y() - current_pointer_y();
if (y_delta > 0 && y_delta < movement_limit) {
_editor->temporal_zoom_step_mouse_focus_scale (true, scale);
} else if (y_delta < 0 && y_delta > -movement_limit) {
_editor->temporal_zoom_step_mouse_focus_scale (false, scale);
}
}
void
RulerZoomDrag::finished (GdkEvent*, bool)
{
_editor->_dragging_playhead = false;
Session* s = _editor->session ();
if (s) {
s->request_locate (_editor->playhead_cursor->current_frame (), _was_rolling);
_editor->_pending_locate_request = true;
}
}
void
RulerZoomDrag::aborted (bool)
{
}

View File

@ -1189,5 +1189,21 @@ class CrossfadeEdgeDrag : public Drag
bool start;
};
class RulerZoomDrag : public Drag
{
public:
RulerZoomDrag (Editor*, ArdourCanvas::Item*);
void start_grab (GdkEvent*, Gdk::Cursor* c = 0);
void motion (GdkEvent *, bool);
void finished (GdkEvent*, bool);
void aborted (bool);
virtual bool allow_vertical_autoscroll () const {
return false;
}
};
#endif /* __gtk2_ardour_editor_drag_h_ */

View File

@ -2536,6 +2536,14 @@ if (!Profile->get_mixbus()) {
));
} // !mixbus
add_option (_("Editor"),
new BoolOption (
"use-time-rulers-to-zoom-with-vertical-drag",
_("Use time rulers area to zoom when clicking and dragging vertically"),
sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::get_use_time_rulers_to_zoom_with_vertical_drag),
sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::set_use_time_rulers_to_zoom_with_vertical_drag)
));
add_option (_("Editor"),
new BoolOption (
"update-editor-during-summary-drag",

View File

@ -49,6 +49,7 @@ UI_CONFIG_VARIABLE (bool, sound_midi_notes, "sound-midi-notes", false)
UI_CONFIG_VARIABLE (bool, show_plugin_scan_window, "show-plugin-scan-window", false)
UI_CONFIG_VARIABLE (bool, show_zoom_tools, "show-zoom-tools", true)
UI_CONFIG_VARIABLE (bool, use_mouse_position_as_zoom_focus_on_scroll, "use-mouse-position-as-zoom-focus-on-scroll", true)
UI_CONFIG_VARIABLE (bool, use_time_rulers_to_zoom_with_vertical_drag, "use-time-rulers-to-zoom-with-vertical-drag", false)
UI_CONFIG_VARIABLE (bool, widget_prelight, "widget-prelight", true)
UI_CONFIG_VARIABLE (bool, use_tooltips, "use-tooltips", true)
UI_CONFIG_VARIABLE (std::string, mixer_strip_visibility, "mixer-element-visibility", "Input,PhaseInvert,RecMon,SoloIsoLock,Output,Comments")