style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMELINECOMMON_H
|
||||
#define TIMELINECOMMON_H
|
||||
#ifndef OAK_TIMELINECOMMON_H
|
||||
#define OAK_TIMELINECOMMON_H
|
||||
|
||||
#include <olive/core/core.h>
|
||||
|
||||
@@ -36,20 +36,20 @@ class Track;
|
||||
|
||||
class Timeline {
|
||||
public:
|
||||
enum MovementMode { kNone, kMove, kTrimIn, kTrimOut };
|
||||
enum MovementMode { k_none, k_move, k_trim_in, k_trim_out };
|
||||
|
||||
enum ThumbnailMode { kThumbnailOff, kThumbnailInOut, kThumbnailOn };
|
||||
enum ThumbnailMode { k_thumbnail_off, k_thumbnail_in_out, k_thumbnail_on };
|
||||
|
||||
enum WaveformMode { kWaveformsDisabled, kWaveformsEnabled };
|
||||
enum WaveformMode { k_waveforms_disabled, k_waveforms_enabled };
|
||||
|
||||
static bool IsATrimMode(MovementMode mode)
|
||||
static bool is_a_trim_mode(MovementMode mode)
|
||||
{
|
||||
return mode == kTrimIn || mode == kTrimOut;
|
||||
return mode == k_trim_in || mode == k_trim_out;
|
||||
}
|
||||
|
||||
struct EditToInfo {
|
||||
Track *track;
|
||||
rational nearest_time;
|
||||
Rational nearest_time;
|
||||
Block *nearest_block;
|
||||
};
|
||||
};
|
||||
@@ -58,4 +58,4 @@ public:
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMELINECOMMON_H
|
||||
#endif // OAK_TIMELINECOMMON_H
|
||||
|
||||
@@ -25,18 +25,18 @@ namespace olive
|
||||
{
|
||||
|
||||
TimelineCoordinate::TimelineCoordinate()
|
||||
: track_(Track::kNone, 0)
|
||||
: track_(Track::k_none, 0)
|
||||
{
|
||||
}
|
||||
|
||||
TimelineCoordinate::TimelineCoordinate(const rational &frame,
|
||||
TimelineCoordinate::TimelineCoordinate(const Rational &frame,
|
||||
const Track::Reference &track)
|
||||
: frame_(frame)
|
||||
, track_(track)
|
||||
{
|
||||
}
|
||||
|
||||
TimelineCoordinate::TimelineCoordinate(const rational &frame,
|
||||
TimelineCoordinate::TimelineCoordinate(const Rational &frame,
|
||||
const Track::Type &track_type,
|
||||
const int &track_index)
|
||||
: frame_(frame)
|
||||
@@ -44,22 +44,22 @@ TimelineCoordinate::TimelineCoordinate(const rational &frame,
|
||||
{
|
||||
}
|
||||
|
||||
const rational &TimelineCoordinate::GetFrame() const
|
||||
const Rational &TimelineCoordinate::get_frame() const
|
||||
{
|
||||
return frame_;
|
||||
}
|
||||
|
||||
const Track::Reference &TimelineCoordinate::GetTrack() const
|
||||
const Track::Reference &TimelineCoordinate::get_track() const
|
||||
{
|
||||
return track_;
|
||||
}
|
||||
|
||||
void TimelineCoordinate::SetFrame(const rational &frame)
|
||||
void TimelineCoordinate::set_frame(const Rational &frame)
|
||||
{
|
||||
frame_ = frame;
|
||||
}
|
||||
|
||||
void TimelineCoordinate::SetTrack(const Track::Reference &track)
|
||||
void TimelineCoordinate::set_track(const Track::Reference &track)
|
||||
{
|
||||
track_ = track;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMELINECOORDINATE_H
|
||||
#define TIMELINECOORDINATE_H
|
||||
#ifndef OAK_TIMELINECOORDINATE_H
|
||||
#define OAK_TIMELINECOORDINATE_H
|
||||
|
||||
#include "node/output/track/track.h"
|
||||
|
||||
@@ -30,22 +30,22 @@ namespace olive
|
||||
class TimelineCoordinate {
|
||||
public:
|
||||
TimelineCoordinate();
|
||||
TimelineCoordinate(const rational &frame, const Track::Reference &track);
|
||||
TimelineCoordinate(const rational &frame, const Track::Type &track_type,
|
||||
TimelineCoordinate(const Rational &frame, const Track::Reference &track);
|
||||
TimelineCoordinate(const Rational &frame, const Track::Type &track_type,
|
||||
const int &track_index);
|
||||
|
||||
const rational &GetFrame() const;
|
||||
const Track::Reference &GetTrack() const;
|
||||
const Rational &get_frame() const;
|
||||
const Track::Reference &get_track() const;
|
||||
|
||||
void SetFrame(const rational &frame);
|
||||
void SetTrack(const Track::Reference &track);
|
||||
void set_frame(const Rational &frame);
|
||||
void set_track(const Track::Reference &track);
|
||||
|
||||
private:
|
||||
rational frame_;
|
||||
Rational frame_;
|
||||
|
||||
Track::Reference track_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMELINECOORDINATE_H
|
||||
#endif // OAK_TIMELINECOORDINATE_H
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace olive
|
||||
{
|
||||
|
||||
TimelineMarker::TimelineMarker(QObject *parent)
|
||||
: color_(OLIVE_CONFIG("MarkerColor").toInt())
|
||||
: color_(OAK_CONFIG("MarkerColor").toInt())
|
||||
{
|
||||
setParent(parent);
|
||||
}
|
||||
@@ -50,49 +50,49 @@ TimelineMarker::TimelineMarker(int color, const TimeRange &time,
|
||||
void TimelineMarker::set_time(const TimeRange &time)
|
||||
{
|
||||
time_ = time;
|
||||
emit TimeChanged(time_);
|
||||
emit time_changed(time_);
|
||||
}
|
||||
|
||||
void TimelineMarker::set_time(const rational &time)
|
||||
void TimelineMarker::set_time(const Rational &time)
|
||||
{
|
||||
set_time(TimeRange(time, time + time_.length()));
|
||||
}
|
||||
|
||||
bool TimelineMarker::has_sibling_at_time(const rational &t) const
|
||||
bool TimelineMarker::has_sibling_at_time(const Rational &t) const
|
||||
{
|
||||
TimelineMarker *m =
|
||||
static_cast<TimelineMarkerList *>(parent())->GetMarkerAtTime(t);
|
||||
static_cast<TimelineMarkerList *>(parent())->get_marker_at_time(t);
|
||||
return m && m != this;
|
||||
}
|
||||
|
||||
void TimelineMarker::set_name(const QString &name)
|
||||
{
|
||||
name_ = name;
|
||||
emit NameChanged(name_);
|
||||
emit name_changed(name_);
|
||||
}
|
||||
|
||||
void TimelineMarker::set_color(int c)
|
||||
{
|
||||
color_ = c;
|
||||
emit ColorChanged(color_);
|
||||
emit color_changed(color_);
|
||||
}
|
||||
|
||||
int TimelineMarker::GetMarkerHeight(const QFontMetrics &fm)
|
||||
int TimelineMarker::get_marker_height(const QFontMetrics &fm)
|
||||
{
|
||||
return fm.height();
|
||||
}
|
||||
|
||||
QRect TimelineMarker::Draw(QPainter *p, const QPoint &pt, int max_right,
|
||||
QRect TimelineMarker::draw(QPainter *p, const QPoint &pt, int max_right,
|
||||
double scale, bool selected)
|
||||
{
|
||||
QFontMetrics fm = p->fontMetrics();
|
||||
|
||||
int marker_height = GetMarkerHeight(fm);
|
||||
int marker_width = QtUtils::QFontMetricsWidth(fm, QStringLiteral("H"));
|
||||
int marker_height = get_marker_height(fm);
|
||||
int marker_width = QtUtils::q_font_metrics_width(fm, QStringLiteral("H"));
|
||||
|
||||
int half_width = marker_width / 2;
|
||||
|
||||
QColor c = QtUtils::toQColor(ColorCoding::GetColor(color()));
|
||||
QColor c = QtUtils::to_q_color(ColorCoding::get_color(color()));
|
||||
if (selected) {
|
||||
p->setPen(Qt::white);
|
||||
p->setBrush(c.lighter());
|
||||
@@ -107,14 +107,14 @@ QRect TimelineMarker::Draw(QPainter *p, const QPoint &pt, int max_right,
|
||||
op.setWrapMode(QTextOption::NoWrap);
|
||||
|
||||
if (time_.out() != time_.in()) {
|
||||
QRect marker_rect(pt.x(), top, time_.length().toDouble() * scale,
|
||||
QRect marker_rect(pt.x(), top, time_.length().to_double() * scale,
|
||||
marker_height);
|
||||
|
||||
p->drawRect(marker_rect);
|
||||
|
||||
if (!name_.isEmpty()) {
|
||||
p->setPen(
|
||||
ColorCoding::GetUISelectorColor(ColorCoding::GetColor(color_)));
|
||||
ColorCoding::get_ui_selector_color(ColorCoding::get_color(color_)));
|
||||
p->drawText(marker_rect.adjusted(marker_width / 4, 0, 0, 0), name_,
|
||||
op);
|
||||
}
|
||||
@@ -141,7 +141,7 @@ QRect TimelineMarker::Draw(QPainter *p, const QPoint &pt, int max_right,
|
||||
if (!name_.isEmpty() && max_right != -1) {
|
||||
QRect text_rect(right, top, max_right - right, marker_height);
|
||||
|
||||
int padding = QtUtils::QFontMetricsWidth(p->fontMetrics(),
|
||||
int padding = QtUtils::q_font_metrics_width(p->fontMetrics(),
|
||||
QStringLiteral(" "));
|
||||
text_rect.adjust(padding, 0, -padding - half_width, 0);
|
||||
|
||||
@@ -155,16 +155,16 @@ QRect TimelineMarker::Draw(QPainter *p, const QPoint &pt, int max_right,
|
||||
|
||||
bool TimelineMarker::load(QXmlStreamReader *reader)
|
||||
{
|
||||
rational in, out;
|
||||
Rational in, out;
|
||||
|
||||
XMLAttributeLoop(reader, attr)
|
||||
{
|
||||
if (attr.name() == QStringLiteral("name")) {
|
||||
this->set_name(attr.value().toString());
|
||||
} else if (attr.name() == QStringLiteral("in")) {
|
||||
in = rational::fromString(attr.value().toString().toStdString());
|
||||
in = Rational::from_string(attr.value().toString().toStdString());
|
||||
} else if (attr.name() == QStringLiteral("out")) {
|
||||
out = rational::fromString(attr.value().toString().toStdString());
|
||||
out = Rational::from_string(attr.value().toString().toStdString());
|
||||
} else if (attr.name() == QStringLiteral("color")) {
|
||||
this->set_color(attr.value().toInt());
|
||||
}
|
||||
@@ -183,17 +183,17 @@ void TimelineMarker::save(QXmlStreamWriter *writer) const
|
||||
writer->writeAttribute(QStringLiteral("name"), this->name());
|
||||
writer->writeAttribute(
|
||||
QStringLiteral("in"),
|
||||
QString::fromStdString(this->time().in().toString()));
|
||||
QString::fromStdString(this->time().in().to_string()));
|
||||
writer->writeAttribute(
|
||||
QStringLiteral("out"),
|
||||
QString::fromStdString(this->time().out().toString()));
|
||||
QString::fromStdString(this->time().out().to_string()));
|
||||
writer->writeAttribute(QStringLiteral("color"),
|
||||
QString::number(this->color()));
|
||||
}
|
||||
|
||||
bool TimelineMarkerList::load(QXmlStreamReader *reader)
|
||||
{
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
while (xml_read_next_start_element(reader)) {
|
||||
if (reader->name() == QStringLiteral("marker")) {
|
||||
TimelineMarker *marker = new TimelineMarker(this);
|
||||
if (!marker->load(reader)) {
|
||||
@@ -226,37 +226,37 @@ void TimelineMarkerList::childEvent(QChildEvent *e)
|
||||
|
||||
if (TimelineMarker *marker = dynamic_cast<TimelineMarker *>(e->child())) {
|
||||
if (e->type() == QChildEvent::ChildAdded) {
|
||||
connect(marker, &TimelineMarker::TimeChanged, this,
|
||||
&TimelineMarkerList::HandleMarkerTimeChange);
|
||||
connect(marker, &TimelineMarker::TimeChanged, this,
|
||||
&TimelineMarkerList::HandleMarkerModification);
|
||||
connect(marker, &TimelineMarker::NameChanged, this,
|
||||
&TimelineMarkerList::HandleMarkerModification);
|
||||
connect(marker, &TimelineMarker::ColorChanged, this,
|
||||
&TimelineMarkerList::HandleMarkerModification);
|
||||
connect(marker, &TimelineMarker::time_changed, this,
|
||||
&TimelineMarkerList::handle_marker_time_change);
|
||||
connect(marker, &TimelineMarker::time_changed, this,
|
||||
&TimelineMarkerList::handle_marker_modification);
|
||||
connect(marker, &TimelineMarker::name_changed, this,
|
||||
&TimelineMarkerList::handle_marker_modification);
|
||||
connect(marker, &TimelineMarker::color_changed, this,
|
||||
&TimelineMarkerList::handle_marker_modification);
|
||||
|
||||
InsertIntoList(marker);
|
||||
insert_into_list(marker);
|
||||
|
||||
emit MarkerAdded(marker);
|
||||
emit marker_added(marker);
|
||||
|
||||
} else if (e->type() == QChildEvent::ChildRemoved) {
|
||||
RemoveFromList(marker);
|
||||
remove_from_list(marker);
|
||||
|
||||
disconnect(marker, &TimelineMarker::TimeChanged, this,
|
||||
&TimelineMarkerList::HandleMarkerTimeChange);
|
||||
disconnect(marker, &TimelineMarker::TimeChanged, this,
|
||||
&TimelineMarkerList::HandleMarkerModification);
|
||||
disconnect(marker, &TimelineMarker::NameChanged, this,
|
||||
&TimelineMarkerList::HandleMarkerModification);
|
||||
disconnect(marker, &TimelineMarker::ColorChanged, this,
|
||||
&TimelineMarkerList::HandleMarkerModification);
|
||||
disconnect(marker, &TimelineMarker::time_changed, this,
|
||||
&TimelineMarkerList::handle_marker_time_change);
|
||||
disconnect(marker, &TimelineMarker::time_changed, this,
|
||||
&TimelineMarkerList::handle_marker_modification);
|
||||
disconnect(marker, &TimelineMarker::name_changed, this,
|
||||
&TimelineMarkerList::handle_marker_modification);
|
||||
disconnect(marker, &TimelineMarker::color_changed, this,
|
||||
&TimelineMarkerList::handle_marker_modification);
|
||||
|
||||
emit MarkerRemoved(marker);
|
||||
emit marker_removed(marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineMarkerList::InsertIntoList(TimelineMarker *marker)
|
||||
void TimelineMarkerList::insert_into_list(TimelineMarker *marker)
|
||||
{
|
||||
// Insertion sort by time to allow some loop optimizations
|
||||
bool found = false;
|
||||
@@ -277,7 +277,7 @@ void TimelineMarkerList::InsertIntoList(TimelineMarker *marker)
|
||||
}
|
||||
}
|
||||
|
||||
bool TimelineMarkerList::RemoveFromList(TimelineMarker *marker)
|
||||
bool TimelineMarkerList::remove_from_list(TimelineMarker *marker)
|
||||
{
|
||||
auto it = std::find(markers_.begin(), markers_.end(), marker);
|
||||
|
||||
@@ -289,12 +289,12 @@ bool TimelineMarkerList::RemoveFromList(TimelineMarker *marker)
|
||||
return false;
|
||||
}
|
||||
|
||||
void TimelineMarkerList::HandleMarkerModification()
|
||||
void TimelineMarkerList::handle_marker_modification()
|
||||
{
|
||||
emit MarkerModified(static_cast<TimelineMarker *>(sender()));
|
||||
emit marker_modified(static_cast<TimelineMarker *>(sender()));
|
||||
}
|
||||
|
||||
void TimelineMarkerList::HandleMarkerTimeChange()
|
||||
void TimelineMarkerList::handle_marker_time_change()
|
||||
{
|
||||
TimelineMarker *m = static_cast<TimelineMarker *>(sender());
|
||||
|
||||
@@ -302,7 +302,7 @@ void TimelineMarkerList::HandleMarkerTimeChange()
|
||||
|
||||
if (it != markers_.end()) {
|
||||
markers_.erase(it);
|
||||
InsertIntoList(m);
|
||||
insert_into_list(m);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,9 +324,9 @@ MarkerAddCommand::MarkerAddCommand(TimelineMarkerList *marker_list,
|
||||
added_marker_->setParent(&memory_manager_);
|
||||
}
|
||||
|
||||
Project *MarkerAddCommand::GetRelevantProject() const
|
||||
Project *MarkerAddCommand::get_relevant_project() const
|
||||
{
|
||||
return Project::GetProjectFromObject(marker_list_);
|
||||
return Project::get_project_from_object(marker_list_);
|
||||
}
|
||||
|
||||
void MarkerAddCommand::redo()
|
||||
@@ -344,9 +344,9 @@ MarkerRemoveCommand::MarkerRemoveCommand(TimelineMarker *marker)
|
||||
{
|
||||
}
|
||||
|
||||
Project *MarkerRemoveCommand::GetRelevantProject() const
|
||||
Project *MarkerRemoveCommand::get_relevant_project() const
|
||||
{
|
||||
return Project::GetProjectFromObject(marker_);
|
||||
return Project::get_project_from_object(marker_);
|
||||
}
|
||||
|
||||
void MarkerRemoveCommand::redo()
|
||||
@@ -367,9 +367,9 @@ MarkerChangeColorCommand::MarkerChangeColorCommand(TimelineMarker *marker,
|
||||
{
|
||||
}
|
||||
|
||||
Project *MarkerChangeColorCommand::GetRelevantProject() const
|
||||
Project *MarkerChangeColorCommand::get_relevant_project() const
|
||||
{
|
||||
return Project::GetProjectFromObject(marker_);
|
||||
return Project::get_project_from_object(marker_);
|
||||
}
|
||||
|
||||
void MarkerChangeColorCommand::redo()
|
||||
@@ -390,9 +390,9 @@ MarkerChangeNameCommand::MarkerChangeNameCommand(TimelineMarker *marker,
|
||||
{
|
||||
}
|
||||
|
||||
Project *MarkerChangeNameCommand::GetRelevantProject() const
|
||||
Project *MarkerChangeNameCommand::get_relevant_project() const
|
||||
{
|
||||
return Project::GetProjectFromObject(marker_);
|
||||
return Project::get_project_from_object(marker_);
|
||||
}
|
||||
|
||||
void MarkerChangeNameCommand::redo()
|
||||
@@ -415,9 +415,9 @@ MarkerChangeTimeCommand::MarkerChangeTimeCommand(TimelineMarker *marker,
|
||||
{
|
||||
}
|
||||
|
||||
Project *MarkerChangeTimeCommand::GetRelevantProject() const
|
||||
Project *MarkerChangeTimeCommand::get_relevant_project() const
|
||||
{
|
||||
return Project::GetProjectFromObject(marker_);
|
||||
return Project::get_project_from_object(marker_);
|
||||
}
|
||||
|
||||
void MarkerChangeTimeCommand::redo()
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMELINEMARKER_H
|
||||
#define TIMELINEMARKER_H
|
||||
#ifndef OAK_TIMELINEMARKER_H
|
||||
#define OAK_TIMELINEMARKER_H
|
||||
|
||||
#include <olive/core/core.h>
|
||||
#include <QPainter>
|
||||
@@ -47,9 +47,9 @@ public:
|
||||
return time_;
|
||||
}
|
||||
void set_time(const TimeRange &time);
|
||||
void set_time(const rational &time);
|
||||
void set_time(const Rational &time);
|
||||
|
||||
bool has_sibling_at_time(const rational &t) const;
|
||||
bool has_sibling_at_time(const Rational &t) const;
|
||||
|
||||
const QString &name() const
|
||||
{
|
||||
@@ -63,19 +63,19 @@ public:
|
||||
}
|
||||
void set_color(int c);
|
||||
|
||||
static int GetMarkerHeight(const QFontMetrics &fm);
|
||||
QRect Draw(QPainter *p, const QPoint &pt, int max_right, double scale,
|
||||
static int get_marker_height(const QFontMetrics &fm);
|
||||
QRect draw(QPainter *p, const QPoint &pt, int max_right, double scale,
|
||||
bool selected);
|
||||
|
||||
bool load(QXmlStreamReader *reader);
|
||||
void save(QXmlStreamWriter *writer) const;
|
||||
|
||||
signals:
|
||||
void TimeChanged(const TimeRange &time);
|
||||
void time_changed(const TimeRange &time);
|
||||
|
||||
void NameChanged(const QString &name);
|
||||
void name_changed(const QString &name);
|
||||
|
||||
void ColorChanged(int c);
|
||||
void color_changed(int c);
|
||||
|
||||
private:
|
||||
TimeRange time_;
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
bool load(QXmlStreamReader *reader);
|
||||
void save(QXmlStreamWriter *writer) const;
|
||||
|
||||
TimelineMarker *GetMarkerAtTime(const rational &t) const
|
||||
TimelineMarker *get_marker_at_time(const Rational &t) const
|
||||
{
|
||||
for (auto it = markers_.cbegin(); it != markers_.cend(); it++) {
|
||||
TimelineMarker *m = *it;
|
||||
@@ -141,17 +141,17 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TimelineMarker *GetClosestMarkerToTime(const rational &t) const
|
||||
TimelineMarker *get_closest_marker_to_time(const Rational &t) const
|
||||
{
|
||||
TimelineMarker *closest = nullptr;
|
||||
|
||||
for (auto it = markers_.cbegin(); it != markers_.cend(); it++) {
|
||||
TimelineMarker *m = *it;
|
||||
|
||||
rational this_diff = qAbs(m->time().in() - t);
|
||||
Rational this_diff = qAbs(m->time().in() - t);
|
||||
|
||||
if (closest) {
|
||||
rational stored_diff = qAbs(closest->time().in() - t);
|
||||
Rational stored_diff = qAbs(closest->time().in() - t);
|
||||
|
||||
if (this_diff > stored_diff) {
|
||||
// Since the list is organized by time, if the diff increases, assume we are only going
|
||||
@@ -167,25 +167,25 @@ public:
|
||||
}
|
||||
|
||||
signals:
|
||||
void MarkerAdded(TimelineMarker *marker);
|
||||
void marker_added(TimelineMarker *marker);
|
||||
|
||||
void MarkerRemoved(TimelineMarker *marker);
|
||||
void marker_removed(TimelineMarker *marker);
|
||||
|
||||
void MarkerModified(TimelineMarker *marker);
|
||||
void marker_modified(TimelineMarker *marker);
|
||||
|
||||
protected:
|
||||
virtual void childEvent(QChildEvent *e) override;
|
||||
|
||||
private:
|
||||
void InsertIntoList(TimelineMarker *m);
|
||||
bool RemoveFromList(TimelineMarker *m);
|
||||
void insert_into_list(TimelineMarker *m);
|
||||
bool remove_from_list(TimelineMarker *m);
|
||||
|
||||
std::vector<TimelineMarker *> markers_;
|
||||
|
||||
private slots:
|
||||
void HandleMarkerModification();
|
||||
void handle_marker_modification();
|
||||
|
||||
void HandleMarkerTimeChange();
|
||||
void handle_marker_time_change();
|
||||
};
|
||||
|
||||
class MarkerAddCommand : public UndoCommand {
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
const QString &name, int color);
|
||||
MarkerAddCommand(TimelineMarkerList *marker_list, TimelineMarker *marker);
|
||||
|
||||
virtual Project *GetRelevantProject() const override;
|
||||
virtual Project *get_relevant_project() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo() override;
|
||||
@@ -211,7 +211,7 @@ class MarkerRemoveCommand : public UndoCommand {
|
||||
public:
|
||||
MarkerRemoveCommand(TimelineMarker *marker);
|
||||
|
||||
virtual Project *GetRelevantProject() const override;
|
||||
virtual Project *get_relevant_project() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo() override;
|
||||
@@ -228,7 +228,7 @@ class MarkerChangeColorCommand : public UndoCommand {
|
||||
public:
|
||||
MarkerChangeColorCommand(TimelineMarker *marker, int new_color);
|
||||
|
||||
virtual Project *GetRelevantProject() const override;
|
||||
virtual Project *get_relevant_project() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo() override;
|
||||
@@ -244,7 +244,7 @@ class MarkerChangeNameCommand : public UndoCommand {
|
||||
public:
|
||||
MarkerChangeNameCommand(TimelineMarker *marker, QString name);
|
||||
|
||||
virtual Project *GetRelevantProject() const override;
|
||||
virtual Project *get_relevant_project() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo() override;
|
||||
@@ -265,7 +265,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override;
|
||||
virtual Project *get_relevant_project() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo() override;
|
||||
@@ -279,4 +279,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMELINEMARKER_H
|
||||
#endif // OAK_TIMELINEMARKER_H
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMELINEUNDOCOMMON_H
|
||||
#define TIMELINEUNDOCOMMON_H
|
||||
#ifndef OAK_TIMELINEUNDOCOMMON_H
|
||||
#define OAK_TIMELINEUNDOCOMMON_H
|
||||
|
||||
#include "node/node.h"
|
||||
#include "node/nodeundo.h"
|
||||
@@ -28,23 +28,23 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
inline bool NodeCanBeRemoved(Node *n)
|
||||
inline bool node_can_be_removed(Node *n)
|
||||
{
|
||||
return n->output_connections().empty();
|
||||
}
|
||||
|
||||
inline UndoCommand *CreateRemoveCommand(Node *n)
|
||||
inline UndoCommand *create_remove_command(Node *n)
|
||||
{
|
||||
return new NodeRemoveWithExclusiveDependenciesAndDisconnect(n);
|
||||
}
|
||||
|
||||
inline UndoCommand *CreateAndRunRemoveCommand(Node *n)
|
||||
inline UndoCommand *create_and_run_remove_command(Node *n)
|
||||
{
|
||||
UndoCommand *command = CreateRemoveCommand(n);
|
||||
UndoCommand *command = create_remove_command(n);
|
||||
command->redo_now();
|
||||
return command;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMELINEUNDOCOMMON_H
|
||||
#endif // OAK_TIMELINEUNDOCOMMON_H
|
||||
|
||||
@@ -90,10 +90,10 @@ TimelineAddTrackCommand::TimelineAddTrackCommand(TrackList *timeline,
|
||||
// Determine what input to connect it to
|
||||
QString relevant_input;
|
||||
|
||||
if (timeline_->type() == Track::kVideo) {
|
||||
relevant_input = Sequence::kTextureInput;
|
||||
} else if (timeline_->type() == Track::kAudio) {
|
||||
relevant_input = Sequence::kSamplesInput;
|
||||
if (timeline_->type() == Track::k_video) {
|
||||
relevant_input = Sequence::k_texture_input;
|
||||
} else if (timeline_->type() == Track::k_audio) {
|
||||
relevant_input = Sequence::k_samples_input;
|
||||
}
|
||||
|
||||
// If we have an input to connect to, set it as our `direct` connection
|
||||
@@ -101,17 +101,17 @@ TimelineAddTrackCommand::TimelineAddTrackCommand(TrackList *timeline,
|
||||
direct_ = NodeInput(timeline_->parent(), relevant_input);
|
||||
|
||||
// If we're automerging and something is already connected, determine if/how to merge it
|
||||
if (automerge_tracks && direct_.IsConnected()) {
|
||||
if (timeline_->type() == Track::kVideo) {
|
||||
if (automerge_tracks && direct_.is_connected()) {
|
||||
if (timeline_->type() == Track::k_video) {
|
||||
// Use merge for video
|
||||
merge_ = new MergeNode();
|
||||
base_ = NodeInput(merge_, MergeNode::kBaseIn);
|
||||
blend_ = NodeInput(merge_, MergeNode::kBlendIn);
|
||||
} else if (timeline_->type() == Track::kAudio) {
|
||||
base_ = NodeInput(merge_, MergeNode::k_base_in);
|
||||
blend_ = NodeInput(merge_, MergeNode::k_blend_in);
|
||||
} else if (timeline_->type() == Track::k_audio) {
|
||||
// Use math (add) for audio
|
||||
merge_ = new MathNode();
|
||||
base_ = NodeInput(merge_, MathNode::kParamAIn);
|
||||
blend_ = NodeInput(merge_, MathNode::kParamBIn);
|
||||
base_ = NodeInput(merge_, MathNode::k_param_a_in);
|
||||
blend_ = NodeInput(merge_, MathNode::k_param_b_in);
|
||||
}
|
||||
|
||||
if (merge_) {
|
||||
@@ -128,23 +128,23 @@ void TimelineAddTrackCommand::redo()
|
||||
Sequence *sequence = timeline_->parent();
|
||||
|
||||
// Add track to sequence
|
||||
track_->setParent(timeline_->GetParentGraph());
|
||||
if (timeline_->GetTrackCount() > 0) {
|
||||
track_->SetTrackHeight(
|
||||
timeline_->GetTrackAt(timeline_->GetTrackCount() - 1)
|
||||
->GetTrackHeight());
|
||||
track_->setParent(timeline_->get_parent_graph());
|
||||
if (timeline_->get_track_count() > 0) {
|
||||
track_->set_track_height(
|
||||
timeline_->get_track_at(timeline_->get_track_count() - 1)
|
||||
->get_track_height());
|
||||
}
|
||||
timeline_->ArrayAppend();
|
||||
Node::ConnectEdge(track_,
|
||||
timeline_->track_input(timeline_->ArraySize() - 1));
|
||||
timeline_->array_append();
|
||||
Node::connect_edge(track_,
|
||||
timeline_->track_input(timeline_->array_size() - 1));
|
||||
|
||||
qreal position_factor = 0.5;
|
||||
if (timeline_->type() == Track::kVideo) {
|
||||
if (timeline_->type() == Track::k_video) {
|
||||
position_factor = -position_factor;
|
||||
}
|
||||
bool create_pos_command =
|
||||
(!position_command_ && (timeline_->type() == Track::kVideo ||
|
||||
timeline_->type() == Track::kAudio));
|
||||
(!position_command_ && (timeline_->type() == Track::k_video ||
|
||||
timeline_->type() == Track::k_audio));
|
||||
if (create_pos_command) {
|
||||
position_command_ = new MultiUndoCommand();
|
||||
}
|
||||
@@ -152,41 +152,41 @@ void TimelineAddTrackCommand::redo()
|
||||
// Add merge if applicable
|
||||
if (merge_) {
|
||||
// Determine what was previously connected
|
||||
Node *previous_connection = direct_.GetConnectedOutput();
|
||||
Node *previous_connection = direct_.get_connected_output();
|
||||
|
||||
// Add merge to graph
|
||||
merge_->setParent(timeline_->GetParentGraph());
|
||||
merge_->setParent(timeline_->get_parent_graph());
|
||||
|
||||
// Connect merge between what used to be here
|
||||
Node::DisconnectEdge(previous_connection, direct_);
|
||||
Node::ConnectEdge(merge_, direct_);
|
||||
Node::ConnectEdge(previous_connection, base_);
|
||||
Node::ConnectEdge(track_, blend_);
|
||||
Node::disconnect_edge(previous_connection, direct_);
|
||||
Node::connect_edge(merge_, direct_);
|
||||
Node::connect_edge(previous_connection, base_);
|
||||
Node::connect_edge(track_, blend_);
|
||||
|
||||
if (create_pos_command) {
|
||||
position_command_->add_child(new NodeSetPositionCommand(
|
||||
track_, sequence,
|
||||
sequence->GetNodePositionInContext(sequence) +
|
||||
sequence->get_node_position_in_context(sequence) +
|
||||
QPointF(-1, -position_factor)));
|
||||
position_command_->add_child(new NodeSetPositionCommand(
|
||||
merge_, sequence,
|
||||
sequence->GetNodePositionInContext(sequence)));
|
||||
sequence->get_node_position_in_context(sequence)));
|
||||
position_command_->add_child(
|
||||
new NodeSetPositionAndDependenciesRecursivelyCommand(
|
||||
merge_, sequence,
|
||||
sequence->GetNodePositionInContext(sequence) +
|
||||
sequence->get_node_position_in_context(sequence) +
|
||||
QPointF(-1,
|
||||
position_factor * timeline_->GetTrackCount())));
|
||||
position_factor * timeline_->get_track_count())));
|
||||
}
|
||||
} else if (direct_.IsValid() && !direct_.IsConnected()) {
|
||||
} else if (direct_.is_valid() && !direct_.is_connected()) {
|
||||
// If no merge, we have a direct connection, and nothing else is connected, connect this
|
||||
Node::ConnectEdge(track_, direct_);
|
||||
Node::connect_edge(track_, direct_);
|
||||
|
||||
if (create_pos_command) {
|
||||
// Just position directly next to the context node
|
||||
position_command_->add_child(new NodeSetPositionCommand(
|
||||
track_, sequence,
|
||||
sequence->GetNodePositionInContext(sequence) +
|
||||
sequence->get_node_position_in_context(sequence) +
|
||||
QPointF(-1, position_factor)));
|
||||
}
|
||||
}
|
||||
@@ -205,22 +205,22 @@ void TimelineAddTrackCommand::undo()
|
||||
|
||||
// Remove merge if applicable
|
||||
if (merge_) {
|
||||
Node *previous_connection = base_.GetConnectedOutput();
|
||||
Node *previous_connection = base_.get_connected_output();
|
||||
|
||||
Node::DisconnectEdge(track_, blend_);
|
||||
Node::DisconnectEdge(previous_connection, base_);
|
||||
Node::DisconnectEdge(merge_, direct_);
|
||||
Node::ConnectEdge(previous_connection, direct_);
|
||||
Node::disconnect_edge(track_, blend_);
|
||||
Node::disconnect_edge(previous_connection, base_);
|
||||
Node::disconnect_edge(merge_, direct_);
|
||||
Node::connect_edge(previous_connection, direct_);
|
||||
|
||||
merge_->setParent(&memory_manager_);
|
||||
} else if (direct_.IsValid() && direct_.GetConnectedOutput() == track_) {
|
||||
Node::DisconnectEdge(track_, direct_);
|
||||
} else if (direct_.is_valid() && direct_.get_connected_output() == track_) {
|
||||
Node::disconnect_edge(track_, direct_);
|
||||
}
|
||||
|
||||
// Remove track
|
||||
Node::DisconnectEdge(track_,
|
||||
timeline_->track_input(timeline_->ArraySize() - 1));
|
||||
timeline_->ArrayRemoveLast();
|
||||
Node::disconnect_edge(track_,
|
||||
timeline_->track_input(timeline_->array_size() - 1));
|
||||
timeline_->array_remove_last();
|
||||
track_->setParent(&memory_manager_);
|
||||
}
|
||||
|
||||
@@ -248,20 +248,20 @@ void TransitionRemoveCommand::redo()
|
||||
}
|
||||
|
||||
if (in_block_) {
|
||||
Node::DisconnectEdge(in_block_,
|
||||
NodeInput(block_, TransitionBlock::kInBlockInput));
|
||||
Node::disconnect_edge(in_block_,
|
||||
NodeInput(block_, TransitionBlock::k_in_block_input));
|
||||
}
|
||||
|
||||
if (out_block_) {
|
||||
Node::DisconnectEdge(
|
||||
out_block_, NodeInput(block_, TransitionBlock::kOutBlockInput));
|
||||
Node::disconnect_edge(
|
||||
out_block_, NodeInput(block_, TransitionBlock::k_out_block_input));
|
||||
}
|
||||
|
||||
track_->RippleRemoveBlock(block_);
|
||||
track_->ripple_remove_block(block_);
|
||||
|
||||
if (remove_from_graph_) {
|
||||
if (!remove_command_) {
|
||||
remove_command_ = CreateRemoveCommand(block_);
|
||||
remove_command_ = create_remove_command(block_);
|
||||
}
|
||||
|
||||
remove_command_->redo_now();
|
||||
@@ -275,19 +275,19 @@ void TransitionRemoveCommand::undo()
|
||||
}
|
||||
|
||||
if (in_block_) {
|
||||
track_->InsertBlockBefore(block_, in_block_);
|
||||
track_->insert_block_before(block_, in_block_);
|
||||
} else {
|
||||
track_->InsertBlockAfter(block_, out_block_);
|
||||
track_->insert_block_after(block_, out_block_);
|
||||
}
|
||||
|
||||
if (in_block_) {
|
||||
Node::ConnectEdge(in_block_,
|
||||
NodeInput(block_, TransitionBlock::kInBlockInput));
|
||||
Node::connect_edge(in_block_,
|
||||
NodeInput(block_, TransitionBlock::k_in_block_input));
|
||||
}
|
||||
|
||||
if (out_block_) {
|
||||
Node::ConnectEdge(out_block_,
|
||||
NodeInput(block_, TransitionBlock::kOutBlockInput));
|
||||
Node::connect_edge(out_block_,
|
||||
NodeInput(block_, TransitionBlock::k_out_block_input));
|
||||
}
|
||||
|
||||
// These if statements must be separated because in_offset and out_offset report different things
|
||||
@@ -310,8 +310,8 @@ void TransitionRemoveCommand::undo()
|
||||
void TrackListInsertGaps::prepare()
|
||||
{
|
||||
// Determine if all tracks will be affected, which will allow us to make some optimizations
|
||||
foreach (Track *track, track_list_->GetTracks()) {
|
||||
if (track->IsLocked()) {
|
||||
foreach (Track *track, track_list_->get_tracks()) {
|
||||
if (track->is_locked()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ void TrackListInsertGaps::prepare()
|
||||
QVector<Track *> tracks_to_append_gap_to;
|
||||
|
||||
for (Track *track : qAsConst(working_tracks_)) {
|
||||
for (Block *b : track->Blocks()) {
|
||||
for (Block *b : track->blocks()) {
|
||||
if (dynamic_cast<GapBlock *>(b) && b->in() <= point_ &&
|
||||
b->out() >= point_) {
|
||||
// Found a gap at the location
|
||||
@@ -379,7 +379,7 @@ void TrackListInsertGaps::redo()
|
||||
|
||||
foreach (auto add_gap, gaps_added_) {
|
||||
add_gap.gap->setParent(add_gap.track->parent());
|
||||
add_gap.track->InsertBlockAfter(add_gap.gap, add_gap.before);
|
||||
add_gap.track->insert_block_after(add_gap.gap, add_gap.before);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ void TrackListInsertGaps::undo()
|
||||
{
|
||||
// Remove added gaps
|
||||
foreach (auto add_gap, gaps_added_) {
|
||||
add_gap.gap->track()->RippleRemoveBlock(add_gap.gap);
|
||||
add_gap.gap->track()->ripple_remove_block(add_gap.gap);
|
||||
add_gap.gap->setParent(&memory_manager_);
|
||||
}
|
||||
|
||||
@@ -409,8 +409,8 @@ void TrackReplaceBlockWithGapCommand::redo()
|
||||
{
|
||||
// Determine if this block is connected to any transitions that should also be removed by this operation
|
||||
if (handle_transitions_ && transition_remove_commands_.isEmpty()) {
|
||||
CreateRemoveTransitionCommandIfNecessary(false);
|
||||
CreateRemoveTransitionCommandIfNecessary(true);
|
||||
create_remove_transition_command_if_necessary(false);
|
||||
create_remove_transition_command_if_necessary(true);
|
||||
}
|
||||
for (auto it = transition_remove_commands_.cbegin();
|
||||
it != transition_remove_commands_.cend(); it++) {
|
||||
@@ -422,7 +422,7 @@ void TrackReplaceBlockWithGapCommand::redo()
|
||||
TimeRange invalidate_range(block_->in(), block_->out());
|
||||
|
||||
// Block has a next, which means it's NOT at the end of the sequence and thus requires a gap
|
||||
rational new_gap_length = block_->length();
|
||||
Rational new_gap_length = block_->length();
|
||||
|
||||
Block *previous = block_->previous();
|
||||
Block *next = block_->next();
|
||||
@@ -436,7 +436,7 @@ void TrackReplaceBlockWithGapCommand::redo()
|
||||
|
||||
existing_merged_gap_ = static_cast<GapBlock *>(next);
|
||||
new_gap_length += existing_merged_gap_->length();
|
||||
track_->RippleRemoveBlock(existing_merged_gap_);
|
||||
track_->ripple_remove_block(existing_merged_gap_);
|
||||
existing_merged_gap_->setParent(&memory_manager_);
|
||||
} else if (previous_is_a_gap) {
|
||||
// Extend this gap to fill space left by block
|
||||
@@ -450,7 +450,7 @@ void TrackReplaceBlockWithGapCommand::redo()
|
||||
// Extend an existing gap
|
||||
new_gap_length += existing_gap_->length();
|
||||
existing_gap_->set_length_and_media_out(new_gap_length);
|
||||
track_->RippleRemoveBlock(block_);
|
||||
track_->ripple_remove_block(block_);
|
||||
|
||||
existing_gap_precedes_ = (existing_gap_ == previous);
|
||||
} else {
|
||||
@@ -461,17 +461,17 @@ void TrackReplaceBlockWithGapCommand::redo()
|
||||
}
|
||||
|
||||
our_gap_->setParent(track_->parent());
|
||||
track_->ReplaceBlock(block_, our_gap_);
|
||||
track_->replace_block(block_, our_gap_);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Block is at the end of the track, simply remove it
|
||||
Block *preceding = block_->previous();
|
||||
track_->RippleRemoveBlock(block_);
|
||||
track_->ripple_remove_block(block_);
|
||||
|
||||
// Determine if it's preceded by a gap, and remove that gap if so
|
||||
if (dynamic_cast<GapBlock *>(preceding)) {
|
||||
track_->RippleRemoveBlock(preceding);
|
||||
track_->ripple_remove_block(preceding);
|
||||
preceding->setParent(&memory_manager_);
|
||||
|
||||
existing_merged_gap_ = static_cast<GapBlock *>(preceding);
|
||||
@@ -484,27 +484,27 @@ void TrackReplaceBlockWithGapCommand::undo()
|
||||
if (our_gap_ || existing_gap_) {
|
||||
if (our_gap_) {
|
||||
// We made this gap, simply swap our gap back
|
||||
track_->ReplaceBlock(our_gap_, block_);
|
||||
track_->replace_block(our_gap_, block_);
|
||||
our_gap_->setParent(&memory_manager_);
|
||||
|
||||
} else {
|
||||
// If we're here, assume that we extended an existing gap
|
||||
rational original_gap_length =
|
||||
Rational original_gap_length =
|
||||
existing_gap_->length() - block_->length();
|
||||
|
||||
// If we merged two gaps together, restore the second one now
|
||||
if (existing_merged_gap_) {
|
||||
original_gap_length -= existing_merged_gap_->length();
|
||||
existing_merged_gap_->setParent(track_->parent());
|
||||
track_->InsertBlockAfter(existing_merged_gap_, existing_gap_);
|
||||
track_->insert_block_after(existing_merged_gap_, existing_gap_);
|
||||
existing_merged_gap_ = nullptr;
|
||||
}
|
||||
|
||||
// Restore original block
|
||||
if (existing_gap_precedes_) {
|
||||
track_->InsertBlockAfter(block_, existing_gap_);
|
||||
track_->insert_block_after(block_, existing_gap_);
|
||||
} else {
|
||||
track_->InsertBlockBefore(block_, existing_gap_);
|
||||
track_->insert_block_before(block_, existing_gap_);
|
||||
}
|
||||
|
||||
// Restore gap's original length
|
||||
@@ -520,12 +520,12 @@ void TrackReplaceBlockWithGapCommand::undo()
|
||||
// However, we may have removed an unnecessary gap that preceded it
|
||||
if (existing_merged_gap_) {
|
||||
existing_merged_gap_->setParent(track_->parent());
|
||||
track_->AppendBlock(existing_merged_gap_);
|
||||
track_->append_block(existing_merged_gap_);
|
||||
existing_merged_gap_ = nullptr;
|
||||
}
|
||||
|
||||
// Restore block
|
||||
track_->AppendBlock(block_);
|
||||
track_->append_block(block_);
|
||||
}
|
||||
|
||||
for (auto it = transition_remove_commands_.crbegin();
|
||||
@@ -534,7 +534,7 @@ void TrackReplaceBlockWithGapCommand::undo()
|
||||
}
|
||||
}
|
||||
|
||||
void TrackReplaceBlockWithGapCommand::CreateRemoveTransitionCommandIfNecessary(
|
||||
void TrackReplaceBlockWithGapCommand::create_remove_transition_command_if_necessary(
|
||||
bool next)
|
||||
{
|
||||
Block *relevant_block;
|
||||
@@ -564,7 +564,7 @@ void TimelineRemoveTrackCommand::prepare()
|
||||
{
|
||||
list_ = track_->sequence()->track_list(track_->type());
|
||||
|
||||
index_ = list_->GetArrayIndexFromCacheIndex(track_->Index());
|
||||
index_ = list_->get_array_index_from_cache_index(track_->index());
|
||||
|
||||
remove_command_ =
|
||||
new NodeRemoveWithExclusiveDependenciesAndDisconnect(track_);
|
||||
@@ -574,12 +574,12 @@ void TimelineRemoveTrackCommand::redo()
|
||||
{
|
||||
remove_command_->redo_now();
|
||||
|
||||
list_->parent()->InputArrayRemove(list_->track_input(), index_);
|
||||
list_->parent()->input_array_remove(list_->track_input(), index_);
|
||||
}
|
||||
|
||||
void TimelineRemoveTrackCommand::undo()
|
||||
{
|
||||
list_->parent()->InputArrayInsert(list_->track_input(), index_);
|
||||
list_->parent()->input_array_insert(list_->track_input(), index_);
|
||||
|
||||
remove_command_->undo_now();
|
||||
}
|
||||
@@ -594,64 +594,64 @@ void TimelineAddDefaultTransitionCommand::prepare()
|
||||
// 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);
|
||||
add_transition(c, k_in);
|
||||
}
|
||||
|
||||
// Handle out transition
|
||||
if (clips_.contains(static_cast<ClipBlock *>(c->next()))) {
|
||||
AddTransition(c, kOutDual);
|
||||
add_transition(c, k_out_dual);
|
||||
} else if (dynamic_cast<GapBlock *>(c->next()) || !c->next()) {
|
||||
// Create out transition
|
||||
AddTransition(c, kOut);
|
||||
add_transition(c, k_out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineAddDefaultTransitionCommand::AddTransition(
|
||||
void TimelineAddDefaultTransitionCommand::add_transition(
|
||||
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());
|
||||
if (t->type() == Track::k_video) {
|
||||
p = NodeFactory::create_from_id(
|
||||
OAK_CONFIG("DefaultVideoTransition").toString());
|
||||
} else if (t->type() == Track::k_audio) {
|
||||
p = NodeFactory::create_from_id(
|
||||
OAK_CONFIG("DefaultAudioTransition").toString());
|
||||
}
|
||||
|
||||
rational transition_length =
|
||||
OLIVE_CONFIG("DefaultTransitionLength").value<rational>();
|
||||
Rational transition_length =
|
||||
OAK_CONFIG("DefaultTransitionLength").value<Rational>();
|
||||
|
||||
// Resize original clip
|
||||
switch (mode) {
|
||||
case kIn:
|
||||
ValidateTransitionLength(c, transition_length);
|
||||
case k_in:
|
||||
validate_transition_length(c, transition_length);
|
||||
|
||||
if (transition_length > 0) {
|
||||
AdjustClipLength(c, transition_length, false);
|
||||
adjust_clip_length(c, transition_length, false);
|
||||
}
|
||||
break;
|
||||
case kOut:
|
||||
ValidateTransitionLength(c, transition_length);
|
||||
case k_out:
|
||||
validate_transition_length(c, transition_length);
|
||||
|
||||
if (transition_length > 0) {
|
||||
AdjustClipLength(c, transition_length, true);
|
||||
adjust_clip_length(c, transition_length, true);
|
||||
}
|
||||
break;
|
||||
case kOutDual: {
|
||||
rational half_length = transition_length / 2;
|
||||
case k_out_dual: {
|
||||
Rational half_length = transition_length / 2;
|
||||
|
||||
ValidateTransitionLength(static_cast<ClipBlock *>(c->next()),
|
||||
validate_transition_length(static_cast<ClipBlock *>(c->next()),
|
||||
half_length);
|
||||
ValidateTransitionLength(c, half_length);
|
||||
validate_transition_length(c, half_length);
|
||||
|
||||
transition_length = half_length * 2;
|
||||
|
||||
if (transition_length > 0) {
|
||||
AdjustClipLength(static_cast<ClipBlock *>(c->next()),
|
||||
adjust_clip_length(static_cast<ClipBlock *>(c->next()),
|
||||
half_length, false);
|
||||
AdjustClipLength(c, half_length, true);
|
||||
adjust_clip_length(c, half_length, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -666,26 +666,26 @@ void TimelineAddDefaultTransitionCommand::AddTransition(
|
||||
commands_.append(new NodeAddCommand(c->parent(), transition));
|
||||
|
||||
// Insert block
|
||||
Block *insert_after = (mode == kIn) ? c->previous() : c;
|
||||
Block *insert_after = (mode == k_in) ? c->previous() : c;
|
||||
commands_.append(new TrackInsertBlockAfterCommand(
|
||||
c->track(), transition, insert_after));
|
||||
|
||||
// Connect
|
||||
switch (mode) {
|
||||
case kIn:
|
||||
case k_in:
|
||||
commands_.append(new NodeEdgeAddCommand(
|
||||
c,
|
||||
NodeInput(transition, TransitionBlock::kInBlockInput)));
|
||||
NodeInput(transition, TransitionBlock::k_in_block_input)));
|
||||
break;
|
||||
case kOutDual:
|
||||
case k_out_dual:
|
||||
commands_.append(new NodeEdgeAddCommand(
|
||||
c->next(),
|
||||
NodeInput(transition, TransitionBlock::kInBlockInput)));
|
||||
NodeInput(transition, TransitionBlock::k_in_block_input)));
|
||||
/* fall through */
|
||||
case kOut:
|
||||
case k_out:
|
||||
commands_.append(new NodeEdgeAddCommand(
|
||||
c, NodeInput(transition,
|
||||
TransitionBlock::kOutBlockInput)));
|
||||
TransitionBlock::k_out_block_input)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -693,11 +693,11 @@ void TimelineAddDefaultTransitionCommand::AddTransition(
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineAddDefaultTransitionCommand::AdjustClipLength(
|
||||
ClipBlock *c, const rational &transition_length, bool out)
|
||||
void TimelineAddDefaultTransitionCommand::adjust_clip_length(
|
||||
ClipBlock *c, const Rational &transition_length, bool out)
|
||||
{
|
||||
rational cur_len = lengths_.value(c, c->length());
|
||||
rational new_len = cur_len - transition_length;
|
||||
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 {
|
||||
@@ -706,11 +706,11 @@ void TimelineAddDefaultTransitionCommand::AdjustClipLength(
|
||||
lengths_.insert(c, new_len);
|
||||
}
|
||||
|
||||
void TimelineAddDefaultTransitionCommand::ValidateTransitionLength(
|
||||
ClipBlock *c, rational &transition_length)
|
||||
void TimelineAddDefaultTransitionCommand::validate_transition_length(
|
||||
ClipBlock *c, Rational &transition_length)
|
||||
{
|
||||
rational cur_len = lengths_.value(c, c->length());
|
||||
rational half_cur_len = cur_len / 2;
|
||||
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_;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMELINEUNDOGENERAL_H
|
||||
#define TIMELINEUNDOGENERAL_H
|
||||
#ifndef OAK_TIMELINEUNDOGENERAL_H
|
||||
#define OAK_TIMELINEUNDOGENERAL_H
|
||||
|
||||
#include "config/config.h"
|
||||
#include "node/block/clip/clip.h"
|
||||
@@ -37,13 +37,13 @@ namespace olive
|
||||
|
||||
class BlockResizeCommand : public UndoCommand {
|
||||
public:
|
||||
BlockResizeCommand(Block *block, rational new_length)
|
||||
BlockResizeCommand(Block *block, Rational new_length)
|
||||
: block_(block)
|
||||
, new_length_(new_length)
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return block_->project();
|
||||
}
|
||||
@@ -54,19 +54,19 @@ protected:
|
||||
|
||||
private:
|
||||
Block *block_;
|
||||
rational old_length_;
|
||||
rational new_length_;
|
||||
Rational old_length_;
|
||||
Rational new_length_;
|
||||
};
|
||||
|
||||
class BlockResizeWithMediaInCommand : public UndoCommand {
|
||||
public:
|
||||
BlockResizeWithMediaInCommand(Block *block, rational new_length)
|
||||
BlockResizeWithMediaInCommand(Block *block, Rational new_length)
|
||||
: block_(block)
|
||||
, new_length_(new_length)
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const
|
||||
virtual Project *get_relevant_project() const
|
||||
{
|
||||
return block_->project();
|
||||
}
|
||||
@@ -77,19 +77,19 @@ protected:
|
||||
|
||||
private:
|
||||
Block *block_;
|
||||
rational old_length_;
|
||||
rational new_length_;
|
||||
Rational old_length_;
|
||||
Rational new_length_;
|
||||
};
|
||||
|
||||
class BlockSetMediaInCommand : public UndoCommand {
|
||||
public:
|
||||
BlockSetMediaInCommand(ClipBlock *block, rational new_media_in)
|
||||
BlockSetMediaInCommand(ClipBlock *block, Rational new_media_in)
|
||||
: block_(block)
|
||||
, new_media_in_(new_media_in)
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const
|
||||
virtual Project *get_relevant_project() const
|
||||
{
|
||||
return block_->project();
|
||||
}
|
||||
@@ -100,28 +100,28 @@ protected:
|
||||
|
||||
private:
|
||||
ClipBlock *block_;
|
||||
rational old_media_in_;
|
||||
rational new_media_in_;
|
||||
Rational old_media_in_;
|
||||
Rational new_media_in_;
|
||||
};
|
||||
|
||||
class TimelineAddTrackCommand : public UndoCommand {
|
||||
public:
|
||||
TimelineAddTrackCommand(TrackList *timeline)
|
||||
: TimelineAddTrackCommand(timeline,
|
||||
OLIVE_CONFIG("AutoMergeTracks").toBool())
|
||||
OAK_CONFIG("AutoMergeTracks").toBool())
|
||||
{
|
||||
}
|
||||
|
||||
TimelineAddTrackCommand(TrackList *timeline, bool automerge_tracks);
|
||||
|
||||
static Track *RunImmediately(TrackList *timeline)
|
||||
static Track *run_immediately(TrackList *timeline)
|
||||
{
|
||||
TimelineAddTrackCommand c(timeline);
|
||||
c.redo();
|
||||
return c.track();
|
||||
}
|
||||
|
||||
static Track *RunImmediately(TrackList *timeline, bool automerge)
|
||||
static Track *run_immediately(TrackList *timeline, bool automerge)
|
||||
{
|
||||
TimelineAddTrackCommand c(timeline, automerge);
|
||||
c.redo();
|
||||
@@ -138,7 +138,7 @@ public:
|
||||
return track_;
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return timeline_->parent()->project();
|
||||
}
|
||||
@@ -176,7 +176,7 @@ public:
|
||||
delete remove_command_;
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return track_->project();
|
||||
}
|
||||
@@ -208,7 +208,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return track_->project();
|
||||
}
|
||||
@@ -243,7 +243,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return block_->project();
|
||||
}
|
||||
@@ -254,7 +254,7 @@ protected:
|
||||
virtual void undo() override;
|
||||
|
||||
private:
|
||||
void CreateRemoveTransitionCommandIfNecessary(bool next);
|
||||
void create_remove_transition_command_if_necessary(bool next);
|
||||
|
||||
Track *track_;
|
||||
Block *block_;
|
||||
@@ -280,7 +280,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return block_->project();
|
||||
}
|
||||
@@ -306,8 +306,8 @@ private:
|
||||
|
||||
class TrackListInsertGaps : public UndoCommand {
|
||||
public:
|
||||
TrackListInsertGaps(TrackList *track_list, const rational &point,
|
||||
const rational &length)
|
||||
TrackListInsertGaps(TrackList *track_list, const Rational &point,
|
||||
const Rational &length)
|
||||
: track_list_(track_list)
|
||||
, point_(point)
|
||||
, length_(length)
|
||||
@@ -320,7 +320,7 @@ public:
|
||||
delete split_command_;
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return track_list_->parent()->project();
|
||||
}
|
||||
@@ -335,9 +335,9 @@ protected:
|
||||
private:
|
||||
TrackList *track_list_;
|
||||
|
||||
rational point_;
|
||||
Rational point_;
|
||||
|
||||
rational length_;
|
||||
Rational length_;
|
||||
|
||||
QVector<Track *> working_tracks_;
|
||||
|
||||
@@ -359,7 +359,7 @@ private:
|
||||
class TimelineAddDefaultTransitionCommand : public UndoCommand {
|
||||
public:
|
||||
TimelineAddDefaultTransitionCommand(const QVector<ClipBlock *> &clips,
|
||||
const rational &timebase)
|
||||
const Rational &timebase)
|
||||
: clips_(clips)
|
||||
, timebase_(timebase)
|
||||
{
|
||||
@@ -370,7 +370,7 @@ public:
|
||||
qDeleteAll(commands_);
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return clips_.empty() ? nullptr : clips_.first()->project();
|
||||
}
|
||||
@@ -393,20 +393,20 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
enum CreateTransitionMode { kIn, kOut, kOutDual };
|
||||
enum CreateTransitionMode { k_in, k_out, k_out_dual };
|
||||
|
||||
void AddTransition(ClipBlock *c, CreateTransitionMode mode);
|
||||
void AdjustClipLength(ClipBlock *c, const rational &transition_length,
|
||||
void add_transition(ClipBlock *c, CreateTransitionMode mode);
|
||||
void adjust_clip_length(ClipBlock *c, const Rational &transition_length,
|
||||
bool out);
|
||||
void ValidateTransitionLength(ClipBlock *c, rational &transition_length);
|
||||
void validate_transition_length(ClipBlock *c, Rational &transition_length);
|
||||
|
||||
QVector<ClipBlock *> clips_;
|
||||
rational timebase_;
|
||||
Rational timebase_;
|
||||
QVector<UndoCommand *> commands_;
|
||||
|
||||
QHash<ClipBlock *, rational> lengths_;
|
||||
QHash<ClipBlock *, Rational> lengths_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMELINEUNDOGENERAL_H
|
||||
#endif // OAK_TIMELINEUNDOGENERAL_H
|
||||
|
||||
@@ -41,7 +41,7 @@ void BlockTrimCommand::redo()
|
||||
// Determine how much time to invalidate
|
||||
TimeRange invalidate_range;
|
||||
|
||||
if (mode_ == Timeline::kTrimIn) {
|
||||
if (mode_ == Timeline::k_trim_in) {
|
||||
invalidate_range = TimeRange(block_->in(), block_->in() + trim_diff_);
|
||||
block_->set_length_and_media_in(new_length_);
|
||||
} else {
|
||||
@@ -54,27 +54,27 @@ void BlockTrimCommand::redo()
|
||||
// Add adjacent and insert it
|
||||
adjacent_->setParent(track_->parent());
|
||||
|
||||
if (mode_ == Timeline::kTrimIn) {
|
||||
track_->InsertBlockBefore(adjacent_, block_);
|
||||
if (mode_ == Timeline::k_trim_in) {
|
||||
track_->insert_block_before(adjacent_, block_);
|
||||
} else {
|
||||
track_->InsertBlockAfter(adjacent_, block_);
|
||||
track_->insert_block_after(adjacent_, block_);
|
||||
}
|
||||
} else if (we_removed_adjacent_) {
|
||||
track_->RippleRemoveBlock(adjacent_);
|
||||
track_->ripple_remove_block(adjacent_);
|
||||
|
||||
// It no longer inputs/outputs anything, remove it
|
||||
if (remove_block_from_graph_ && NodeCanBeRemoved(adjacent_)) {
|
||||
if (remove_block_from_graph_ && node_can_be_removed(adjacent_)) {
|
||||
if (!deleted_adjacent_command_) {
|
||||
deleted_adjacent_command_ =
|
||||
CreateAndRunRemoveCommand(adjacent_);
|
||||
create_and_run_remove_command(adjacent_);
|
||||
} else {
|
||||
deleted_adjacent_command_->redo_now();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rational adjacent_length = adjacent_->length() + trim_diff_;
|
||||
Rational adjacent_length = adjacent_->length() + trim_diff_;
|
||||
|
||||
if (mode_ == Timeline::kTrimIn) {
|
||||
if (mode_ == Timeline::k_trim_in) {
|
||||
adjacent_->set_length_and_media_out(adjacent_length);
|
||||
} else {
|
||||
adjacent_->set_length_and_media_in(adjacent_length);
|
||||
@@ -98,7 +98,7 @@ void BlockTrimCommand::undo()
|
||||
if (needs_adjacent_) {
|
||||
if (we_created_adjacent_) {
|
||||
// Adjacent is ours, just delete it
|
||||
track_->RippleRemoveBlock(adjacent_);
|
||||
track_->ripple_remove_block(adjacent_);
|
||||
adjacent_->setParent(&memory_manager_);
|
||||
} else {
|
||||
if (we_removed_adjacent_) {
|
||||
@@ -107,15 +107,15 @@ void BlockTrimCommand::undo()
|
||||
deleted_adjacent_command_->undo_now();
|
||||
}
|
||||
|
||||
if (mode_ == Timeline::kTrimIn) {
|
||||
track_->InsertBlockBefore(adjacent_, block_);
|
||||
if (mode_ == Timeline::k_trim_in) {
|
||||
track_->insert_block_before(adjacent_, block_);
|
||||
} else {
|
||||
track_->InsertBlockAfter(adjacent_, block_);
|
||||
track_->insert_block_after(adjacent_, block_);
|
||||
}
|
||||
} else {
|
||||
rational adjacent_length = adjacent_->length() - trim_diff_;
|
||||
Rational adjacent_length = adjacent_->length() - trim_diff_;
|
||||
|
||||
if (mode_ == Timeline::kTrimIn) {
|
||||
if (mode_ == Timeline::k_trim_in) {
|
||||
adjacent_->set_length_and_media_out(adjacent_length);
|
||||
} else {
|
||||
adjacent_->set_length_and_media_in(adjacent_length);
|
||||
@@ -126,7 +126,7 @@ void BlockTrimCommand::undo()
|
||||
|
||||
TimeRange invalidate_range;
|
||||
|
||||
if (mode_ == Timeline::kTrimIn) {
|
||||
if (mode_ == Timeline::k_trim_in) {
|
||||
block_->set_length_and_media_in(old_length_);
|
||||
|
||||
invalidate_range = TimeRange(block_->in(), block_->in() + trim_diff_);
|
||||
@@ -156,7 +156,7 @@ void BlockTrimCommand::prepare()
|
||||
trim_diff_ = old_length_ - new_length_;
|
||||
|
||||
// Retrieve our adjacent block (or nullptr if none)
|
||||
if (mode_ == Timeline::kTrimIn) {
|
||||
if (mode_ == Timeline::k_trim_in) {
|
||||
adjacent_ = block_->previous();
|
||||
} else {
|
||||
adjacent_ = block_->next();
|
||||
@@ -164,7 +164,7 @@ void BlockTrimCommand::prepare()
|
||||
|
||||
// Ignore when trimming the out with no adjacent, because the user must have trimmed the end
|
||||
// of the last block in the track, so we don't need to do anything elses
|
||||
needs_adjacent_ = (mode_ == Timeline::kTrimIn || adjacent_);
|
||||
needs_adjacent_ = (mode_ == Timeline::k_trim_in || adjacent_);
|
||||
|
||||
if (needs_adjacent_) {
|
||||
// If we're trimming shorter, we need an adjacent, so check if we have a viable one.
|
||||
@@ -179,7 +179,7 @@ void BlockTrimCommand::prepare()
|
||||
adjacent_->set_length_and_media_out(trim_diff_);
|
||||
} else {
|
||||
// Determine if we're removing the adjacent
|
||||
rational adjacent_length = adjacent_->length() + trim_diff_;
|
||||
Rational adjacent_length = adjacent_->length() + trim_diff_;
|
||||
we_removed_adjacent_ = adjacent_length.isNull();
|
||||
}
|
||||
}
|
||||
@@ -197,14 +197,14 @@ void TrackSlideCommand::redo()
|
||||
if (we_created_in_adjacent_) {
|
||||
// We created in adjacent, so all we have to do is insert it
|
||||
in_adjacent_->setParent(track_->parent());
|
||||
track_->InsertBlockBefore(in_adjacent_, blocks_.first());
|
||||
track_->insert_block_before(in_adjacent_, blocks_.first());
|
||||
} else if (-movement_ == in_adjacent_->length()) {
|
||||
// Movement will remove in adjacent
|
||||
track_->RippleRemoveBlock(in_adjacent_);
|
||||
track_->ripple_remove_block(in_adjacent_);
|
||||
|
||||
if (NodeCanBeRemoved(in_adjacent_)) {
|
||||
if (node_can_be_removed(in_adjacent_)) {
|
||||
if (!in_adjacent_remove_command_) {
|
||||
in_adjacent_remove_command_ = CreateRemoveCommand(in_adjacent_);
|
||||
in_adjacent_remove_command_ = create_remove_command(in_adjacent_);
|
||||
}
|
||||
|
||||
in_adjacent_remove_command_->redo_now();
|
||||
@@ -222,15 +222,15 @@ void TrackSlideCommand::redo()
|
||||
if (we_created_out_adjacent_) {
|
||||
// We created out adjacent, so we just have to insert it
|
||||
out_adjacent_->setParent(track_->parent());
|
||||
track_->InsertBlockAfter(out_adjacent_, blocks_.last());
|
||||
track_->insert_block_after(out_adjacent_, blocks_.last());
|
||||
} else if (movement_ == out_adjacent_->length()) {
|
||||
// Movement will remove out adjacent
|
||||
track_->RippleRemoveBlock(out_adjacent_);
|
||||
track_->ripple_remove_block(out_adjacent_);
|
||||
|
||||
if (NodeCanBeRemoved(out_adjacent_)) {
|
||||
if (node_can_be_removed(out_adjacent_)) {
|
||||
if (!out_adjacent_remove_command_) {
|
||||
out_adjacent_remove_command_ =
|
||||
CreateRemoveCommand(out_adjacent_);
|
||||
create_remove_command(out_adjacent_);
|
||||
}
|
||||
|
||||
out_adjacent_remove_command_->redo_now();
|
||||
@@ -257,7 +257,7 @@ void TrackSlideCommand::undo()
|
||||
|
||||
if (we_created_in_adjacent_) {
|
||||
// We created this, so we can remove it now
|
||||
track_->RippleRemoveBlock(in_adjacent_);
|
||||
track_->ripple_remove_block(in_adjacent_);
|
||||
in_adjacent_->setParent(&memory_manager_);
|
||||
} else if (we_removed_in_adjacent_) {
|
||||
if (in_adjacent_remove_command_) {
|
||||
@@ -265,7 +265,7 @@ void TrackSlideCommand::undo()
|
||||
in_adjacent_remove_command_->undo_now();
|
||||
}
|
||||
|
||||
track_->InsertBlockBefore(in_adjacent_, blocks_.first());
|
||||
track_->insert_block_before(in_adjacent_, blocks_.first());
|
||||
} else {
|
||||
// Simply resize adjacent
|
||||
in_adjacent_->set_length_and_media_out(in_adjacent_->length() -
|
||||
@@ -275,14 +275,14 @@ void TrackSlideCommand::undo()
|
||||
if (out_adjacent_) {
|
||||
if (we_created_out_adjacent_) {
|
||||
// We created this, so we can remove it now
|
||||
track_->RippleRemoveBlock(out_adjacent_);
|
||||
track_->ripple_remove_block(out_adjacent_);
|
||||
out_adjacent_->setParent(&memory_manager_);
|
||||
} else if (we_removed_out_adjacent_) {
|
||||
if (out_adjacent_remove_command_) {
|
||||
out_adjacent_remove_command_->undo_now();
|
||||
}
|
||||
|
||||
track_->InsertBlockAfter(out_adjacent_, blocks_.last());
|
||||
track_->insert_block_after(out_adjacent_, blocks_.last());
|
||||
} else {
|
||||
out_adjacent_->set_length_and_media_in(out_adjacent_->length() +
|
||||
movement_);
|
||||
@@ -328,11 +328,11 @@ TrackPlaceBlockCommand::~TrackPlaceBlockCommand()
|
||||
void TrackPlaceBlockCommand::redo()
|
||||
{
|
||||
// Determine if we need to add tracks
|
||||
if (track_index_ >= timeline_->GetTracks().size()) {
|
||||
if (track_index_ >= timeline_->get_tracks().size()) {
|
||||
if (add_track_commands_.isEmpty()) {
|
||||
// First redo, create tracks now
|
||||
add_track_commands_.resize(track_index_ -
|
||||
timeline_->GetTracks().size() + 1);
|
||||
timeline_->get_tracks().size() + 1);
|
||||
|
||||
for (int i = 0; i < add_track_commands_.size(); i++) {
|
||||
add_track_commands_[i] = new TimelineAddTrackCommand(timeline_);
|
||||
@@ -344,7 +344,7 @@ void TrackPlaceBlockCommand::redo()
|
||||
}
|
||||
}
|
||||
|
||||
Track *track = timeline_->GetTrackAt(track_index_);
|
||||
Track *track = timeline_->get_track_at(track_index_);
|
||||
|
||||
bool append = (in_ >= track->track_length());
|
||||
|
||||
@@ -357,38 +357,38 @@ void TrackPlaceBlockCommand::redo()
|
||||
gap_->set_length_and_media_out(in_ - track->track_length());
|
||||
}
|
||||
gap_->setParent(track->parent());
|
||||
track->AppendBlock(gap_);
|
||||
track->append_block(gap_);
|
||||
}
|
||||
|
||||
track->AppendBlock(insert_);
|
||||
track->append_block(insert_);
|
||||
} else {
|
||||
// Place the Block at this point
|
||||
if (!ripple_remove_command_) {
|
||||
ripple_remove_command_ = new TrackRippleRemoveAreaCommand(
|
||||
track, TimeRange(in_, in_ + insert_->length()));
|
||||
ripple_remove_command_->SetAllowSplittingGaps(true);
|
||||
ripple_remove_command_->set_allow_splitting_gaps(true);
|
||||
}
|
||||
|
||||
ripple_remove_command_->redo_now();
|
||||
track->InsertBlockAfter(insert_,
|
||||
ripple_remove_command_->GetInsertionIndex());
|
||||
track->insert_block_after(insert_,
|
||||
ripple_remove_command_->get_insertion_index());
|
||||
}
|
||||
}
|
||||
|
||||
void TrackPlaceBlockCommand::undo()
|
||||
{
|
||||
Track *t = timeline_->GetTrackAt(track_index_);
|
||||
Track *t = timeline_->get_track_at(track_index_);
|
||||
|
||||
TimeRange insert_range(insert_->in(), insert_->out());
|
||||
|
||||
// Firstly, remove our insert
|
||||
t->RippleRemoveBlock(insert_);
|
||||
t->ripple_remove_block(insert_);
|
||||
|
||||
if (ripple_remove_command_) {
|
||||
// If we ripple removed, just undo that
|
||||
ripple_remove_command_->undo_now();
|
||||
} else if (gap_) {
|
||||
t->RippleRemoveBlock(gap_);
|
||||
t->ripple_remove_block(gap_);
|
||||
gap_->setParent(&memory_manager_);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMELINEUNDOPOINTER_H
|
||||
#define TIMELINEUNDOPOINTER_H
|
||||
#ifndef OAK_TIMELINEUNDOPOINTER_H
|
||||
#define OAK_TIMELINEUNDOPOINTER_H
|
||||
|
||||
#include "node/block/gap/gap.h"
|
||||
#include "node/output/track/track.h"
|
||||
@@ -44,7 +44,7 @@ namespace olive
|
||||
*/
|
||||
class BlockTrimCommand : public UndoCommand {
|
||||
public:
|
||||
BlockTrimCommand(Track *track, Block *block, rational new_length,
|
||||
BlockTrimCommand(Track *track, Block *block, Rational new_length,
|
||||
Timeline::MovementMode mode)
|
||||
: track_(track)
|
||||
, block_(block)
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
delete deleted_adjacent_command_;
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return track_->project();
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
/**
|
||||
* @brief Set this if the trim should always affect the adjacent clip and not create a gap
|
||||
*/
|
||||
void SetTrimIsARollEdit(bool e)
|
||||
void set_trim_is_a_roll_edit(bool e)
|
||||
{
|
||||
trim_is_a_roll_edit_ = e;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
* default it also gets removed from the whole graph. Set this to FALSE to disable that
|
||||
* functionality.
|
||||
*/
|
||||
void SetRemoveZeroLengthFromGraph(bool e)
|
||||
void set_remove_zero_length_from_graph(bool e)
|
||||
{
|
||||
remove_block_from_graph_ = e;
|
||||
}
|
||||
@@ -93,12 +93,12 @@ protected:
|
||||
|
||||
private:
|
||||
bool doing_nothing_;
|
||||
rational trim_diff_;
|
||||
Rational trim_diff_;
|
||||
|
||||
Track *track_;
|
||||
Block *block_;
|
||||
rational old_length_;
|
||||
rational new_length_;
|
||||
Rational old_length_;
|
||||
Rational new_length_;
|
||||
Timeline::MovementMode mode_;
|
||||
|
||||
Block *adjacent_;
|
||||
@@ -117,7 +117,7 @@ class TrackSlideCommand : public UndoCommand {
|
||||
public:
|
||||
TrackSlideCommand(Track *track, const QList<Block *> &moving_blocks,
|
||||
Block *in_adjacent, Block *out_adjacent,
|
||||
const rational &movement)
|
||||
const Rational &movement)
|
||||
: track_(track)
|
||||
, blocks_(moving_blocks)
|
||||
, movement_(movement)
|
||||
@@ -137,7 +137,7 @@ public:
|
||||
delete out_adjacent_remove_command_;
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return track_->project();
|
||||
}
|
||||
@@ -152,7 +152,7 @@ protected:
|
||||
private:
|
||||
Track *track_;
|
||||
QList<Block *> blocks_;
|
||||
rational movement_;
|
||||
Rational movement_;
|
||||
|
||||
bool we_created_in_adjacent_;
|
||||
bool we_removed_in_adjacent_;
|
||||
@@ -176,7 +176,7 @@ private:
|
||||
class TrackPlaceBlockCommand : public UndoCommand {
|
||||
public:
|
||||
TrackPlaceBlockCommand(TrackList *timeline, int track, Block *block,
|
||||
rational in)
|
||||
Rational in)
|
||||
: timeline_(timeline)
|
||||
, track_index_(track)
|
||||
, in_(in)
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
|
||||
virtual ~TrackPlaceBlockCommand() override;
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return timeline_->parent()->project();
|
||||
}
|
||||
@@ -201,7 +201,7 @@ protected:
|
||||
private:
|
||||
TrackList *timeline_;
|
||||
int track_index_;
|
||||
rational in_;
|
||||
Rational in_;
|
||||
GapBlock *gap_;
|
||||
Block *insert_;
|
||||
QVector<TimelineAddTrackCommand *> add_track_commands_;
|
||||
@@ -211,4 +211,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMELINEUNDOPOINTER_H
|
||||
#endif // OAK_TIMELINEUNDOPOINTER_H
|
||||
|
||||
@@ -49,7 +49,7 @@ TrackRippleRemoveAreaCommand::~TrackRippleRemoveAreaCommand()
|
||||
void TrackRippleRemoveAreaCommand::prepare()
|
||||
{
|
||||
// Determine precisely what will be happening to these tracks
|
||||
Block *first_block = track_->NearestBlockBeforeOrAt(range_.in());
|
||||
Block *first_block = track_->nearest_block_before_or_at(range_.in());
|
||||
|
||||
if (!first_block) {
|
||||
// No blocks at this time, nothing to be done on this track
|
||||
@@ -140,15 +140,15 @@ void TrackRippleRemoveAreaCommand::redo()
|
||||
if (!removals_.isEmpty()) {
|
||||
foreach (auto op, removals_) {
|
||||
// Ripple remove them all first
|
||||
track_->RippleRemoveBlock(op.block);
|
||||
track_->ripple_remove_block(op.block);
|
||||
}
|
||||
|
||||
// Create undo commands for node removals where possible
|
||||
if (remove_block_commands_.isEmpty()) {
|
||||
foreach (auto op, removals_) {
|
||||
if (NodeCanBeRemoved(op.block)) {
|
||||
if (node_can_be_removed(op.block)) {
|
||||
remove_block_commands_.append(
|
||||
CreateRemoveCommand(op.block));
|
||||
create_remove_command(op.block));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ void TrackRippleRemoveAreaCommand::undo()
|
||||
}
|
||||
|
||||
foreach (auto op, removals_) {
|
||||
track_->InsertBlockAfter(op.block, op.before);
|
||||
track_->insert_block_after(op.block, op.before);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,8 +189,8 @@ void TrackRippleRemoveAreaCommand::undo()
|
||||
//
|
||||
void TrackListRippleRemoveAreaCommand::prepare()
|
||||
{
|
||||
foreach (Track *track, list_->GetTracks()) {
|
||||
if (track->IsLocked()) {
|
||||
foreach (Track *track, list_->get_tracks()) {
|
||||
if (track->is_locked()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -219,10 +219,10 @@ void TrackListRippleRemoveAreaCommand::undo()
|
||||
// TimelineRippleRemoveAreaCommand
|
||||
//
|
||||
TimelineRippleRemoveAreaCommand::TimelineRippleRemoveAreaCommand(
|
||||
Sequence *timeline, rational in, rational out)
|
||||
Sequence *timeline, Rational in, Rational out)
|
||||
: timeline_(timeline)
|
||||
{
|
||||
for (int i = 0; i < Track::kCount; i++) {
|
||||
for (int i = 0; i < Track::k_count; i++) {
|
||||
add_child(new TrackListRippleRemoveAreaCommand(
|
||||
timeline->track_list(static_cast<Track::Type>(i)), in, out));
|
||||
}
|
||||
@@ -233,7 +233,7 @@ TimelineRippleRemoveAreaCommand::TimelineRippleRemoveAreaCommand(
|
||||
//
|
||||
TrackListRippleToolCommand::TrackListRippleToolCommand(
|
||||
TrackList *track_list, const QHash<Track *, RippleInfo> &info,
|
||||
const rational &ripple_movement,
|
||||
const Rational &ripple_movement,
|
||||
const Timeline::MovementMode &movement_mode)
|
||||
: track_list_(track_list)
|
||||
, info_(info)
|
||||
@@ -252,8 +252,8 @@ void TrackListRippleToolCommand::ripple(bool redo)
|
||||
|
||||
// If we can shift, we will shift from the latest out before the ripple to the latest out after,
|
||||
// since those sections will be unchanged by this ripple
|
||||
rational pre_latest_out = RATIONAL_MIN;
|
||||
rational post_latest_out = RATIONAL_MIN;
|
||||
Rational pre_latest_out = RATIONAL_MIN;
|
||||
Rational post_latest_out = RATIONAL_MIN;
|
||||
|
||||
// Make timeline changes
|
||||
for (auto it = info_.cbegin(); it != info_.cend(); it++) {
|
||||
@@ -263,10 +263,10 @@ void TrackListRippleToolCommand::ripple(bool redo)
|
||||
Block *b = info.block;
|
||||
|
||||
// Generate block length
|
||||
rational new_block_length;
|
||||
rational operation_movement = ripple_movement_;
|
||||
Rational new_block_length;
|
||||
Rational operation_movement = ripple_movement_;
|
||||
|
||||
if (movement_mode_ == Timeline::kTrimIn) {
|
||||
if (movement_mode_ == Timeline::k_trim_in) {
|
||||
operation_movement = -operation_movement;
|
||||
}
|
||||
|
||||
@@ -278,8 +278,8 @@ void TrackListRippleToolCommand::ripple(bool redo)
|
||||
new_block_length = b->length() + operation_movement;
|
||||
}
|
||||
|
||||
rational pre_shift;
|
||||
rational post_shift;
|
||||
Rational pre_shift;
|
||||
Rational post_shift;
|
||||
|
||||
if (info.append_gap) {
|
||||
// Rather than rippling the referenced block, we'll insert a gap and ripple with that
|
||||
@@ -293,7 +293,7 @@ void TrackListRippleToolCommand::ripple(bool redo)
|
||||
}
|
||||
|
||||
gap->setParent(track->parent());
|
||||
track->InsertBlockBefore(gap, b);
|
||||
track->insert_block_before(gap, b);
|
||||
|
||||
// As an insertion, we will shift from the gap's in to the gap's out
|
||||
pre_shift = gap->in();
|
||||
@@ -304,7 +304,7 @@ void TrackListRippleToolCommand::ripple(bool redo)
|
||||
pre_shift = gap->out();
|
||||
post_shift = gap->in();
|
||||
|
||||
track->RippleRemoveBlock(gap);
|
||||
track->ripple_remove_block(gap);
|
||||
gap->setParent(&memory_manager_);
|
||||
}
|
||||
|
||||
@@ -323,12 +323,12 @@ void TrackListRippleToolCommand::ripple(bool redo)
|
||||
|
||||
// Remove gap from track and from graph
|
||||
working_data.removed_gap_after = b->previous();
|
||||
track->RippleRemoveBlock(b);
|
||||
track->ripple_remove_block(b);
|
||||
b->setParent(&memory_manager_);
|
||||
} else {
|
||||
// Restore gap to graph and track
|
||||
b->setParent(track->parent());
|
||||
track->InsertBlockAfter(b, working_data.removed_gap_after);
|
||||
track->insert_block_after(b, working_data.removed_gap_after);
|
||||
|
||||
// The earliest point changes will happen is at the start of this block
|
||||
working_data.earliest_point_of_change = b->in();
|
||||
@@ -342,13 +342,13 @@ void TrackListRippleToolCommand::ripple(bool redo)
|
||||
// Store old length
|
||||
working_data.old_length = b->length();
|
||||
|
||||
if (movement_mode_ == Timeline::kTrimIn) {
|
||||
if (movement_mode_ == Timeline::k_trim_in) {
|
||||
// The earliest point changes will occur is in point of this bloc
|
||||
working_data.earliest_point_of_change = b->in();
|
||||
|
||||
// Undo the trim in inversion we do above, this will still be inverted accurately for
|
||||
// undoing where appropriate
|
||||
rational inverted = -operation_movement;
|
||||
Rational inverted = -operation_movement;
|
||||
if (inverted > 0) {
|
||||
pre_shift = b->in() + inverted;
|
||||
post_shift = b->in();
|
||||
@@ -396,7 +396,7 @@ void TimelineRippleDeleteGapsAtRegionsCommand::prepare()
|
||||
const TimeRange &range = region.second;
|
||||
|
||||
GapBlock *gap =
|
||||
dynamic_cast<GapBlock *>(track->NearestBlockBeforeOrAt(range.in()));
|
||||
dynamic_cast<GapBlock *>(track->nearest_block_before_or_at(range.in()));
|
||||
|
||||
if (gap) {
|
||||
QVector<RemovalRequest> &gaps_on_track = requested_gaps[track];
|
||||
@@ -424,11 +424,11 @@ void TimelineRippleDeleteGapsAtRegionsCommand::prepare()
|
||||
|
||||
// For each gap on each track, find a corresponding gap on every other track (which may include
|
||||
// a requested gap) to ripple in order to keep everything synchronized
|
||||
QHash<GapBlock *, rational> gap_lengths;
|
||||
QHash<GapBlock *, Rational> gap_lengths;
|
||||
for (int gap_index = 0; gap_index < max_gaps; gap_index++) {
|
||||
rational earliest_point = RATIONAL_MAX;
|
||||
rational ripple_length = RATIONAL_MAX;
|
||||
rational latest_point = RATIONAL_MIN;
|
||||
Rational earliest_point = RATIONAL_MAX;
|
||||
Rational ripple_length = RATIONAL_MAX;
|
||||
Rational latest_point = RATIONAL_MIN;
|
||||
|
||||
foreach (const QVector<RemovalRequest> &gaps_on_track, requested_gaps) {
|
||||
if (gap_index < gaps_on_track.size()) {
|
||||
@@ -442,8 +442,8 @@ void TimelineRippleDeleteGapsAtRegionsCommand::prepare()
|
||||
// Determine which gaps will be involved in this operation
|
||||
QVector<GapBlock *> gaps;
|
||||
|
||||
foreach (Track *track, timeline_->GetTracks()) {
|
||||
if (track->IsLocked()) {
|
||||
foreach (Track *track, timeline_->get_tracks()) {
|
||||
if (track->is_locked()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@ void TimelineRippleDeleteGapsAtRegionsCommand::prepare()
|
||||
gap = requested_gaps_on_track.at(gap_index).gap;
|
||||
} else {
|
||||
// No requested gap was at this index, find one
|
||||
Block *block = track->NearestBlockAfterOrAt(earliest_point);
|
||||
Block *block = track->nearest_block_after_or_at(earliest_point);
|
||||
|
||||
if (block) {
|
||||
// Found a block, test if it's a gap
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMELINEUNDORIPPLE_H
|
||||
#define TIMELINEUNDORIPPLE_H
|
||||
#ifndef OAK_TIMELINEUNDORIPPLE_H
|
||||
#define OAK_TIMELINEUNDORIPPLE_H
|
||||
|
||||
#include "node/block/gap/gap.h"
|
||||
#include "node/output/track/track.h"
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
|
||||
virtual ~TrackRippleRemoveAreaCommand() override;
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return track_->project();
|
||||
}
|
||||
@@ -54,12 +54,12 @@ public:
|
||||
/**
|
||||
* @brief Block to insert after if you want to insert something between this ripple
|
||||
*/
|
||||
Block *GetInsertionIndex() const
|
||||
Block *get_insertion_index() const
|
||||
{
|
||||
return insert_previous_;
|
||||
}
|
||||
|
||||
Block *GetSplicedBlock() const
|
||||
Block *get_spliced_block() const
|
||||
{
|
||||
if (splice_split_command_) {
|
||||
return splice_split_command_->new_block();
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SetAllowSplittingGaps(bool e)
|
||||
void set_allow_splitting_gaps(bool e)
|
||||
{
|
||||
allow_splitting_gaps_ = e;
|
||||
}
|
||||
@@ -83,8 +83,8 @@ protected:
|
||||
private:
|
||||
struct TrimOperation {
|
||||
Block *block;
|
||||
rational old_length;
|
||||
rational new_length;
|
||||
Rational old_length;
|
||||
Rational new_length;
|
||||
};
|
||||
|
||||
struct RemoveOperation {
|
||||
@@ -107,7 +107,7 @@ private:
|
||||
|
||||
class TrackListRippleRemoveAreaCommand : public UndoCommand {
|
||||
public:
|
||||
TrackListRippleRemoveAreaCommand(TrackList *list, rational in, rational out)
|
||||
TrackListRippleRemoveAreaCommand(TrackList *list, Rational in, Rational out)
|
||||
: list_(list)
|
||||
, range_(in, out)
|
||||
{
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
qDeleteAll(commands_);
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return list_->parent()->project();
|
||||
}
|
||||
@@ -142,10 +142,10 @@ private:
|
||||
|
||||
class TimelineRippleRemoveAreaCommand : public MultiUndoCommand {
|
||||
public:
|
||||
TimelineRippleRemoveAreaCommand(Sequence *timeline, rational in,
|
||||
rational out);
|
||||
TimelineRippleRemoveAreaCommand(Sequence *timeline, Rational in,
|
||||
Rational out);
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return timeline_->project();
|
||||
}
|
||||
@@ -163,10 +163,10 @@ public:
|
||||
|
||||
TrackListRippleToolCommand(TrackList *track_list,
|
||||
const QHash<Track *, RippleInfo> &info,
|
||||
const rational &ripple_movement,
|
||||
const Rational &ripple_movement,
|
||||
const Timeline::MovementMode &movement_mode);
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return track_list_->parent()->project();
|
||||
}
|
||||
@@ -188,14 +188,14 @@ private:
|
||||
TrackList *track_list_;
|
||||
|
||||
QHash<Track *, RippleInfo> info_;
|
||||
rational ripple_movement_;
|
||||
Rational ripple_movement_;
|
||||
Timeline::MovementMode movement_mode_;
|
||||
|
||||
struct WorkingData {
|
||||
GapBlock *created_gap = nullptr;
|
||||
Block *removed_gap_after;
|
||||
rational old_length;
|
||||
rational earliest_point_of_change;
|
||||
Rational old_length;
|
||||
Rational earliest_point_of_change;
|
||||
};
|
||||
|
||||
QHash<Track *, WorkingData> working_data_;
|
||||
@@ -219,12 +219,12 @@ public:
|
||||
qDeleteAll(commands_);
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return timeline_->project();
|
||||
}
|
||||
|
||||
bool HasCommands() const
|
||||
bool has_commands() const
|
||||
{
|
||||
return !commands_.isEmpty();
|
||||
}
|
||||
@@ -250,4 +250,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMELINEUNDORIPPLE_H
|
||||
#endif // OAK_TIMELINEUNDORIPPLE_H
|
||||
|
||||
@@ -35,7 +35,7 @@ void BlockSplitCommand::prepare()
|
||||
{
|
||||
reconnect_tree_command_ = new MultiUndoCommand();
|
||||
new_block_ = static_cast<Block *>(
|
||||
Node::CopyNodeInGraph(block_, reconnect_tree_command_));
|
||||
Node::copy_node_in_graph(block_, reconnect_tree_command_));
|
||||
}
|
||||
|
||||
void BlockSplitCommand::redo()
|
||||
@@ -47,8 +47,8 @@ void BlockSplitCommand::redo()
|
||||
reconnect_tree_command_->redo_now();
|
||||
|
||||
// Determine our new lengths
|
||||
rational new_length = point_ - block_->in();
|
||||
rational new_part_length = block_->out() - point_;
|
||||
Rational new_length = point_ - block_->in();
|
||||
Rational new_part_length = block_->out() - point_;
|
||||
|
||||
// Begin an operation
|
||||
Track *track = block_->track();
|
||||
@@ -58,11 +58,11 @@ void BlockSplitCommand::redo()
|
||||
new_block()->set_length_and_media_in(new_part_length);
|
||||
|
||||
// Insert new block
|
||||
track->InsertBlockAfter(new_block(), block_);
|
||||
track->insert_block_after(new_block(), block_);
|
||||
|
||||
if (ClipBlock *new_clip = dynamic_cast<ClipBlock *>(new_block_)) {
|
||||
ClipBlock *old_clip = static_cast<ClipBlock *>(block_);
|
||||
new_clip->AddCachePassthroughFrom(old_clip);
|
||||
new_clip->add_cache_passthrough_from(old_clip);
|
||||
}
|
||||
|
||||
// If the block had an out transition, we move it to the new block
|
||||
@@ -75,9 +75,9 @@ void BlockSplitCommand::redo()
|
||||
block_->output_connections()) {
|
||||
if (output.second.node() == potential_transition) {
|
||||
moved_transition_ = NodeInput(potential_transition,
|
||||
TransitionBlock::kOutBlockInput);
|
||||
Node::DisconnectEdge(block_, moved_transition_);
|
||||
Node::ConnectEdge(new_block(), moved_transition_);
|
||||
TransitionBlock::k_out_block_input);
|
||||
Node::disconnect_edge(block_, moved_transition_);
|
||||
Node::connect_edge(new_block(), moved_transition_);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -88,13 +88,13 @@ void BlockSplitCommand::undo()
|
||||
{
|
||||
Track *track = block_->track();
|
||||
|
||||
if (moved_transition_.IsValid()) {
|
||||
Node::DisconnectEdge(new_block(), moved_transition_);
|
||||
Node::ConnectEdge(block_, moved_transition_);
|
||||
if (moved_transition_.is_valid()) {
|
||||
Node::disconnect_edge(new_block(), moved_transition_);
|
||||
Node::connect_edge(block_, moved_transition_);
|
||||
}
|
||||
|
||||
block_->set_length_and_media_out(old_length_);
|
||||
track->RippleRemoveBlock(new_block());
|
||||
track->ripple_remove_block(new_block());
|
||||
|
||||
// If we ran a reconnect command, disconnect now
|
||||
reconnect_tree_command_->undo_now();
|
||||
@@ -103,7 +103,7 @@ void BlockSplitCommand::undo()
|
||||
//
|
||||
// BlockSplitPreservingLinksCommand
|
||||
//
|
||||
Block *BlockSplitPreservingLinksCommand::GetSplit(Block *original,
|
||||
Block *BlockSplitPreservingLinksCommand::get_split(Block *original,
|
||||
int time_index) const
|
||||
{
|
||||
if (time_index >= 0 && time_index < times_.size()) {
|
||||
@@ -121,7 +121,7 @@ void BlockSplitPreservingLinksCommand::prepare()
|
||||
splits_.resize(times_.size());
|
||||
|
||||
for (int i = 0; i < times_.size(); i++) {
|
||||
const rational &time = times_.at(i);
|
||||
const Rational &time = times_.at(i);
|
||||
|
||||
// FIXME: I realize this isn't going to work if the times aren't ordered. I'm lazy so rather
|
||||
// than writing in a sorting algorithm here, I'll just put an assert as a reminder
|
||||
@@ -158,7 +158,7 @@ void BlockSplitPreservingLinksCommand::prepare()
|
||||
|
||||
Block *b = blocks_.at(j);
|
||||
|
||||
if (Block::AreLinked(a, b)) {
|
||||
if (Block::are_linked(a, b)) {
|
||||
// These blocks are linked, ensure all the splits are linked too
|
||||
|
||||
foreach (const QVector<Block *> &split_list, splits_) {
|
||||
@@ -178,7 +178,7 @@ void BlockSplitPreservingLinksCommand::prepare()
|
||||
void TrackSplitAtTimeCommand::prepare()
|
||||
{
|
||||
// Find Block that contains this time
|
||||
Block *b = track_->BlockContainingTime(point_);
|
||||
Block *b = track_->block_containing_time(point_);
|
||||
|
||||
if (b) {
|
||||
command_ = new BlockSplitCommand(b, point_);
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMELINEUNDOSPLIT_H
|
||||
#define TIMELINEUNDOSPLIT_H
|
||||
#ifndef OAK_TIMELINEUNDOSPLIT_H
|
||||
#define OAK_TIMELINEUNDOSPLIT_H
|
||||
|
||||
#include "node/output/track/track.h"
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace olive
|
||||
|
||||
class BlockSplitCommand : public UndoCommand {
|
||||
public:
|
||||
BlockSplitCommand(Block *block, rational point)
|
||||
BlockSplitCommand(Block *block, Rational point)
|
||||
: block_(block)
|
||||
, new_block_(nullptr)
|
||||
, point_(point)
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
delete reconnect_tree_command_;
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return block_->project();
|
||||
}
|
||||
@@ -66,8 +66,8 @@ private:
|
||||
Block *block_;
|
||||
Block *new_block_;
|
||||
|
||||
rational old_length_;
|
||||
rational point_;
|
||||
Rational old_length_;
|
||||
Rational point_;
|
||||
|
||||
MultiUndoCommand *reconnect_tree_command_;
|
||||
|
||||
@@ -77,7 +77,7 @@ private:
|
||||
class BlockSplitPreservingLinksCommand : public UndoCommand {
|
||||
public:
|
||||
BlockSplitPreservingLinksCommand(const QVector<Block *> &blocks,
|
||||
const QList<rational> ×)
|
||||
const QList<Rational> ×)
|
||||
: blocks_(blocks)
|
||||
, times_(times)
|
||||
{
|
||||
@@ -88,12 +88,12 @@ public:
|
||||
qDeleteAll(commands_);
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return blocks_.first()->project();
|
||||
}
|
||||
|
||||
Block *GetSplit(Block *original, int time_index) const;
|
||||
Block *get_split(Block *original, int time_index) const;
|
||||
|
||||
protected:
|
||||
virtual void prepare() override;
|
||||
@@ -115,7 +115,7 @@ protected:
|
||||
private:
|
||||
QVector<Block *> blocks_;
|
||||
|
||||
QList<rational> times_;
|
||||
QList<Rational> times_;
|
||||
|
||||
QVector<UndoCommand *> commands_;
|
||||
|
||||
@@ -124,7 +124,7 @@ private:
|
||||
|
||||
class TrackSplitAtTimeCommand : public UndoCommand {
|
||||
public:
|
||||
TrackSplitAtTimeCommand(Track *track, rational point)
|
||||
TrackSplitAtTimeCommand(Track *track, Rational point)
|
||||
: track_(track)
|
||||
, point_(point)
|
||||
, command_(nullptr)
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
delete command_;
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return track_->project();
|
||||
}
|
||||
@@ -161,11 +161,11 @@ protected:
|
||||
private:
|
||||
Track *track_;
|
||||
|
||||
rational point_;
|
||||
Rational point_;
|
||||
|
||||
UndoCommand *command_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMELINEUNDOSPLIT_H
|
||||
#endif // OAK_TIMELINEUNDOSPLIT_H
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMELINEUNDOTRACK_H
|
||||
#define TIMELINEUNDOTRACK_H
|
||||
#ifndef OAK_TIMELINEUNDOTRACK_H
|
||||
#define OAK_TIMELINEUNDOTRACK_H
|
||||
|
||||
#include "node/output/track/track.h"
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return track_->project();
|
||||
}
|
||||
@@ -44,12 +44,12 @@ protected:
|
||||
virtual void redo() override
|
||||
{
|
||||
before_ = block_->previous();
|
||||
track_->RippleRemoveBlock(block_);
|
||||
track_->ripple_remove_block(block_);
|
||||
}
|
||||
|
||||
virtual void undo() override
|
||||
{
|
||||
track_->InsertBlockAfter(block_, before_);
|
||||
track_->insert_block_after(block_, before_);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return track_->project();
|
||||
}
|
||||
@@ -76,12 +76,12 @@ public:
|
||||
protected:
|
||||
virtual void redo() override
|
||||
{
|
||||
track_->PrependBlock(block_);
|
||||
track_->prepend_block(block_);
|
||||
}
|
||||
|
||||
virtual void undo() override
|
||||
{
|
||||
track_->RippleRemoveBlock(block_);
|
||||
track_->ripple_remove_block(block_);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return block_->project();
|
||||
}
|
||||
@@ -106,12 +106,12 @@ public:
|
||||
protected:
|
||||
virtual void redo() override
|
||||
{
|
||||
track_->InsertBlockAfter(block_, before_);
|
||||
track_->insert_block_after(block_, before_);
|
||||
}
|
||||
|
||||
virtual void undo() override
|
||||
{
|
||||
track_->RippleRemoveBlock(block_);
|
||||
track_->ripple_remove_block(block_);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return track_->project();
|
||||
}
|
||||
@@ -144,12 +144,12 @@ public:
|
||||
protected:
|
||||
virtual void redo() override
|
||||
{
|
||||
track_->ReplaceBlock(old_, replace_);
|
||||
track_->replace_block(old_, replace_);
|
||||
}
|
||||
|
||||
virtual void undo() override
|
||||
{
|
||||
track_->ReplaceBlock(replace_, old_);
|
||||
track_->replace_block(replace_, old_);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -160,4 +160,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMELINEUNDOTRACK_H
|
||||
#endif // OAK_TIMELINEUNDOTRACK_H
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMELINEUNDOWORKAREA_H
|
||||
#define TIMELINEUNDOWORKAREA_H
|
||||
#ifndef OAK_TIMELINEUNDOWORKAREA_H
|
||||
#define OAK_TIMELINEUNDOWORKAREA_H
|
||||
|
||||
#include "node/project.h"
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return project_;
|
||||
}
|
||||
@@ -79,9 +79,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual Project *GetRelevantProject() const override
|
||||
virtual Project *get_relevant_project() const override
|
||||
{
|
||||
return Project::GetProjectFromObject(workarea_);
|
||||
return Project::get_project_from_object(workarea_);
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -105,4 +105,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMELINEUNDOWORKAREA_H
|
||||
#endif // OAK_TIMELINEUNDOWORKAREA_H
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const rational TimelineWorkArea::kResetIn = 0;
|
||||
const rational TimelineWorkArea::kResetOut = RATIONAL_MAX;
|
||||
const Rational TimelineWorkArea::k_reset_in = 0;
|
||||
const Rational TimelineWorkArea::k_reset_out = RATIONAL_MAX;
|
||||
|
||||
TimelineWorkArea::TimelineWorkArea(QObject *parent)
|
||||
: QObject(parent)
|
||||
@@ -43,7 +43,7 @@ bool TimelineWorkArea::enabled() const
|
||||
void TimelineWorkArea::set_enabled(bool e)
|
||||
{
|
||||
workarea_enabled_ = e;
|
||||
emit EnabledChanged(workarea_enabled_);
|
||||
emit enabled_changed(workarea_enabled_);
|
||||
}
|
||||
|
||||
const TimeRange &TimelineWorkArea::range() const
|
||||
@@ -54,13 +54,13 @@ const TimeRange &TimelineWorkArea::range() const
|
||||
void TimelineWorkArea::set_range(const TimeRange &range)
|
||||
{
|
||||
workarea_range_ = range;
|
||||
emit RangeChanged(workarea_range_);
|
||||
emit range_changed(workarea_range_);
|
||||
}
|
||||
|
||||
bool TimelineWorkArea::load(QXmlStreamReader *reader)
|
||||
{
|
||||
rational range_in = this->in();
|
||||
rational range_out = this->out();
|
||||
Rational range_in = this->in();
|
||||
Rational range_out = this->out();
|
||||
|
||||
uint version = 0;
|
||||
XMLAttributeLoop(reader, attr)
|
||||
@@ -71,15 +71,15 @@ bool TimelineWorkArea::load(QXmlStreamReader *reader)
|
||||
}
|
||||
Q_UNUSED(version)
|
||||
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
while (xml_read_next_start_element(reader)) {
|
||||
if (reader->name() == QStringLiteral("enabled")) {
|
||||
this->set_enabled(reader->readElementText() != QStringLiteral("0"));
|
||||
} else if (reader->name() == QStringLiteral("in")) {
|
||||
range_in =
|
||||
rational::fromString(reader->readElementText().toStdString());
|
||||
Rational::from_string(reader->readElementText().toStdString());
|
||||
} else if (reader->name() == QStringLiteral("out")) {
|
||||
range_out =
|
||||
rational::fromString(reader->readElementText().toStdString());
|
||||
Rational::from_string(reader->readElementText().toStdString());
|
||||
} else {
|
||||
reader->skipCurrentElement();
|
||||
}
|
||||
@@ -101,22 +101,22 @@ void TimelineWorkArea::save(QXmlStreamWriter *writer) const
|
||||
writer->writeTextElement(QStringLiteral("enabled"),
|
||||
QString::number(this->enabled()));
|
||||
writer->writeTextElement(QStringLiteral("in"),
|
||||
QString::fromStdString(this->in().toString()));
|
||||
QString::fromStdString(this->in().to_string()));
|
||||
writer->writeTextElement(QStringLiteral("out"),
|
||||
QString::fromStdString(this->out().toString()));
|
||||
QString::fromStdString(this->out().to_string()));
|
||||
}
|
||||
|
||||
const rational &TimelineWorkArea::in() const
|
||||
const Rational &TimelineWorkArea::in() const
|
||||
{
|
||||
return workarea_range_.in();
|
||||
}
|
||||
|
||||
const rational &TimelineWorkArea::out() const
|
||||
const Rational &TimelineWorkArea::out() const
|
||||
{
|
||||
return workarea_range_.out();
|
||||
}
|
||||
|
||||
const rational &TimelineWorkArea::length() const
|
||||
const Rational &TimelineWorkArea::length() const
|
||||
{
|
||||
return workarea_range_.length();
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMELINEWORKAREA_H
|
||||
#define TIMELINEWORKAREA_H
|
||||
#ifndef OAK_TIMELINEWORKAREA_H
|
||||
#define OAK_TIMELINEWORKAREA_H
|
||||
|
||||
#include <olive/core/core.h>
|
||||
#include <QObject>
|
||||
@@ -40,22 +40,22 @@ public:
|
||||
bool enabled() const;
|
||||
void set_enabled(bool e);
|
||||
|
||||
const rational &in() const;
|
||||
const rational &out() const;
|
||||
const rational &length() const;
|
||||
const Rational &in() const;
|
||||
const Rational &out() const;
|
||||
const Rational &length() const;
|
||||
const TimeRange &range() const;
|
||||
void set_range(const TimeRange &range);
|
||||
|
||||
bool load(QXmlStreamReader *reader);
|
||||
void save(QXmlStreamWriter *writer) const;
|
||||
|
||||
static const rational kResetIn;
|
||||
static const rational kResetOut;
|
||||
static const Rational k_reset_in;
|
||||
static const Rational k_reset_out;
|
||||
|
||||
signals:
|
||||
void EnabledChanged(bool e);
|
||||
void enabled_changed(bool e);
|
||||
|
||||
void RangeChanged(const TimeRange &r);
|
||||
void range_changed(const TimeRange &r);
|
||||
|
||||
private:
|
||||
bool workarea_enabled_;
|
||||
@@ -65,4 +65,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMELINEWORKAREA_H
|
||||
#endif // OAK_TIMELINEWORKAREA_H
|
||||
|
||||
Reference in New Issue
Block a user