Preview video frame when dragging
This commit is contained in:
@@ -211,7 +211,10 @@ ARDOUR_UI::update_transport_clocks (samplepos_t pos)
|
||||
if (big_clock_window) {
|
||||
big_clock->set (pos);
|
||||
}
|
||||
ARDOUR_UI::instance()->video_timeline->manual_seek_video_monitor(pos);
|
||||
|
||||
if (!editor->preview_video_drag_active ()) {
|
||||
ARDOUR_UI::instance()->video_timeline->manual_seek_video_monitor(pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -596,7 +596,7 @@ Editor::drag_active () const
|
||||
bool
|
||||
Editor::preview_video_drag_active () const
|
||||
{
|
||||
return false;
|
||||
return _drags->preview_video ();
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
#include "patch_change.h"
|
||||
#include "ui_config.h"
|
||||
#include "verbose_cursor.h"
|
||||
#include "video_timeline.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ARDOUR;
|
||||
@@ -139,6 +140,16 @@ DragManager::set (Drag* d, GdkEvent* e, Gdk::Cursor* c)
|
||||
start_grab (e, c);
|
||||
}
|
||||
|
||||
bool
|
||||
DragManager::preview_video () const {
|
||||
for (list<Drag*>::const_iterator i = _drags.begin(); i != _drags.end(); ++i) {
|
||||
if ((*i)->preview_video ()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
DragManager::start_grab (GdkEvent* e, Gdk::Cursor* c)
|
||||
{
|
||||
@@ -230,6 +241,8 @@ Drag::Drag (Editor* e, ArdourCanvas::Item* i, bool trackview_only)
|
||||
, _drags (0)
|
||||
, _item (i)
|
||||
, _pointer_sample_offset (0)
|
||||
, _video_sample_offset (0)
|
||||
, _preview_video (false)
|
||||
, _x_constrained (false)
|
||||
, _y_constrained (false)
|
||||
, _was_rolling (false)
|
||||
@@ -277,6 +290,10 @@ Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
|
||||
_raw_grab_sample = _editor->canvas_event_sample (event, &_grab_x, &_grab_y);
|
||||
|
||||
setup_pointer_sample_offset ();
|
||||
setup_video_sample_offset ();
|
||||
if (! UIConfiguration::instance ().get_preview_video_frame_on_drag ()) {
|
||||
_preview_video = false;
|
||||
}
|
||||
_grab_sample = adjusted_sample (_raw_grab_sample, event).sample;
|
||||
_last_pointer_sample = _grab_sample;
|
||||
_last_pointer_x = _grab_x;
|
||||
@@ -530,6 +547,14 @@ Drag::show_verbose_cursor_text (string const & text)
|
||||
_editor->verbose_cursor()->show ();
|
||||
}
|
||||
|
||||
void
|
||||
Drag::show_view_preview (samplepos_t sample)
|
||||
{
|
||||
if (_preview_video) {
|
||||
ARDOUR_UI::instance()->video_timeline->manual_seek_video_monitor (sample);
|
||||
}
|
||||
}
|
||||
|
||||
boost::shared_ptr<Region>
|
||||
Drag::add_midi_region (MidiTimeAxisView* view, bool commit)
|
||||
{
|
||||
@@ -619,6 +644,21 @@ RegionDrag::find_time_axis_view (TimeAxisView* t) const
|
||||
return i;
|
||||
}
|
||||
|
||||
void
|
||||
RegionDrag::setup_video_sample_offset ()
|
||||
{
|
||||
if (_views.empty ()) {
|
||||
_preview_video = true;
|
||||
return;
|
||||
}
|
||||
samplepos_t first_sync = _views.begin()->view->region()->sync_position ();
|
||||
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
||||
first_sync = std::min (first_sync, i->view->region()->sync_position ());
|
||||
}
|
||||
_video_sample_offset = first_sync + _pointer_sample_offset - raw_grab_sample ();
|
||||
_preview_video = true;
|
||||
}
|
||||
|
||||
RegionMotionDrag::RegionMotionDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v, bool b)
|
||||
: RegionDrag (e, i, p, v)
|
||||
, _brushing (b)
|
||||
@@ -641,6 +681,7 @@ RegionMotionDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
|
||||
setup_snap_delta (_last_position);
|
||||
|
||||
show_verbose_cursor_time (_last_position.sample);
|
||||
show_view_preview (_last_position.sample + _video_sample_offset);
|
||||
|
||||
pair<TimeAxisView*, double> const tv = _editor->trackview_by_y_position (current_pointer_y ());
|
||||
if (tv.first) {
|
||||
@@ -1221,6 +1262,7 @@ RegionMotionDrag::motion (GdkEvent* event, bool first_move)
|
||||
|
||||
if (x_delta != 0 && !_brushing) {
|
||||
show_verbose_cursor_time (_last_position.sample);
|
||||
show_view_preview (_last_position.sample + _video_sample_offset);
|
||||
}
|
||||
|
||||
/* keep track of pointer movement */
|
||||
@@ -2888,6 +2930,7 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*)
|
||||
if (Keyboard::modifier_state_equals (event->button.state, ArdourKeyboard::trim_contents_modifier ())) {
|
||||
/* Move the contents of the region around without changing the region bounds */
|
||||
_operation = ContentsTrim;
|
||||
_preview_video = false;
|
||||
Drag::start_grab (event, _editor->cursors()->trimmer);
|
||||
} else {
|
||||
/* These will get overridden for a point trim.*/
|
||||
@@ -2926,6 +2969,7 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*)
|
||||
show_verbose_cursor_time (pf);
|
||||
break;
|
||||
}
|
||||
show_view_preview (_operation == StartTrim ? region_start : region_end);
|
||||
|
||||
for (list<DraggingView>::const_iterator i = _views.begin(); i != _views.end(); ++i) {
|
||||
i->view->region()->suspend_property_changes ();
|
||||
@@ -3101,6 +3145,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move)
|
||||
// show_verbose_cursor_time (sample_delta);
|
||||
break;
|
||||
}
|
||||
show_view_preview ((_operation == StartTrim ? rv->region()->position() : rv->region()->last_sample()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -4093,6 +4138,7 @@ FadeInDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
|
||||
setup_snap_delta (MusicSample (r->position(), 0));
|
||||
|
||||
show_verbose_cursor_duration (r->position(), r->position() + r->fade_in()->back()->when, 32);
|
||||
show_view_preview (r->position() + r->fade_in()->back()->when);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -4135,6 +4181,7 @@ FadeInDrag::motion (GdkEvent* event, bool)
|
||||
}
|
||||
|
||||
show_verbose_cursor_duration (region->position(), region->position() + fade_length, 32);
|
||||
show_view_preview (region->position() + fade_length);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -4219,6 +4266,7 @@ FadeOutDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
|
||||
setup_snap_delta (MusicSample (r->last_sample(), 0));
|
||||
|
||||
show_verbose_cursor_duration (r->last_sample() - r->fade_out()->back()->when, r->last_sample());
|
||||
show_view_preview (r->fade_out()->back()->when);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -4260,6 +4308,7 @@ FadeOutDrag::motion (GdkEvent* event, bool)
|
||||
}
|
||||
|
||||
show_verbose_cursor_duration (region->last_sample() - fade_length, region->last_sample());
|
||||
show_view_preview (region->last_sample() - fade_length);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -4377,6 +4426,7 @@ MarkerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
|
||||
} else {
|
||||
show_verbose_cursor_time (location->end());
|
||||
}
|
||||
show_view_preview ((is_start ? location->start() : location->end()) + _video_sample_offset);
|
||||
setup_snap_delta (MusicSample (is_start ? location->start() : location->end(), 0));
|
||||
|
||||
Selection::Operation op = ArdourKeyboard::selection_type (event->button.state);
|
||||
@@ -4471,6 +4521,13 @@ MarkerDrag::setup_pointer_sample_offset ()
|
||||
_pointer_sample_offset = raw_grab_sample() - (is_start ? location->start() : location->end());
|
||||
}
|
||||
|
||||
void
|
||||
MarkerDrag::setup_video_sample_offset ()
|
||||
{
|
||||
_video_sample_offset = 0;
|
||||
_preview_video = true;
|
||||
}
|
||||
|
||||
void
|
||||
MarkerDrag::motion (GdkEvent* event, bool)
|
||||
{
|
||||
@@ -4615,6 +4672,7 @@ MarkerDrag::motion (GdkEvent* event, bool)
|
||||
assert (!_copied_locations.empty());
|
||||
|
||||
show_verbose_cursor_time (newframe);
|
||||
show_view_preview (newframe + _video_sample_offset);
|
||||
_editor->set_snapped_cursor_position(newframe);
|
||||
}
|
||||
|
||||
@@ -5253,6 +5311,7 @@ TimeFXDrag::TimeFXDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, std::li
|
||||
: RegionDrag (e, i, p, v)
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::Drags, "New TimeFXDrag\n");
|
||||
_preview_video = false;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -120,6 +120,9 @@ public:
|
||||
return _current_pointer_sample;
|
||||
}
|
||||
|
||||
/** return drag-motion displays video-frame of drag-location */
|
||||
bool preview_video () const;
|
||||
|
||||
private:
|
||||
Editor* _editor;
|
||||
std::list<Drag*> _drags;
|
||||
@@ -189,6 +192,10 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool preview_video () const {
|
||||
return _preview_video;
|
||||
}
|
||||
|
||||
/** @return minimum number of samples (in x) and pixels (in y) that should be considered a movement */
|
||||
virtual std::pair<ARDOUR::samplecnt_t, int> move_threshold () const {
|
||||
return std::make_pair (1, 1);
|
||||
@@ -217,6 +224,12 @@ public:
|
||||
_pointer_sample_offset = 0;
|
||||
}
|
||||
|
||||
/** Set up the _video_sample_offset - relative to _current_pointer_sample */
|
||||
virtual void setup_video_sample_offset () {
|
||||
_video_sample_offset = 0;
|
||||
_preview_video = false;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
double grab_x () const {
|
||||
@@ -261,12 +274,15 @@ protected:
|
||||
void show_verbose_cursor_time (samplepos_t);
|
||||
void show_verbose_cursor_duration (samplepos_t, samplepos_t, double xoffset = 0);
|
||||
void show_verbose_cursor_text (std::string const &);
|
||||
void show_view_preview (samplepos_t);
|
||||
|
||||
Editor* _editor; ///< our editor
|
||||
DragManager* _drags;
|
||||
ArdourCanvas::Item* _item; ///< our item
|
||||
/** Offset from the mouse's position for the drag to the start of the thing that is being dragged */
|
||||
ARDOUR::samplecnt_t _pointer_sample_offset;
|
||||
ARDOUR::samplecnt_t _video_sample_offset;
|
||||
bool _preview_video;
|
||||
bool _x_constrained; ///< true if x motion is constrained, otherwise false
|
||||
bool _y_constrained; ///< true if y motion is constrained, otherwise false
|
||||
bool _was_rolling; ///< true if the session was rolling before the drag started, otherwise false
|
||||
@@ -341,6 +357,8 @@ protected:
|
||||
int _visible_y_high;
|
||||
uint32_t _ntracks;
|
||||
|
||||
void setup_video_sample_offset ();
|
||||
|
||||
friend class DraggingView;
|
||||
|
||||
private:
|
||||
@@ -979,6 +997,7 @@ public:
|
||||
}
|
||||
|
||||
void setup_pointer_sample_offset ();
|
||||
void setup_video_sample_offset ();
|
||||
|
||||
private:
|
||||
void update_item (ARDOUR::Location *);
|
||||
|
||||
@@ -61,6 +61,7 @@ UI_CONFIG_VARIABLE (bool, show_plugin_scan_window, "show-plugin-scan-window", fa
|
||||
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, preview_video_frame_on_drag, "preview-video-frame-on-drag", true)
|
||||
UI_CONFIG_VARIABLE (bool, use_double_click_to_zoom_to_selection, "use-double-click-to-zoom-to-selection", false)
|
||||
UI_CONFIG_VARIABLE (bool, widget_prelight, "widget-prelight", true)
|
||||
UI_CONFIG_VARIABLE (bool, use_tooltips, "use-tooltips", true)
|
||||
|
||||
@@ -473,7 +473,9 @@ void
|
||||
VideoMonitor::srsupdate ()
|
||||
{
|
||||
if (!_session) { return; }
|
||||
if (editor->dragging_playhead()) { return ;}
|
||||
if (editor->dragging_playhead() || editor->preview_video_drag_active()) {
|
||||
return;
|
||||
}
|
||||
manual_seek(_session->audible_sample(), false, NO_OFFSET);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user