updates for C++17
This commit is contained in:
@@ -60,10 +60,10 @@ MarkerPropertiesDialog::MarkerPropertiesDialog(const std::vector<TimelineMarker
|
||||
}
|
||||
|
||||
if (markers.size() == 1) {
|
||||
in_slider_->SetValue(markers.front()->time_range().in());
|
||||
in_slider_->SetValue(markers.front()->time().in());
|
||||
in_slider_->SetDisplayType(RationalSlider::kTime);
|
||||
in_slider_->SetTimebase(timebase);
|
||||
out_slider_->SetValue(markers.front()->time_range().out());
|
||||
out_slider_->SetValue(markers.front()->time().out());
|
||||
out_slider_->SetDisplayType(RationalSlider::kTime);
|
||||
out_slider_->SetTimebase(timebase);
|
||||
} else {
|
||||
|
||||
@@ -87,14 +87,6 @@ public:
|
||||
const rational& time() const;
|
||||
void set_time(const rational& time);
|
||||
|
||||
/**
|
||||
* @brief Dummy function for TimeBasedViewSelectionManager compatibility
|
||||
*
|
||||
* FIXME: Once we upgrade to C++17, we won't need this because we'll be able to check types in
|
||||
* TimeBasedViewSelectionManager's template functions
|
||||
*/
|
||||
TimeRange time_range() const { return TimeRange(time_, time_); }
|
||||
|
||||
/**
|
||||
* @brief The value of this keyframe (i.e. the value to use at this keyframe's time)
|
||||
*/
|
||||
|
||||
@@ -1175,8 +1175,8 @@ void ProjectSerializer220403::LoadMarker(QXmlStreamReader *reader, TimelineMarke
|
||||
void ProjectSerializer220403::SaveMarker(QXmlStreamWriter *writer, TimelineMarker *marker) const
|
||||
{
|
||||
writer->writeAttribute(QStringLiteral("name"), marker->name());
|
||||
writer->writeAttribute(QStringLiteral("in"), marker->time_range().in().toString());
|
||||
writer->writeAttribute(QStringLiteral("out"), marker->time_range().out().toString());
|
||||
writer->writeAttribute(QStringLiteral("in"), marker->time().in().toString());
|
||||
writer->writeAttribute(QStringLiteral("out"), marker->time().out().toString());
|
||||
writer->writeAttribute(QStringLiteral("color"), QString::number(marker->color()));
|
||||
}
|
||||
|
||||
|
||||
@@ -167,9 +167,9 @@ void TimelineMarkerList::InsertIntoList(TimelineMarker *marker)
|
||||
for (auto it=markers_.begin(); it!=markers_.end(); it++) {
|
||||
TimelineMarker *m = *it;
|
||||
|
||||
Q_ASSERT(m->time() != marker->time());
|
||||
Q_ASSERT(m->time().in() != marker->time().in());
|
||||
|
||||
if (m->time() > marker->time()) {
|
||||
if (m->time().in() > marker->time().in()) {
|
||||
markers_.insert(it, marker);
|
||||
found = true;
|
||||
break;
|
||||
@@ -316,7 +316,7 @@ Project* MarkerChangeTimeCommand::GetRelevantProject() const
|
||||
|
||||
void MarkerChangeTimeCommand::redo()
|
||||
{
|
||||
old_time_ = marker_->time_range();
|
||||
old_time_ = marker_->time();
|
||||
marker_->set_time(new_time_);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,17 +38,9 @@ public:
|
||||
TimelineMarker(QObject* parent = nullptr);
|
||||
TimelineMarker(int color, const TimeRange& time, const QString& name = QString(), QObject* parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Dummy function for TimeBasedViewSelectionManager compatibility
|
||||
*
|
||||
* FIXME: Once we upgrade to C++17, we won't need this because we'll be able to check types in
|
||||
* TimeBasedViewSelectionManager's template functions
|
||||
*/
|
||||
const rational &time() const { return time_.in(); }
|
||||
void set_time(const rational& time);
|
||||
|
||||
const TimeRange &time_range() const { return time_; }
|
||||
const TimeRange &time() const { return time_; }
|
||||
void set_time(const TimeRange& time);
|
||||
void set_time(const rational& time);
|
||||
|
||||
bool has_sibling_at_time(const rational &t) const;
|
||||
|
||||
@@ -99,7 +91,7 @@ public:
|
||||
{
|
||||
for (auto it=markers_.cbegin(); it!=markers_.cend(); it++) {
|
||||
TimelineMarker *m = *it;
|
||||
if (m->time() == t) {
|
||||
if (m->time().in() == t) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -114,10 +106,10 @@ public:
|
||||
for (auto it=markers_.cbegin(); it!=markers_.cend(); it++) {
|
||||
TimelineMarker *m = *it;
|
||||
|
||||
rational this_diff = qAbs(m->time() - t);
|
||||
rational this_diff = qAbs(m->time().in() - t);
|
||||
|
||||
if (closest) {
|
||||
rational stored_diff = qAbs(closest->time() - 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
|
||||
@@ -229,7 +221,7 @@ class MarkerChangeTimeCommand : public UndoCommand {
|
||||
public:
|
||||
MarkerChangeTimeCommand(TimelineMarker* marker, const TimeRange &time, const TimeRange &old_time);
|
||||
MarkerChangeTimeCommand(TimelineMarker* marker, const TimeRange &time) :
|
||||
MarkerChangeTimeCommand(marker, time, marker->time_range())
|
||||
MarkerChangeTimeCommand(marker, time, marker->time())
|
||||
{}
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
@@ -117,8 +117,8 @@ void ResizableTimelineScrollBar::paintEvent(QPaintEvent *event)
|
||||
TimelineMarker* marker = *it;
|
||||
|
||||
QColor marker_color = ColorCoding::GetColor(marker->color()).toQColor();
|
||||
int64_t in = qRound64(ratio * TimeToScene(marker->time_range().in()));
|
||||
int64_t out = qRound64(ratio * TimeToScene(marker->time_range().out()));
|
||||
int64_t in = qRound64(ratio * TimeToScene(marker->time().in()));
|
||||
int64_t out = qRound64(ratio * TimeToScene(marker->time().out()));
|
||||
int64_t length = qMax(int64_t(1), out-in);
|
||||
|
||||
p.fillRect(gr.x() + in,
|
||||
|
||||
@@ -163,14 +163,24 @@ public:
|
||||
initial_drag_item_ = initial_item;
|
||||
|
||||
dragging_.resize(selected_.size());
|
||||
snap_points_.resize(selected_.size()*2);
|
||||
|
||||
if constexpr (std::is_same_v<T, TimelineMarker>) {
|
||||
snap_points_.resize(selected_.size()*2);
|
||||
} else {
|
||||
snap_points_.resize(selected_.size());
|
||||
}
|
||||
|
||||
for (size_t i=0; i<selected_.size(); i++) {
|
||||
T *obj = selected_.at(i);
|
||||
|
||||
dragging_[i] = obj->time();
|
||||
|
||||
snap_points_[i] = obj->time();
|
||||
snap_points_[i+selected_.size()] = obj->time_range().out();
|
||||
if constexpr (std::is_same_v<T, TimelineMarker>) {
|
||||
dragging_[i] = obj->time().in();
|
||||
snap_points_[i] = obj->time().in();
|
||||
snap_points_[i+selected_.size()] = obj->time().out();
|
||||
} else {
|
||||
dragging_[i] = obj->time();
|
||||
snap_points_[i] = obj->time();
|
||||
}
|
||||
}
|
||||
|
||||
drag_mouse_start_ = view_->mapToScene(event->pos());
|
||||
@@ -258,7 +268,15 @@ public:
|
||||
}
|
||||
|
||||
// Show information about this keyframe
|
||||
QString tip = Timecode::time_to_timecode(initial_drag_item_->time(), timebase_,
|
||||
rational display_time;
|
||||
|
||||
if constexpr (std::is_same_v<T, TimelineMarker>) {
|
||||
display_time = initial_drag_item_->time().in();
|
||||
} else {
|
||||
display_time = initial_drag_item_->time();
|
||||
}
|
||||
|
||||
QString tip = Timecode::time_to_timecode(display_time, timebase_,
|
||||
Core::instance()->GetTimecodeDisplay(), false);
|
||||
|
||||
if (!tip_format.isEmpty()) {
|
||||
@@ -274,7 +292,13 @@ public:
|
||||
QToolTip::hideText();
|
||||
|
||||
for (size_t i=0; i<selected_.size(); i++) {
|
||||
command->add_child(new SetTimeCommand(selected_.at(i), selected_.at(i)->time(), dragging_.at(i)));
|
||||
rational current;
|
||||
if constexpr (std::is_same_v<T, TimelineMarker>) {
|
||||
current = selected_.at(i)->time().in();
|
||||
} else {
|
||||
current = selected_.at(i)->time();
|
||||
}
|
||||
command->add_child(new SetTimeCommand(selected_.at(i), current, dragging_.at(i)));
|
||||
}
|
||||
|
||||
dragging_.clear();
|
||||
|
||||
@@ -346,10 +346,10 @@ void TimeBasedWidget::GoToPrevCut()
|
||||
|
||||
rational closest_cut = 0;
|
||||
|
||||
foreach (Track* track, sequence->GetTracks()) {
|
||||
for (Track* track : sequence->GetTracks()) {
|
||||
rational this_track_closest_cut = 0;
|
||||
|
||||
foreach (Block* block, track->Blocks()) {
|
||||
for (Block* block : track->Blocks()) {
|
||||
if (block->out() < GetTime()) {
|
||||
this_track_closest_cut = block->out();
|
||||
} else {
|
||||
@@ -754,7 +754,7 @@ bool TimeBasedWidget::SnapPoint(const std::vector<rational> &start_times, ration
|
||||
for (auto jt=markers->cbegin(); jt!=markers->cend(); jt++) {
|
||||
TimelineMarker *marker = *jt;
|
||||
|
||||
TimeRange marker_range = marker->time_range() + clip->in() - clip->media_in();
|
||||
TimeRange marker_range = marker->time() + clip->in() - clip->media_in();
|
||||
|
||||
qreal marker_in_screen = TimeToScene(marker_range.in());
|
||||
qreal marker_out_screen = TimeToScene(marker_range.out());
|
||||
@@ -777,12 +777,12 @@ bool TimeBasedWidget::SnapPoint(const std::vector<rational> &start_times, ration
|
||||
continue;
|
||||
}
|
||||
|
||||
qreal marker_pos = TimeToScene(m->time_range().in());
|
||||
AttemptSnap(potential_snaps, screen_pt, marker_pos, start_times, m->time_range().in());
|
||||
qreal marker_pos = TimeToScene(m->time().in());
|
||||
AttemptSnap(potential_snaps, screen_pt, marker_pos, start_times, m->time().in());
|
||||
|
||||
if (m->time_range().in() != m->time_range().out()) {
|
||||
marker_pos = TimeToScene(m->time_range().out());
|
||||
AttemptSnap(potential_snaps, screen_pt, marker_pos, start_times, m->time_range().out());
|
||||
if (m->time().in() != m->time().out()) {
|
||||
marker_pos = TimeToScene(m->time().out());
|
||||
AttemptSnap(potential_snaps, screen_pt, marker_pos, start_times, m->time().out());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ void TimelineView::mousePressEvent(QMouseEvent *event)
|
||||
QObject *p = this->parent();
|
||||
while (p) {
|
||||
if (TimelineWidget *timeline = dynamic_cast<TimelineWidget *>(p)) {
|
||||
timeline->SetTime(it.key()->time());
|
||||
timeline->SetTime(it.key()->time().in());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -555,8 +555,8 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, q
|
||||
for (auto it=marker_list->cbegin(); it!=marker_list->cend(); it++) {
|
||||
TimelineMarker *marker = *it;
|
||||
// Make sure marker is within In/Out points of the clip
|
||||
if (marker->time_range().in() >= clip->media_in() && marker->time_range().out() <= clip->media_in() + clip->length()) {
|
||||
QPoint marker_pt(TimeToScene(clip->in() - clip->media_in() + marker->time_range().in()), block_top + block_height);
|
||||
if (marker->time().in() >= clip->media_in() && marker->time().out() <= clip->media_in() + clip->length()) {
|
||||
QPoint marker_pt(TimeToScene(clip->in() - clip->media_in() + marker->time().in()), block_top + block_height);
|
||||
painter->setClipRect(r);
|
||||
QRect marker_rect = marker->Draw(painter, marker_pt, GetScale(), false);
|
||||
clip_marker_rects_.insert(marker, marker_rect);
|
||||
|
||||
@@ -128,16 +128,16 @@ bool SeekableWidget::PasteMarkers()
|
||||
// Normalize markers to start at playhead
|
||||
rational min = RATIONAL_MAX;
|
||||
for (auto it=markers.cbegin(); it!=markers.cend(); it++) {
|
||||
min = std::min(min, (*it)->time());
|
||||
min = std::min(min, (*it)->time().in());
|
||||
}
|
||||
min -= GetTime();
|
||||
|
||||
for (auto it=markers.cbegin(); it!=markers.cend(); it++) {
|
||||
TimelineMarker *m = *it;
|
||||
|
||||
m->set_time(m->time() - min);
|
||||
m->set_time(m->time().in() - min);
|
||||
|
||||
if (TimelineMarker *existing = timeline_points_->markers()->GetMarkerAtTime(m->time())) {
|
||||
if (TimelineMarker *existing = timeline_points_->markers()->GetMarkerAtTime(m->time().in())) {
|
||||
command->add_child(new MarkerRemoveCommand(existing));
|
||||
}
|
||||
|
||||
@@ -333,12 +333,12 @@ void SeekableWidget::DrawTimelinePoints(QPainter* p, int marker_bottom)
|
||||
for (auto it=GetTimelinePoints()->markers()->cbegin(); it!=GetTimelinePoints()->markers()->cend(); it++) {
|
||||
TimelineMarker* marker = *it;
|
||||
|
||||
int marker_right = TimeToScene(marker->time_range().out());
|
||||
int marker_right = TimeToScene(marker->time().out());
|
||||
if (marker_right < lim_left) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int marker_left = TimeToScene(marker->time_range().in());
|
||||
int marker_left = TimeToScene(marker->time().in());
|
||||
if (marker_left >= lim_right) {
|
||||
break;
|
||||
}
|
||||
@@ -430,16 +430,16 @@ bool SeekableWidget::FindResizeHandle(QMouseEvent *event)
|
||||
// Check for markers
|
||||
for (auto it=timeline_points_->markers()->cbegin(); it!=timeline_points_->markers()->cend(); it++) {
|
||||
TimelineMarker *m = *it;
|
||||
if (m->time_range().in() != m->time_range().out()) {
|
||||
if (m->time_range().in() >= min && m->time_range().in() < max) {
|
||||
if (m->time().in() != m->time().out()) {
|
||||
if (m->time().in() >= min && m->time().in() < max) {
|
||||
resize_mode_ = kResizeIn;
|
||||
} else if (m->time_range().out() >= min && m->time_range().out() < max) {
|
||||
} else if (m->time().out() >= min && m->time().out() < max) {
|
||||
resize_mode_ = kResizeOut;
|
||||
}
|
||||
|
||||
if (resize_mode_ != kResizeNone) {
|
||||
resize_item_ = m;
|
||||
resize_item_range_ = m->time_range();
|
||||
resize_item_range_ = m->time();
|
||||
resize_snap_mask_ = TimeBasedWidget::kSnapAll;
|
||||
break;
|
||||
}
|
||||
@@ -508,7 +508,7 @@ void SeekableWidget::CommitResizeHandle()
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
|
||||
if (TimelineMarker *marker = dynamic_cast<TimelineMarker*>(resize_item_)) {
|
||||
command->add_child(new MarkerChangeTimeCommand(marker, marker->time_range(), resize_item_range_));
|
||||
command->add_child(new MarkerChangeTimeCommand(marker, marker->time(), resize_item_range_));
|
||||
} else if (TimelineWorkArea *workarea = dynamic_cast<TimelineWorkArea*>(resize_item_)) {
|
||||
command->add_child(new WorkareaSetRangeCommand(workarea, workarea->range(), resize_item_range_));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user