transition code rewrite for #110
This commit is contained in:
+52
-51
@@ -4,6 +4,7 @@
|
||||
#include "panels/panels.h"
|
||||
#include "io/config.h"
|
||||
#include "project/sequence.h"
|
||||
#include "project/transition.h"
|
||||
#include "project/clip.h"
|
||||
#include "panels/project.h"
|
||||
#include "panels/timeline.h"
|
||||
@@ -604,11 +605,11 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) {
|
||||
|
||||
Selection s;
|
||||
s.track = clip->track;
|
||||
if (panel_timeline->transition_select == TA_OPENING_TRANSITION && clip->opening_transition != NULL) {
|
||||
if (panel_timeline->transition_select == TA_OPENING_TRANSITION && clip->get_opening_transition() != NULL) {
|
||||
s.in = clip->timeline_in;
|
||||
s.out = clip->timeline_in + clip->opening_transition->length;
|
||||
} else if (panel_timeline->transition_select == TA_CLOSING_TRANSITION && clip->closing_transition != NULL) {
|
||||
s.in = clip->timeline_out - clip->closing_transition->length;
|
||||
s.out = clip->timeline_in + clip->get_opening_transition()->length;
|
||||
} else if (panel_timeline->transition_select == TA_CLOSING_TRANSITION && clip->get_closing_transition() != NULL) {
|
||||
s.in = clip->timeline_out - clip->get_closing_transition()->length;
|
||||
s.out = clip->timeline_out;
|
||||
}
|
||||
sequence->selections.append(s);
|
||||
@@ -626,11 +627,11 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) {
|
||||
s.out = clip->timeline_out;
|
||||
|
||||
if (panel_timeline->transition_select == TA_OPENING_TRANSITION) {
|
||||
s.out = clip->timeline_in + clip->opening_transition->length;
|
||||
s.out = clip->timeline_in + clip->get_opening_transition()->length;
|
||||
}
|
||||
|
||||
if (panel_timeline->transition_select == TA_CLOSING_TRANSITION) {
|
||||
s.in = clip->timeline_out - clip->closing_transition->length;
|
||||
s.in = clip->timeline_out - clip->get_closing_transition()->length;
|
||||
}
|
||||
|
||||
s.track = clip->track;
|
||||
@@ -695,24 +696,24 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) {
|
||||
void make_room_for_transition(ComboAction* ca, Clip* c, int type, long transition_start, long transition_end) {
|
||||
// make room for transition
|
||||
if (type == TA_OPENING_TRANSITION) {
|
||||
if (c->opening_transition != NULL) {
|
||||
if (c->get_opening_transition() != NULL) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_OPENING_TRANSITION));
|
||||
}
|
||||
if (c->closing_transition != NULL) {
|
||||
if (c->get_closing_transition() != NULL) {
|
||||
if (transition_end >= c->timeline_out) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_CLOSING_TRANSITION));
|
||||
} else if (transition_end > c->timeline_out - c->closing_transition->length) {
|
||||
} else if (transition_end > c->timeline_out - c->get_closing_transition()->length) {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_CLOSING_TRANSITION, c->timeline_out - transition_end));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (c->closing_transition != NULL) {
|
||||
if (c->get_closing_transition() != NULL) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_CLOSING_TRANSITION));
|
||||
}
|
||||
if (c->opening_transition != NULL) {
|
||||
if (c->get_opening_transition() != NULL) {
|
||||
if (transition_start <= c->timeline_in) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_OPENING_TRANSITION));
|
||||
} else if (transition_start < c->timeline_in + c->opening_transition->length) {
|
||||
} else if (transition_start < c->timeline_in + c->get_opening_transition()->length) {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_OPENING_TRANSITION, transition_start - c->timeline_in));
|
||||
}
|
||||
}
|
||||
@@ -923,30 +924,30 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
||||
|
||||
// adjust transitions if we need to
|
||||
long new_clip_length = (g.out - g.in);
|
||||
if (c->opening_transition != NULL) {
|
||||
if (c->get_opening_transition() != NULL) {
|
||||
long max_open_length = new_clip_length;
|
||||
if (c->closing_transition != NULL && !panel_timeline->trim_in_point) {
|
||||
max_open_length -= c->closing_transition->length;
|
||||
if (c->get_closing_transition() != NULL && !panel_timeline->trim_in_point) {
|
||||
max_open_length -= c->get_closing_transition()->length;
|
||||
}
|
||||
if (max_open_length <= 0) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_OPENING_TRANSITION));
|
||||
} else if (c->opening_transition->length > max_open_length) {
|
||||
} else if (c->get_opening_transition()->length > max_open_length) {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_OPENING_TRANSITION, max_open_length));
|
||||
}
|
||||
}
|
||||
if (c->closing_transition != NULL) {
|
||||
if (c->get_closing_transition() != NULL) {
|
||||
long max_open_length = new_clip_length;
|
||||
if (c->opening_transition != NULL && panel_timeline->trim_in_point) {
|
||||
max_open_length -= c->opening_transition->length;
|
||||
if (c->get_opening_transition() != NULL && panel_timeline->trim_in_point) {
|
||||
max_open_length -= c->get_opening_transition()->length;
|
||||
}
|
||||
if (max_open_length <= 0) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_CLOSING_TRANSITION));
|
||||
} else if (c->closing_transition->length > max_open_length) {
|
||||
} else if (c->get_closing_transition()->length > max_open_length) {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_CLOSING_TRANSITION, max_open_length));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bool is_opening_transition = (g.transition == c->opening_transition);
|
||||
bool is_opening_transition = (g.transition == c->get_opening_transition());
|
||||
long new_transition_length = g.out - g.in;
|
||||
ca->append(new ModifyTransitionCommand(c, is_opening_transition ? TA_OPENING_TRANSITION : TA_CLOSING_TRANSITION, new_transition_length));
|
||||
|
||||
@@ -958,10 +959,10 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
||||
clip_length -= (g.in - g.old_in);
|
||||
}
|
||||
|
||||
if (c->closing_transition != NULL) {
|
||||
if (c->get_closing_transition() != NULL) {
|
||||
if (new_transition_length == clip_length) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_CLOSING_TRANSITION));
|
||||
} else if (new_transition_length > clip_length - c->closing_transition->length) {
|
||||
} else if (new_transition_length > clip_length - c->get_closing_transition()->length) {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_CLOSING_TRANSITION, clip_length - new_transition_length));
|
||||
}
|
||||
}
|
||||
@@ -972,10 +973,10 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
||||
clip_length += (g.out - g.old_out);
|
||||
}
|
||||
|
||||
if (c->opening_transition != NULL) {
|
||||
if (c->get_opening_transition() != NULL) {
|
||||
if (new_transition_length == clip_length) {
|
||||
ca->append(new DeleteTransitionCommand(c, TA_OPENING_TRANSITION));
|
||||
} else if (new_transition_length > clip_length - c->opening_transition->length) {
|
||||
} else if (new_transition_length > clip_length - c->get_opening_transition()->length) {
|
||||
ca->append(new ModifyTransitionCommand(c, TA_OPENING_TRANSITION, clip_length - new_transition_length));
|
||||
}
|
||||
}
|
||||
@@ -1106,15 +1107,15 @@ void TimelineWidget::init_ghosts() {
|
||||
g.in = g.old_in = c->timeline_in;
|
||||
g.out = g.old_out = c->timeline_out;
|
||||
g.ghost_length = g.old_out - g.old_in;
|
||||
} else if (g.transition == c->opening_transition) {
|
||||
} else if (g.transition == c->get_opening_transition()) {
|
||||
g.in = g.old_in = c->timeline_in;
|
||||
g.out = g.old_out = c->timeline_in + c->opening_transition->length;
|
||||
g.ghost_length = c->opening_transition->length;
|
||||
} else if (g.transition == c->closing_transition) {
|
||||
g.in = g.old_in = c->timeline_out - c->closing_transition->length;
|
||||
g.out = g.old_out = c->timeline_in + c->get_opening_transition()->length;
|
||||
g.ghost_length = c->get_opening_transition()->length;
|
||||
} else if (g.transition == c->get_closing_transition()) {
|
||||
g.in = g.old_in = c->timeline_out - c->get_closing_transition()->length;
|
||||
g.out = g.old_out = c->timeline_out;
|
||||
g.ghost_length = c->closing_transition->length;
|
||||
g.clip_in = g.old_clip_in = c->clip_in + c->getLength() - c->closing_transition->length;
|
||||
g.ghost_length = c->get_closing_transition()->length;
|
||||
g.clip_in = g.old_clip_in = c->clip_in + c->getLength() - c->get_closing_transition()->length;
|
||||
}
|
||||
|
||||
// used for trim ops
|
||||
@@ -1354,7 +1355,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) {
|
||||
g.in = g.old_in + frame_diff;
|
||||
g.out = g.old_out + frame_diff;
|
||||
|
||||
if (g.transition != NULL && g.transition == sequence->clips.at(g.clip)->opening_transition) {
|
||||
if (g.transition != NULL && g.transition == sequence->clips.at(g.clip)->get_opening_transition()) {
|
||||
g.clip_in = g.old_clip_in + frame_diff;
|
||||
}
|
||||
|
||||
@@ -1544,21 +1545,21 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
bool add = panel_timeline->is_clip_selected(c, true);
|
||||
|
||||
// if a whole clip is not selected, maybe just a transition is
|
||||
if (!add && panel_timeline->tool == TIMELINE_TOOL_POINTER && (c->opening_transition != NULL || c->closing_transition != NULL)) {
|
||||
if (!add && panel_timeline->tool == TIMELINE_TOOL_POINTER && (c->get_opening_transition() != NULL || c->get_closing_transition() != NULL)) {
|
||||
// check if any selections contain the whole clip or transition
|
||||
for (int j=0;j<sequence->selections.size();j++) {
|
||||
const Selection& s = sequence->selections.at(j);
|
||||
if (s.track == c->track) {
|
||||
if (c->opening_transition != NULL
|
||||
if (c->get_opening_transition() != NULL
|
||||
&& s.in == c->timeline_in
|
||||
&& s.out == c->timeline_in + c->opening_transition->length) {
|
||||
g.transition = c->opening_transition;
|
||||
&& s.out == c->timeline_in + c->get_opening_transition()->length) {
|
||||
g.transition = c->get_opening_transition();
|
||||
add = true;
|
||||
break;
|
||||
} else if (c->closing_transition != NULL
|
||||
&& s.in == c->timeline_out - c->closing_transition->length
|
||||
} else if (c->get_closing_transition() != NULL
|
||||
&& s.in == c->timeline_out - c->get_closing_transition()->length
|
||||
&& s.out == c->timeline_out) {
|
||||
g.transition = c->closing_transition;
|
||||
g.transition = c->get_closing_transition();
|
||||
add = true;
|
||||
break;
|
||||
}
|
||||
@@ -1844,9 +1845,9 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
tooltip_timer.start();
|
||||
tooltip_clip = i;
|
||||
|
||||
if (c->opening_transition != NULL && panel_timeline->cursor_frame <= c->timeline_in + c->opening_transition->length) {
|
||||
if (c->get_opening_transition() != NULL && panel_timeline->cursor_frame <= c->timeline_in + c->get_opening_transition()->length) {
|
||||
panel_timeline->transition_select = TA_OPENING_TRANSITION;
|
||||
} else if (c->closing_transition != NULL && panel_timeline->cursor_frame >= c->timeline_out - c->closing_transition->length) {
|
||||
} else if (c->get_closing_transition() != NULL && panel_timeline->cursor_frame >= c->timeline_out - c->get_closing_transition()->length) {
|
||||
panel_timeline->transition_select = TA_CLOSING_TRANSITION;
|
||||
}
|
||||
}
|
||||
@@ -1869,8 +1870,8 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
}
|
||||
}
|
||||
if (panel_timeline->tool == TIMELINE_TOOL_POINTER) {
|
||||
if (c->opening_transition != NULL) {
|
||||
long transition_point = c->timeline_in + c->opening_transition->length;
|
||||
if (c->get_opening_transition() != NULL) {
|
||||
long transition_point = c->timeline_in + c->get_opening_transition()->length;
|
||||
|
||||
if (transition_point > mouse_frame_lower && transition_point < mouse_frame_upper) {
|
||||
int nc = qAbs(transition_point - 1 - panel_timeline->cursor_frame);
|
||||
@@ -1883,8 +1884,8 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c->closing_transition != NULL) {
|
||||
long transition_point = c->timeline_out - c->closing_transition->length;
|
||||
if (c->get_closing_transition() != NULL) {
|
||||
long transition_point = c->timeline_out - c->get_closing_transition()->length;
|
||||
if (transition_point > mouse_frame_lower && transition_point < mouse_frame_upper) {
|
||||
int nc = qAbs(transition_point + 1 - panel_timeline->cursor_frame);
|
||||
if (nc < closeness) {
|
||||
@@ -2133,13 +2134,13 @@ void TimelineWidget::paintEvent(QPaintEvent*) {
|
||||
int thumb_y = p.fontMetrics().height()+CLIP_TEXT_PADDING+CLIP_TEXT_PADDING;
|
||||
if (thumb_x < width() && thumb_y < height()) {
|
||||
int space_for_thumb = clip_rect.width()-1;
|
||||
if (clip->opening_transition != NULL) {
|
||||
int ot_width = getScreenPointFromFrame(panel_timeline->zoom, clip->opening_transition->length);
|
||||
if (clip->get_opening_transition() != NULL) {
|
||||
int ot_width = getScreenPointFromFrame(panel_timeline->zoom, clip->get_opening_transition()->length);
|
||||
thumb_x += ot_width;
|
||||
space_for_thumb -= ot_width;
|
||||
}
|
||||
if (clip->closing_transition != NULL) {
|
||||
space_for_thumb -= getScreenPointFromFrame(panel_timeline->zoom, clip->closing_transition->length);
|
||||
if (clip->get_closing_transition() != NULL) {
|
||||
space_for_thumb -= getScreenPointFromFrame(panel_timeline->zoom, clip->get_closing_transition()->length);
|
||||
}
|
||||
int thumb_height = clip_rect.height()-thumb_y;
|
||||
int thumb_width = (thumb_height*((double)ms->video_preview.width()/(double)ms->video_preview.height()));
|
||||
@@ -2203,7 +2204,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) {
|
||||
|
||||
// draw clip transitions
|
||||
for (int i=0;i<2;i++) {
|
||||
Effect* t = (i == 0) ? clip->opening_transition : clip->closing_transition;
|
||||
Transition* t = (i == 0) ? clip->get_opening_transition() : clip->get_closing_transition();
|
||||
if (t != NULL) {
|
||||
int transition_width = getScreenPointFromFrame(panel_timeline->zoom, t->length);
|
||||
int transition_height = clip_rect.height();
|
||||
|
||||
Reference in New Issue
Block a user