Merge branch 'master' into cache-update
This commit is contained in:
@@ -569,6 +569,22 @@ void TimelineWidget::ToggleLinksOnSelected()
|
||||
Core::instance()->undo_stack()->push(new NodeLinkManyCommand(blocks, link));
|
||||
}
|
||||
|
||||
void TimelineWidget::AddDefaultTransitionsToSelected()
|
||||
{
|
||||
QVector<ClipBlock*> blocks;
|
||||
|
||||
foreach (Block* item, GetSelectedBlocks()) {
|
||||
// Only clips can be linked
|
||||
if (ClipBlock *clip = dynamic_cast<ClipBlock*>(item)) {
|
||||
blocks.append(clip);
|
||||
}
|
||||
}
|
||||
|
||||
if (!blocks.isEmpty()) {
|
||||
Core::instance()->undo_stack()->push(new TimelineAddDefaultTransitionCommand(blocks, timebase()));
|
||||
}
|
||||
}
|
||||
|
||||
bool TimelineWidget::CopySelected(bool cut)
|
||||
{
|
||||
if (super::CopySelected(cut)) {
|
||||
@@ -639,7 +655,7 @@ void TimelineWidget::PasteInsert()
|
||||
void TimelineWidget::DeleteInToOut(bool ripple)
|
||||
{
|
||||
if (!GetConnectedNode()
|
||||
|| !GetConnectedNode()->GetTimelinePoints()->workarea()->enabled()) {
|
||||
|| !GetConnectedNode()->GetWorkArea()->enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -649,8 +665,8 @@ void TimelineWidget::DeleteInToOut(bool ripple)
|
||||
|
||||
command->add_child(new TimelineRippleRemoveAreaCommand(
|
||||
sequence(),
|
||||
GetConnectedNode()->GetTimelinePoints()->workarea()->in(),
|
||||
GetConnectedNode()->GetTimelinePoints()->workarea()->out()));
|
||||
GetConnectedNode()->GetWorkArea()->in(),
|
||||
GetConnectedNode()->GetWorkArea()->out()));
|
||||
|
||||
} else {
|
||||
QVector<Track*> unlocked_tracks = sequence()->GetUnlockedTracks();
|
||||
@@ -658,7 +674,7 @@ void TimelineWidget::DeleteInToOut(bool ripple)
|
||||
foreach (Track* track, unlocked_tracks) {
|
||||
GapBlock* gap = new GapBlock();
|
||||
|
||||
gap->set_length_and_media_out(GetConnectedNode()->GetTimelinePoints()->workarea()->length());
|
||||
gap->set_length_and_media_out(GetConnectedNode()->GetWorkArea()->length());
|
||||
|
||||
command->add_child(new NodeAddCommand(static_cast<NodeGraph*>(track->parent()),
|
||||
gap));
|
||||
@@ -666,17 +682,17 @@ void TimelineWidget::DeleteInToOut(bool ripple)
|
||||
command->add_child(new TrackPlaceBlockCommand(sequence()->track_list(track->type()),
|
||||
track->Index(),
|
||||
gap,
|
||||
GetConnectedNode()->GetTimelinePoints()->workarea()->in()));
|
||||
GetConnectedNode()->GetWorkArea()->in()));
|
||||
}
|
||||
}
|
||||
|
||||
// Clear workarea after this
|
||||
command->add_child(new WorkareaSetEnabledCommand(GetConnectedNode()->project(),
|
||||
GetConnectedNode()->GetTimelinePoints(),
|
||||
GetConnectedNode()->GetWorkArea(),
|
||||
false));
|
||||
|
||||
if (ripple) {
|
||||
SetTimeAndSignal(GetConnectedNode()->GetTimelinePoints()->workarea()->in());
|
||||
SetTimeAndSignal(GetConnectedNode()->GetWorkArea()->in());
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->push(command);
|
||||
@@ -1079,6 +1095,11 @@ void TimelineWidget::ShowContextMenu()
|
||||
connect(autocache_action, &QAction::triggered, this, &TimelineWidget::SetSelectedClipsAutocaching);
|
||||
|
||||
if (clip->connected_viewer()) {
|
||||
QAction *reveal_in_footage_viewer = menu.addAction(tr("Reveal in Footage Viewer"));
|
||||
reveal_in_footage_viewer->setData(reinterpret_cast<quintptr>(clip->connected_viewer()));
|
||||
reveal_in_footage_viewer->setProperty("range", QVariant::fromValue(clip->media_range()));
|
||||
connect(reveal_in_footage_viewer, &QAction::triggered, this, &TimelineWidget::RevealInFootageViewer);
|
||||
|
||||
QAction *reveal_in_project = menu.addAction(tr("Reveal in Project"));
|
||||
reveal_in_project->setData(reinterpret_cast<quintptr>(clip->connected_viewer()));
|
||||
connect(reveal_in_project, &QAction::triggered, this, &TimelineWidget::RevealInProject);
|
||||
@@ -1221,6 +1242,16 @@ void TimelineWidget::SignalBlockSelectionChange()
|
||||
signal_block_change_timer_->start();
|
||||
}
|
||||
|
||||
void TimelineWidget::RevealInFootageViewer()
|
||||
{
|
||||
QAction *a = static_cast<QAction*>(sender());
|
||||
|
||||
ViewerOutput *item_to_reveal = reinterpret_cast<ViewerOutput*>(a->data().value<quintptr>());
|
||||
TimeRange r = a->property("range").value<TimeRange>();
|
||||
|
||||
emit RevealViewerInFootageViewer(item_to_reveal, r);
|
||||
}
|
||||
|
||||
void TimelineWidget::RevealInProject()
|
||||
{
|
||||
QAction *a = static_cast<QAction*>(sender());
|
||||
|
||||
@@ -79,6 +79,8 @@ public:
|
||||
|
||||
void ToggleLinksOnSelected();
|
||||
|
||||
void AddDefaultTransitionsToSelected();
|
||||
|
||||
virtual bool CopySelected(bool cut) override;
|
||||
|
||||
virtual bool Paste() override;
|
||||
@@ -277,6 +279,7 @@ signals:
|
||||
|
||||
void RequestCaptureStart(const TimeRange &time, const Track::Reference &track);
|
||||
|
||||
void RevealViewerInFootageViewer(ViewerOutput *r, const TimeRange &range);
|
||||
void RevealViewerInProject(ViewerOutput *r);
|
||||
|
||||
protected:
|
||||
@@ -427,6 +430,7 @@ private slots:
|
||||
|
||||
void SignalBlockSelectionChange();
|
||||
|
||||
void RevealInFootageViewer();
|
||||
void RevealInProject();
|
||||
|
||||
void RenameSelectedBlocks();
|
||||
|
||||
@@ -231,7 +231,7 @@ void ImportTool::FootageToGhosts(rational ghost_start, const DraggedFootageData
|
||||
rational footage_duration;
|
||||
rational ghost_in;
|
||||
|
||||
TimelineWorkArea* wk = footage->GetTimelinePoints()->workarea();
|
||||
TimelineWorkArea* wk = footage->GetWorkArea();
|
||||
if (wk->enabled()) {
|
||||
footage_duration = wk->length();
|
||||
ghost_in = wk->in();
|
||||
|
||||
@@ -689,6 +689,8 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event)
|
||||
InsertGapsAtGhostDestination(command);
|
||||
}
|
||||
|
||||
QMap<Node*, Node*> relinks;
|
||||
|
||||
// Now we can re-add each clip
|
||||
foreach (const GhostBlockPair& p, blocks_moving) {
|
||||
Block* block = p.block;
|
||||
@@ -696,7 +698,10 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event)
|
||||
if (duplicate_clips) {
|
||||
// Duplicate rather than move
|
||||
// Place the copy instead of the original block
|
||||
block = static_cast<Block*>(Node::CopyNodeInGraph(block, command));
|
||||
Block *new_block = static_cast<Block*>(Node::CopyNodeInGraph(block, command));
|
||||
relinks.insert(block, new_block);
|
||||
block = new_block;
|
||||
|
||||
if (ClipBlock *new_clip = dynamic_cast<ClipBlock*>(block)) {
|
||||
new_clip->AddCachePassthroughFrom(static_cast<ClipBlock*>(p.block));
|
||||
}
|
||||
@@ -709,6 +714,18 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event)
|
||||
p.ghost->GetAdjustedIn()));
|
||||
}
|
||||
|
||||
if (!relinks.empty()) {
|
||||
for (auto it=relinks.cbegin(); it!=relinks.cend(); it++) {
|
||||
for (auto jt=it.key()->links().cbegin(); jt!=it.key()->links().cend(); jt++) {
|
||||
Node *link = *jt;
|
||||
Node *copy_link = relinks.value(link);
|
||||
if (copy_link) {
|
||||
command->add_child(new NodeLinkCommand(it.value(), copy_link, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust selections
|
||||
TimelineWidgetSelections new_sel = parent()->GetSelections();
|
||||
new_sel.ShiftTime(blocks_moving.first().ghost->GetInAdjustment());
|
||||
|
||||
@@ -22,9 +22,11 @@
|
||||
|
||||
#include "node/block/clip/clip.h"
|
||||
#include "node/block/transition/transition.h"
|
||||
#include "node/factory.h"
|
||||
#include "node/math/math/math.h"
|
||||
#include "node/math/merge/merge.h"
|
||||
#include "timelineundocommon.h"
|
||||
#include "widget/timelinewidget/undo/timelineundotrack.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -287,8 +289,8 @@ void TrackListInsertGaps::prepare()
|
||||
QVector<Block*> blocks_to_append_gap_to;
|
||||
QVector<Track*> tracks_to_append_gap_to;
|
||||
|
||||
foreach (Track* track, working_tracks_) {
|
||||
foreach (Block* b, track->Blocks()) {
|
||||
for (Track* track : qAsConst(working_tracks_)) {
|
||||
for (Block* b : track->Blocks()) {
|
||||
if (dynamic_cast<GapBlock*>(b) && b->in() <= point_ && b->out() >= point_) {
|
||||
// Found a gap at the location
|
||||
gaps_to_extend_.append(b);
|
||||
@@ -542,4 +544,121 @@ void TimelineRemoveTrackCommand::undo()
|
||||
remove_command_->undo_now();
|
||||
}
|
||||
|
||||
void TimelineAddDefaultTransitionCommand::prepare()
|
||||
{
|
||||
for (auto it=clips_.cbegin(); it!=clips_.cend(); it++) {
|
||||
ClipBlock *c = *it;
|
||||
|
||||
// Handle in transition
|
||||
if (clips_.contains(static_cast<ClipBlock*>(c->previous()))) {
|
||||
// Do nothing, assume this will be handled by a dual transition from that clip
|
||||
} else if (dynamic_cast<GapBlock*>(c->previous()) || !c->previous()) {
|
||||
// Create in transition
|
||||
AddTransition(c, kIn);
|
||||
}
|
||||
|
||||
// Handle out transition
|
||||
if (clips_.contains(static_cast<ClipBlock*>(c->next()))) {
|
||||
AddTransition(c, kOutDual);
|
||||
} else if (dynamic_cast<GapBlock*>(c->next()) || !c->next()) {
|
||||
// Create out transition
|
||||
AddTransition(c, kOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineAddDefaultTransitionCommand::AddTransition(ClipBlock *c, CreateTransitionMode mode)
|
||||
{
|
||||
if (Track *t = c->track()) {
|
||||
Node *p = nullptr;
|
||||
if (t->type() == Track::kVideo) {
|
||||
p = NodeFactory::CreateFromID(OLIVE_CONFIG("DefaultVideoTransition").toString());
|
||||
} else if (t->type() == Track::kAudio) {
|
||||
p = NodeFactory::CreateFromID(OLIVE_CONFIG("DefaultAudioTransition").toString());
|
||||
}
|
||||
|
||||
rational transition_length = OLIVE_CONFIG("DefaultTransitionLength").value<rational>();
|
||||
|
||||
// Resize original clip
|
||||
switch (mode) {
|
||||
case kIn:
|
||||
ValidateTransitionLength(c, transition_length);
|
||||
|
||||
if (transition_length > 0) {
|
||||
AdjustClipLength(c, transition_length, false);
|
||||
}
|
||||
break;
|
||||
case kOut:
|
||||
ValidateTransitionLength(c, transition_length);
|
||||
|
||||
if (transition_length > 0) {
|
||||
AdjustClipLength(c, transition_length, true);
|
||||
}
|
||||
break;
|
||||
case kOutDual:
|
||||
{
|
||||
rational half_length = transition_length / 2;
|
||||
|
||||
ValidateTransitionLength(static_cast<ClipBlock*>(c->next()), half_length);
|
||||
ValidateTransitionLength(c, half_length);
|
||||
|
||||
transition_length = half_length * 2;
|
||||
|
||||
if (transition_length > 0) {
|
||||
AdjustClipLength(static_cast<ClipBlock*>(c->next()), half_length, false);
|
||||
AdjustClipLength(c, half_length, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (transition_length > 0) {
|
||||
if (TransitionBlock *transition = dynamic_cast<TransitionBlock*>(p)) {
|
||||
transition->set_length_and_media_out(transition_length);
|
||||
|
||||
// Add transition
|
||||
commands_.append(new NodeAddCommand(c->parent(), transition));
|
||||
|
||||
// Insert block
|
||||
Block *insert_after = (mode == kIn) ? c->previous() : c;
|
||||
commands_.append(new TrackInsertBlockAfterCommand(c->track(), transition, insert_after));
|
||||
|
||||
// Connect
|
||||
switch (mode) {
|
||||
case kIn:
|
||||
commands_.append(new NodeEdgeAddCommand(c, NodeInput(transition, TransitionBlock::kInBlockInput)));
|
||||
break;
|
||||
case kOutDual:
|
||||
commands_.append(new NodeEdgeAddCommand(c->next(), NodeInput(transition, TransitionBlock::kInBlockInput)));
|
||||
/* fall through */
|
||||
case kOut:
|
||||
commands_.append(new NodeEdgeAddCommand(c, NodeInput(transition, TransitionBlock::kOutBlockInput)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineAddDefaultTransitionCommand::AdjustClipLength(ClipBlock *c, const rational &transition_length, bool out)
|
||||
{
|
||||
rational cur_len = lengths_.value(c, c->length());
|
||||
rational new_len = cur_len - transition_length;
|
||||
if (out) {
|
||||
commands_.append(new BlockResizeCommand(c, new_len));
|
||||
} else {
|
||||
commands_.append(new BlockResizeWithMediaInCommand(c, new_len));
|
||||
}
|
||||
lengths_.insert(c, new_len);
|
||||
}
|
||||
|
||||
void TimelineAddDefaultTransitionCommand::ValidateTransitionLength(ClipBlock *c, rational &transition_length)
|
||||
{
|
||||
rational cur_len = lengths_.value(c, c->length());
|
||||
rational half_cur_len = cur_len/2;
|
||||
if (transition_length >= half_cur_len) {
|
||||
transition_length = half_cur_len - timebase_;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -358,6 +358,61 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class TimelineAddDefaultTransitionCommand : public UndoCommand
|
||||
{
|
||||
public:
|
||||
TimelineAddDefaultTransitionCommand(const QVector<ClipBlock*> &clips, const rational &timebase) :
|
||||
clips_(clips),
|
||||
timebase_(timebase)
|
||||
{}
|
||||
|
||||
virtual ~TimelineAddDefaultTransitionCommand() override
|
||||
{
|
||||
qDeleteAll(commands_);
|
||||
}
|
||||
|
||||
virtual Project* GetRelevantProject() const override
|
||||
{
|
||||
return clips_.empty() ? nullptr : clips_.first()->project();
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void prepare() override;
|
||||
|
||||
virtual void redo() override
|
||||
{
|
||||
for (auto it=commands_.cbegin(); it!=commands_.cend(); it++) {
|
||||
(*it)->redo_now();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void undo() override
|
||||
{
|
||||
for (auto it=commands_.crbegin(); it!=commands_.crend(); it++) {
|
||||
(*it)->undo_now();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
enum CreateTransitionMode {
|
||||
kIn,
|
||||
kOut,
|
||||
kOutDual
|
||||
};
|
||||
|
||||
void AddTransition(ClipBlock *c, CreateTransitionMode mode);
|
||||
void AdjustClipLength(ClipBlock *c, const rational &transition_length, bool out);
|
||||
void ValidateTransitionLength(ClipBlock *c, rational &transition_length);
|
||||
|
||||
|
||||
QVector<ClipBlock*> clips_;
|
||||
rational timebase_;
|
||||
QVector<UndoCommand*> commands_;
|
||||
|
||||
QHash<ClipBlock*, rational> lengths_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMELINEUNDOGENERAL_H
|
||||
|
||||
@@ -22,16 +22,15 @@
|
||||
#define TIMELINEUNDOWORKAREA_H
|
||||
|
||||
#include "node/project/project.h"
|
||||
#include "timeline/timelinepoints.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class WorkareaSetEnabledCommand : public UndoCommand {
|
||||
public:
|
||||
WorkareaSetEnabledCommand(Project *project, TimelinePoints* points, bool enabled) :
|
||||
WorkareaSetEnabledCommand(Project *project, TimelineWorkArea* points, bool enabled) :
|
||||
project_(project),
|
||||
points_(points),
|
||||
old_enabled_(points_->workarea()->enabled()),
|
||||
old_enabled_(points_->enabled()),
|
||||
new_enabled_(enabled)
|
||||
{
|
||||
}
|
||||
@@ -44,18 +43,18 @@ public:
|
||||
protected:
|
||||
virtual void redo() override
|
||||
{
|
||||
points_->workarea()->set_enabled(new_enabled_);
|
||||
points_->set_enabled(new_enabled_);
|
||||
}
|
||||
|
||||
virtual void undo() override
|
||||
{
|
||||
points_->workarea()->set_enabled(old_enabled_);
|
||||
points_->set_enabled(old_enabled_);
|
||||
}
|
||||
|
||||
private:
|
||||
Project* project_;
|
||||
|
||||
TimelinePoints* points_;
|
||||
TimelineWorkArea* points_;
|
||||
|
||||
bool old_enabled_;
|
||||
|
||||
|
||||
@@ -585,7 +585,7 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, q
|
||||
}
|
||||
}
|
||||
|
||||
TimelineMarkerList *marker_list = clip->connected_viewer()->GetTimelinePoints()->markers();
|
||||
TimelineMarkerList *marker_list = clip->connected_viewer()->GetMarkers();
|
||||
if (!marker_list->empty()) {
|
||||
|
||||
clip_marker_rects_.clear();
|
||||
@@ -752,12 +752,14 @@ void TimelineView::ConnectTrackList(TrackList *list)
|
||||
{
|
||||
if (connected_track_list_) {
|
||||
disconnect(connected_track_list_, &TrackList::TrackListChanged, this, &TimelineView::TrackListChanged);
|
||||
disconnect(connected_track_list_, &TrackList::TrackHeightChanged, this, &TimelineView::TrackListChanged);
|
||||
}
|
||||
|
||||
connected_track_list_ = list;
|
||||
|
||||
if (connected_track_list_) {
|
||||
connect(connected_track_list_, &TrackList::TrackListChanged, this, &TimelineView::TrackListChanged);
|
||||
connect(connected_track_list_, &TrackList::TrackHeightChanged, this, &TimelineView::TrackListChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user