Merge branch 'move-time-to-viewer'

This commit is contained in:
itsmattkc
2022-11-01 18:20:22 -07:00
49 changed files with 297 additions and 414 deletions
+1 -1
View File
@@ -82,7 +82,7 @@ void Config::SetDefaults()
SetEntryInternal(QStringLiteral("InvertTimelineScrollAxes"), NodeValue::kBoolean, true); SetEntryInternal(QStringLiteral("InvertTimelineScrollAxes"), NodeValue::kBoolean, true);
SetEntryInternal(QStringLiteral("SelectAlsoSeeks"), NodeValue::kBoolean, false); SetEntryInternal(QStringLiteral("SelectAlsoSeeks"), NodeValue::kBoolean, false);
SetEntryInternal(QStringLiteral("PasteSeeks"), NodeValue::kBoolean, true); SetEntryInternal(QStringLiteral("PasteSeeks"), NodeValue::kBoolean, true);
SetEntryInternal(QStringLiteral("SelectAlsoSeeks"), NodeValue::kBoolean, false); SetEntryInternal(QStringLiteral("SeekAlsoSelects"), NodeValue::kBoolean, false);
SetEntryInternal(QStringLiteral("SetNameWithMarker"), NodeValue::kBoolean, false); SetEntryInternal(QStringLiteral("SetNameWithMarker"), NodeValue::kBoolean, false);
SetEntryInternal(QStringLiteral("AutoSeekToBeginning"), NodeValue::kBoolean, true); SetEntryInternal(QStringLiteral("AutoSeekToBeginning"), NodeValue::kBoolean, true);
SetEntryInternal(QStringLiteral("DropFileOnMediaToReplace"), NodeValue::kBoolean, false); SetEntryInternal(QStringLiteral("DropFileOnMediaToReplace"), NodeValue::kBoolean, false);
+6 -12
View File
@@ -379,11 +379,8 @@ void Core::DialogProjectPropertiesShow()
void Core::DialogExportShow() void Core::DialogExportShow()
{ {
ViewerOutput* viewer; if (ViewerOutput* viewer = GetSequenceToExport()) {
rational time; OpenExportDialogForViewer(viewer, false);
if (GetSequenceToExport(&viewer, &time)) {
OpenExportDialogForViewer(viewer, time, false);
} }
} }
@@ -850,7 +847,7 @@ void Core::SaveProjectInternal(Project* project, const QString& override_filenam
psm->deleteLater(); psm->deleteLater();
} }
bool Core::GetSequenceToExport(ViewerOutput **viewer, rational *time) ViewerOutput *Core::GetSequenceToExport()
{ {
// First try the most recently focused time based window // First try the most recently focused time based window
TimeBasedPanel* time_panel = PanelManager::instance()->MostRecentlyFocused<TimeBasedPanel>(); TimeBasedPanel* time_panel = PanelManager::instance()->MostRecentlyFocused<TimeBasedPanel>();
@@ -868,9 +865,7 @@ bool Core::GetSequenceToExport(ViewerOutput **viewer, rational *time)
tr("This Sequence is empty. There is nothing to export."), tr("This Sequence is empty. There is nothing to export."),
QMessageBox::Ok); QMessageBox::Ok);
} else { } else {
*viewer = time_panel->GetConnectedViewer(); return time_panel->GetConnectedViewer();
*time = time_panel->GetTime();
return true;
} }
} else { } else {
QMessageBox::critical(main_window_, QMessageBox::critical(main_window_,
@@ -879,7 +874,7 @@ bool Core::GetSequenceToExport(ViewerOutput **viewer, rational *time)
QMessageBox::Ok); QMessageBox::Ok);
} }
return false; return nullptr;
} }
QString Core::GetAutoRecoveryIndexFilename() QString Core::GetAutoRecoveryIndexFilename()
@@ -1249,10 +1244,9 @@ void Core::OpenNodeInViewer(ViewerOutput *viewer)
main_window_->OpenNodeInViewer(viewer); main_window_->OpenNodeInViewer(viewer);
} }
void Core::OpenExportDialogForViewer(ViewerOutput *viewer, const rational &time, bool start_still_image) void Core::OpenExportDialogForViewer(ViewerOutput *viewer, bool start_still_image)
{ {
ExportDialog* ed = new ExportDialog(viewer, start_still_image, main_window_); ExportDialog* ed = new ExportDialog(viewer, start_still_image, main_window_);
ed->SetTime(time);
connect(ed, &ExportDialog::finished, ed, &ExportDialog::deleteLater); connect(ed, &ExportDialog::finished, ed, &ExportDialog::deleteLater);
ed->open(); ed->open();
connect(ed, &ExportDialog::RequestImportFile, this, &Core::ImportSingleFile); connect(ed, &ExportDialog::RequestImportFile, this, &Core::ImportSingleFile);
+2 -2
View File
@@ -317,7 +317,7 @@ public:
void OpenNodeInViewer(ViewerOutput* viewer); void OpenNodeInViewer(ViewerOutput* viewer);
void OpenExportDialogForViewer(ViewerOutput *viewer, const rational &time, bool start_still_image); void OpenExportDialogForViewer(ViewerOutput *viewer, bool start_still_image);
public slots: public slots:
/** /**
@@ -551,7 +551,7 @@ private:
/** /**
* @brief Retrieves the currently most active sequence for exporting * @brief Retrieves the currently most active sequence for exporting
*/ */
bool GetSequenceToExport(ViewerOutput **viewer, rational *time); ViewerOutput *GetSequenceToExport();
static QString GetAutoRecoveryIndexFilename(); static QString GetAutoRecoveryIndexFilename();
+1
View File
@@ -47,6 +47,7 @@ ImageSection::ImageSection(QWidget* parent) :
frame_slider_->SetMinimum(0); frame_slider_->SetMinimum(0);
frame_slider_->SetValue(0); frame_slider_->SetValue(0);
frame_slider_->SetDisplayType(RationalSlider::kTime); frame_slider_->SetDisplayType(RationalSlider::kTime);
connect(frame_slider_, &RationalSlider::ValueChanged, this, &ImageSection::TimeChanged);
layout->addWidget(frame_slider_, row, 1); layout->addWidget(frame_slider_, row, 1);
} }
+3
View File
@@ -59,6 +59,9 @@ public:
frame_slider_->SetValue(t); frame_slider_->SetValue(t);
} }
signals:
void TimeChanged(const rational &t);
private: private:
QCheckBox* image_sequence_checkbox_; QCheckBox* image_sequence_checkbox_;
+5 -1
View File
@@ -148,6 +148,11 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, bool stills_only_mode, QWi
video_tab_ = new ExportVideoTab(color_manager_); video_tab_ = new ExportVideoTab(color_manager_);
AddPreferencesTab(video_tab_, tr("Video")); AddPreferencesTab(video_tab_, tr("Video"));
// Set video tab time and make connections
connect(viewer_node, &ViewerOutput::PlayheadChanged, video_tab_, &ExportVideoTab::SetTime);
connect(video_tab_, &ExportVideoTab::TimeChanged, viewer_node, &ViewerOutput::SetPlayhead);
video_tab_->SetTime(viewer_node->GetPlayhead());
audio_tab_ = new ExportAudioTab(); audio_tab_ = new ExportAudioTab();
AddPreferencesTab(audio_tab_, tr("Audio")); AddPreferencesTab(audio_tab_, tr("Audio"));
@@ -206,7 +211,6 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, bool stills_only_mode, QWi
preview_viewer_ = new ViewerWidget(); preview_viewer_ = new ViewerWidget();
preview_viewer_->ruler()->SetMarkerEditingEnabled(false); preview_viewer_->ruler()->SetMarkerEditingEnabled(false);
preview_viewer_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); preview_viewer_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
connect(preview_viewer_, &ViewerWidget::TimeChanged, video_tab_, &ExportVideoTab::SetTime);
preview_layout->addWidget(preview_viewer_); preview_layout->addWidget(preview_viewer_);
splitter->addWidget(preview_area); splitter->addWidget(preview_area);
-8
View File
@@ -51,14 +51,6 @@ public:
rational GetSelectedTimebase() const; rational GetSelectedTimebase() const;
void SetSelectedTimebase(const rational &r); void SetSelectedTimebase(const rational &r);
void SetTime(const rational &time)
{
preview_viewer_->SetAudioScrubbingEnabled(false);
preview_viewer_->SetTime(time);
video_tab_->SetTime(time);
preview_viewer_->SetAudioScrubbingEnabled(true);
}
EncodingParams GenerateParams() const; EncodingParams GenerateParams() const;
void SetParams(const EncodingParams &e); void SetParams(const EncodingParams &e);
+1
View File
@@ -184,6 +184,7 @@ QWidget *ExportVideoTab::SetupCodecSection()
codec_layout->addWidget(codec_stack_, row, 0, 1, 2); codec_layout->addWidget(codec_stack_, row, 0, 1, 2);
image_section_ = new ImageSection(); image_section_ = new ImageSection();
connect(image_section_, &ImageSection::TimeChanged, this, &ExportVideoTab::TimeChanged);
codec_stack_->addWidget(image_section_); codec_stack_->addWidget(image_section_);
h264_section_ = new H264Section(); h264_section_ = new H264Section();
+2
View File
@@ -166,6 +166,8 @@ signals:
void ImageSequenceCheckBoxChanged(bool e); void ImageSequenceCheckBoxChanged(bool e);
void TimeChanged(const rational &time);
private: private:
QWidget* SetupResolutionSection(); QWidget* SetupResolutionSection();
QWidget* SetupColorSection(); QWidget* SetupColorSection();
@@ -73,7 +73,7 @@ PreferencesBehaviorTab::PreferencesBehaviorTab()
tr("Hold ALT on any UI element to switch scrolling axes"), tr("Hold ALT on any UI element to switch scrolling axes"),
timeline_group); timeline_group);
AddItem(tr("Seek Also Selects"), AddItem(tr("Seek Also Selects"),
QStringLiteral("SelectAlsoSeeks"), QStringLiteral("SeekAlsoSelects"),
timeline_group); timeline_group);
AddItem(tr("Seek to the End of Pastes"), AddItem(tr("Seek to the End of Pastes"),
QStringLiteral("PasteSeeks"), QStringLiteral("PasteSeeks"),
+6
View File
@@ -316,6 +316,12 @@ void ViewerOutput::VerifyLength()
} }
} }
void ViewerOutput::SetPlayhead(const rational &t)
{
playhead_ = t;
emit PlayheadChanged(t);
}
void ViewerOutput::InputConnectedEvent(const QString &input, int element, Node *output) void ViewerOutput::InputConnectedEvent(const QString &input, int element, Node *output)
{ {
if (input == kTextureInput) { if (input == kTextureInput) {
+8
View File
@@ -97,6 +97,8 @@ public:
} }
} }
const rational &GetPlayhead() { return playhead_; }
void SetVideoParams(const VideoParams &video, int index = 0) void SetVideoParams(const VideoParams &video, int index = 0)
{ {
SetStandardValue(kVideoParamsInput, QVariant::fromValue(video), index); SetStandardValue(kVideoParamsInput, QVariant::fromValue(video), index);
@@ -219,9 +221,13 @@ signals:
void ConnectedWaveformChanged(); void ConnectedWaveformChanged();
void PlayheadChanged(const rational &t);
public slots: public slots:
void VerifyLength(); void VerifyLength();
void SetPlayhead(const rational &t);
protected: protected:
virtual void InputConnectedEvent(const QString &input, int element, Node *output) override; virtual void InputConnectedEvent(const QString &input, int element, Node *output) override;
@@ -253,6 +259,8 @@ private:
bool waveform_requests_enabled_; bool waveform_requests_enabled_;
rational playhead_;
}; };
} }
-14
View File
@@ -34,11 +34,6 @@ TimeBasedPanel::~TimeBasedPanel()
delete widget_; delete widget_;
} }
rational TimeBasedPanel::GetTime()
{
return widget_->GetTime();
}
const rational& TimeBasedPanel::timebase() const rational& TimeBasedPanel::timebase()
{ {
return widget_->timebase(); return widget_->timebase();
@@ -79,11 +74,6 @@ void TimeBasedPanel::SetTimebase(const rational &timebase)
widget_->SetTimebase(timebase); widget_->SetTimebase(timebase);
} }
void TimeBasedPanel::SetTime(const rational &time)
{
widget_->SetTime(time);
}
void TimeBasedPanel::GoToPrevCut() void TimeBasedPanel::GoToPrevCut()
{ {
widget_->GoToPrevCut(); widget_->GoToPrevCut();
@@ -127,16 +117,12 @@ void TimeBasedPanel::ConnectViewerNode(ViewerOutput *node)
void TimeBasedPanel::SetTimeBasedWidget(TimeBasedWidget *widget) void TimeBasedPanel::SetTimeBasedWidget(TimeBasedWidget *widget)
{ {
if (widget_) { if (widget_) {
disconnect(widget_, &TimeBasedWidget::TimeChanged, this, &TimeBasedPanel::TimeChanged);
disconnect(widget_, &TimeBasedWidget::TimebaseChanged, this, &TimeBasedPanel::TimebaseChanged);
disconnect(widget_, &TimeBasedWidget::ConnectedNodeChanged, this, &TimeBasedPanel::ConnectedNodeChanged); disconnect(widget_, &TimeBasedWidget::ConnectedNodeChanged, this, &TimeBasedPanel::ConnectedNodeChanged);
} }
widget_ = widget; widget_ = widget;
if (widget_) { if (widget_) {
connect(widget_, &TimeBasedWidget::TimeChanged, this, &TimeBasedPanel::TimeChanged);
connect(widget_, &TimeBasedWidget::TimebaseChanged, this, &TimeBasedPanel::TimebaseChanged);
connect(widget_, &TimeBasedWidget::ConnectedNodeChanged, this, &TimeBasedPanel::ConnectedNodeChanged); connect(widget_, &TimeBasedWidget::ConnectedNodeChanged, this, &TimeBasedPanel::ConnectedNodeChanged);
} }
-8
View File
@@ -41,8 +41,6 @@ public:
ConnectViewerNode(nullptr); ConnectViewerNode(nullptr);
} }
rational GetTime();
// Get the timebase of this panels widget // Get the timebase of this panels widget
const rational& timebase(); const rational& timebase();
@@ -113,13 +111,7 @@ public:
public slots: public slots:
void SetTimebase(const rational& timebase); void SetTimebase(const rational& timebase);
void SetTime(const rational &time);
signals: signals:
void TimeChanged(const rational& time);
void TimebaseChanged(const rational& timebase);
void PlayPauseRequested(); void PlayPauseRequested();
void PlayInToOutRequested(); void PlayInToOutRequested();
+3 -16
View File
@@ -59,7 +59,6 @@ CurveWidget::CurveWidget(QWidget *parent) :
QHBoxLayout* top_controls = new QHBoxLayout(); QHBoxLayout* top_controls = new QHBoxLayout();
key_control_ = new NodeParamViewKeyframeControl(false); key_control_ = new NodeParamViewKeyframeControl(false);
connect(key_control_, &NodeParamViewKeyframeControl::RequestSetTime, this, &CurveWidget::SetTimeAndSignal);
top_controls->addWidget(key_control_); top_controls->addWidget(key_control_);
top_controls->addStretch(); top_controls->addStretch();
@@ -99,7 +98,6 @@ CurveWidget::CurveWidget(QWidget *parent) :
layout->addLayout(ruler_view_layout); layout->addLayout(ruler_view_layout);
// Connect ruler and view together // Connect ruler and view together
connect(view_, &CurveView::TimeChanged, this, &CurveWidget::SetTimeAndSignal);
connect(view_, &CurveView::SelectionChanged, this, &CurveWidget::SelectionChanged); connect(view_, &CurveView::SelectionChanged, this, &CurveWidget::SelectionChanged);
connect(view_, &CurveView::Dragged, this, &CurveWidget::KeyframeViewDragged); connect(view_, &CurveView::Dragged, this, &CurveWidget::KeyframeViewDragged);
connect(view_, &CurveView::Released, this, &CurveWidget::KeyframeViewReleased); connect(view_, &CurveView::Released, this, &CurveWidget::KeyframeViewReleased);
@@ -191,14 +189,6 @@ void CurveWidget::SetNodes(const QVector<Node *> &nodes)
} }
} }
void CurveWidget::TimeChangedEvent(const rational &time)
{
super::TimeChangedEvent(time);
view_->SetTime(time);
UpdateBridgeTime(time);
}
void CurveWidget::TimebaseChangedEvent(const rational &timebase) void CurveWidget::TimebaseChangedEvent(const rational &timebase)
{ {
super::TimebaseChangedEvent(timebase); super::TimebaseChangedEvent(timebase);
@@ -213,7 +203,7 @@ void CurveWidget::ScaleChangedEvent(const double &scale)
view_->SetScale(scale); view_->SetScale(scale);
} }
void CurveWidget::TimeTargetChangedEvent(Node *target) void CurveWidget::TimeTargetChangedEvent(ViewerOutput *target)
{ {
TimeTargetObject::TimeTargetChangedEvent(target); TimeTargetObject::TimeTargetChangedEvent(target);
@@ -226,6 +216,8 @@ void CurveWidget::ConnectedNodeChangeEvent(ViewerOutput *n)
{ {
super::ConnectedNodeChangeEvent(n); super::ConnectedNodeChangeEvent(n);
key_control_->SetTimeTarget(n);
SetTimeTarget(n); SetTimeTarget(n);
} }
@@ -250,11 +242,6 @@ void CurveWidget::SetKeyframeButtonCheckedFromType(NodeKeyframe::Type type)
hold_button_->setChecked(type == NodeKeyframe::kHold); hold_button_->setChecked(type == NodeKeyframe::kHold);
} }
void CurveWidget::UpdateBridgeTime(const rational &time)
{
key_control_->SetTime(time);
}
void CurveWidget::ConnectInput(Node *node, const QString &input, int element) void CurveWidget::ConnectInput(Node *node, const QString &input, int element)
{ {
if (element == -1 && node->InputIsArray(input)) { if (element == -1 && node->InputIsArray(input)) {
+1 -4
View File
@@ -65,11 +65,10 @@ public slots:
void SetNodes(const QVector<Node *> &nodes); void SetNodes(const QVector<Node *> &nodes);
protected: protected:
virtual void TimeChangedEvent(const rational &) override;
virtual void TimebaseChangedEvent(const rational &) override; virtual void TimebaseChangedEvent(const rational &) override;
virtual void ScaleChangedEvent(const double &) override; virtual void ScaleChangedEvent(const double &) override;
virtual void TimeTargetChangedEvent(Node* target) override; virtual void TimeTargetChangedEvent(ViewerOutput *target) override;
virtual void ConnectedNodeChangeEvent(ViewerOutput* n) override; virtual void ConnectedNodeChangeEvent(ViewerOutput* n) override;
@@ -95,8 +94,6 @@ private:
void SetKeyframeButtonCheckedFromType(NodeKeyframe::Type type); void SetKeyframeButtonCheckedFromType(NodeKeyframe::Type type);
void UpdateBridgeTime(const rational &time);
void ConnectInput(Node *node, const QString &input, int element); void ConnectInput(Node *node, const QString &input, int element);
void ConnectInputInternal(Node *node, const QString &input, int element); void ConnectInputInternal(Node *node, const QString &input, int element);
+6 -2
View File
@@ -204,6 +204,10 @@ bool KeyframeView::CopySelected(bool cut)
bool KeyframeView::Paste(std::function<Node *(const QString &)> find_node_function) bool KeyframeView::Paste(std::function<Node *(const QString &)> find_node_function)
{ {
if (!GetViewerNode()) {
return false;
}
ProjectSerializer::Result res = ProjectSerializer::Paste(QStringLiteral("keyframes")); ProjectSerializer::Result res = ProjectSerializer::Paste(QStringLiteral("keyframes"));
if (res == ProjectSerializer::kSuccess) { if (res == ProjectSerializer::kSuccess) {
const ProjectSerializer::SerializedKeyframes &keys = res.GetLoadData().keyframes; const ProjectSerializer::SerializedKeyframes &keys = res.GetLoadData().keyframes;
@@ -216,7 +220,7 @@ bool KeyframeView::Paste(std::function<Node *(const QString &)> find_node_functi
min = std::min(min, key->time()); min = std::min(min, key->time());
} }
} }
min -= GetTime(); min -= GetViewerNode()->GetPlayhead();
for (auto it=keys.cbegin(); it!=keys.cend(); it++) { for (auto it=keys.cbegin(); it!=keys.cend(); it++) {
const QString &paste_id = it.key(); const QString &paste_id = it.key();
@@ -454,7 +458,7 @@ void KeyframeView::ScaleChangedEvent(const double &scale)
Redraw(); Redraw();
} }
void KeyframeView::TimeTargetChangedEvent(Node *target) void KeyframeView::TimeTargetChangedEvent(ViewerOutput *v)
{ {
Redraw(); Redraw();
} }
+1 -1
View File
@@ -101,7 +101,7 @@ protected:
virtual void ScaleChangedEvent(const double& scale) override; virtual void ScaleChangedEvent(const double& scale) override;
virtual void TimeTargetChangedEvent(Node*) override; virtual void TimeTargetChangedEvent(ViewerOutput *v) override;
virtual void TimebaseChangedEvent(const rational &timebase) override; virtual void TimebaseChangedEvent(const rational &timebase) override;
+3 -3
View File
@@ -74,7 +74,7 @@ void MulticamWidget::SetMulticamNodeInternal(ViewerOutput *viewer, MultiCamNode
void MulticamWidget::SetMulticamNode(ViewerOutput *viewer, MultiCamNode *n, ClipBlock *clip, const rational &time) void MulticamWidget::SetMulticamNode(ViewerOutput *viewer, MultiCamNode *n, ClipBlock *clip, const rational &time)
{ {
if (time.isNaN() || time == GetTime()) { if (time.isNaN() || !GetConnectedNode() || time == GetConnectedNode()->GetPlayhead()) {
SetMulticamNodeInternal(viewer, n, clip); SetMulticamNodeInternal(viewer, n, clip);
play_queue_.clear(); play_queue_.clear();
} else { } else {
@@ -125,13 +125,13 @@ void MulticamWidget::Switch(int source, bool split_clip)
BlockSplitPreservingLinksCommand *split = nullptr; BlockSplitPreservingLinksCommand *split = nullptr;
if (clip_ && split_clip && clip_->in() < GetTime() && clip_->out() > GetTime()) { if (clip_ && split_clip && clip_->in() < GetConnectedNode()->GetPlayhead() && clip_->out() > GetConnectedNode()->GetPlayhead()) {
QVector<Block*> blocks; QVector<Block*> blocks;
blocks.append(clip_); blocks.append(clip_);
blocks.append(clip_->block_links()); blocks.append(clip_->block_links());
split = new BlockSplitPreservingLinksCommand(blocks, {GetTime()}); split = new BlockSplitPreservingLinksCommand(blocks, {GetConnectedNode()->GetPlayhead()});
split->redo_now(); split->redo_now();
command->add_child(split); command->add_child(split);
+1 -26
View File
@@ -126,9 +126,6 @@ NodeParamView::NodeParamView(bool create_keyframe_view, QWidget *parent) :
keyframe_area_layout->addWidget(keyframe_view_); keyframe_area_layout->addWidget(keyframe_view_);
// Connect ruler and keyframe view together // Connect ruler and keyframe view together
connect(ruler(), &TimeRuler::TimeChanged, keyframe_view_, &KeyframeView::SetTime);
connect(keyframe_view_, &KeyframeView::TimeChanged, ruler(), &TimeRuler::SetTime);
connect(keyframe_view_, &KeyframeView::TimeChanged, this, &NodeParamView::SetTime);
connect(keyframe_view_, &KeyframeView::Dragged, this, &NodeParamView::KeyframeViewDragged); connect(keyframe_view_, &KeyframeView::Dragged, this, &NodeParamView::KeyframeViewDragged);
connect(keyframe_view_, &KeyframeView::Released, this, &NodeParamView::KeyframeViewReleased); connect(keyframe_view_, &KeyframeView::Released, this, &NodeParamView::KeyframeViewReleased);
@@ -356,19 +353,6 @@ void NodeParamView::TimebaseChangedEvent(const rational &timebase)
foreach (NodeParamViewContext* ctx, context_items_) { foreach (NodeParamViewContext* ctx, context_items_) {
ctx->SetTimebase(timebase); ctx->SetTimebase(timebase);
} }
UpdateItemTime(GetTime());
}
void NodeParamView::TimeChangedEvent(const rational &time)
{
super::TimeChangedEvent(time);
if (keyframe_view_) {
keyframe_view_->SetTime(time);
}
UpdateItemTime(time);
} }
void NodeParamView::ConnectedNodeChangeEvent(ViewerOutput *n) void NodeParamView::ConnectedNodeChangeEvent(ViewerOutput *n)
@@ -385,7 +369,7 @@ void NodeParamView::ConnectedNodeChangeEvent(ViewerOutput *n)
time_target_ = n; time_target_ = n;
} }
Node *NodeParamView::GetTimeTarget() const ViewerOutput *NodeParamView::GetTimeTarget() const
{ {
return time_target_; return time_target_;
} }
@@ -678,13 +662,6 @@ bool NodeParamView::Paste(QWidget *parent, std::function<QHash<Node *, Node*>(co
return true; return true;
} }
void NodeParamView::UpdateItemTime(const rational &time)
{
foreach (NodeParamViewContext* item, context_items_) {
item->SetTime(time);
}
}
void NodeParamView::QueueKeyframePositionUpdate() void NodeParamView::QueueKeyframePositionUpdate()
{ {
QMetaObject::invokeMethod(this, &NodeParamView::UpdateElementY, Qt::QueuedConnection); QMetaObject::invokeMethod(this, &NodeParamView::UpdateElementY, Qt::QueuedConnection);
@@ -737,7 +714,6 @@ void NodeParamView::AddNode(Node *n, Node *ctx, NodeParamViewContext *context)
NodeParamViewItem* item = new NodeParamViewItem(n, IsGroupMode() ? kCheckBoxesOnNonConnected : kNoCheckBoxes, context->GetDockArea()); NodeParamViewItem* item = new NodeParamViewItem(n, IsGroupMode() ? kCheckBoxesOnNonConnected : kNoCheckBoxes, context->GetDockArea());
connect(item, &NodeParamViewItem::RequestSetTime, this, &NodeParamView::SetTimeAndSignal);
connect(item, &NodeParamViewItem::RequestSelectNode, this, &NodeParamView::SelectNodeFromConnectedLink); connect(item, &NodeParamViewItem::RequestSelectNode, this, &NodeParamView::SelectNodeFromConnectedLink);
connect(item, &NodeParamViewItem::PinToggled, this, &NodeParamView::PinNode); connect(item, &NodeParamViewItem::PinToggled, this, &NodeParamView::PinNode);
connect(item, &NodeParamViewItem::InputCheckedChanged, this, &NodeParamView::InputCheckBoxChanged); connect(item, &NodeParamViewItem::InputCheckedChanged, this, &NodeParamView::InputCheckBoxChanged);
@@ -747,7 +723,6 @@ void NodeParamView::AddNode(Node *n, Node *ctx, NodeParamViewContext *context)
item->SetContext(ctx); item->SetContext(ctx);
item->SetTimeTarget(GetTimeTarget()); item->SetTimeTarget(GetTimeTarget());
item->SetTimebase(timebase()); item->SetTimebase(timebase());
item->SetTime(GetTime());
context->AddNode(item); context->AddNode(item);
+2 -5
View File
@@ -48,7 +48,7 @@ public:
void CloseContextsBelongingToProject(Project *p); void CloseContextsBelongingToProject(Project *p);
Node* GetTimeTarget() const; ViewerOutput *GetTimeTarget() const;
void DeleteSelected(); void DeleteSelected();
@@ -95,7 +95,6 @@ protected:
virtual void ScaleChangedEvent(const double &) override; virtual void ScaleChangedEvent(const double &) override;
virtual void TimebaseChangedEvent(const rational&) override; virtual void TimebaseChangedEvent(const rational&) override;
virtual void TimeChangedEvent(const rational &time) override;
virtual void ConnectedNodeChangeEvent(ViewerOutput* n) override; virtual void ConnectedNodeChangeEvent(ViewerOutput* n) override;
@@ -115,8 +114,6 @@ protected:
} }
private: private:
void UpdateItemTime(const rational &time);
void QueueKeyframePositionUpdate(); void QueueKeyframePositionUpdate();
void AddContext(Node *context); void AddContext(Node *context);
@@ -159,7 +156,7 @@ private:
NodeParamViewItem* focused_node_; NodeParamViewItem* focused_node_;
QVector<NodeParamViewItem*> selected_nodes_; QVector<NodeParamViewItem*> selected_nodes_;
Node *time_target_; ViewerOutput *time_target_;
QVector<Node*> contexts_; QVector<Node*> contexts_;
QVector<Node*> current_contexts_; QVector<Node*> current_contexts_;
@@ -34,7 +34,8 @@ namespace olive {
NodeParamViewConnectedLabel::NodeParamViewConnectedLabel(const NodeInput &input, QWidget *parent) : NodeParamViewConnectedLabel::NodeParamViewConnectedLabel(const NodeInput &input, QWidget *parent) :
QWidget(parent), QWidget(parent),
input_(input), input_(input),
connected_node_(nullptr) connected_node_(nullptr),
viewer_(nullptr)
{ {
QVBoxLayout *layout = new QVBoxLayout(this); QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
@@ -85,6 +86,20 @@ NodeParamViewConnectedLabel::NodeParamViewConnectedLabel(const NodeInput &input,
connect(collapse_btn, &CollapseButton::toggled, this, &NodeParamViewConnectedLabel::SetValueTreeVisible); connect(collapse_btn, &CollapseButton::toggled, this, &NodeParamViewConnectedLabel::SetValueTreeVisible);
} }
void NodeParamViewConnectedLabel::SetViewerNode(ViewerOutput *viewer)
{
if (viewer_) {
disconnect(viewer_, &ViewerOutput::PlayheadChanged, this, &NodeParamViewConnectedLabel::UpdateValueTree);
}
viewer_ = viewer;
if (viewer_) {
connect(viewer_, &ViewerOutput::PlayheadChanged, this, &NodeParamViewConnectedLabel::UpdateValueTree);
UpdateValueTree();
}
}
void NodeParamViewConnectedLabel::CreateTree() void NodeParamViewConnectedLabel::CreateTree()
{ {
// Set up table area // Set up table area
@@ -92,15 +107,6 @@ void NodeParamViewConnectedLabel::CreateTree()
layout()->addWidget(value_tree_); layout()->addWidget(value_tree_);
} }
void NodeParamViewConnectedLabel::SetTime(const rational &time)
{
time_ = time;
if (value_tree_ && value_tree_->isVisible()) {
UpdateValueTree();
}
}
void NodeParamViewConnectedLabel::InputConnected(Node *output, const NodeInput& input) void NodeParamViewConnectedLabel::InputConnected(Node *output, const NodeInput& input)
{ {
if (input_ != input) { if (input_ != input) {
@@ -159,8 +165,8 @@ void NodeParamViewConnectedLabel::UpdateLabel()
void NodeParamViewConnectedLabel::UpdateValueTree() void NodeParamViewConnectedLabel::UpdateValueTree()
{ {
if (value_tree_) { if (value_tree_ && viewer_ && value_tree_->isVisible()) {
value_tree_->SetNode(input_, time_); value_tree_->SetNode(input_, viewer_->GetPlayhead());
} }
} }
@@ -173,6 +179,7 @@ void NodeParamViewConnectedLabel::SetValueTreeVisible(bool e)
if (e) { if (e) {
if (!value_tree_) { if (!value_tree_) {
CreateTree(); CreateTree();
value_tree_->setVisible(true);
} }
UpdateValueTree(); UpdateValueTree();
@@ -32,7 +32,7 @@ class NodeParamViewConnectedLabel : public QWidget {
public: public:
NodeParamViewConnectedLabel(const NodeInput& input, QWidget* parent = nullptr); NodeParamViewConnectedLabel(const NodeInput& input, QWidget* parent = nullptr);
void SetTime(const rational &time); void SetViewerNode(ViewerOutput *viewer);
signals: signals:
void RequestSelectNode(Node *n); void RequestSelectNode(Node *n);
@@ -61,7 +61,7 @@ private:
NodeValueTree *value_tree_; NodeValueTree *value_tree_;
rational time_; ViewerOutput *viewer_;
private slots: private slots:
void SetValueTreeVisible(bool e); void SetValueTreeVisible(bool e);
@@ -113,20 +113,13 @@ void NodeParamViewContext::SetTimebase(const rational &timebase)
} }
} }
void NodeParamViewContext::SetTimeTarget(Node *n) void NodeParamViewContext::SetTimeTarget(ViewerOutput *n)
{ {
foreach (NodeParamViewItem* item, items_) { foreach (NodeParamViewItem* item, items_) {
item->SetTimeTarget(n); item->SetTimeTarget(n);
} }
} }
void NodeParamViewContext::SetTime(const rational &time)
{
foreach (NodeParamViewItem* item, items_) {
item->SetTime(time);
}
}
void NodeParamViewContext::SetEffectType(Track::Type type) void NodeParamViewContext::SetEffectType(Track::Type type)
{ {
type_ = type; type_ = type;
@@ -60,9 +60,7 @@ public:
void SetTimebase(const rational &timebase); void SetTimebase(const rational &timebase);
void SetTimeTarget(Node *n); void SetTimeTarget(ViewerOutput *n);
void SetTime(const rational &time);
void SetEffectType(Track::Type type); void SetEffectType(Track::Type type);
+3 -20
View File
@@ -90,12 +90,10 @@ void NodeParamViewItem::RecreateBody()
body_ = new NodeParamViewItemBody(node_, create_checkboxes_, this); body_ = new NodeParamViewItemBody(node_, create_checkboxes_, this);
connect(body_, &NodeParamViewItemBody::RequestSelectNode, this, &NodeParamViewItem::RequestSelectNode); connect(body_, &NodeParamViewItemBody::RequestSelectNode, this, &NodeParamViewItem::RequestSelectNode);
connect(body_, &NodeParamViewItemBody::RequestSetTime, this, &NodeParamViewItem::RequestSetTime);
connect(body_, &NodeParamViewItemBody::ArrayExpandedChanged, this, &NodeParamViewItem::ArrayExpandedChanged); connect(body_, &NodeParamViewItemBody::ArrayExpandedChanged, this, &NodeParamViewItem::ArrayExpandedChanged);
connect(body_, &NodeParamViewItemBody::InputCheckedChanged, this, &NodeParamViewItem::InputCheckedChanged); connect(body_, &NodeParamViewItemBody::InputCheckedChanged, this, &NodeParamViewItem::InputCheckedChanged);
connect(body_, &NodeParamViewItemBody::RequestEditTextInViewer, this, &NodeParamViewItem::RequestEditTextInViewer); connect(body_, &NodeParamViewItemBody::RequestEditTextInViewer, this, &NodeParamViewItem::RequestEditTextInViewer);
body_->Retranslate(); body_->Retranslate();
body_->SetTime(time_);
body_->SetTimebase(timebase_); body_->SetTimebase(timebase_);
SetBody(body_); SetBody(body_);
} }
@@ -259,7 +257,6 @@ void NodeParamViewItemBody::CreateWidgets(QGridLayout* layout, Node *node, const
ui_objects.key_control = new NodeParamViewKeyframeControl(this); ui_objects.key_control = new NodeParamViewKeyframeControl(this);
ui_objects.key_control->SetInput(resolved); ui_objects.key_control->SetInput(resolved);
layout->addWidget(ui_objects.key_control, row, kKeyControlColumn); layout->addWidget(ui_objects.key_control, row, kKeyControlColumn);
connect(ui_objects.key_control, &NodeParamViewKeyframeControl::RequestSetTime, this, &NodeParamViewItemBody::RequestSetTime);
} }
input_ui_map_.insert(input_ref, ui_objects); input_ui_map_.insert(input_ref, ui_objects);
@@ -269,31 +266,17 @@ void NodeParamViewItemBody::CreateWidgets(QGridLayout* layout, Node *node, const
} }
} }
void NodeParamViewItemBody::SetTimeTarget(Node *target) void NodeParamViewItemBody::SetTimeTarget(ViewerOutput *target)
{ {
foreach (const InputUI& ui_obj, input_ui_map_) { foreach (const InputUI& ui_obj, input_ui_map_) {
// Only keyframable inputs have a key control widget // Only keyframable inputs have a key control widget
if (ui_obj.key_control) { if (ui_obj.key_control) {
ui_obj.key_control->SetTimeTarget(target); ui_obj.key_control->SetTimeTarget(target);
} }
ui_obj.widget_bridge->SetTimeTarget(target);
}
}
void NodeParamViewItemBody::SetTime(const rational &time)
{
foreach (const InputUI& ui_obj, input_ui_map_) {
// Only keyframable inputs have a key control widget
if (ui_obj.key_control) {
ui_obj.key_control->SetTime(time);
}
if (ui_obj.connected_label) { if (ui_obj.connected_label) {
ui_obj.connected_label->SetTime(time); ui_obj.connected_label->SetViewerNode(target);
} }
ui_obj.widget_bridge->SetTimeTarget(target);
ui_obj.widget_bridge->SetTime(time);
} }
} }
+2 -16
View File
@@ -51,9 +51,7 @@ class NodeParamViewItemBody : public QWidget {
public: public:
NodeParamViewItemBody(Node* node, NodeParamViewCheckBoxBehavior create_checkboxes, QWidget* parent = nullptr); NodeParamViewItemBody(Node* node, NodeParamViewCheckBoxBehavior create_checkboxes, QWidget* parent = nullptr);
void SetTimeTarget(Node* target); void SetTimeTarget(ViewerOutput *target);
void SetTime(const rational& time);
void Retranslate(); void Retranslate();
@@ -65,8 +63,6 @@ public:
void SetInputChecked(const NodeInput &input, bool e); void SetInputChecked(const NodeInput &input, bool e);
signals: signals:
void RequestSetTime(const rational& time);
void RequestSelectNode(Node *node); void RequestSelectNode(Node *node);
void ArrayExpandedChanged(bool e); void ArrayExpandedChanged(bool e);
@@ -167,18 +163,11 @@ class NodeParamViewItem : public NodeParamViewItemBase
public: public:
NodeParamViewItem(Node* node, NodeParamViewCheckBoxBehavior create_checkboxes, QWidget* parent = nullptr); NodeParamViewItem(Node* node, NodeParamViewCheckBoxBehavior create_checkboxes, QWidget* parent = nullptr);
void SetTimeTarget(Node* target) void SetTimeTarget(ViewerOutput* target)
{ {
body_->SetTimeTarget(target); body_->SetTimeTarget(target);
} }
void SetTime(const rational& time)
{
time_ = time;
body_->SetTime(time_);
}
void SetTimebase(const rational& timebase) void SetTimebase(const rational& timebase)
{ {
timebase_ = timebase; timebase_ = timebase;
@@ -216,8 +205,6 @@ public:
} }
signals: signals:
void RequestSetTime(const rational& time);
void RequestSelectNode(Node *node); void RequestSelectNode(Node *node);
void ArrayExpandedChanged(bool e); void ArrayExpandedChanged(bool e);
@@ -238,7 +225,6 @@ private:
Node *ctx_; Node *ctx_;
rational time_;
rational timebase_; rational timebase_;
KeyframeView::NodeConnections keyframe_connections_; KeyframeView::NodeConnections keyframe_connections_;
@@ -96,10 +96,14 @@ void NodeParamViewKeyframeControl::SetInput(const NodeInput& input)
} }
} }
void NodeParamViewKeyframeControl::SetTime(const rational &time) void NodeParamViewKeyframeControl::TimeTargetDisconnectEvent(ViewerOutput *v)
{ {
time_ = time; disconnect(v, &ViewerOutput::PlayheadChanged, this, &NodeParamViewKeyframeControl::UpdateState);
}
void NodeParamViewKeyframeControl::TimeTargetConnectEvent(ViewerOutput *v)
{
connect(v, &ViewerOutput::PlayheadChanged, this, &NodeParamViewKeyframeControl::UpdateState);
UpdateState(); UpdateState();
} }
@@ -122,7 +126,7 @@ void NodeParamViewKeyframeControl::SetButtonsEnabled(bool e)
rational NodeParamViewKeyframeControl::GetCurrentTimeAsNodeTime() const rational NodeParamViewKeyframeControl::GetCurrentTimeAsNodeTime() const
{ {
return GetAdjustedTime(GetTimeTarget(), input_.node(), time_, Node::kTransformTowardsInput); return GetAdjustedTime(GetTimeTarget(), input_.node(), GetTimeTarget()->GetPlayhead(), Node::kTransformTowardsInput);
} }
rational NodeParamViewKeyframeControl::ConvertToViewerTime(const rational &r) const rational NodeParamViewKeyframeControl::ConvertToViewerTime(const rational &r) const
@@ -177,7 +181,7 @@ void NodeParamViewKeyframeControl::ToggleKeyframe(bool e)
void NodeParamViewKeyframeControl::UpdateState() void NodeParamViewKeyframeControl::UpdateState()
{ {
if (!input_.IsValid() || !input_.IsKeyframing()) { if (!input_.IsValid() || !input_.IsKeyframing() || !GetTimeTarget()) {
return; return;
} }
@@ -197,10 +201,9 @@ void NodeParamViewKeyframeControl::GoToPreviousKey()
NodeKeyframe* previous_key = input_.node()->GetClosestKeyframeBeforeTime(input_, node_time); NodeKeyframe* previous_key = input_.node()->GetClosestKeyframeBeforeTime(input_, node_time);
if (previous_key) { if (previous_key && GetTimeTarget()) {
rational key_time = ConvertToViewerTime(previous_key->time()); rational key_time = ConvertToViewerTime(previous_key->time());
GetTimeTarget()->SetPlayhead(key_time);
emit RequestSetTime(key_time);
} }
} }
@@ -210,10 +213,9 @@ void NodeParamViewKeyframeControl::GoToNextKey()
NodeKeyframe* next_key = input_.node()->GetClosestKeyframeAfterTime(input_, node_time); NodeKeyframe* next_key = input_.node()->GetClosestKeyframeAfterTime(input_, node_time);
if (next_key) { if (next_key && GetTimeTarget()) {
rational key_time = ConvertToViewerTime(next_key->time()); rational key_time = ConvertToViewerTime(next_key->time());
GetTimeTarget()->SetPlayhead(key_time);
emit RequestSetTime(key_time);
} }
} }
@@ -46,10 +46,9 @@ public:
void SetInput(const NodeInput& input); void SetInput(const NodeInput& input);
void SetTime(const rational& time); protected:
virtual void TimeTargetDisconnectEvent(ViewerOutput *v) override;
signals: virtual void TimeTargetConnectEvent(ViewerOutput *v) override;
void RequestSetTime(const rational& time);
private: private:
QPushButton* CreateNewToolButton(const QIcon &icon) const; QPushButton* CreateNewToolButton(const QIcon &icon) const;
@@ -67,8 +66,6 @@ private:
NodeInput input_; NodeInput input_;
rational time_;
private slots: private slots:
void ShowButtonsFromKeyframeEnable(bool e); void ShowButtonsFromKeyframeEnable(bool e);
@@ -57,13 +57,6 @@ NodeParamViewWidgetBridge::NodeParamViewWidgetBridge(NodeInput input, QObject *p
CreateWidgets(); CreateWidgets();
} }
void NodeParamViewWidgetBridge::SetTime(const rational &time)
{
time_ = time;
UpdateWidgetValues();
}
int GetSliderCount(NodeValue::Type type) int GetSliderCount(NodeValue::Type type)
{ {
return NodeValue::get_number_of_keyframe_tracks(type); return NodeValue::get_number_of_keyframe_tracks(type);
@@ -528,7 +521,11 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues()
rational NodeParamViewWidgetBridge::GetCurrentTimeAsNodeTime() const rational NodeParamViewWidgetBridge::GetCurrentTimeAsNodeTime() const
{ {
return GetAdjustedTime(GetTimeTarget(), GetInnerInput().node(), time_, Node::kTransformTowardsInput); if (GetTimeTarget()) {
return GetAdjustedTime(GetTimeTarget(), GetInnerInput().node(), GetTimeTarget()->GetPlayhead(), Node::kTransformTowardsInput);
} else {
return 0;
}
} }
void NodeParamViewWidgetBridge::SetTimebase(const rational& timebase) void NodeParamViewWidgetBridge::SetTimebase(const rational& timebase)
@@ -538,11 +535,21 @@ void NodeParamViewWidgetBridge::SetTimebase(const rational& timebase)
} }
} }
void NodeParamViewWidgetBridge::TimeTargetDisconnectEvent(ViewerOutput *v)
{
disconnect(v, &ViewerOutput::PlayheadChanged, this, &NodeParamViewWidgetBridge::UpdateWidgetValues);
}
void NodeParamViewWidgetBridge::TimeTargetConnectEvent(ViewerOutput *v)
{
connect(v, &ViewerOutput::PlayheadChanged, this, &NodeParamViewWidgetBridge::UpdateWidgetValues);
}
void NodeParamViewWidgetBridge::InputValueChanged(const NodeInput &input, const TimeRange &range) void NodeParamViewWidgetBridge::InputValueChanged(const NodeInput &input, const TimeRange &range)
{ {
if (GetInnerInput() == input if (GetInnerInput() == input
&& !dragger_.IsStarted() && !dragger_.IsStarted()
&& range.in() <= time_ && range.out() >= time_) { && range.in() <= GetTimeTarget()->GetPlayhead() && range.out() >= GetTimeTarget()->GetPlayhead()) {
// We'll need to update the widgets because the values have changed on our current time // We'll need to update the widgets because the values have changed on our current time
UpdateWidgetValues(); UpdateWidgetValues();
} }
@@ -42,8 +42,6 @@ class NodeParamViewWidgetBridge : public QObject, public TimeTargetObject
public: public:
NodeParamViewWidgetBridge(NodeInput input, QObject* parent); NodeParamViewWidgetBridge(NodeInput input, QObject* parent);
void SetTime(const rational& time);
const QVector<QWidget*>& widgets() const const QVector<QWidget*>& widgets() const
{ {
return widgets_; return widgets_;
@@ -59,6 +57,10 @@ signals:
void RequestEditTextInViewer(); void RequestEditTextInViewer();
protected:
virtual void TimeTargetDisconnectEvent(ViewerOutput *v) override;
virtual void TimeTargetConnectEvent(ViewerOutput *v) override;
private: private:
void CreateWidgets(); void CreateWidgets();
@@ -102,8 +104,6 @@ private:
QVector<QWidget*> widgets_; QVector<QWidget*> widgets_;
rational time_;
NodeInputDragger dragger_; NodeInputDragger dragger_;
NodeParamViewScrollBlocker scroll_filter_; NodeParamViewScrollBlocker scroll_filter_;
+26 -15
View File
@@ -38,7 +38,8 @@ TimeBasedView::TimeBasedView(QWidget *parent) :
snapped_(false), snapped_(false),
snap_service_(nullptr), snap_service_(nullptr),
y_axis_enabled_(false), y_axis_enabled_(false),
y_scale_(1.0) y_scale_(1.0),
viewer_(nullptr)
{ {
// Sets scene to our scene // Sets scene to our scene
setScene(&scene_); setScene(&scene_);
@@ -142,12 +143,17 @@ void TimeBasedView::SetYScale(const double &y_scale)
} }
} }
void TimeBasedView::SetTime(const rational &time) void TimeBasedView::SetViewerNode(ViewerOutput *v)
{ {
playhead_ = time; if (viewer_) {
disconnect(viewer_, &ViewerOutput::PlayheadChanged, viewport(), static_cast<void(QWidget::*)()>(&TimeBasedView::update));
}
// Force redraw for playhead viewer_ = v;
viewport()->update();
if (viewer_) {
connect(viewer_, &ViewerOutput::PlayheadChanged, viewport(), static_cast<void(QWidget::*)()>(&TimeBasedView::update));
}
} }
void TimeBasedView::drawForeground(QPainter *painter, const QRectF &rect) void TimeBasedView::drawForeground(QPainter *painter, const QRectF &rect)
@@ -203,20 +209,21 @@ bool TimeBasedView::PlayheadMove(QMouseEvent *event)
return false; return false;
} }
QPointF scene_pos = mapToScene(event->pos()); if (viewer_) {
rational mouse_time = qMax(rational(0), SceneToTime(scene_pos.x())); QPointF scene_pos = mapToScene(event->pos());
rational mouse_time = qMax(rational(0), SceneToTime(scene_pos.x()));
if (Core::instance()->snapping() && snap_service_) { if (Core::instance()->snapping() && snap_service_) {
rational movement; rational movement;
snap_service_->SnapPoint({mouse_time}, &movement, TimeBasedWidget::kSnapAll & ~TimeBasedWidget::kSnapToPlayhead); snap_service_->SnapPoint({mouse_time}, &movement, TimeBasedWidget::kSnapAll & ~TimeBasedWidget::kSnapToPlayhead);
mouse_time += movement; mouse_time += movement;
}
viewer_->SetPlayhead(mouse_time);
} }
SetTime(mouse_time);
emit TimeChanged(mouse_time);
return true; return true;
} }
@@ -237,7 +244,11 @@ bool TimeBasedView::PlayheadRelease(QMouseEvent*)
qreal TimeBasedView::GetPlayheadX() qreal TimeBasedView::GetPlayheadX()
{ {
return TimeToScene(playhead_); if (viewer_) {
return TimeToScene(viewer_->GetPlayhead());
} else {
return 0;
}
} }
void TimeBasedView::SetEndTime(const rational &length) void TimeBasedView::SetEndTime(const rational &length)
+6 -8
View File
@@ -45,8 +45,6 @@ public:
return snapped_; return snapped_;
} }
const rational &GetTime() const { return playhead_; }
TimeBasedWidget *GetSnapService() const { return snap_service_; } TimeBasedWidget *GetSnapService() const { return snap_service_; }
void SetSnapService(TimeBasedWidget* service) { snap_service_ = service; } void SetSnapService(TimeBasedWidget* service) { snap_service_ = service; }
@@ -62,9 +60,11 @@ public:
virtual void SelectionManagerSelectEvent(void *obj){} virtual void SelectionManagerSelectEvent(void *obj){}
virtual void SelectionManagerDeselectEvent(void *obj){} virtual void SelectionManagerDeselectEvent(void *obj){}
public slots: ViewerOutput *GetViewerNode() const { return viewer_; }
void SetTime(const rational &time);
void SetViewerNode(ViewerOutput *v);
public slots:
void SetEndTime(const rational& length); void SetEndTime(const rational& length);
/** /**
@@ -73,8 +73,6 @@ public slots:
void UpdateSceneRect(); void UpdateSceneRect();
signals: signals:
void TimeChanged(const rational& time);
void ScaleChanged(double scale); void ScaleChanged(double scale);
protected: protected:
@@ -109,8 +107,6 @@ protected:
private: private:
qreal GetPlayheadX(); qreal GetPlayheadX();
rational playhead_;
double playhead_scene_left_; double playhead_scene_left_;
double playhead_scene_right_; double playhead_scene_right_;
@@ -129,6 +125,8 @@ private:
double y_scale_; double y_scale_;
ViewerOutput *viewer_;
}; };
} }
+37 -51
View File
@@ -48,7 +48,7 @@ TimeBasedWidget::TimeBasedWidget(bool ruler_text_visible, bool ruler_cache_statu
connect(scrollbar_, &ResizableScrollBar::ResizeMoved, this, &TimeBasedWidget::ScrollBarResizeMoved); connect(scrollbar_, &ResizableScrollBar::ResizeMoved, this, &TimeBasedWidget::ScrollBarResizeMoved);
ruler_ = new TimeRuler(ruler_text_visible, ruler_cache_status_visible, this); ruler_ = new TimeRuler(ruler_text_visible, ruler_cache_status_visible, this);
ConnectTimelineView(ruler_, true); ConnectTimelineView(ruler_);
ruler()->SetSnapService(this); ruler()->SetSnapService(this);
connect(ruler(), &TimeRuler::DragReleased, this, static_cast<void(TimeBasedWidget::*)()>(&TimeBasedWidget::StopCatchUpScrollTimer)); connect(ruler(), &TimeRuler::DragReleased, this, static_cast<void(TimeBasedWidget::*)()>(&TimeBasedWidget::StopCatchUpScrollTimer));
@@ -66,11 +66,6 @@ void TimeBasedWidget::SetScaleAndCenterOnPlayhead(const double &scale)
QTimer::singleShot(0, this, &TimeBasedWidget::CenterScrollOnPlayhead); QTimer::singleShot(0, this, &TimeBasedWidget::CenterScrollOnPlayhead);
} }
const rational &TimeBasedWidget::GetTime() const
{
return ruler_->GetTime();
}
ViewerOutput *TimeBasedWidget::GetConnectedNode() const ViewerOutput *TimeBasedWidget::GetConnectedNode() const
{ {
return viewer_node_; return viewer_node_;
@@ -94,6 +89,7 @@ void TimeBasedWidget::ConnectViewerNode(ViewerOutput *node)
// Disconnect length changed signal // Disconnect length changed signal
disconnect(old, &ViewerOutput::LengthChanged, this, &TimeBasedWidget::UpdateMaximumScroll); disconnect(old, &ViewerOutput::LengthChanged, this, &TimeBasedWidget::UpdateMaximumScroll);
disconnect(old, &ViewerOutput::RemovedFromGraph, this, &TimeBasedWidget::ConnectedNodeRemovedFromGraph); disconnect(old, &ViewerOutput::RemovedFromGraph, this, &TimeBasedWidget::ConnectedNodeRemovedFromGraph);
disconnect(old, &ViewerOutput::PlayheadChanged, this, &TimeBasedWidget::PlayheadTimeChanged);
// Disconnect rate change signals if they were connected // Disconnect rate change signals if they were connected
disconnect(old, &ViewerOutput::FrameRateChanged, this, &TimeBasedWidget::AutoUpdateTimebase); disconnect(old, &ViewerOutput::FrameRateChanged, this, &TimeBasedWidget::AutoUpdateTimebase);
@@ -108,12 +104,16 @@ void TimeBasedWidget::ConnectViewerNode(ViewerOutput *node)
} }
// Call derivatives // Call derivatives
for (TimeBasedView *view : timeline_views_) {
view->SetViewerNode(viewer_node_);
}
ConnectedNodeChangeEvent(viewer_node_); ConnectedNodeChangeEvent(viewer_node_);
if (viewer_node_) { if (viewer_node_) {
// Connect length changed signal // Connect length changed signal
connect(viewer_node_, &ViewerOutput::LengthChanged, this, &TimeBasedWidget::UpdateMaximumScroll); connect(viewer_node_, &ViewerOutput::LengthChanged, this, &TimeBasedWidget::UpdateMaximumScroll);
connect(viewer_node_, &ViewerOutput::RemovedFromGraph, this, &TimeBasedWidget::ConnectedNodeRemovedFromGraph); connect(viewer_node_, &ViewerOutput::RemovedFromGraph, this, &TimeBasedWidget::ConnectedNodeRemovedFromGraph);
connect(viewer_node_, &ViewerOutput::PlayheadChanged, this, &TimeBasedWidget::PlayheadTimeChanged);
// Connect ruler and scrollbar to timeline points // Connect ruler and scrollbar to timeline points
ConnectWorkArea(viewer_node_->GetWorkArea()); ConnectWorkArea(viewer_node_->GetWorkArea());
@@ -207,12 +207,16 @@ void TimeBasedWidget::ScrollBarResizeMoved(int movement)
void TimeBasedWidget::PageScrollToPlayhead() void TimeBasedWidget::PageScrollToPlayhead()
{ {
PageScrollInternal(qRound(TimeToScene(GetTime())), true); if (GetConnectedNode()) {
PageScrollInternal(qRound(TimeToScene(GetConnectedNode()->GetPlayhead())), true);
}
} }
void TimeBasedWidget::CatchUpScrollToPlayhead() void TimeBasedWidget::CatchUpScrollToPlayhead()
{ {
CatchUpScrollToPoint(qRound(TimeToScene(GetTime()))); if (GetConnectedNode()) {
CatchUpScrollToPoint(qRound(TimeToScene(GetConnectedNode()->GetPlayhead())));
}
} }
void TimeBasedWidget::CatchUpScrollToPoint(int point) void TimeBasedWidget::CatchUpScrollToPoint(int point)
@@ -298,12 +302,8 @@ void TimeBasedWidget::resizeEvent(QResizeEvent *event)
UpdateMaximumScroll(); UpdateMaximumScroll();
} }
void TimeBasedWidget::ConnectTimelineView(TimeBasedView *base, bool connect_time_change_event) void TimeBasedWidget::ConnectTimelineView(TimeBasedView *base)
{ {
if (connect_time_change_event) {
connect(base, &TimeBasedView::TimeChanged, this, &TimeBasedWidget::SetTimeAndSignal);
}
// Connect scale // Connect scale
connect(base, &TimeBasedView::ScaleChanged, this, &TimeBasedWidget::SetScale); connect(base, &TimeBasedView::ScaleChanged, this, &TimeBasedWidget::SetScale);
@@ -350,7 +350,7 @@ void TimeBasedWidget::StopCatchUpScrollTimer(QScrollBar *b)
} }
} }
void TimeBasedWidget::SetTime(const rational &time) void TimeBasedWidget::PlayheadTimeChanged(const rational &time)
{ {
if (UserIsDraggingPlayhead()) { if (UserIsDraggingPlayhead()) {
// If the user is dragging the playhead, we will simply nudge over and not use autoscroll rules. // If the user is dragging the playhead, we will simply nudge over and not use autoscroll rules.
@@ -370,8 +370,6 @@ void TimeBasedWidget::SetTime(const rational &time)
} }
} }
ruler_->SetTime(time);
TimeChangedEvent(time); TimeChangedEvent(time);
} }
@@ -405,7 +403,7 @@ void TimeBasedWidget::GoToPrevCut()
return; return;
} }
if (GetTime().isNull()) { if (GetConnectedNode()->GetPlayhead().isNull()) {
return; return;
} }
@@ -415,7 +413,7 @@ void TimeBasedWidget::GoToPrevCut()
rational this_track_closest_cut = 0; rational this_track_closest_cut = 0;
for (Block* block : track->Blocks()) { for (Block* block : track->Blocks()) {
if (block->out() < GetTime()) { if (block->out() < GetConnectedNode()->GetPlayhead()) {
this_track_closest_cut = block->out(); this_track_closest_cut = block->out();
} else { } else {
break; break;
@@ -425,7 +423,7 @@ void TimeBasedWidget::GoToPrevCut()
closest_cut = qMax(closest_cut, this_track_closest_cut); closest_cut = qMax(closest_cut, this_track_closest_cut);
} }
SetTimeAndSignal(closest_cut); GetConnectedNode()->SetPlayhead(closest_cut);
} }
void TimeBasedWidget::GoToNextCut() void TimeBasedWidget::GoToNextCut()
@@ -442,12 +440,12 @@ void TimeBasedWidget::GoToNextCut()
for (Track* track : sequence->GetTracks()) { for (Track* track : sequence->GetTracks()) {
rational this_track_closest_cut = track->track_length(); rational this_track_closest_cut = track->track_length();
if (this_track_closest_cut <= GetTime()) { if (this_track_closest_cut <= GetConnectedNode()->GetPlayhead()) {
this_track_closest_cut = RATIONAL_MAX; this_track_closest_cut = RATIONAL_MAX;
} }
for (Block* block : track->Blocks()) { for (Block* block : track->Blocks()) {
if (block->in() > GetTime()) { if (block->in() > GetConnectedNode()->GetPlayhead()) {
this_track_closest_cut = block->in(); this_track_closest_cut = block->in();
break; break;
} }
@@ -457,57 +455,51 @@ void TimeBasedWidget::GoToNextCut()
} }
if (closest_cut < RATIONAL_MAX) { if (closest_cut < RATIONAL_MAX) {
SetTimeAndSignal(closest_cut); GetConnectedNode()->SetPlayhead(closest_cut);
} }
} }
void TimeBasedWidget::GoToStart() void TimeBasedWidget::GoToStart()
{ {
if (viewer_node_) { if (viewer_node_) {
SetTimeAndSignal(0); viewer_node_->SetPlayhead(0);
} }
} }
void TimeBasedWidget::PrevFrame() void TimeBasedWidget::PrevFrame()
{ {
if (viewer_node_) { if (viewer_node_) {
rational proposed_time = Timecode::snap_time_to_timebase(GetTime() - timebase(), timebase(), Timecode::kCeil); rational proposed_time = Timecode::snap_time_to_timebase(GetConnectedNode()->GetPlayhead() - timebase(), timebase(), Timecode::kCeil);
if (proposed_time == GetTime()) { if (proposed_time == GetConnectedNode()->GetPlayhead()) {
// Catch rounding error, assume this time is snapped and just subtract a timebase // Catch rounding error, assume this time is snapped and just subtract a timebase
proposed_time -= timebase(); proposed_time -= timebase();
} }
SetTimeAndSignal(qMax(rational(0), proposed_time)); viewer_node_->SetPlayhead(qMax(rational(0), proposed_time));
} }
} }
void TimeBasedWidget::NextFrame() void TimeBasedWidget::NextFrame()
{ {
if (viewer_node_) { if (viewer_node_) {
rational proposed_time = Timecode::snap_time_to_timebase(GetTime() + timebase(), timebase(), Timecode::kFloor); rational proposed_time = Timecode::snap_time_to_timebase(GetConnectedNode()->GetPlayhead() + timebase(), timebase(), Timecode::kFloor);
if (proposed_time == GetTime()) { if (proposed_time == GetConnectedNode()->GetPlayhead()) {
// Catch rounding error, assume this time is snapped and just add a timebase // Catch rounding error, assume this time is snapped and just add a timebase
proposed_time += timebase(); proposed_time += timebase();
} }
SetTimeAndSignal(proposed_time); viewer_node_->SetPlayhead(proposed_time);
} }
} }
void TimeBasedWidget::GoToEnd() void TimeBasedWidget::GoToEnd()
{ {
if (viewer_node_) { if (viewer_node_) {
SetTimeAndSignal(viewer_node_->GetLength()); viewer_node_->SetPlayhead(viewer_node_->GetLength());
} }
} }
void TimeBasedWidget::SetTimeAndSignal(const rational &t)
{
SetTime(t);
emit TimeChanged(t);
}
void TimeBasedWidget::CenterScrollOnPlayhead() void TimeBasedWidget::CenterScrollOnPlayhead()
{ {
scrollbar_->setValue(qRound(TimeToScene(ruler_->GetTime())) - scrollbar_->width()/2); scrollbar_->setValue(qRound(TimeToScene(GetConnectedNode()->GetPlayhead())) - scrollbar_->width()/2);
} }
void TimeBasedWidget::SetAutoSetTimebase(bool e) void TimeBasedWidget::SetAutoSetTimebase(bool e)
@@ -608,10 +600,6 @@ void TimeBasedWidget::PageScrollInternal(int screen_position, bool whole_page_sc
bool TimeBasedWidget::UserIsDraggingPlayhead() const bool TimeBasedWidget::UserIsDraggingPlayhead() const
{ {
if (ruler_->IsDraggingPlayhead()) {
return true;
}
foreach (TimeBasedView* view, timeline_views_) { foreach (TimeBasedView* view, timeline_views_) {
if (view->IsDraggingPlayhead()) { if (view->IsDraggingPlayhead()) {
return true; return true;
@@ -623,12 +611,12 @@ bool TimeBasedWidget::UserIsDraggingPlayhead() const
void TimeBasedWidget::SetInAtPlayhead() void TimeBasedWidget::SetInAtPlayhead()
{ {
SetPoint(Timeline::kTrimIn, GetTime()); SetPoint(Timeline::kTrimIn, GetConnectedNode()->GetPlayhead());
} }
void TimeBasedWidget::SetOutAtPlayhead() void TimeBasedWidget::SetOutAtPlayhead()
{ {
SetPoint(Timeline::kTrimOut, GetTime()); SetPoint(Timeline::kTrimOut, GetConnectedNode()->GetPlayhead());
} }
void TimeBasedWidget::ResetIn() void TimeBasedWidget::ResetIn()
@@ -658,14 +646,14 @@ void TimeBasedWidget::SetMarker()
TimelineMarkerList *markers = GetConnectedNode()->GetMarkers(); TimelineMarkerList *markers = GetConnectedNode()->GetMarkers();
if (TimelineMarker *existing = markers->GetMarkerAtTime(GetTime())) { if (TimelineMarker *existing = markers->GetMarkerAtTime(GetConnectedNode()->GetPlayhead())) {
// We already have a marker here, so pop open the edit dialog // We already have a marker here, so pop open the edit dialog
MarkerPropertiesDialog mpd({existing}, timebase(), this); MarkerPropertiesDialog mpd({existing}, timebase(), this);
mpd.exec(); mpd.exec();
} else { } else {
// Create a new marker and place it here // Create a new marker and place it here
int color; int color;
if (TimelineMarker *closest = markers->GetClosestMarkerToTime(GetTime())) { if (TimelineMarker *closest = markers->GetClosestMarkerToTime(GetConnectedNode()->GetPlayhead())) {
// Copy color of closest marker to this time // Copy color of closest marker to this time
color = closest->color(); color = closest->color();
} else { } else {
@@ -673,7 +661,7 @@ void TimeBasedWidget::SetMarker()
color = OLIVE_CONFIG("MarkerColor").toInt(); color = OLIVE_CONFIG("MarkerColor").toInt();
} }
TimelineMarker *marker = new TimelineMarker(color, TimeRange(GetTime(), GetTime())); TimelineMarker *marker = new TimelineMarker(color, TimeRange(GetConnectedNode()->GetPlayhead(), GetConnectedNode()->GetPlayhead()));
if (OLIVE_CONFIG("SetNameWithMarker").toBool()) { if (OLIVE_CONFIG("SetNameWithMarker").toBool()) {
MarkerPropertiesDialog mpd({marker}, timebase(), this); MarkerPropertiesDialog mpd({marker}, timebase(), this);
@@ -709,8 +697,6 @@ void TimeBasedWidget::ToggleShowAll()
w = timeline_views_.first()->width(); w = timeline_views_.first()->width();
} }
toggle_show_all_old_scale_ = GetScale(); toggle_show_all_old_scale_ = GetScale();
toggle_show_all_old_scroll_ = scrollbar_->value(); toggle_show_all_old_scroll_ = scrollbar_->value();
@@ -726,7 +712,7 @@ void TimeBasedWidget::GoToIn()
{ {
if (GetConnectedNode()) { if (GetConnectedNode()) {
if (GetConnectedNode()->GetWorkArea()->enabled()) { if (GetConnectedNode()->GetWorkArea()->enabled()) {
SetTimeAndSignal(GetConnectedNode()->GetWorkArea()->in()); GetConnectedNode()->SetPlayhead(GetConnectedNode()->GetWorkArea()->in());
} else { } else {
GoToStart(); GoToStart();
} }
@@ -737,7 +723,7 @@ void TimeBasedWidget::GoToOut()
{ {
if (GetConnectedNode()) { if (GetConnectedNode()) {
if (GetConnectedNode()->GetWorkArea()->enabled()) { if (GetConnectedNode()->GetWorkArea()->enabled()) {
SetTimeAndSignal(GetConnectedNode()->GetWorkArea()->out()); GetConnectedNode()->SetPlayhead(GetConnectedNode()->GetWorkArea()->out());
} else { } else {
GoToEnd(); GoToEnd();
} }
@@ -783,7 +769,7 @@ bool TimeBasedWidget::SnapPoint(const std::vector<rational> &start_times, ration
std::vector<SnapData> potential_snaps; std::vector<SnapData> potential_snaps;
if (snap_points & kSnapToPlayhead) { if (snap_points & kSnapToPlayhead) {
rational playhead_abs_time = GetTime(); rational playhead_abs_time = GetConnectedNode()->GetPlayhead();
qreal playhead_pos = TimeToScene(playhead_abs_time); qreal playhead_pos = TimeToScene(playhead_abs_time);
AttemptSnap(potential_snaps, screen_pt, playhead_pos, start_times, playhead_abs_time); AttemptSnap(potential_snaps, screen_pt, playhead_pos, start_times, playhead_abs_time);
} }
+3 -9
View File
@@ -41,8 +41,6 @@ class TimeBasedWidget : public TimelineScaledWidget
public: public:
TimeBasedWidget(bool ruler_text_visible = true, bool ruler_cache_status_visible = false, QWidget* parent = nullptr); TimeBasedWidget(bool ruler_text_visible = true, bool ruler_cache_status_visible = false, QWidget* parent = nullptr);
const rational &GetTime() const;
void ZoomIn(); void ZoomIn();
void ZoomOut(); void ZoomOut();
@@ -82,8 +80,6 @@ public:
virtual bool Paste(); virtual bool Paste();
public slots: public slots:
void SetTime(const rational &time);
void SetTimebase(const rational& timebase); void SetTimebase(const rational& timebase);
void SetScale(const double& scale); void SetScale(const double& scale);
@@ -142,7 +138,7 @@ protected:
virtual void resizeEvent(QResizeEvent *event) override; virtual void resizeEvent(QResizeEvent *event) override;
void ConnectTimelineView(TimeBasedView* base, bool connect_time_change_event = true); void ConnectTimelineView(TimeBasedView* base);
void SetCatchUpScrollValue(QScrollBar *b, int v, int maximum); void SetCatchUpScrollValue(QScrollBar *b, int v, int maximum);
void SetCatchUpScrollValue(int v); void SetCatchUpScrollValue(int v);
@@ -168,16 +164,12 @@ protected slots:
static void PageScrollInternal(QScrollBar* bar, int maximum, int screen_position, bool whole_page_scroll); static void PageScrollInternal(QScrollBar* bar, int maximum, int screen_position, bool whole_page_scroll);
void SetTimeAndSignal(const olive::rational& t);
void StopCatchUpScrollTimer() void StopCatchUpScrollTimer()
{ {
StopCatchUpScrollTimer(scrollbar_); StopCatchUpScrollTimer(scrollbar_);
} }
signals: signals:
void TimeChanged(const rational&);
void TimebaseChanged(const rational&); void TimebaseChanged(const rational&);
void ConnectedNodeChanged(ViewerOutput* old, ViewerOutput* now); void ConnectedNodeChanged(ViewerOutput* old, ViewerOutput* now);
@@ -265,6 +257,8 @@ private slots:
void ConnectedNodeRemovedFromGraph(); void ConnectedNodeRemovedFromGraph();
void PlayheadTimeChanged(const rational &time);
}; };
} }
+56 -29
View File
@@ -83,7 +83,6 @@ TimelineWidget::TimelineWidget(QWidget *parent) :
timecode_label_->SetDisplayType(RationalSlider::kTime); timecode_label_->SetDisplayType(RationalSlider::kTime);
timecode_label_->setVisible(false); timecode_label_->setVisible(false);
timecode_label_->SetMinimum(0); timecode_label_->SetMinimum(0);
connect(timecode_label_, &RationalSlider::ValueChanged, this, &TimelineWidget::SetTimeAndSignal);
ruler_and_time_layout->addWidget(timecode_label_); ruler_and_time_layout->addWidget(timecode_label_);
ruler_and_time_layout->addWidget(ruler()); ruler_and_time_layout->addWidget(ruler());
@@ -143,9 +142,8 @@ TimelineWidget::TimelineWidget(QWidget *parent) :
view_splitter_->addWidget(tview); view_splitter_->addWidget(tview);
ConnectTimelineView(view, false); ConnectTimelineView(view);
connect(view, &TimelineView::TimeChanged, this, &TimelineWidget::SetTimeAndSignal);
connect(view, &TimelineView::customContextMenuRequested, this, &TimelineWidget::ShowContextMenu); connect(view, &TimelineView::customContextMenuRequested, this, &TimelineWidget::ShowContextMenu);
connect(view, &TimelineView::MousePressed, this, &TimelineWidget::ViewMousePressed); connect(view, &TimelineView::MousePressed, this, &TimelineWidget::ViewMousePressed);
@@ -186,6 +184,17 @@ TimelineWidget::TimelineWidget(QWidget *parent) :
signal_block_change_timer_->setSingleShot(true); signal_block_change_timer_->setSingleShot(true);
connect(signal_block_change_timer_, &QTimer::timeout, this, [this]{ connect(signal_block_change_timer_, &QTimer::timeout, this, [this]{
signal_block_change_timer_->stop(); signal_block_change_timer_->stop();
if (OLIVE_CONFIG("SelectAlsoSeeks").toBool()) {
rational start = RATIONAL_MAX;
for (Block *b : selected_blocks_) {
start = std::min(start, b->in());
}
if (start != RATIONAL_MAX) {
GetConnectedNode()->SetPlayhead(start);
}
}
emit BlockSelectionChanged(selected_blocks_); emit BlockSelectionChanged(selected_blocks_);
}); });
} }
@@ -230,13 +239,34 @@ void TimelineWidget::resizeEvent(QResizeEvent *event)
UpdateTimecodeWidthFromSplitters(views_.first()->splitter()); UpdateTimecodeWidthFromSplitters(views_.first()->splitter());
} }
void TimelineWidget::TimeChangedEvent(const rational &time) void TimelineWidget::TimeChangedEvent(const rational &t)
{ {
super::TimeChangedEvent(time); if (OLIVE_CONFIG("SeekAlsoSelects").toBool()) {
TimelineWidgetSelections sels;
SetViewTime(time); QVector<Block*> new_blocks;
timecode_label_->SetValue(time); for (auto it=sequence()->GetTracks().cbegin(); it!=sequence()->GetTracks().cend(); it++) {
Track *track = *it;
if (track->IsLocked()) {
continue;
}
Block *b = track->VisibleBlockAtTime(sequence()->GetPlayhead());
if (!b || dynamic_cast<GapBlock*>(b)) {
continue;
}
new_blocks.push_back(b);
sels[track->ToReference()].insert(b->range());
}
if (selected_blocks_ != new_blocks) {
selected_blocks_ = new_blocks;
SetSelections(sels, false);
SignalBlockSelectionChange();
}
}
} }
void TimelineWidget::ScaleChangedEvent(const double &scale) void TimelineWidget::ScaleChangedEvent(const double &scale)
@@ -257,6 +287,9 @@ void TimelineWidget::ConnectNodeEvent(ViewerOutput *n)
connect(s, &Sequence::FrameRateChanged, this, &TimelineWidget::FrameRateChanged); connect(s, &Sequence::FrameRateChanged, this, &TimelineWidget::FrameRateChanged);
connect(s, &Sequence::SampleRateChanged, this, &TimelineWidget::SampleRateChanged); connect(s, &Sequence::SampleRateChanged, this, &TimelineWidget::SampleRateChanged);
connect(timecode_label_, &RationalSlider::ValueChanged, s, &Sequence::SetPlayhead);
connect(s, &Sequence::PlayheadChanged, timecode_label_, &RationalSlider::SetValue);
ruler()->SetPlaybackCache(n->video_frame_cache()); ruler()->SetPlaybackCache(n->video_frame_cache());
SetTimebase(n->GetVideoParams().frame_rate_as_time_base()); SetTimebase(n->GetVideoParams().frame_rate_as_time_base());
@@ -287,6 +320,8 @@ void TimelineWidget::DisconnectNodeEvent(ViewerOutput *n)
disconnect(s, &Sequence::FrameRateChanged, this, &TimelineWidget::FrameRateChanged); disconnect(s, &Sequence::FrameRateChanged, this, &TimelineWidget::FrameRateChanged);
disconnect(s, &Sequence::SampleRateChanged, this, &TimelineWidget::SampleRateChanged); disconnect(s, &Sequence::SampleRateChanged, this, &TimelineWidget::SampleRateChanged);
disconnect(timecode_label_, &RationalSlider::ValueChanged, s, &Sequence::SetPlayhead);
DeselectAll(); DeselectAll();
foreach (Track* track, s->GetTracks()) { foreach (Track* track, s->GetTracks()) {
@@ -357,7 +392,7 @@ void TimelineWidget::SplitAtPlayhead()
return; return;
} }
const rational &playhead_time = GetTime(); const rational &playhead_time = GetConnectedNode()->GetPlayhead();
QVector<Block*> selected_blocks = GetSelectedBlocks(); QVector<Block*> selected_blocks = GetSelectedBlocks();
@@ -504,7 +539,7 @@ void TimelineWidget::DeleteSelected(bool ripple)
ClearGhosts(); ClearGhosts();
if (ripple_command && ripple_command->HasCommands() && new_playhead != RATIONAL_MAX) { if (ripple_command && ripple_command->HasCommands() && new_playhead != RATIONAL_MAX) {
SetTimeAndSignal(new_playhead); GetConnectedNode()->SetPlayhead(new_playhead);
} }
} }
@@ -535,14 +570,14 @@ void TimelineWidget::DecreaseTrackHeight()
void TimelineWidget::InsertFootageAtPlayhead(const QVector<ViewerOutput*>& footage) void TimelineWidget::InsertFootageAtPlayhead(const QVector<ViewerOutput*>& footage)
{ {
auto command = new MultiUndoCommand(); auto command = new MultiUndoCommand();
import_tool_->PlaceAt(footage, GetTime(), true, command); import_tool_->PlaceAt(footage, GetConnectedNode()->GetPlayhead(), true, command);
Core::instance()->undo_stack()->push(command); Core::instance()->undo_stack()->push(command);
} }
void TimelineWidget::OverwriteFootageAtPlayhead(const QVector<ViewerOutput *> &footage) void TimelineWidget::OverwriteFootageAtPlayhead(const QVector<ViewerOutput *> &footage)
{ {
auto command = new MultiUndoCommand(); auto command = new MultiUndoCommand();
import_tool_->PlaceAt(footage, GetTime(), false, command); import_tool_->PlaceAt(footage, GetConnectedNode()->GetPlayhead(), false, command);
Core::instance()->undo_stack()->push(command); Core::instance()->undo_stack()->push(command);
} }
@@ -705,7 +740,7 @@ void TimelineWidget::DeleteInToOut(bool ripple)
false)); false));
if (ripple) { if (ripple) {
SetTimeAndSignal(GetConnectedNode()->GetWorkArea()->in()); GetConnectedNode()->SetPlayhead(GetConnectedNode()->GetWorkArea()->in());
} }
Core::instance()->undo_stack()->push(command); Core::instance()->undo_stack()->push(command);
@@ -1316,14 +1351,6 @@ void TimelineWidget::SetUseAudioTimeUnits(bool use)
UpdateViewTimebases(); UpdateViewTimebases();
} }
void TimelineWidget::SetViewTime(const rational &time)
{
for (int i=0;i<views_.size();i++) {
TimelineAndTrackView* view = views_.at(i);
view->view()->SetTime(time);
}
}
void TimelineWidget::ToolChanged() void TimelineWidget::ToolChanged()
{ {
HideSnaps(); HideSnaps();
@@ -1609,7 +1636,7 @@ void TimelineWidget::MoveToPlayheadInternal(bool out)
} }
foreach (Block *b, selected_blocks_) { foreach (Block *b, selected_blocks_) {
rational shift_amt = GetTime() - earliest_pts.value(b->track()); rational shift_amt = GetConnectedNode()->GetPlayhead() - earliest_pts.value(b->track());
rational new_in = b->in() + shift_amt; rational new_in = b->in() + shift_amt;
bool can_shift = true; bool can_shift = true;
@@ -1632,7 +1659,7 @@ void TimelineWidget::MoveToPlayheadInternal(bool out)
// Shift selections // Shift selections
TimelineWidgetSelections new_sel = GetSelections(); TimelineWidgetSelections new_sel = GetSelections();
for (auto it=new_sel.begin(); it!=new_sel.end(); it++) { for (auto it=new_sel.begin(); it!=new_sel.end(); it++) {
rational track_adj = GetTime() - earliest_pts.value(GetTrackFromReference(it.key()), GetTime()); rational track_adj = GetConnectedNode()->GetPlayhead() - earliest_pts.value(GetTrackFromReference(it.key()), GetConnectedNode()->GetPlayhead());
if (!track_adj.isNull()) { if (!track_adj.isNull()) {
it.value().shift(track_adj); it.value().shift(track_adj);
} }
@@ -1785,7 +1812,7 @@ void TimelineWidget::RippleTo(Timeline::MovementMode mode)
return; return;
} }
rational playhead_time = GetTime(); rational playhead_time = GetConnectedNode()->GetPlayhead();
QVector<Timeline::EditToInfo> tracks = GetEditToInfo(playhead_time, mode); QVector<Timeline::EditToInfo> tracks = GetEditToInfo(playhead_time, mode);
@@ -1833,15 +1860,15 @@ void TimelineWidget::RippleTo(Timeline::MovementMode mode)
// If we rippled, ump to where new cut is if applicable // If we rippled, ump to where new cut is if applicable
if (mode == Timeline::kTrimIn) { if (mode == Timeline::kTrimIn) {
SetTimeAndSignal(closest_point_to_playhead); GetConnectedNode()->SetPlayhead(closest_point_to_playhead);
} else if (mode == Timeline::kTrimOut && closest_point_to_playhead == GetTime()) { } else if (mode == Timeline::kTrimOut && closest_point_to_playhead == GetConnectedNode()->GetPlayhead()) {
SetTimeAndSignal(playhead_time); GetConnectedNode()->SetPlayhead(playhead_time);
} }
} }
void TimelineWidget::EditTo(Timeline::MovementMode mode) void TimelineWidget::EditTo(Timeline::MovementMode mode)
{ {
const rational playhead_time = GetTime(); const rational playhead_time = GetConnectedNode()->GetPlayhead();
// Get list of unlocked tracks // Get list of unlocked tracks
QVector<Timeline::EditToInfo> tracks = GetEditToInfo(playhead_time, mode); QVector<Timeline::EditToInfo> tracks = GetEditToInfo(playhead_time, mode);
@@ -1943,10 +1970,10 @@ bool TimelineWidget::PasteInternal(bool insert)
command->add_child(new NodeAddCommand(GetConnectedNode()->project(), n)); command->add_child(new NodeAddCommand(GetConnectedNode()->project(), n));
} }
rational paste_start = GetTime(); rational paste_start = GetConnectedNode()->GetPlayhead();
if (insert) { if (insert) {
rational paste_end = GetTime(); rational paste_end = paste_start;
for (auto it=res.GetLoadData().properties.cbegin(); it!=res.GetLoadData().properties.cend(); it++) { for (auto it=res.GetLoadData().properties.cbegin(); it!=res.GetLoadData().properties.cend(); it++) {
rational length = static_cast<Block*>(it.key())->length(); rational length = static_cast<Block*>(it.key())->length();
+1 -3
View File
@@ -290,8 +290,8 @@ signals:
protected: protected:
virtual void resizeEvent(QResizeEvent *event) override; virtual void resizeEvent(QResizeEvent *event) override;
virtual void TimeChangedEvent(const rational &) override;
virtual void TimebaseChangedEvent(const rational &) override; virtual void TimebaseChangedEvent(const rational &) override;
virtual void TimeChangedEvent(const rational &time) override;
virtual void ScaleChangedEvent(const double &) override; virtual void ScaleChangedEvent(const double &) override;
virtual void ConnectNodeEvent(ViewerOutput* n) override; virtual void ConnectNodeEvent(ViewerOutput* n) override;
@@ -417,8 +417,6 @@ private slots:
void SetUseAudioTimeUnits(bool use); void SetUseAudioTimeUnits(bool use);
void SetViewTime(const rational &time);
void ToolChanged(); void ToolChanged();
void AddableObjectChanged(); void AddableObjectChanged();
@@ -66,15 +66,8 @@ void TimelineView::mousePressEvent(QMouseEvent *event)
QPointF scene_pos = mapToScene(event->pos()); QPointF scene_pos = mapToScene(event->pos());
for (auto it=clip_marker_rects_.cbegin(); it!=clip_marker_rects_.cend(); it++) { for (auto it=clip_marker_rects_.cbegin(); it!=clip_marker_rects_.cend(); it++) {
if (it.value().contains(scene_pos)) { if (it.value().contains(scene_pos)) {
QObject *p = this->parent(); GetViewerNode()->SetPlayhead(it.key()->time().in());
while (p) { break;
if (TimelineWidget *timeline = dynamic_cast<TimelineWidget *>(p)) {
timeline->SetTime(it.key()->time().in());
break;
}
p = p->parent();
}
} }
} }
@@ -300,7 +293,7 @@ void TimelineView::drawForeground(QPainter *painter, const QRectF &rect)
int x = TimeToScene(recording_coord_.GetFrame()); int x = TimeToScene(recording_coord_.GetFrame());
painter->drawRect(x, GetTrackY(recording_coord_.GetTrack().index()), painter->drawRect(x, GetTrackY(recording_coord_.GetTrack().index()),
TimeToScene(GetTime()) - x, GetTrackHeight(recording_coord_.GetTrack().index())); TimeToScene(GetViewerNode()->GetPlayhead()) - x, GetTrackHeight(recording_coord_.GetTrack().index()));
} }
// Draw standard TimelineViewBase things (such as playhead) // Draw standard TimelineViewBase things (such as playhead)
+3 -5
View File
@@ -151,7 +151,7 @@ bool SeekableWidget::PasteMarkers()
for (auto it=markers.cbegin(); it!=markers.cend(); it++) { for (auto it=markers.cbegin(); it!=markers.cend(); it++) {
min = std::min(min, (*it)->time().in()); min = std::min(min, (*it)->time().in());
} }
min -= GetTime(); min -= GetViewerNode()->GetPlayhead();
for (auto it=markers.cbegin(); it!=markers.cend(); it++) { for (auto it=markers.cbegin(); it!=markers.cend(); it++) {
TimelineMarker *m = *it; TimelineMarker *m = *it;
@@ -391,10 +391,8 @@ void SeekableWidget::SeekToScenePoint(qreal scene)
playhead_time += movement; playhead_time += movement;
} }
if (playhead_time != GetTime()) { if (playhead_time != GetViewerNode()->GetPlayhead()) {
SetTime(playhead_time); GetViewerNode()->SetPlayhead(playhead_time);
emit TimeChanged(playhead_time);
} }
} }
+1 -1
View File
@@ -267,7 +267,7 @@ void TimeRuler::drawForeground(QPainter *p, const QRectF &rect)
} }
// Draw the playhead if it's on screen at the moment // Draw the playhead if it's on screen at the moment
int playhead_pos = TimeToScene(GetTime()); int playhead_pos = TimeToScene(GetViewerNode()->GetPlayhead());
p->setPen(Qt::NoPen); p->setPen(Qt::NoPen);
p->setBrush(PLAYHEAD_COLOR); p->setBrush(PLAYHEAD_COLOR);
DrawPlayhead(p, playhead_pos, line_bottom); DrawPlayhead(p, playhead_pos, line_bottom);
+10 -3
View File
@@ -28,16 +28,23 @@ TimeTargetObject::TimeTargetObject() :
{ {
} }
Node *TimeTargetObject::GetTimeTarget() const ViewerOutput *TimeTargetObject::GetTimeTarget() const
{ {
return time_target_; return time_target_;
} }
void TimeTargetObject::SetTimeTarget(Node *target) void TimeTargetObject::SetTimeTarget(ViewerOutput *target)
{ {
time_target_ = target; if (time_target_) {
TimeTargetDisconnectEvent(time_target_);
}
time_target_ = target;
TimeTargetChangedEvent(time_target_); TimeTargetChangedEvent(time_target_);
if (time_target_) {
TimeTargetConnectEvent(time_target_);
}
} }
void TimeTargetObject::SetPathIndex(int index) void TimeTargetObject::SetPathIndex(int index)
+7 -5
View File
@@ -21,7 +21,7 @@
#ifndef TIMETARGETOBJECT_H #ifndef TIMETARGETOBJECT_H
#define TIMETARGETOBJECT_H #define TIMETARGETOBJECT_H
#include "node/node.h" #include "node/output/viewer/viewer.h"
namespace olive { namespace olive {
@@ -30,8 +30,8 @@ class TimeTargetObject
public: public:
TimeTargetObject(); TimeTargetObject();
Node* GetTimeTarget() const; ViewerOutput* GetTimeTarget() const;
void SetTimeTarget(Node* target); void SetTimeTarget(ViewerOutput* target);
void SetPathIndex(int index); void SetPathIndex(int index);
@@ -41,10 +41,12 @@ public:
//int GetNumberOfPathAdjustments(Node* from, NodeParam::Type direction) const; //int GetNumberOfPathAdjustments(Node* from, NodeParam::Type direction) const;
protected: protected:
virtual void TimeTargetChangedEvent(Node* ){} virtual void TimeTargetDisconnectEvent(ViewerOutput *){}
virtual void TimeTargetChangedEvent(ViewerOutput *){}
virtual void TimeTargetConnectEvent(ViewerOutput *){}
private: private:
Node* time_target_; ViewerOutput* time_target_;
int path_index_; int path_index_;
+1 -1
View File
@@ -96,7 +96,7 @@ void AudioWaveformView::drawForeground(QPainter *p, const QRectF &rect)
// Draw playhead // Draw playhead
p->setPen(PLAYHEAD_COLOR); p->setPen(PLAYHEAD_COLOR);
int playhead_x = TimeToScene(GetTime()); int playhead_x = TimeToScene(GetViewerNode()->GetPlayhead());
p->drawLine(playhead_x, 0, playhead_x, height()); p->drawLine(playhead_x, 0, playhead_x, height());
} }
-19
View File
@@ -56,25 +56,6 @@ void FootageViewerWidget::ResetWorkArea()
} }
} }
void FootageViewerWidget::ConnectNodeEvent(ViewerOutput *n)
{
super::ConnectNodeEvent(n);
IgnoreNextScrubEvent();
SetTime(cached_timestamps_.value(n, 0));
}
void FootageViewerWidget::DisconnectNodeEvent(ViewerOutput *n)
{
// Cache timestamp in case this footage is opened again later
cached_timestamps_.insert(n, GetTime());
super::DisconnectNodeEvent(n);
IgnoreNextScrubEvent();
SetTime(0);
}
void FootageViewerWidget::StartFootageDragInternal(bool enable_video, bool enable_audio) void FootageViewerWidget::StartFootageDragInternal(bool enable_video, bool enable_audio)
{ {
if (!GetConnectedNode()) { if (!GetConnectedNode()) {
-7
View File
@@ -35,16 +35,9 @@ public:
void OverrideWorkArea(const TimeRange &r); void OverrideWorkArea(const TimeRange &r);
void ResetWorkArea(); void ResetWorkArea();
protected:
virtual void ConnectNodeEvent(ViewerOutput *) override;
virtual void DisconnectNodeEvent(ViewerOutput *) override;
private: private:
void StartFootageDragInternal(bool enable_video, bool enable_audio); void StartFootageDragInternal(bool enable_video, bool enable_audio);
QHash<ViewerOutput*, rational> cached_timestamps_;
TimelineWorkArea *override_workarea_; TimelineWorkArea *override_workarea_;
private slots: private slots:
+24 -22
View File
@@ -113,7 +113,7 @@ ViewerWidget::ViewerWidget(ViewerDisplayWidget *display, QWidget *parent) :
// Create waveform view when audio is connected and video isn't // Create waveform view when audio is connected and video isn't
waveform_view_ = new AudioWaveformView(); waveform_view_ = new AudioWaveformView();
ConnectTimelineView(waveform_view_, true); ConnectTimelineView(waveform_view_);
layout->addWidget(waveform_view_); layout->addWidget(waveform_view_);
// Create time ruler // Create time ruler
@@ -132,7 +132,6 @@ ViewerWidget::ViewerWidget(ViewerDisplayWidget *display, QWidget *parent) :
connect(controls_, &PlaybackControls::NextFrameClicked, this, &ViewerWidget::NextFrame); connect(controls_, &PlaybackControls::NextFrameClicked, this, &ViewerWidget::NextFrame);
connect(controls_, &PlaybackControls::BeginClicked, this, &ViewerWidget::GoToStart); connect(controls_, &PlaybackControls::BeginClicked, this, &ViewerWidget::GoToStart);
connect(controls_, &PlaybackControls::EndClicked, this, &ViewerWidget::GoToEnd); connect(controls_, &PlaybackControls::EndClicked, this, &ViewerWidget::GoToEnd);
connect(controls_, &PlaybackControls::TimeChanged, this, &ViewerWidget::SetTimeAndSignal);
layout->addWidget(controls_); layout->addWidget(controls_);
// FIXME: Magic number // FIXME: Magic number
@@ -182,7 +181,6 @@ void ViewerWidget::TimeChangedEvent(const rational &time)
} }
controls_->SetTime(time); controls_->SetTime(time);
waveform_view_->SetTime(time);
if (GetConnectedNode() && last_time_ != time) { if (GetConnectedNode() && last_time_ != time) {
if (!IsPlaying()) { if (!IsPlaying()) {
@@ -216,6 +214,8 @@ void ViewerWidget::ConnectNodeEvent(ViewerOutput *n)
connect(n->video_frame_cache(), &FrameHashCache::Invalidated, this, &ViewerWidget::ViewerInvalidatedVideoRange); connect(n->video_frame_cache(), &FrameHashCache::Invalidated, this, &ViewerWidget::ViewerInvalidatedVideoRange);
connect(n, &ViewerOutput::TextureInputChanged, this, &ViewerWidget::UpdateWaveformViewFromMode); connect(n, &ViewerOutput::TextureInputChanged, this, &ViewerWidget::UpdateWaveformViewFromMode);
connect(controls_, &PlaybackControls::TimeChanged, n, &ViewerOutput::SetPlayhead);
VideoParams vp = n->GetVideoParams(); VideoParams vp = n->GetVideoParams();
InterlacingChangedSlot(vp.interlacing()); InterlacingChangedSlot(vp.interlacing());
@@ -260,6 +260,8 @@ void ViewerWidget::DisconnectNodeEvent(ViewerOutput *n)
disconnect(n->video_frame_cache(), &FrameHashCache::Invalidated, this, &ViewerWidget::ViewerInvalidatedVideoRange); disconnect(n->video_frame_cache(), &FrameHashCache::Invalidated, this, &ViewerWidget::ViewerInvalidatedVideoRange);
disconnect(n, &ViewerOutput::TextureInputChanged, this, &ViewerWidget::UpdateWaveformViewFromMode); disconnect(n, &ViewerOutput::TextureInputChanged, this, &ViewerWidget::UpdateWaveformViewFromMode);
disconnect(controls_, &PlaybackControls::TimeChanged, n, &ViewerOutput::SetPlayhead);
timeline_selected_blocks_.clear(); timeline_selected_blocks_.clear();
node_view_selected_.clear(); node_view_selected_.clear();
if (multicam_panel_) { if (multicam_panel_) {
@@ -417,7 +419,7 @@ void ViewerWidget::SetGizmos(Node *node)
void ViewerWidget::StartCapture(TimelineWidget *source, const TimeRange &time, const Track::Reference &track) void ViewerWidget::StartCapture(TimelineWidget *source, const TimeRange &time, const Track::Reference &track)
{ {
SetTimeAndSignal(time.in()); GetConnectedNode()->SetPlayhead(time.in());
ArmForRecording(); ArmForRecording();
recording_callback_ = source; recording_callback_ = source;
@@ -480,7 +482,7 @@ void ViewerWidget::SetEmptyImage()
void ViewerWidget::UpdateAutoCacher() void ViewerWidget::UpdateAutoCacher()
{ {
auto_cacher_->SetPlayhead(GetTime()); auto_cacher_->SetPlayhead(GetConnectedNode()->GetPlayhead());
} }
void ViewerWidget::DecrementPrequeuedAudio() void ViewerWidget::DecrementPrequeuedAudio()
@@ -523,7 +525,7 @@ void ViewerWidget::CreateAddableAt(const QRectF &f)
Track::Type type = Track::kVideo; Track::Type type = Track::kVideo;
int track_index = -1; int track_index = -1;
TrackList *list = s->track_list(type); TrackList *list = s->track_list(type);
const rational &in = GetTime(); const rational &in = GetConnectedNode()->GetPlayhead();
rational length = OLIVE_CONFIG("DefaultStillLength").value<rational>(); rational length = OLIVE_CONFIG("DefaultStillLength").value<rational>();
rational out = in + length; rational out = in + length;
@@ -597,7 +599,7 @@ void ViewerWidget::RequestNextDryRun()
if (IsPlaying()) { if (IsPlaying()) {
rational next_time = Timecode::timestamp_to_time(dry_run_next_frame_, timebase()); rational next_time = Timecode::timestamp_to_time(dry_run_next_frame_, timebase());
if (FrameExistsAtTime(next_time)) { if (FrameExistsAtTime(next_time)) {
if (next_time > GetTime() + RenderManager::kDryRunInterval) { if (next_time > GetConnectedNode()->GetPlayhead() + RenderManager::kDryRunInterval) {
QTimer::singleShot(timebase().toDouble() / playback_speed_, this, &ViewerWidget::RequestNextDryRun); QTimer::singleShot(timebase().toDouble() / playback_speed_, this, &ViewerWidget::RequestNextDryRun);
} else { } else {
RenderTicketWatcher *watcher = new RenderTicketWatcher(this); RenderTicketWatcher *watcher = new RenderTicketWatcher(this);
@@ -612,12 +614,12 @@ void ViewerWidget::RequestNextDryRun()
void ViewerWidget::SaveFrameAsImage() void ViewerWidget::SaveFrameAsImage()
{ {
Core::instance()->OpenExportDialogForViewer(GetConnectedNode(), GetTime(), true); Core::instance()->OpenExportDialogForViewer(GetConnectedNode(), true);
} }
void ViewerWidget::DetectMulticamNodeNow() void ViewerWidget::DetectMulticamNodeNow()
{ {
DetectMulticamNode(GetTime()); DetectMulticamNode(GetConnectedNode()->GetPlayhead());
} }
void ViewerWidget::CloseAudioProcessor() void ViewerWidget::CloseAudioProcessor()
@@ -828,7 +830,7 @@ void ViewerWidget::QueueStarved()
queue_starved_start_ = now; queue_starved_start_ = now;
} else if (now > queue_starved_start_ + kMaximumWaitTimeMs) { } else if (now > queue_starved_start_ + kMaximumWaitTimeMs) {
if (first_requeue_watcher_) { if (first_requeue_watcher_) {
if (GetTime() + kMaximumWaitTime < first_requeue_watcher_->property("time").value<rational>()) { if (GetConnectedNode()->GetPlayhead() + kMaximumWaitTime < first_requeue_watcher_->property("time").value<rational>()) {
// We still have time // We still have time
return; return;
} }
@@ -874,7 +876,7 @@ void ViewerWidget::UpdateTextureFromNode()
return; return;
} }
rational time = GetTime(); rational time = GetConnectedNode()->GetPlayhead();
bool frame_exists_at_time = FrameExistsAtTime(time); bool frame_exists_at_time = FrameExistsAtTime(time);
bool frame_might_be_still = ViewerMightBeAStill(); bool frame_might_be_still = ViewerMightBeAStill();
@@ -933,11 +935,11 @@ void ViewerWidget::PlayInternal(int speed, bool in_to_out_only)
// If the playhead is beyond the end, restart at 0 // If the playhead is beyond the end, restart at 0
if (!recording_) { if (!recording_) {
rational last_frame = GetConnectedNode()->GetLength() - timebase(); rational last_frame = GetConnectedNode()->GetLength() - timebase();
if (!in_to_out_only && GetTime() >= last_frame) { if (!in_to_out_only && GetConnectedNode()->GetPlayhead() >= last_frame) {
if (speed > 0) { if (speed > 0) {
SetTimeAndSignal(0); GetConnectedNode()->SetPlayhead(0);
} else { } else {
SetTimeAndSignal(last_frame); GetConnectedNode()->SetPlayhead(last_frame);
} }
} }
} }
@@ -977,7 +979,7 @@ void ViewerWidget::PlayInternal(int speed, bool in_to_out_only)
static const int prequeue_count = 2; static const int prequeue_count = 2;
prequeuing_audio_ = prequeue_count; // Queue two buffers ahead of time prequeuing_audio_ = prequeue_count; // Queue two buffers ahead of time
audio_playback_queue_time_ = GetTime(); audio_playback_queue_time_ = GetConnectedNode()->GetPlayhead();
for (int i=0; i<prequeue_count; i++) { for (int i=0; i<prequeue_count; i++) {
QueueNextAudioBuffer(); QueueNextAudioBuffer();
} }
@@ -1056,7 +1058,7 @@ void ViewerWidget::PushScrubbedAudio()
RenderTicketWatcher *watcher = new RenderTicketWatcher(); RenderTicketWatcher *watcher = new RenderTicketWatcher();
connect(watcher, &RenderTicketWatcher::Finished, this, &ViewerWidget::ReceivedAudioBufferForScrubbing); connect(watcher, &RenderTicketWatcher::Finished, this, &ViewerWidget::ReceivedAudioBufferForScrubbing);
audio_scrub_watchers_.push_back(watcher); audio_scrub_watchers_.push_back(watcher);
watcher->SetTicket(auto_cacher_->GetRangeOfAudio(TimeRange(GetTime(), GetTime() + interval))); watcher->SetTicket(auto_cacher_->GetRangeOfAudio(TimeRange(GetConnectedNode()->GetPlayhead(), GetConnectedNode()->GetPlayhead() + interval)));
} }
} }
} }
@@ -1173,7 +1175,7 @@ void ViewerWidget::FinishPlayPreprocess()
prequeued_audio_.clear(); prequeued_audio_.clear();
AudioMonitor::StartWaveformOnAll(GetConnectedNode()->GetConnectedWaveform(), AudioMonitor::StartWaveformOnAll(GetConnectedNode()->GetConnectedWaveform(),
GetTime(), playback_speed_); GetConnectedNode()->GetPlayhead(), playback_speed_);
} }
display_widget_->ResetFPSTimer(); display_widget_->ResetFPSTimer();
@@ -1522,7 +1524,7 @@ void ViewerWidget::Play(bool in_to_out_only)
if (GetConnectedNode() if (GetConnectedNode()
&& GetConnectedNode()->GetWorkArea()->enabled()) { && GetConnectedNode()->GetWorkArea()->enabled()) {
// Jump to in point // Jump to in point
SetTimeAndSignal(GetConnectedNode()->GetWorkArea()->in()); GetConnectedNode()->SetPlayhead(GetConnectedNode()->GetWorkArea()->in());
} else { } else {
in_to_out_only = false; in_to_out_only = false;
} }
@@ -1632,7 +1634,7 @@ void ViewerWidget::TimebaseChangedEvent(const rational &timebase)
controls_->SetTimebase(timebase); controls_->SetTimebase(timebase);
controls_->SetTime(ruler()->GetTime()); controls_->SetTime(GetConnectedNode() ? GetConnectedNode()->GetPlayhead() : 0);
LengthChangedSlot(GetConnectedNode() ? GetConnectedNode()->GetLength() : 0); LengthChangedSlot(GetConnectedNode() ? GetConnectedNode()->GetLength() : 0);
} }
@@ -1717,7 +1719,7 @@ void ViewerWidget::PlaybackTimerUpdate()
// pausing. Even if we pause it later with `end_of_line`, we prefer pausing after setting the time // pausing. Even if we pause it later with `end_of_line`, we prefer pausing after setting the time
// so that an audio scrub event, etc. isn't sent. // so that an audio scrub event, etc. isn't sent.
time_changed_from_timer_ = true; time_changed_from_timer_ = true;
SetTimeAndSignal(time_to_set); GetConnectedNode()->SetPlayhead(time_to_set);
time_changed_from_timer_ = false; time_changed_from_timer_ = false;
if (end_of_line) { if (end_of_line) {
// Cache the current speed // Cache the current speed
@@ -1767,7 +1769,7 @@ void ViewerWidget::LengthChangedSlot(const rational &length)
controls_->SetEndTime(length); controls_->SetEndTime(length);
UpdateMinimumScale(); UpdateMinimumScale();
if (length < last_length_ && GetTime() >= length) { if (GetConnectedNode() && length < last_length_ && GetConnectedNode()->GetPlayhead() >= length) {
UpdateTextureFromNode(); UpdateTextureFromNode();
} }
@@ -1813,7 +1815,7 @@ void ViewerWidget::SetZoomFromMenu(QAction *action)
void ViewerWidget::ViewerInvalidatedVideoRange(const TimeRange &range) void ViewerWidget::ViewerInvalidatedVideoRange(const TimeRange &range)
{ {
// If our current frame is within this range, we need to update // If our current frame is within this range, we need to update
if (!IsPlaying() && GetTime() >= range.in() && (GetTime() < range.out() || range.in() == range.out())) { if (!IsPlaying() && GetConnectedNode()->GetPlayhead() >= range.in() && (GetConnectedNode()->GetPlayhead() < range.out() || range.in() == range.out())) {
QMetaObject::invokeMethod(this, &ViewerWidget::UpdateTextureFromNode, Qt::QueuedConnection); QMetaObject::invokeMethod(this, &ViewerWidget::UpdateTextureFromNode, Qt::QueuedConnection);
} }
} }
+1 -1
View File
@@ -229,7 +229,7 @@ protected:
private: private:
int64_t GetTimestamp() const int64_t GetTimestamp() const
{ {
return Timecode::time_to_timestamp(GetTime(), timebase(), Timecode::kFloor); return Timecode::time_to_timestamp(GetConnectedNode()->GetPlayhead(), timebase(), Timecode::kFloor);
} }
void UpdateTimeInternal(int64_t i); void UpdateTimeInternal(int64_t i);
+2 -25
View File
@@ -106,12 +106,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(node_panel_, &NodePanel::NodeSelectionChanged, sequence_viewer_panel_, &ViewerPanel::SetNodeViewSelections); connect(node_panel_, &NodePanel::NodeSelectionChanged, sequence_viewer_panel_, &ViewerPanel::SetNodeViewSelections);
// Connect time signals together // Route play/pause/shuttle commands from these panels to the sequence viewer
AddMainTimePanel(multicam_panel_);
AddMainTimePanel(curve_panel_);
AddMainTimePanel(param_panel_);
AddMainTimePanel(sequence_viewer_panel_);
sequence_viewer_panel_->ConnectTimeBasedPanel(param_panel_); sequence_viewer_panel_->ConnectTimeBasedPanel(param_panel_);
sequence_viewer_panel_->ConnectTimeBasedPanel(curve_panel_); sequence_viewer_panel_->ConnectTimeBasedPanel(curve_panel_);
sequence_viewer_panel_->ConnectTimeBasedPanel(multicam_panel_); sequence_viewer_panel_->ConnectTimeBasedPanel(multicam_panel_);
@@ -525,7 +520,7 @@ void MainWindow::RevealViewerInFootageViewer(ViewerOutput *r, const TimeRange &r
command->add_child(new WorkareaSetRangeCommand(r->GetWorkArea(), range)); command->add_child(new WorkareaSetRangeCommand(r->GetWorkArea(), range));
Core::instance()->undo_stack()->push(command); Core::instance()->undo_stack()->push(command);
footage_viewer_panel_->SetTime(range.in()); r->SetPlayhead(range.in());
} }
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
@@ -556,7 +551,6 @@ void MainWindow::TimelineCloseRequested()
{ {
TimelinePanel *t = static_cast<TimelinePanel*>(sender()); TimelinePanel *t = static_cast<TimelinePanel*>(sender());
RemoveTimelinePanel(t); RemoveTimelinePanel(t);
main_time_panels_.removeOne(t);
} }
void MainWindow::ProjectCloseRequested() void MainWindow::ProjectCloseRequested()
@@ -598,21 +592,6 @@ void MainWindow::FloatingPanelCloseRequested()
panel->deleteLater(); panel->deleteLater();
} }
void MainWindow::AddMainTimePanel(TimeBasedPanel *p)
{
main_time_panels_.append(p);
connect(p, &TimeBasedPanel::TimeChanged, this, &MainWindow::UpdateMainTimePanels);
}
void MainWindow::UpdateMainTimePanels(const rational &r)
{
for (TimeBasedPanel *p : main_time_panels_) {
if (p != sender()) {
p->SetTime(r);
}
}
}
TimelinePanel* MainWindow::AppendTimelinePanel() TimelinePanel* MainWindow::AppendTimelinePanel()
{ {
TimelinePanel* panel = AppendPanelInternal<TimelinePanel>(timeline_panels_); TimelinePanel* panel = AppendPanelInternal<TimelinePanel>(timeline_panels_);
@@ -623,8 +602,6 @@ TimelinePanel* MainWindow::AppendTimelinePanel()
connect(panel, &TimelinePanel::RevealViewerInProject, this, &MainWindow::RevealViewerInProject); connect(panel, &TimelinePanel::RevealViewerInProject, this, &MainWindow::RevealViewerInProject);
connect(panel, &TimelinePanel::RevealViewerInFootageViewer, this, &MainWindow::RevealViewerInFootageViewer); connect(panel, &TimelinePanel::RevealViewerInFootageViewer, this, &MainWindow::RevealViewerInFootageViewer);
AddMainTimePanel(panel);
sequence_viewer_panel_->ConnectTimeBasedPanel(panel); sequence_viewer_panel_->ConnectTimeBasedPanel(panel);
return panel; return panel;
-6
View File
@@ -147,8 +147,6 @@ private:
void SelectFootageForProjectPanel(const QVector<Footage*> &e, ProjectPanel *p); void SelectFootageForProjectPanel(const QVector<Footage*> &e, ProjectPanel *p);
void AddMainTimePanel(TimeBasedPanel *p);
QByteArray premaximized_state_; QByteArray premaximized_state_;
// Standard panels // Standard panels
@@ -176,8 +174,6 @@ private:
bool first_show_; bool first_show_;
QVector<TimeBasedPanel*> main_time_panels_;
private slots: private slots:
void FocusedPanelChanged(PanelWidget* panel); void FocusedPanelChanged(PanelWidget* panel);
@@ -208,8 +204,6 @@ private slots:
void RevealViewerInProject(ViewerOutput *r); void RevealViewerInProject(ViewerOutput *r);
void RevealViewerInFootageViewer(ViewerOutput *r, const TimeRange &range); void RevealViewerInFootageViewer(ViewerOutput *r, const TimeRange &range);
void UpdateMainTimePanels(const rational &r);
}; };
} }