added ripple delete empty to hover focus
This commit is contained in:
+9
-1
@@ -436,7 +436,15 @@ void MainWindow::export_dialog() {
|
||||
}
|
||||
|
||||
void MainWindow::ripple_delete() {
|
||||
if (sequence != nullptr) panel_timeline->delete_selection(sequence->selections, true);
|
||||
if (sequence != nullptr) {
|
||||
if (sequence->selections.size() > 0) {
|
||||
panel_timeline->delete_selection(sequence->selections, true);
|
||||
} else if (config.hover_focus && get_focused_panel() == panel_timeline) {
|
||||
if (panel_timeline->can_ripple_empty_space(panel_timeline->cursor_frame, panel_timeline->cursor_track)) {
|
||||
panel_timeline->ripple_delete_empty_space();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::editMenu_About_To_Be_Shown() {
|
||||
|
||||
@@ -484,6 +484,47 @@ void Timeline::select_from_playhead() {
|
||||
}
|
||||
}
|
||||
|
||||
bool Timeline::can_ripple_empty_space(long frame, int track) {
|
||||
bool can_ripple_delete = true;
|
||||
bool at_end_of_sequence = true;
|
||||
rc_ripple_min = 0;
|
||||
rc_ripple_max = LONG_MAX;
|
||||
|
||||
for (int i=0;i<sequence->clips.size();i++) {
|
||||
Clip* c = sequence->clips.at(i);
|
||||
if (c != nullptr) {
|
||||
if (c->timeline_in > frame || c->timeline_out > frame) {
|
||||
at_end_of_sequence = false;
|
||||
}
|
||||
if (c->track == track) {
|
||||
if (c->timeline_in <= frame && c->timeline_out >= frame) {
|
||||
can_ripple_delete = false;
|
||||
break;
|
||||
} else if (c->timeline_out < frame) {
|
||||
rc_ripple_min = qMax(rc_ripple_min, c->timeline_out);
|
||||
} else if (c->timeline_in > frame) {
|
||||
rc_ripple_max = qMin(rc_ripple_max, c->timeline_in);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (can_ripple_delete && !at_end_of_sequence);
|
||||
}
|
||||
|
||||
void Timeline::ripple_delete_empty_space() {
|
||||
QVector<Selection> sels;
|
||||
|
||||
Selection s;
|
||||
s.in = rc_ripple_min;
|
||||
s.out = rc_ripple_max;
|
||||
s.track = panel_timeline->cursor_track;
|
||||
|
||||
sels.append(s);
|
||||
|
||||
panel_timeline->delete_selection(sels, true);
|
||||
}
|
||||
|
||||
void Timeline::resizeEvent(QResizeEvent *) {
|
||||
// adjust maximum scrollbar
|
||||
if (sequence != nullptr) set_sb_max();
|
||||
|
||||
+8
-1
@@ -72,7 +72,7 @@ class Timeline : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Timeline(QWidget *parent = 0);
|
||||
explicit Timeline(QWidget *parent = nullptr);
|
||||
~Timeline();
|
||||
|
||||
bool focused();
|
||||
@@ -204,6 +204,8 @@ public:
|
||||
void scroll_to_frame(long frame);
|
||||
void select_from_playhead();
|
||||
|
||||
bool can_ripple_empty_space(long frame, int track);
|
||||
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
public slots:
|
||||
void paste(bool insert = false);
|
||||
@@ -212,6 +214,7 @@ public slots:
|
||||
void deselect();
|
||||
void toggle_links();
|
||||
void split_at_playhead();
|
||||
void ripple_delete_empty_space();
|
||||
|
||||
private slots:
|
||||
void zoom_in();
|
||||
@@ -238,6 +241,10 @@ private:
|
||||
|
||||
int default_track_height;
|
||||
|
||||
// ripple delete empty space variables
|
||||
long rc_ripple_min;
|
||||
long rc_ripple_max;
|
||||
|
||||
QWidget* timeline_area;
|
||||
TimelineWidget* video_area;
|
||||
TimelineWidget* audio_area;
|
||||
|
||||
+4
-39
@@ -66,19 +66,6 @@ TimelineWidget::TimelineWidget(QWidget *parent) : QWidget(parent) {
|
||||
connect(&tooltip_timer, SIGNAL(timeout()), this, SLOT(tooltip_timer_timeout()));
|
||||
}
|
||||
|
||||
void TimelineWidget::right_click_ripple() {
|
||||
QVector<Selection> sels;
|
||||
|
||||
Selection s;
|
||||
s.in = rc_ripple_min;
|
||||
s.out = rc_ripple_max;
|
||||
s.track = panel_timeline->cursor_track;
|
||||
|
||||
sels.append(s);
|
||||
|
||||
panel_timeline->delete_selection(sels, true);
|
||||
}
|
||||
|
||||
void TimelineWidget::show_context_menu(const QPoint& pos) {
|
||||
if (sequence != nullptr) {
|
||||
// hack because sometimes right clicking doesn't trigger mouse release event
|
||||
@@ -114,36 +101,14 @@ void TimelineWidget::show_context_menu(const QPoint& pos) {
|
||||
|
||||
if (selected_clips.isEmpty()) {
|
||||
// no clips are selected
|
||||
|
||||
// determine if we can perform a ripple empty space
|
||||
panel_timeline->cursor_frame = panel_timeline->getTimelineFrameFromScreenPoint(pos.x());
|
||||
panel_timeline->cursor_track = getTrackFromScreenPoint(pos.y());
|
||||
|
||||
bool can_ripple_delete = true;
|
||||
bool at_end_of_sequence = true;
|
||||
rc_ripple_min = 0;
|
||||
rc_ripple_max = LONG_MAX;
|
||||
|
||||
for (int i=0;i<sequence->clips.size();i++) {
|
||||
Clip* c = sequence->clips.at(i);
|
||||
if (c != nullptr) {
|
||||
if (c->timeline_in > panel_timeline->cursor_frame || c->timeline_out > panel_timeline->cursor_frame) {
|
||||
at_end_of_sequence = false;
|
||||
}
|
||||
if (c->track == panel_timeline->cursor_track) {
|
||||
if (c->timeline_in <= panel_timeline->cursor_frame && c->timeline_out >= panel_timeline->cursor_frame) {
|
||||
can_ripple_delete = false;
|
||||
break;
|
||||
} else if (c->timeline_out < panel_timeline->cursor_frame) {
|
||||
rc_ripple_min = qMax(rc_ripple_min, c->timeline_out);
|
||||
} else if (c->timeline_in > panel_timeline->cursor_frame) {
|
||||
rc_ripple_max = qMin(rc_ripple_max, c->timeline_in);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (can_ripple_delete && !at_end_of_sequence) {
|
||||
if (panel_timeline->can_ripple_empty_space(panel_timeline->cursor_frame, panel_timeline->cursor_track)) {
|
||||
QAction* ripple_delete_action = menu.addAction("R&ipple Delete");
|
||||
connect(ripple_delete_action, SIGNAL(triggered(bool)), this, SLOT(right_click_ripple()));
|
||||
connect(ripple_delete_action, SIGNAL(triggered(bool)), panel_timeline, SLOT(ripple_delete_empty_space()));
|
||||
}
|
||||
|
||||
QAction* seq_settings = menu.addAction("Sequence Settings");
|
||||
|
||||
+2
-6
@@ -63,13 +63,10 @@ private:
|
||||
QVector<Clip*> pre_clips;
|
||||
QVector<Clip*> post_clips;
|
||||
|
||||
Sequence* self_created_sequence;
|
||||
|
||||
// used for "right click ripple"
|
||||
long rc_ripple_min;
|
||||
long rc_ripple_max;
|
||||
Media* rc_reveal_media;
|
||||
|
||||
Sequence* self_created_sequence;
|
||||
|
||||
QTimer tooltip_timer;
|
||||
int tooltip_clip;
|
||||
|
||||
@@ -83,7 +80,6 @@ public slots:
|
||||
|
||||
private slots:
|
||||
void reveal_media();
|
||||
void right_click_ripple();
|
||||
void show_context_menu(const QPoint& pos);
|
||||
void toggle_autoscale();
|
||||
void tooltip_timer_timeout();
|
||||
|
||||
Reference in New Issue
Block a user