diff --git a/olive.pro b/olive.pro index 77966607a..672286233 100644 --- a/olive.pro +++ b/olive.pro @@ -57,7 +57,6 @@ SOURCES += \ panels/timeline.cpp \ ui/sourcetable.cpp \ dialogs/aboutdialog.cpp \ - ui/timelinewidget.cpp \ project/media.cpp \ project/footage.cpp \ timeline/sequence.cpp \ @@ -178,7 +177,11 @@ SOURCES += \ timeline/track.cpp \ timeline/tracklist.cpp \ project/savethread.cpp \ - project/projectfunctions.cpp + project/projectfunctions.cpp \ + ui/timelinearea.cpp \ + timeline/timelineshared.cpp \ + ui/timelineview.cpp \ + ui/timelinelabel.cpp HEADERS += \ ui/mainwindow.h \ @@ -188,7 +191,6 @@ HEADERS += \ panels/timeline.h \ ui/sourcetable.h \ dialogs/aboutdialog.h \ - ui/timelinewidget.h \ project/media.h \ project/footage.h \ timeline/sequence.h \ @@ -316,7 +318,11 @@ HEADERS += \ timeline/track.h \ timeline/tracklist.h \ project/savethread.h \ - project/projectfunctions.h + project/projectfunctions.h \ + ui/timelinearea.h \ + timeline/timelineshared.h \ + ui/timelineview.h \ + ui/timelinelabel.h FORMS += diff --git a/panels/timeline.cpp b/panels/timeline.cpp index de6fe4eba..b0858baee 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -37,7 +37,7 @@ #include "global/global.h" #include "panels/panels.h" #include "project/projectelements.h" -#include "ui/timelinewidget.h" +#include "ui/timelineview.h" #include "ui/icons.h" #include "ui/viewerwidget.h" #include "rendering/audio.h" @@ -2058,7 +2058,7 @@ void Timeline::setup_ui() { videoContainerLayout->setSpacing(0); videoContainerLayout->setContentsMargins(0, 0, 0, 0); - video_area = new TimelineWidget(); + video_area = new TimelineView(); video_area->setFocusPolicy(Qt::ClickFocus); videoContainerLayout->addWidget(video_area); @@ -2075,7 +2075,7 @@ void Timeline::setup_ui() { audioContainerLayout->setSpacing(0); audioContainerLayout->setContentsMargins(0, 0, 0, 0); - audio_area = new TimelineWidget(); + audio_area = new TimelineView(); audio_area->setFocusPolicy(Qt::ClickFocus); audioContainerLayout->addWidget(audio_area); diff --git a/panels/timeline.h b/panels/timeline.h index 9f15ab10c..c6c8915e9 100644 --- a/panels/timeline.h +++ b/panels/timeline.h @@ -25,7 +25,7 @@ #include #include -#include "ui/timelinewidget.h" +#include "ui/timelinearea.h" #include "ui/timelinetools.h" #include "timeline/selection.h" #include "timeline/clip.h" @@ -94,9 +94,6 @@ public: bool showing_all; double old_zoom; - int GetTrackHeight(int track); - void SetTrackHeight(int track, int height); - // snapping bool snapping; bool snapped; @@ -233,8 +230,8 @@ private: long rc_ripple_max; QWidget* timeline_area; - TimelineWidget* video_area; - TimelineWidget* audio_area; + TimelineArea* video_area; + TimelineArea* audio_area; QWidget* editAreas; QScrollBar* videoScrollbar; QScrollBar* audioScrollbar; diff --git a/panels/viewer.h b/panels/viewer.h index 431c5eb06..fb5835737 100644 --- a/panels/viewer.h +++ b/panels/viewer.h @@ -32,7 +32,7 @@ #include "ui/panel.h" #include "ui/viewerwidget.h" -#include "ui/timelinewidget.h" +#include "ui/timelineview.h" #include "ui/timelineheader.h" #include "ui/labelslider.h" #include "ui/resizablescrollbar.h" diff --git a/timeline/timelinefunctions.h b/timeline/timelinefunctions.h index b42ce8b50..6cf5cb75e 100644 --- a/timeline/timelinefunctions.h +++ b/timeline/timelinefunctions.h @@ -19,6 +19,12 @@ enum TrimType { TRIM_OUT }; +enum Alignment { + kAlignmentTop, + kAlignmentBottom, + kAlignmentSingle +}; + } } diff --git a/timeline/timelineshared.cpp b/timeline/timelineshared.cpp new file mode 100644 index 000000000..6f5fd8337 --- /dev/null +++ b/timeline/timelineshared.cpp @@ -0,0 +1,6 @@ +#include "timelineshared.h" + +TimelineShared::TimelineShared() +{ + +} diff --git a/timeline/timelineshared.h b/timeline/timelineshared.h new file mode 100644 index 000000000..0622ac154 --- /dev/null +++ b/timeline/timelineshared.h @@ -0,0 +1,11 @@ +#ifndef TIMELINESHARED_H +#define TIMELINESHARED_H + + +class TimelineShared +{ +public: + TimelineShared(); +}; + +#endif // TIMELINESHARED_H diff --git a/timeline/track.cpp b/timeline/track.cpp index 2b6d4d52f..8a2f3fa31 100644 --- a/timeline/track.cpp +++ b/timeline/track.cpp @@ -8,7 +8,10 @@ int olive::timeline::kTrackHeightIncrement = 10; Track::Track(TrackList* parent, Type type) : parent_(parent), - type_(type) + type_(type), + muted_(false), + soloed_(false), + locked_(false) { } @@ -172,3 +175,33 @@ long Track::GetEndFrame() return end_frame; } + +bool Track::IsMuted() +{ + return muted_; +} + +void Track::SetMuted(bool muted) +{ + muted_ = muted; +} + +bool Track::IsSoloed() +{ + return soloed_; +} + +void Track::SetSoloed(bool soloed) +{ + soloed_ = soloed; +} + +bool Track::IsLocked() +{ + return locked_; +} + +void Track::SetLocked(bool locked) +{ + locked_ = locked; +} diff --git a/timeline/track.h b/timeline/track.h index 43d90735e..4a947363e 100644 --- a/timeline/track.h +++ b/timeline/track.h @@ -65,6 +65,16 @@ public: void ClearSelections(); long GetEndFrame(); + + bool IsMuted(); + bool IsSoloed(); + bool IsLocked(); + +public slots: + void SetMuted(bool muted); + void SetSoloed(bool soloed); + void SetLocked(bool locked); + private: void ResizeClipArray(int new_size); @@ -74,6 +84,10 @@ private: QVector clips_; QVector effects_; QVector selections_; + + bool muted_; + bool soloed_; + bool locked_; }; #endif // TRACK_H diff --git a/timeline/tracklist.cpp b/timeline/tracklist.cpp index 1f4bcf469..45bf5418b 100644 --- a/timeline/tracklist.cpp +++ b/timeline/tracklist.cpp @@ -39,6 +39,11 @@ Track *TrackList::First() return tracks_.first().get(); } +int TrackList::TrackCount() +{ + return tracks_.size(); +} + QVector TrackList::tracks() { return tracks_; diff --git a/timeline/tracklist.h b/timeline/tracklist.h index 599a76bf3..40975c55c 100644 --- a/timeline/tracklist.h +++ b/timeline/tracklist.h @@ -13,11 +13,11 @@ public: void AddTrack(); void RemoveTrack(int i); Track* First(); + int TrackCount(); QVector tracks(); Sequence* GetParent(); - private: void ResizeTrackArray(int i); diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 298750e98..17e55c257 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -684,7 +684,7 @@ void MainWindow::setup_menus() { window_project_action = MenuHelper::create_menu_action(window_menu, "panelproject", this, SLOT(toggle_panel_visibility())); window_project_action->setCheckable(true); - window_project_action->setData(reinterpret_cast(panel_project)); + window_project_action->setData(reinterpret_cast(panel_project.first())); window_effectcontrols_action = MenuHelper::create_menu_action(window_menu, "paneleffectcontrols", this, SLOT(toggle_panel_visibility())); window_effectcontrols_action->setCheckable(true); diff --git a/ui/timelinearea.cpp b/ui/timelinearea.cpp new file mode 100644 index 000000000..ae3ac7c6f --- /dev/null +++ b/ui/timelinearea.cpp @@ -0,0 +1,36 @@ +#include "timelinearea.h" + +TimelineArea::TimelineArea() : + track_list_(nullptr) +{ + +} + +void TimelineArea::SetTrackList(Sequence *sequence, Track::Type track_list) +{ + if (sequence == nullptr) { + + track_list_ = nullptr; + + } else { + + track_list_ = sequence->GetTrackList(track_list); + + } + + +} + +void TimelineArea::RefreshLabels() +{ + if (track_list_ == nullptr) { + labels_.clear(); + } else { + + labels_.resize(track_list_->TrackCount()); + for (int i=0;i labels_; +}; + +#endif // TIMELINEAREA_H diff --git a/ui/timelinelabel.cpp b/ui/timelinelabel.cpp new file mode 100644 index 000000000..937042408 --- /dev/null +++ b/ui/timelinelabel.cpp @@ -0,0 +1,50 @@ +#include "timelinelabel.h" + +#include +#include +#include + +TimelineLabel::TimelineLabel() : + track_(nullptr) +{ + QHBoxLayout* layout = new QHBoxLayout(this); + + QLabel* label = new QLabel("Track!"); + layout->addWidget(label); + + mute_button_ = new QPushButton("M"); + mute_button_->setCheckable(true); + mute_button_->setFlat(true); + layout->addWidget(mute_button_); + + solo_button_ = new QPushButton("S"); + solo_button_->setCheckable(true); + solo_button_->setFlat(true); + layout->addWidget(solo_button_); + + lock_button_ = new QPushButton("L"); + lock_button_->setCheckable(true); + lock_button_->setFlat(true); + layout->addWidget(lock_button_); +} + +void TimelineLabel::SetTrack(Track *track) +{ + if (track_ != nullptr) { + disconnect(mute_button_, SIGNAL(toggled(bool)), track_, SLOT(SetMuted(bool))); + disconnect(solo_button_, SIGNAL(toggled(bool)), track_, SLOT(SetSoloed(bool))); + disconnect(lock_button_, SIGNAL(toggled(bool)), track_, SLOT(SetLocked(bool))); + } + + track_ = track; + + if (track != nullptr) { + mute_button_->setChecked(track->IsMuted()); + solo_button_->setChecked(track->IsSoloed()); + lock_button_->setChecked(track->IsLocked()); + + connect(mute_button_, SIGNAL(toggled(bool)), track_, SLOT(SetMuted(bool))); + connect(solo_button_, SIGNAL(toggled(bool)), track_, SLOT(SetSoloed(bool))); + connect(lock_button_, SIGNAL(toggled(bool)), track_, SLOT(SetLocked(bool))); + } +} diff --git a/ui/timelinelabel.h b/ui/timelinelabel.h new file mode 100644 index 000000000..448f5d955 --- /dev/null +++ b/ui/timelinelabel.h @@ -0,0 +1,23 @@ +#ifndef TIMELINELABEL_H +#define TIMELINELABEL_H + +#include + +#include "timeline/track.h" + +class TimelineLabel : public QWidget +{ + Q_OBJECT +public: + TimelineLabel(); + + void SetTrack(Track* track); +private: + QPushButton* mute_button_; + QPushButton* solo_button_; + QPushButton* lock_button_; + + Track* track_; +}; + +#endif // TIMELINELABEL_H diff --git a/ui/timelinewidget.cpp b/ui/timelineview.cpp similarity index 95% rename from ui/timelinewidget.cpp rename to ui/timelineview.cpp index 7e1873ca7..8616461ec 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelineview.cpp @@ -18,7 +18,7 @@ ***/ -#include "timelinewidget.h" +#include "timelineview.h" #include #include @@ -63,7 +63,7 @@ #define MAX_TEXT_WIDTH 20 #define TRANSITION_BETWEEN_RANGE 40 -TimelineWidget::TimelineWidget(QWidget *parent) : QWidget(parent) { +TimelineView::TimelineView(QWidget *parent) : QWidget(parent) { selection_command = nullptr; self_created_sequence = nullptr; scroll = 0; @@ -81,7 +81,7 @@ TimelineWidget::TimelineWidget(QWidget *parent) : QWidget(parent) { connect(&tooltip_timer, SIGNAL(timeout()), this, SLOT(tooltip_timer_timeout())); } -void TimelineWidget::show_context_menu(const QPoint& pos) { +void TimelineView::show_context_menu(const QPoint& pos) { if (olive::ActiveSequence != nullptr) { // hack because sometimes right clicking doesn't trigger mouse release event panel_timeline->rect_select_init = false; @@ -146,23 +146,6 @@ void TimelineWidget::show_context_menu(const QPoint& pos) { olive::MenuHelper.make_clip_functions_menu(&menu); - // stabilizer option - /*int video_clip_count = 0; - bool all_video_is_footage = true; - for (int i=0;itrack() < 0) { - video_clip_count++; - if (selected_clips.at(i)->media() == nullptr - || selected_clips.at(i)->media()->get_type() != MEDIA_TYPE_FOOTAGE) { - all_video_is_footage = false; - } - } - } - if (video_clip_count == 1 && all_video_is_footage) { - QAction* stabilizerAction = menu.addAction("S&tabilizer"); - connect(stabilizerAction, SIGNAL(triggered(bool)), this, SLOT(show_stabilizer_diag())); - }*/ - // check if all selected clips have the same media for a "Reveal In Project" bool same_media = true; rc_reveal_media = selected_clips.at(0)->media(); @@ -185,7 +168,7 @@ void TimelineWidget::show_context_menu(const QPoint& pos) { } } -void TimelineWidget::toggle_autoscale() { +void TimelineView::toggle_autoscale() { QVector selected_clips = olive::ActiveSequence->SelectedClips(); if (!selected_clips.isEmpty()) { @@ -200,7 +183,7 @@ void TimelineWidget::toggle_autoscale() { } } -void TimelineWidget::tooltip_timer_timeout() { +void TimelineView::tooltip_timer_timeout() { if (tooltip_clip != nullptr) { QToolTip::showText(QCursor::pos(), tr("%1\nStart: %2\nEnd: %3\nDuration: %4").arg( @@ -214,7 +197,7 @@ void TimelineWidget::tooltip_timer_timeout() { tooltip_timer.stop(); } -void TimelineWidget::open_sequence_properties() { +void TimelineView::open_sequence_properties() { QVector sequence_items = olive::project_model.GetAllSequences(); for (int i=0;i selected_clips = olive::ActiveSequence->SelectedClips(); @@ -244,19 +227,26 @@ bool same_sign(int a, int b) { return (a < 0) == (b < 0); } -void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) { +void TimelineView::dragEnterEvent(QDragEnterEvent *event) { bool import_init = false; QVector media_list; panel_timeline->importing_files = false; - if (panel_project->IsProjectWidget(event->source())) { - QModelIndexList items = panel_project->get_current_selected(); - media_list.resize(items.size()); - for (int i=0;iitem_to_media(items.at(i)); + for (int i=0;iIsProjectWidget(event->source())) { + + QModelIndexList items = panel_project.at(i)->get_current_selected(); + + media_list.resize(items.size()); + for (int i=0;iitem_to_media(items.at(i)); + } + import_init = true; + + break; + } - import_init = true; } if (event->source() == panel_footage_viewer) { @@ -326,7 +316,7 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) { } } -void TimelineWidget::dragMoveEvent(QDragMoveEvent *event) { +void TimelineView::dragMoveEvent(QDragMoveEvent *event) { if (panel_timeline->importing) { event->acceptProposedAction(); @@ -340,7 +330,7 @@ void TimelineWidget::dragMoveEvent(QDragMoveEvent *event) { } } -void TimelineWidget::wheelEvent(QWheelEvent *event) { +void TimelineView::wheelEvent(QWheelEvent *event) { // TODO: implement pixel scrolling @@ -403,7 +393,7 @@ void TimelineWidget::wheelEvent(QWheelEvent *event) { } } -void TimelineWidget::dragLeaveEvent(QDragLeaveEvent* event) { +void TimelineView::dragLeaveEvent(QDragLeaveEvent* event) { event->accept(); if (panel_timeline->importing) { if (panel_timeline->importing_files) { @@ -511,7 +501,7 @@ void insert_clips(ComboAction* ca) { } } -void TimelineWidget::dropEvent(QDropEvent* event) { +void TimelineView::dropEvent(QDropEvent* event) { if (panel_timeline->importing && panel_timeline->ghosts.size() > 0) { event->acceptProposedAction(); @@ -540,7 +530,7 @@ void TimelineWidget::dropEvent(QDropEvent* event) { } } -void TimelineWidget::mouseDoubleClickEvent(QMouseEvent *event) { +void TimelineView::mouseDoubleClickEvent(QMouseEvent *event) { if (olive::ActiveSequence != nullptr) { if (panel_timeline->tool == TIMELINE_TOOL_EDIT) { int clip_index = getClipIndexFromCoords(panel_timeline->cursor_frame, panel_timeline->cursor_track); @@ -570,7 +560,7 @@ bool current_tool_shows_cursor() { return (panel_timeline->tool == TIMELINE_TOOL_EDIT || panel_timeline->tool == TIMELINE_TOOL_RAZOR || panel_timeline->creating); } -void TimelineWidget::mousePressEvent(QMouseEvent *event) { +void TimelineView::mousePressEvent(QMouseEvent *event) { if (olive::ActiveSequence != nullptr) { int effective_tool = panel_timeline->tool; @@ -980,7 +970,7 @@ void VerifyTransitionsAfterCreating(ComboAction* ca, Clip* open, Clip* close, lo } } -void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { +void TimelineView::mouseReleaseEvent(QMouseEvent *event) { QToolTip::hideText(); if (olive::ActiveSequence != nullptr) { bool alt = (event->modifiers() & Qt::AltModifier); @@ -1542,7 +1532,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { } } -void TimelineWidget::init_ghosts() { +void TimelineView::init_ghosts() { for (int i=0;ighosts.size();i++) { Ghost& g = panel_timeline->ghosts[i]; ClipPtr c = olive::ActiveSequence->clips.at(g.clip); @@ -1612,7 +1602,7 @@ void validate_transitions(Clip* c, int transition_type, long& frame_diff) { } } -void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { +void TimelineView::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { int effective_tool = panel_timeline->tool; if (panel_timeline->importing || panel_timeline->creating) effective_tool = TIMELINE_TOOL_POINTER; @@ -1997,7 +1987,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { } } -void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { +void TimelineView::mouseMoveEvent(QMouseEvent *event) { // interrupt any potential tooltip about to show tooltip_timer.stop(); @@ -2794,7 +2784,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { } } -void TimelineWidget::leaveEvent(QEvent*) { +void TimelineView::leaveEvent(QEvent*) { tooltip_timer.stop(); } @@ -2906,7 +2896,7 @@ void draw_transition(QPainter& p, ClipPtr c, const QRect& clip_rect, QRect& text } -void TimelineWidget::paintEvent(QPaintEvent*) { +void TimelineView::paintEvent(QPaintEvent*) { // Draw clips if (olive::ActiveSequence != nullptr) { QPainter p(this); @@ -3352,11 +3342,11 @@ void TimelineWidget::paintEvent(QPaintEvent*) { } } -void TimelineWidget::resizeEvent(QResizeEvent *) { +void TimelineView::resizeEvent(QResizeEvent *) { scrollBar->setPageStep(height()); } -bool TimelineWidget::is_track_visible(int track) { +bool TimelineView::is_track_visible(int track) { return (bottom_align == (track < 0)); } @@ -3364,7 +3354,7 @@ bool TimelineWidget::is_track_visible(int track) { // screen point <-> frame/track functions // ************************************** -int TimelineWidget::getTrackFromScreenPoint(int y) { +int TimelineView::getTrackFromScreenPoint(int y) { int track_candidate = 0; y += scroll; @@ -3403,7 +3393,7 @@ int TimelineWidget::getTrackFromScreenPoint(int y) { } } -int TimelineWidget::getScreenPointFromTrack(int track) { +int TimelineView::getScreenPointFromTrack(int track) { int point = 0; int start = (track < 0) ? -1 : 0; @@ -3423,7 +3413,7 @@ int TimelineWidget::getScreenPointFromTrack(int track) { } } -int TimelineWidget::getClipIndexFromCoords(long frame, int track) { +int TimelineView::getClipIndexFromCoords(long frame, int track) { for (int i=0;iclips.size();i++) { ClipPtr c = olive::ActiveSequence->clips.at(i); if (c != nullptr && c->track() == track && frame >= c->timeline_in() && frame < c->timeline_out()) { @@ -3433,11 +3423,11 @@ int TimelineWidget::getClipIndexFromCoords(long frame, int track) { return -1; } -void TimelineWidget::setScroll(int s) { +void TimelineView::setScroll(int s) { scroll = s; update(); } -void TimelineWidget::reveal_media() { +void TimelineView::reveal_media() { panel_project->reveal_media(rc_reveal_media); } diff --git a/ui/timelinewidget.h b/ui/timelineview.h similarity index 91% rename from ui/timelinewidget.h rename to ui/timelineview.h index bb61279fc..539f291a2 100644 --- a/ui/timelinewidget.h +++ b/ui/timelineview.h @@ -40,12 +40,10 @@ class Timeline; bool same_sign(int a, int b); void draw_waveform(ClipPtr clip, const FootageStream *ms, long media_length, QPainter* p, const QRect& clip_rect, int waveform_start, int waveform_limit, double zoom); -class TimelineWidget : public QWidget { +class TimelineView : public QWidget { Q_OBJECT public: - explicit TimelineWidget(QWidget *parent); - - void SetTracks(QVector& tracks); + explicit TimelineView(QWidget *parent); QScrollBar* scrollBar; bool bottom_align; diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index c78309f6b..a6ce74f59 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -55,7 +55,7 @@ extern "C" { #include "project/media.h" #include "ui/viewercontainer.h" #include "rendering/cacher.h" -#include "ui/timelinewidget.h" +#include "ui/timelineview.h" #include "rendering/renderfunctions.h" #include "rendering/renderthread.h" #include "rendering/shadergenerators.h"