timeline: implemented in/out points

This commit is contained in:
itsmattkc
2020-03-08 01:06:45 +11:00
parent 52fc4f064b
commit dc37389d02
23 changed files with 609 additions and 25 deletions
+6
View File
@@ -18,6 +18,12 @@ set(OLIVE_SOURCES
${OLIVE_SOURCES}
timeline/timelinecoordinate.h
timeline/timelinecoordinate.cpp
timeline/timelinemarker.h
timeline/timelinemarker.cpp
timeline/timelinepoints.h
timeline/timelinepoints.cpp
timeline/timelineworkarea.h
timeline/timelineworkarea.cpp
timeline/trackreference.h
timeline/trackreference.cpp
PARENT_SCOPE
+61
View File
@@ -0,0 +1,61 @@
#include "timelinemarker.h"
TimelineMarker::TimelineMarker(const TimeRange &time, const QString &name, QObject *parent) :
QObject(parent),
time_(time),
name_(name)
{
}
const TimeRange &TimelineMarker::time() const
{
return time_;
}
void TimelineMarker::set_time(const TimeRange &time)
{
time_ = time;
emit TimeChanged(time_);
}
const QString &TimelineMarker::name() const
{
return name_;
}
void TimelineMarker::set_name(const QString &name)
{
name_ = name;
emit NameChanged(name_);
}
TimelineMarkerList::~TimelineMarkerList()
{
qDeleteAll(markers_);
}
void TimelineMarkerList::AddMarker(const TimeRange &time, const QString &name)
{
TimelineMarker* m = new TimelineMarker(time, name);
markers_.append(m);
emit MarkerAdded(m);
}
void TimelineMarkerList::RemoveMarker(TimelineMarker *marker)
{
for (int i=0;i<markers_.size();i++) {
TimelineMarker* m = markers_.at(i);
if (m == marker) {
markers_.removeAt(i);
emit MarkerRemoved(m);
delete m;
break;
}
}
}
const QList<TimelineMarker*> &TimelineMarkerList::list() const
{
return markers_;
}
+56
View File
@@ -0,0 +1,56 @@
#ifndef TIMELINEMARKER_H
#define TIMELINEMARKER_H
#include <QString>
#include "common/timerange.h"
class TimelineMarker : public QObject
{
Q_OBJECT
public:
TimelineMarker(const TimeRange& time = TimeRange(), const QString& name = QString(), QObject* parent = nullptr);
const TimeRange &time() const;
void set_time(const TimeRange& time);
const QString& name() const;
void set_name(const QString& name);
signals:
void TimeChanged(const TimeRange& time);
void NameChanged(const QString& name);
private:
TimeRange time_;
QString name_;
};
class TimelineMarkerList : public QObject
{
Q_OBJECT
public:
TimelineMarkerList() = default;
virtual ~TimelineMarkerList() override;
void AddMarker(const TimeRange& time = TimeRange(), const QString& name = QString());
void RemoveMarker(TimelineMarker* marker);
const QList<TimelineMarker *> &list() const;
signals:
void MarkerAdded(TimelineMarker* marker);
void MarkerRemoved(TimelineMarker* marker);
private:
QList<TimelineMarker*> markers_;
};
#endif // TIMELINEMARKER_H
+21
View File
@@ -0,0 +1,21 @@
#include "timelinepoints.h"
TimelineMarkerList *TimelinePoints::markers()
{
return &markers_;
}
const TimelineMarkerList *TimelinePoints::markers() const
{
return &markers_;
}
const TimelineWorkArea *TimelinePoints::workarea() const
{
return &workarea_;
}
TimelineWorkArea *TimelinePoints::workarea()
{
return &workarea_;
}
+25
View File
@@ -0,0 +1,25 @@
#ifndef TIMELINEPOINTS_H
#define TIMELINEPOINTS_H
#include "timelinemarker.h"
#include "timelineworkarea.h"
class TimelinePoints
{
public:
TimelinePoints() = default;
TimelineMarkerList* markers();
const TimelineMarkerList* markers() const;
TimelineWorkArea* workarea();
const TimelineWorkArea* workarea() const;
private:
TimelineMarkerList markers_;
TimelineWorkArea workarea_;
};
#endif // TIMELINEPOINTS_H
+41
View File
@@ -0,0 +1,41 @@
#include "timelineworkarea.h"
const rational TimelineWorkArea::kResetIn = 0;
const rational TimelineWorkArea::kResetOut = RATIONAL_MAX;
TimelineWorkArea::TimelineWorkArea(QObject *parent) :
QObject(parent)
{
}
bool TimelineWorkArea::enabled() const
{
return workarea_enabled_;
}
void TimelineWorkArea::set_enabled(bool e)
{
workarea_enabled_ = e;
emit EnabledChanged(workarea_enabled_);
}
const TimeRange &TimelineWorkArea::range() const
{
return workarea_range_;
}
void TimelineWorkArea::set_range(const TimeRange &range)
{
workarea_range_ = range;
emit RangeChanged(workarea_range_);
}
const rational &TimelineWorkArea::in() const
{
return workarea_range_.in();
}
const rational &TimelineWorkArea::out() const
{
return workarea_range_.out();
}
+37
View File
@@ -0,0 +1,37 @@
#ifndef TIMELINEWORKAREA_H
#define TIMELINEWORKAREA_H
#include <QObject>
#include "common/timerange.h"
class TimelineWorkArea : public QObject
{
Q_OBJECT
public:
TimelineWorkArea(QObject* parent = nullptr);
bool enabled() const;
void set_enabled(bool e);
const rational& in() const;
const rational& out() const;
const TimeRange& range() const;
void set_range(const TimeRange& range);
static const rational kResetIn;
static const rational kResetOut;
signals:
void EnabledChanged(bool e);
void RangeChanged(const TimeRange& r);
private:
bool workarea_enabled_;
TimeRange workarea_range_;
};
#endif // TIMELINEWORKAREA_H