Files
oak-editor/engine/timeline/timelineundogeneral.h
T
Mike-Solar 28c4426236 build: split the engine into liboakengine.so; worker drops the UI entirely
Physical split: app/{audio,cli,codec,common,config,node,pluginSupport,
render,task,timeline,undo,tool,shaders} plus coreengine, version and
ui/icons+colorcoding move to a new top-level engine/ tree, built as
liboakengine.so (shared). The render backends (oakgl/oakvulkan) move
with it and link the engine library instead of embedding a static
render-core subset (libolive-rendercore is gone).

- oak-render-worker now links liboakengine instead of the whole
  libolive-editor object set: 336MB -> 2.9MB, no Qt Widgets UI
- the editor links liboakengine for the engine and keeps only UI
  objects in libolive-editor
- install/packaging: GNUInstallDirs libdir on Linux, bundle copy on
  macOS, oakengine.dll staged for NSIS, AppImage validation entry
- fix backend lookup for the new layout: DynamicRenderer searched
  ../app but backends now live in engine/; a stale pre-split liboakgl
  in the build tree got dlopened instead, re-initialized and later
  destroyed the interposed engine statics (full-suite segfault at
  DialogSequenceParameterTab, found via gdb watchpoint)
2026-07-20 03:23:28 +08:00

413 lines
7.8 KiB
C++

