started new timeline paradigm

This commit is contained in:
itsmattkc
2019-03-30 19:43:22 +11:00
parent 7f92774dc9
commit 8e95210b22
19 changed files with 272 additions and 72 deletions
+10 -4
View File
@@ -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 +=
+3 -3
View File
@@ -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);
+3 -6
View File
@@ -25,7 +25,7 @@
#include <QTime>
#include <QPushButton>
#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;
+1 -1
View File
@@ -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"
+6
View File
@@ -19,6 +19,12 @@ enum TrimType {
TRIM_OUT
};
enum Alignment {
kAlignmentTop,
kAlignmentBottom,
kAlignmentSingle
};
}
}
+6
View File
@@ -0,0 +1,6 @@
#include "timelineshared.h"
TimelineShared::TimelineShared()
{
}
+11
View File
@@ -0,0 +1,11 @@
#ifndef TIMELINESHARED_H
#define TIMELINESHARED_H
class TimelineShared
{
public:
TimelineShared();
};
#endif // TIMELINESHARED_H
+34 -1
View File
@@ -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;
}
+14
View File
@@ -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<ClipPtr> clips_;
QVector<EffectPtr> effects_;
QVector<Selection> selections_;
bool muted_;
bool soloed_;
bool locked_;
};
#endif // TRACK_H
+5
View File
@@ -39,6 +39,11 @@ Track *TrackList::First()
return tracks_.first().get();
}
int TrackList::TrackCount()
{
return tracks_.size();
}
QVector<TrackPtr> TrackList::tracks()
{
return tracks_;
+1 -1
View File
@@ -13,11 +13,11 @@ public:
void AddTrack();
void RemoveTrack(int i);
Track* First();
int TrackCount();
QVector<Track*> tracks();
Sequence* GetParent();
private:
void ResizeTrackArray(int i);
+1 -1
View File
@@ -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<quintptr>(panel_project));
window_project_action->setData(reinterpret_cast<quintptr>(panel_project.first()));
window_effectcontrols_action = MenuHelper::create_menu_action(window_menu, "paneleffectcontrols", this, SLOT(toggle_panel_visibility()));
window_effectcontrols_action->setCheckable(true);
+36
View File
@@ -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_.size();i++) {
labels_.at(i).settra
}
}
}
+25
View File
@@ -0,0 +1,25 @@
#ifndef TIMELINEAREA_H
#define TIMELINEAREA_H
#include "timeline/sequence.h"
#include "timeline/track.h"
#include "timeline/tracklist.h"
#include "ui/timelineview.h"
#include "ui/timelinelabel.h"
class TimelineArea : public QWidget
{
Q_OBJECT
public:
TimelineArea();
void SetTrackList(Sequence* sequence, Track::Type track_list);
public slots:
void RefreshLabels();
private:
TrackList* track_list_;
TimelineView* view_;
QVector<TimelineLabel> labels_;
};
#endif // TIMELINEAREA_H
+50
View File
@@ -0,0 +1,50 @@
#include "timelinelabel.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
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)));
}
}
+23
View File
@@ -0,0 +1,23 @@
#ifndef TIMELINELABEL_H
#define TIMELINELABEL_H
#include <QWidget>
#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
+40 -50
View File
@@ -18,7 +18,7 @@
***/
#include "timelinewidget.h"
#include "timelineview.h"
#include <QPainter>
#include <QColor>
@@ -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;i<selected_clips.size();i++) {
if (selected_clips.at(i)->track() < 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<Clip*> 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<Media*> sequence_items = olive::project_model.GetAllSequences();
for (int i=0;i<sequence_items.size();i++) {
@@ -228,7 +211,7 @@ void TimelineWidget::open_sequence_properties() {
QMessageBox::critical(this, tr("Error"), tr("Couldn't locate media wrapper for sequence."));
}
void TimelineWidget::show_clip_properties()
void TimelineView::show_clip_properties()
{
// get list of selected clips
QVector<Clip*> 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<olive::timeline::MediaImportData> 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;i<items.size();i++) {
media_list[i] = panel_project->item_to_media(items.at(i));
for (int i=0;i<panel_project.size();i++) {
if (panel_project.at(i)->IsProjectWidget(event->source())) {
QModelIndexList items = panel_project.at(i)->get_current_selected();
media_list.resize(items.size());
for (int i=0;i<items.size();i++) {
media_list[i] = panel_project.at(i)->item_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;i<panel_timeline->ghosts.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;i<olive::ActiveSequence->clips.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);
}
+2 -4
View File
@@ -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<Track>& tracks);
explicit TimelineView(QWidget *parent);
QScrollBar* scrollBar;
bool bottom_align;
+1 -1
View File
@@ -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"