diff --git a/dialogs/speeddialog.cpp b/dialogs/speeddialog.cpp index 9b7cad23e..9c82c2705 100644 --- a/dialogs/speeddialog.cpp +++ b/dialogs/speeddialog.cpp @@ -113,7 +113,7 @@ int SpeedDialog::exec() { } if (process_video) { - double media_frame_rate = c->media_frame_rate(); + double media_frame_rate = c->MediaFrameRate(); // get "default" frame rate" if (enable_frame_rate) { @@ -193,7 +193,7 @@ void SpeedDialog::percent_update() { // get frame rate if (frame_rate->isEnabled() && c->type() == olive::kTypeVideo) { - double clip_fr = c->media_frame_rate() * percent->value(); + double clip_fr = c->MediaFrameRate() * percent->value(); if (got_fr) { if (!qIsNaN(fr_val) && !qFuzzyCompare(fr_val, clip_fr)) { fr_val = qSNaN(); @@ -237,7 +237,7 @@ void SpeedDialog::duration_update() { // get frame rate if (frame_rate->isEnabled() && c->type() == olive::kTypeVideo) { - double clip_fr = c->media_frame_rate() * clip_pc; + double clip_fr = c->MediaFrameRate() * clip_pc; if (got_fr) { if (!qIsNaN(fr_val) && !qFuzzyCompare(fr_val, clip_fr)) { fr_val = qSNaN(); @@ -278,7 +278,7 @@ void SpeedDialog::frame_rate_update() { if (c->type() == olive::kTypeVideo) { // what would the new speed be based on this frame rate - double new_clip_speed = frame_rate->value() / c->media_frame_rate(); + double new_clip_speed = frame_rate->value() / c->MediaFrameRate(); if (!got_pc_val) { pc_val = new_clip_speed; got_pc_val = true; @@ -420,8 +420,8 @@ void SpeedDialog::accept() { } if (c->type() == olive::kTypeVideo) { if (qIsNaN(cached_fr)) { - cached_fr = c->media_frame_rate(); - } else if (!qFuzzyCompare(cached_fr, c->media_frame_rate())) { + cached_fr = c->MediaFrameRate(); + } else if (!qFuzzyCompare(cached_fr, c->MediaFrameRate())) { can_change_all = false; break; } @@ -432,7 +432,7 @@ void SpeedDialog::accept() { for (int i=0;itype() == olive::kTypeVideo) { - set_speed(ca, c, frame_rate->value() / c->media_frame_rate(), ripple->isChecked(), earliest_point, longest_ripple); + set_speed(ca, c, frame_rate->value() / c->MediaFrameRate(), ripple->isChecked(), earliest_point, longest_ripple); } else if (can_change_all) { set_speed(ca, c, frame_rate->value() / cached_fr, ripple->isChecked(), earliest_point, longest_ripple); } diff --git a/effects/internal/richtexteffect.cpp b/effects/internal/richtexteffect.cpp index 43d7ec399..2aa46ed2f 100644 --- a/effects/internal/richtexteffect.cpp +++ b/effects/internal/richtexteffect.cpp @@ -143,8 +143,8 @@ void RichTextEffect::redraw(double timecode) double scroll_progress = 0; if (auto_scroll_dir != SCROLL_OFF) { - double clip_length_secs = double(parent_clip->length()) / parent_clip->media_frame_rate(); - scroll_progress = (timecode - double(parent_clip->clip_in()) / parent_clip->media_frame_rate()) / clip_length_secs; + double clip_length_secs = double(parent_clip->length()) / parent_clip->MediaFrameRate(); + scroll_progress = (timecode - double(parent_clip->clip_in()) / parent_clip->MediaFrameRate()) / clip_length_secs; } if (auto_scroll_dir == SCROLL_OFF || auto_scroll_dir == SCROLL_LEFT || auto_scroll_dir == SCROLL_RIGHT) { diff --git a/effects/internal/shakeeffect.cpp b/effects/internal/shakeeffect.cpp index 7d623dd19..d7bdbfbca 100644 --- a/effects/internal/shakeeffect.cpp +++ b/effects/internal/shakeeffect.cpp @@ -28,7 +28,6 @@ #include "ui/labelslider.h" #include "ui/collapsiblewidget.h" #include "timeline/clip.h" -#include "timeline/sequence.h" #include "panels/timeline.h" #include "global/debug.h" diff --git a/effects/internal/solideffect.cpp b/effects/internal/solideffect.cpp index 452ea1e93..73ea6344b 100644 --- a/effects/internal/solideffect.cpp +++ b/effects/internal/solideffect.cpp @@ -28,7 +28,6 @@ #include #include "timeline/clip.h" -#include "timeline/sequence.h" const int SMPTE_BARS = 7; const int SMPTE_STRIP_COUNT = 3; diff --git a/effects/internal/texteffect.cpp b/effects/internal/texteffect.cpp index 14515ad68..9d3d49c09 100644 --- a/effects/internal/texteffect.cpp +++ b/effects/internal/texteffect.cpp @@ -36,7 +36,6 @@ #include "ui/labelslider.h" #include "ui/collapsiblewidget.h" #include "timeline/clip.h" -#include "timeline/sequence.h" #include "ui/comboboxex.h" #include "ui/colorbutton.h" #include "ui/blur.h" diff --git a/effects/internal/timecodeeffect.cpp b/effects/internal/timecodeeffect.cpp index 32a892cdf..40c809846 100644 --- a/effects/internal/timecodeeffect.cpp +++ b/effects/internal/timecodeeffect.cpp @@ -118,7 +118,7 @@ void TimecodeEffect::redraw(double timecode) { olive::config.timecode_view, sequence->frame_rate); } else { - double media_rate = parent_clip->media_frame_rate(); + double media_rate = parent_clip->MediaFrameRate(); display_timecode = prepend_text->GetStringAt(timecode) + frame_to_timecode(qRound(timecode * media_rate), olive::config.timecode_view, media_rate); diff --git a/effects/internal/toneeffect.cpp b/effects/internal/toneeffect.cpp index b0b66fa46..96dbaf4db 100644 --- a/effects/internal/toneeffect.cpp +++ b/effects/internal/toneeffect.cpp @@ -25,7 +25,7 @@ #define TONE_TYPE_SINE 0 #include "timeline/clip.h" -#include "timeline/sequence.h" +#include "rendering/audio.h" ToneEffect::ToneEffect(Clip* c) : Node(c), sinX(INT_MIN) { type_val = new ComboInput(this, "type", tr("Type")); @@ -90,7 +90,7 @@ void ToneEffect::process_audio(double timecode_start, double timecode = timecode_start+(interval*i); float tone_sample = qSin((2*M_PI*sinX*freq_val->GetDoubleAt(timecode)) - /parent_clip->track()->sequence()->audio_frequency) + /current_audio_freq()) *log_volume(amount_val->GetDoubleAt(timecode)*0.01); for (int j=0;jSetDisplayType(LabelSlider::FrameNumber); if (parent_clip != nullptr) { - length_field->SetFrameRate(parent_clip->track()->sequence() == nullptr ? - parent_clip->cached_frame_rate() : parent_clip->track()->sequence()->frame_rate); + length_field->SetFrameRate(GetParentClip()->track()->sequence() == nullptr ? + GetParentClip()->cached_frame_rate() : GetParentClip()->SequenceFrameRate()); } connect(length_field, SIGNAL(Changed()), this, SLOT(UpdateMaximumLength())); } -NodePtr Transition::copy(Clip *c) { +Clip *Transition::GetParentClip() +{ + return static_cast(parent_clip); +} + +NodePtr Transition::copy(TimelineObject *c) { NodePtr node = Node::copy(c); static_cast(node.get())->set_length(get_true_length()); @@ -86,8 +91,8 @@ int Transition::get_length() { } Clip* Transition::get_opened_clip() { - if (parent_clip->opening_transition.get() == this) { - return parent_clip; + if (GetParentClip()->opening_transition.get() == this) { + return GetParentClip(); } else if (secondary_clip != nullptr && secondary_clip->opening_transition.get() == this) { return secondary_clip; } @@ -95,8 +100,8 @@ Clip* Transition::get_opened_clip() { } Clip* Transition::get_closed_clip() { - if (parent_clip->closing_transition.get() == this) { - return parent_clip; + if (GetParentClip()->closing_transition.get() == this) { + return GetParentClip(); } else if (secondary_clip != nullptr && secondary_clip->closing_transition.get() == this) { return secondary_clip; } @@ -131,7 +136,7 @@ TransitionPtr Transition::CreateFromMeta(Clip* c, Clip* s) { void Transition::UpdateMaximumLength() { // Get the maximum area this transition can occupy on the clip - long maximum_length = GetMaximumEmptySpaceOnClip(parent_clip); + long maximum_length = GetMaximumEmptySpaceOnClip(GetParentClip()); // If this clip is a shared transition, get the maximum area this can occupy on the other clip too if (secondary_clip != nullptr) { diff --git a/effects/transition.h b/effects/transition.h index 7be393c5c..00309c42a 100644 --- a/effects/transition.h +++ b/effects/transition.h @@ -24,6 +24,8 @@ #include "nodes/node.h" #include "nodes/inputs.h" +class Clip; + enum TransitionType { kTransitionNone, kTransitionOpening, @@ -38,7 +40,9 @@ class Transition : public Node { public: Transition(Clip* c); - virtual NodePtr copy(Clip* c) override; + virtual NodePtr copy(TimelineObject* c) override; + + Clip* GetParentClip(); Clip* secondary_clip; diff --git a/nodes/node.cpp b/nodes/node.cpp index 17c11c6c6..a43f9b5b5 100644 --- a/nodes/node.cpp +++ b/nodes/node.cpp @@ -60,7 +60,7 @@ QVector olive::node_library; -Node::Node(Clip* c) : +Node::Node(TimelineObject* c) : parent_clip(c), flags_(0), shader_program_(nullptr), @@ -182,6 +182,7 @@ void Node::delete_self() { } void Node::move_up() { + /* int index_of_effect = parent_clip->IndexOfEffect(this); if (index_of_effect == 0) { return; @@ -194,9 +195,11 @@ void Node::move_up() { olive::undo_stack.push(command); panel_effect_controls->Reload(); panel_sequence_viewer->viewer_widget()->frame_update(); + */ } void Node::move_down() { + /* int index_of_effect = parent_clip->IndexOfEffect(this); if (index_of_effect == parent_clip->effects.size()-1) { return; @@ -209,6 +212,7 @@ void Node::move_down() { olive::undo_stack.push(command); panel_effect_controls->Reload(); panel_sequence_viewer->viewer_widget()->frame_update(); + */ } void Node::save_to_file() { @@ -603,7 +607,7 @@ const QPointF &Node::pos() void Node::process_image(double, uint8_t *, uint8_t *, int){} -NodePtr Node::copy(Clip *c) { +NodePtr Node::copy(TimelineObject *c) { NodePtr copy = Create(c); copy->SetEnabled(IsEnabled()); copy_field_keyframes(copy); @@ -671,8 +675,8 @@ GLuint Node::process_superimpose(QOpenGLContext* ctx, double timecode) { bool dimensions_changed = false; bool redrew_image = false; - int width = parent_clip->media_width(); - int height = parent_clip->media_height(); + int width = parent_clip->MediaWidth(); + int height = parent_clip->MediaHeight(); if (width != img.width() || height != img.height()) { img = QImage(width, height, QImage::Format_RGBA8888_Premultiplied); @@ -806,10 +810,10 @@ void Node::gizmo_world_to_screen(const QMatrix4x4& matrix, const QMatrix4x4& pro projection, QRect(0, 0, - parent_clip->track()->sequence()->width, - parent_clip->track()->sequence()->height)); + parent_clip->SequenceWidth(), + parent_clip->SequenceHeight())); - g->screen_pos[j] = QPoint(screen_pos.x(), parent_clip->track()->sequence()->height-screen_pos.y()); + g->screen_pos[j] = QPoint(screen_pos.x(), parent_clip->SequenceHeight()-screen_pos.y()); } } diff --git a/nodes/node.h b/nodes/node.h index 2acf02ef9..77db3fb8f 100644 --- a/nodes/node.h +++ b/nodes/node.h @@ -48,8 +48,7 @@ class EffectGizmo; class KeyframeDataChange; -class Clip; -using ClipPtr = std::shared_ptr; +class TimelineObject; class Node; using NodePtr = std::shared_ptr; @@ -112,10 +111,10 @@ struct GLTextureCoords { class Node : public QObject { Q_OBJECT public: - Node(Clip *c); + Node(TimelineObject *c); ~Node(); - Clip* parent_clip; + TimelineObject* parent_clip; virtual QString name() = 0; virtual QString id() = 0; @@ -124,7 +123,7 @@ public: virtual EffectType type() = 0; virtual olive::TrackType subtype() = 0; virtual bool IsCreatable(); - virtual NodePtr Create(Clip *c) = 0; + virtual NodePtr Create(TimelineObject *c) = 0; void AddRow(EffectRow* row); int IndexOfRow(EffectRow* row); @@ -142,7 +141,7 @@ public: virtual void refresh(); - virtual NodePtr copy(Clip* c); + virtual NodePtr copy(TimelineObject* c); void copy_field_keyframes(NodePtr e); virtual void load(QXmlStreamReader& stream); diff --git a/olive.pro b/olive.pro index 404cee082..472fa9430 100644 --- a/olive.pro +++ b/olive.pro @@ -208,7 +208,8 @@ SOURCES += \ decoders/decoder.cpp \ nodes/node.cpp \ nodes/nodeedge.cpp \ - ui/nodeedgeui.cpp + ui/nodeedgeui.cpp \ + timeline/timelineobject.cpp HEADERS += \ ui/mainwindow.h \ @@ -374,7 +375,8 @@ HEADERS += \ nodes/node.h \ timeline/tracktypes.h \ nodes/nodeedge.h \ - ui/nodeedgeui.h + ui/nodeedgeui.h \ + timeline/timelineobject.h FORMS += diff --git a/panels/timeline.cpp b/panels/timeline.cpp index 0cb4c0f1b..c2c51493a 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -1108,11 +1108,3 @@ void Timeline::visibility_changed_slot(bool visibility) emit SequenceChanged(sequence_); } } - -void olive::timeline::MultiplyTrackSizesByDPI() -{ - kTrackDefaultHeight *= QApplication::desktop()->devicePixelRatio(); - kTrackMinHeight *= QApplication::desktop()->devicePixelRatio(); - kTrackHeightIncrement *= QApplication::desktop()->devicePixelRatio(); - kTimelineLabelFixedWidth *= QApplication::desktop()->devicePixelRatio(); -} diff --git a/rendering/renderfunctions.cpp b/rendering/renderfunctions.cpp index ba1e94778..f3767bfcd 100644 --- a/rendering/renderfunctions.cpp +++ b/rendering/renderfunctions.cpp @@ -375,8 +375,8 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams ¶ms) { GLuint textureID = 0; // store video source dimensions - int video_width = c->media_width(); - int video_height = c->media_height(); + int video_width = c->MediaWidth(); + int video_height = c->MediaHeight(); // prepare framebuffers for backend drawing operations if (c->fbo.isEmpty()) { diff --git a/timeline/clip.cpp b/timeline/clip.cpp index 57e705fb3..aa17d29d6 100644 --- a/timeline/clip.cpp +++ b/timeline/clip.cpp @@ -297,7 +297,7 @@ void Clip::Save(QXmlStreamWriter &stream) if (this == transition->secondary_clip) { // if so, just save a reference to the other clip stream.writeAttribute("shared", - QString::number(transition->parent_clip->load_id)); + QString::number(transition->GetParentClip()->load_id)); } else { // otherwise save the whole transition transition->save(stream); @@ -426,16 +426,89 @@ long Clip::length() { return timeline_out_ - timeline_in_; } -double Clip::media_frame_rate() { +int Clip::MediaWidth() { + if (media_ != nullptr) { + switch (media_->get_type()) { + case MEDIA_TYPE_FOOTAGE: + { + const FootageStream* ms = media_stream(); + if (ms != nullptr) return ms->video_width; + break; + } + case MEDIA_TYPE_SEQUENCE: + { + Sequence* s = media_->to_sequence().get(); + return s->width; + } + } + } + + if (track() != nullptr) { + return SequenceWidth(); + } + + return 0; +} + +int Clip::MediaHeight() { + if (media_ != nullptr) { + switch (media_->get_type()) { + case MEDIA_TYPE_FOOTAGE: + { + const FootageStream* ms = media_stream(); + if (ms != nullptr) return ms->video_height; + } + break; + case MEDIA_TYPE_SEQUENCE: + { + Sequence* s = media_->to_sequence().get(); + return s->height; + } + } + } + + if (track() != nullptr) { + return SequenceHeight(); + } + + return 0; +} + +double Clip::MediaFrameRate() { Q_ASSERT(type() == olive::kTypeVideo); + if (media_ != nullptr) { double rate = media_->get_frame_rate(media_stream_index()); if (!qIsNaN(rate)) return rate; } - if (track() != nullptr) return track()->sequence()->frame_rate; + + if (track() != nullptr) { + return SequenceFrameRate(); + } + return qSNaN(); } +int Clip::SequenceWidth() +{ + return track()->sequence()->width; +} + +int Clip::SequenceHeight() +{ + return track()->sequence()->height; +} + +double Clip::SequenceFrameRate() +{ + return track()->sequence()->frame_rate; +} + +long Clip::SequencePlayhead() +{ + return track()->sequence()->playhead; +} + long Clip::media_length() { if (this->track() != nullptr) { double fr = this->track()->sequence()->frame_rate; @@ -467,44 +540,6 @@ long Clip::media_length() { return 0; } -int Clip::media_width() { - if (media_ == nullptr && track() != nullptr) return track()->sequence()->width; - switch (media_->get_type()) { - case MEDIA_TYPE_FOOTAGE: - { - const FootageStream* ms = media_stream(); - if (ms != nullptr) return ms->video_width; - if (track() != nullptr) return track()->sequence()->width; - break; - } - case MEDIA_TYPE_SEQUENCE: - { - Sequence* s = media_->to_sequence().get(); - return s->width; - } - } - return 0; -} - -int Clip::media_height() { - if (media_ == nullptr && track() != nullptr) return track()->sequence()->height; - switch (media_->get_type()) { - case MEDIA_TYPE_FOOTAGE: - { - const FootageStream* ms = media_stream(); - if (ms != nullptr) return ms->video_height; - if (track() != nullptr) return track()->sequence()->height; - } - break; - case MEDIA_TYPE_SEQUENCE: - { - Sequence* s = media_->to_sequence().get(); - return s->height; - } - } - return 0; -} - void Clip::refactor_frame_rate(ComboAction* ca, double multiplier, bool change_timeline_points) { if (change_timeline_points) { track()->sequence()->MoveClip(this, diff --git a/timeline/clip.h b/timeline/clip.h index 30ea217ce..b264b0d0c 100644 --- a/timeline/clip.h +++ b/timeline/clip.h @@ -39,6 +39,7 @@ #include "marker.h" #include "nodes/nodegraph.h" #include "selection.h" +#include "timelineobject.h" class Track; @@ -48,10 +49,13 @@ struct ClipSpeed { bool maintain_audio_pitch; }; -class Clip { +class Clip; +using ClipPtr = std::shared_ptr; + +class Clip : public TimelineObject { public: Clip(Track *s); - ~Clip(); + virtual ~Clip() override; ClipPtr copy(Track *s); void Save(QXmlStreamWriter& stream); @@ -71,9 +75,17 @@ public: Media* media(); FootageStream* media_stream(); int media_stream_index(); - int media_width(); - int media_height(); - double media_frame_rate(); + + virtual int MediaWidth() override; + virtual int MediaHeight() override; + virtual double MediaFrameRate() override; + + virtual int SequenceWidth() override; + virtual int SequenceHeight() override; + virtual double SequenceFrameRate() override; + + virtual long SequencePlayhead() override; + long media_length(); void set_media(Media* m, int s); @@ -181,8 +193,6 @@ private: Cacher cacher; long cacher_frame; - NodeGraph pipeline_; - QVector markers; QColor color_; bool open_; diff --git a/timeline/sequence.cpp b/timeline/sequence.cpp index 75340e974..4c8ee1b0b 100644 --- a/timeline/sequence.cpp +++ b/timeline/sequence.cpp @@ -100,6 +100,26 @@ void Sequence::Save(QXmlStreamWriter &stream) stream.writeEndElement(); } +int Sequence::SequenceWidth() +{ + return width; +} + +int Sequence::SequenceHeight() +{ + return height; +} + +double Sequence::SequenceFrameRate() +{ + return frame_rate; +} + +long Sequence::SequencePlayhead() +{ + return playhead; +} + long Sequence::GetEndFrame() { long end_frame = 0; @@ -271,7 +291,7 @@ void Sequence::MoveClip(Clip *c, ComboAction *ca, long iin, long iout, long icli if (c->closing_transition != nullptr && c->closing_transition->secondary_clip != nullptr - && c->closing_transition->parent_clip->timeline_in() != iout) { + && c->closing_transition->GetParentClip()->timeline_in() != iout) { // separate transition ca->append(new SetPointer(reinterpret_cast(&c->closing_transition->secondary_clip), nullptr)); ca->append(new AddTransitionCommand(nullptr, diff --git a/timeline/sequence.h b/timeline/sequence.h index 94051ae83..8d9dde9c0 100644 --- a/timeline/sequence.h +++ b/timeline/sequence.h @@ -29,8 +29,9 @@ #include "selection.h" #include "tracklist.h" #include "ghost.h" +#include "timelineobject.h" -class Sequence : public QObject { +class Sequence : public TimelineObject { Q_OBJECT public: Sequence(); @@ -45,6 +46,12 @@ public: int audio_frequency; int audio_layout; + virtual int SequenceWidth() override; + virtual int SequenceHeight() override; + virtual double SequenceFrameRate() override; + + virtual long SequencePlayhead() override; + long GetEndFrame(); QVector GetAllClips(); TrackList* GetTrackList(olive::TrackType type); diff --git a/timeline/timelineobject.cpp b/timeline/timelineobject.cpp new file mode 100644 index 000000000..5331e8939 --- /dev/null +++ b/timeline/timelineobject.cpp @@ -0,0 +1,29 @@ +#include "timelineobject.h" + +TimelineObject::TimelineObject() +{ +} + +TimelineObject::~TimelineObject() +{ +} + +int TimelineObject::MediaWidth() +{ + return SequenceWidth(); +} + +int TimelineObject::MediaHeight() +{ + return SequenceHeight(); +} + +double TimelineObject::MediaFrameRate() +{ + return SequenceFrameRate(); +} + +NodeGraph *TimelineObject::pipeline() +{ + return &pipeline_; +} diff --git a/timeline/timelineobject.h b/timeline/timelineobject.h new file mode 100644 index 000000000..56e07220c --- /dev/null +++ b/timeline/timelineobject.h @@ -0,0 +1,32 @@ +#ifndef TIMELINEOBJECT_H +#define TIMELINEOBJECT_H + +#include "nodes/nodegraph.h" + +/** + * @brief The TimelineObject class + * + * A base class for Clip, Sequence, and Track to allow compatibility between each of them and any effects nodes. + */ +class TimelineObject : public QObject +{ +public: + TimelineObject(); + virtual ~TimelineObject(); + + virtual int MediaWidth(); + virtual int MediaHeight(); + virtual double MediaFrameRate(); + + virtual int SequenceWidth() = 0; + virtual int SequenceHeight() = 0; + virtual double SequenceFrameRate() = 0; + + virtual long SequencePlayhead() = 0; + + NodeGraph* pipeline(); +private: + NodeGraph pipeline_; +}; + +#endif // TIMELINEOBJECT_H diff --git a/timeline/track.cpp b/timeline/track.cpp index 9273b67ed..bc0e36f9a 100644 --- a/timeline/track.cpp +++ b/timeline/track.cpp @@ -1,5 +1,8 @@ #include "track.h" +#include +#include + #include "timeline/clip.h" #include "timeline/tracklist.h" #include "timeline/sequence.h" @@ -9,6 +12,8 @@ int olive::timeline::kTrackDefaultHeight = 40; int olive::timeline::kTrackMinHeight = 30; int olive::timeline::kTrackHeightIncrement = 10; +int olive::timeline::kTimelineLabelFixedWidth = 200; + Track::Track(TrackList* parent, olive::TrackType type) : parent_(parent), type_(type), @@ -206,6 +211,26 @@ bool Track::ContainsClip(Clip *c) return false; } +int Track::SequenceWidth() +{ + return sequence()->width; +} + +int Track::SequenceHeight() +{ + return sequence()->height; +} + +double Track::SequenceFrameRate() +{ + return sequence()->frame_rate; +} + +long Track::SequencePlayhead() +{ + return sequence()->playhead; +} + Track *Track::Previous() { int index = Index(); @@ -433,3 +458,12 @@ void Track::SetLocked(bool locked) { locked_ = locked; } + +void olive::timeline::MultiplyTrackSizesByDPI() +{ + kTrackDefaultHeight *= qApp->fontMetrics().height() * 3; + kTrackMinHeight *= qApp->fontMetrics().height(); + kTrackHeightIncrement *= qApp->fontMetrics().height() / 2; + kTimelineLabelFixedWidth *= QApplication::desktop()->devicePixelRatio(); +} + diff --git a/timeline/track.h b/timeline/track.h index 310cd69e9..d3d3a4efb 100644 --- a/timeline/track.h +++ b/timeline/track.h @@ -8,6 +8,8 @@ #include "tracktypes.h" #include "undo/comboaction.h" #include "timeline/selection.h" +#include "timelineobject.h" +#include "clip.h" class Sequence; class Transition; @@ -37,7 +39,7 @@ namespace olive { class TrackList; -class Track : public QObject +class Track : public TimelineObject { Q_OBJECT public: @@ -68,6 +70,12 @@ public: Clip* GetClipFromPoint(long point); bool ContainsClip(Clip* c); + virtual int SequenceWidth() override; + virtual int SequenceHeight() override; + virtual double SequenceFrameRate() override; + + virtual long SequencePlayhead() override; + Track* Previous(); Track* Next(); Track* Sibling(int diff); diff --git a/ui/effectui.cpp b/ui/effectui.cpp index 62a1cdb35..7d1113d74 100644 --- a/ui/effectui.cpp +++ b/ui/effectui.cpp @@ -43,7 +43,7 @@ EffectUI::EffectUI(Node* e) : Transition* t = static_cast(e); // Since effects can have two clip attachments, find out which one is selected - Clip* selected_clip = t->parent_clip; + Clip* selected_clip = t->GetParentClip(); bool both_selected = false; // Check if this is a shared transition @@ -54,12 +54,12 @@ EffectUI::EffectUI(Node* e) : selected_clip = t->secondary_clip; - if (t->parent_clip->IsSelected()) { + if (t->GetParentClip()->IsSelected()) { // Both clips are selected both_selected = true; } - } else if (!t->parent_clip->IsSelected()) { + } else if (!t->GetParentClip()->IsSelected()) { // Neither are selected, but the naming scheme (no "opening" or "closing" modifier) will be the same both_selected = true; @@ -267,7 +267,7 @@ void EffectUI::UpdateFromEffect() } } -bool EffectUI::IsAttachedToClip(Clip *c) +bool EffectUI::IsAttachedToClip(TimelineObject *c) { if (GetEffect()->parent_clip == c) { return true; diff --git a/ui/effectui.h b/ui/effectui.h index 9eb12201c..5372540dc 100644 --- a/ui/effectui.h +++ b/ui/effectui.h @@ -131,7 +131,7 @@ public: * * True is an Effect from this Clip is already attached to this EffectUI. */ - bool IsAttachedToClip(Clip* c); + bool IsAttachedToClip(TimelineObject* c); void SetNodeParent(NodeUI* parent); diff --git a/ui/timelinearea.cpp b/ui/timelinearea.cpp index e0c795ab8..a9d1c9c9a 100644 --- a/ui/timelinearea.cpp +++ b/ui/timelinearea.cpp @@ -5,8 +5,6 @@ #include "panels/timeline.h" #include "global/config.h" -int olive::timeline::kTimelineLabelFixedWidth = 200; - TimelineArea::TimelineArea(Timeline* timeline, olive::timeline::Alignment alignment) : timeline_(timeline), track_list_(nullptr), diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index 5fb7dd057..6670a028c 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -344,7 +344,7 @@ void ViewerWidget::move_gizmos(QMouseEvent *event, bool done) { x_movement, y_movement, get_timecode(gizmos->parent_clip, - gizmos->parent_clip->track()->sequence()->playhead), + gizmos->parent_clip->SequencePlayhead()), done); gizmo_x_mvmt += x_movement;