/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef OAK_TIMELINEUNDOGENERAL_H
#define OAK_TIMELINEUNDOGENERAL_H
#include "config/config.h"
#include "node/block/clip/clip.h"
#include "node/block/gap/gap.h"
#include "node/block/transition/transition.h"
#include "node/output/track/track.h"
#include "node/output/track/tracklist.h"
#include "node/output/viewer/viewer.h"
#include "node/project/sequence/sequence.h"
#include "timelineundosplit.h"
namespace olive
{
class BlockResizeCommand : public UndoCommand {
public:
BlockResizeCommand(Block *block, Rational new_length)
: block_(block)
, new_length_(new_length)
{
}
virtual Project *get_relevant_project() const override
{
return block_->project();
}
protected:
virtual void redo() override;
virtual void undo() override;
private:
Block *block_;
Rational old_length_;
Rational new_length_;
};
class BlockResizeWithMediaInCommand : public UndoCommand {
public:
BlockResizeWithMediaInCommand(Block *block, Rational new_length)
: block_(block)
, new_length_(new_length)
{
}
virtual Project *get_relevant_project() const
{
return block_->project();
}
protected:
virtual void redo();
virtual void undo();
private:
Block *block_;
Rational old_length_;
Rational new_length_;
};
class BlockSetMediaInCommand : public UndoCommand {
public:
BlockSetMediaInCommand(ClipBlock *block, Rational new_media_in)
: block_(block)
, new_media_in_(new_media_in)
{
}
virtual Project *get_relevant_project() const
{
return block_->project();
}
protected:
virtual void redo();
virtual void undo();
private:
ClipBlock *block_;
Rational old_media_in_;
Rational new_media_in_;
};
class TimelineAddTrackCommand : public UndoCommand {
public:
TimelineAddTrackCommand(TrackList *timeline)
: TimelineAddTrackCommand(timeline,
OAK_CONFIG("AutoMergeTracks").toBool())
{
}
TimelineAddTrackCommand(TrackList *timeline, bool automerge_tracks);
static Track *run_immediately(TrackList *timeline)
{
TimelineAddTrackCommand c(timeline);
c.redo();
return c.track();
}
static Track *run_immediately(TrackList *timeline, bool automerge)
{
TimelineAddTrackCommand c(timeline, automerge);
c.redo();
return c.track();
}
virtual ~TimelineAddTrackCommand() override
{
delete position_command_;
}
Track *track() const
{
return track_;
}
virtual Project *get_relevant_project() const override
{
return timeline_->parent()->project();
}
protected:
virtual void redo() override;
virtual void undo() override;
private:
TrackList *timeline_;
Track *track_;
Node *merge_;
NodeInput base_;
NodeInput blend_;
NodeInput direct_;
MultiUndoCommand *position_command_;
QObject memory_manager_;
};
class TimelineRemoveTrackCommand : public UndoCommand {
public:
TimelineRemoveTrackCommand(Track *track)
: track_(track)
, remove_command_(nullptr)
{
}
virtual ~TimelineRemoveTrackCommand()
{
delete remove_command_;
}
virtual Project *get_relevant_project() const override
{
return track_->project();
}
protected:
virtual void prepare() override;
virtual void redo() override;
virtual void undo() override;
private:
Track *track_;
TrackList *list_;
int index_;
UndoCommand *remove_command_;
};
class TransitionRemoveCommand : public UndoCommand {
public:
TransitionRemoveCommand(TransitionBlock *block, bool remove_from_graph)
: block_(block)
, track_(block->track())
, remove_from_graph_(remove_from_graph)
, remove_command_(nullptr)
{
}
virtual Project *get_relevant_project() const override
{
return track_->project();
}
protected:
virtual void redo() override;
virtual void undo() override;
private:
TransitionBlock *block_;
Track *track_;
Block *out_block_;
Block *in_block_;
bool remove_from_graph_;
UndoCommand *remove_command_;
};
class TrackReplaceBlockWithGapCommand : public UndoCommand {
public:
TrackReplaceBlockWithGapCommand(Track *track, Block *block,
bool handle_transitions = true)
: track_(track)
, block_(block)
, existing_gap_(nullptr)
, existing_merged_gap_(nullptr)
, our_gap_(nullptr)
, handle_transitions_(handle_transitions)
{
}
virtual Project *get_relevant_project() const override
{
return block_->project();
}
protected:
virtual void redo() override;
virtual void undo() override;
private:
void create_remove_transition_command_if_necessary(bool next);
Track *track_;
Block *block_;
GapBlock *existing_gap_;
GapBlock *existing_merged_gap_;
bool existing_gap_precedes_;
GapBlock *our_gap_;
bool handle_transitions_;
QObject memory_manager_;
QVector<TransitionRemoveCommand *> transition_remove_commands_;
};
class BlockEnableDisableCommand : public UndoCommand {
public:
BlockEnableDisableCommand(Block *block, bool enabled)
: block_(block)
, old_enabled_(block_->is_enabled())
, new_enabled_(enabled)
{
}
virtual Project *get_relevant_project() const override
{
return block_->project();
}
protected:
virtual void redo() override
{
block_->set_enabled(new_enabled_);
}
virtual void undo() override
{
block_->set_enabled(old_enabled_);
}
private:
Block *block_;
bool old_enabled_;
bool new_enabled_;
};
class TrackListInsertGaps : public UndoCommand {
public:
TrackListInsertGaps(TrackList *track_list, const Rational &point,
const Rational &length)
: track_list_(track_list)
, point_(point)
, length_(length)
, split_command_(nullptr)
{
}
virtual ~TrackListInsertGaps() override
{
delete split_command_;
}
virtual Project *get_relevant_project() const override
{
return track_list_->parent()->project();
}
protected:
virtual void prepare() override;
virtual void redo() override;
virtual void undo() override;
private:
TrackList *track_list_;
Rational point_;
Rational length_;
QVector<Track *> working_tracks_;
QVector<Block *> gaps_to_extend_;
struct AddGap {
GapBlock *gap;
Block *before;
Track *track;
};
QVector<AddGap> gaps_added_;
BlockSplitPreservingLinksCommand *split_command_;
QObject memory_manager_;
};
class TimelineAddDefaultTransitionCommand : public UndoCommand {
public:
TimelineAddDefaultTransitionCommand(const QVector<ClipBlock *> &clips,
const Rational &timebase)
: clips_(clips)
, timebase_(timebase)
{
}
virtual ~TimelineAddDefaultTransitionCommand() override
{
qDeleteAll(commands_);
}
virtual Project *get_relevant_project() 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 { k_in, k_out, k_out_dual };
void add_transition(ClipBlock *c, CreateTransitionMode mode);
void adjust_clip_length(ClipBlock *c, const Rational &transition_length,
bool out);
void validate_transition_length(ClipBlock *c, Rational &transition_length);
QVector<ClipBlock *> clips_;
Rational timebase_;
QVector<UndoCommand *> commands_;
QHash<ClipBlock *, Rational> lengths_;
};
}
#endif // OAK_TIMELINEUNDOGENERAL_H