footageviewer: auto switch waveform mode when clicking video/audio buttons

This commit is contained in:
itsmattkc
2023-03-20 16:51:39 -07:00
parent 0a54585ece
commit 537908c605
7 changed files with 55 additions and 13 deletions
+22 -3
View File
@@ -1,7 +1,7 @@
/*** /***
Olive - Non-Linear Video Editor Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team Copyright (C) 2023 Olive Studios LLC
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -20,18 +20,37 @@
#include "dragbutton.h" #include "dragbutton.h"
#include <QMouseEvent>
namespace olive { namespace olive {
DragButton::DragButton(QWidget *parent) : DragButton::DragButton(QWidget *parent) :
QPushButton(parent) QPushButton(parent)
{ {
setCursor(Qt::OpenHandCursor); setCursor(Qt::OpenHandCursor);
dragging_ = false;
} }
void DragButton::mousePressEvent(QMouseEvent *event) { void DragButton::mousePressEvent(QMouseEvent *event)
{
QPushButton::mousePressEvent(event); QPushButton::mousePressEvent(event);
}
emit MousePressed(); void DragButton::mouseMoveEvent(QMouseEvent *event)
{
QPushButton::mouseMoveEvent(event);
if (event->buttons() && !dragging_) {
emit DragStarted();
dragging_ = true;
}
}
void DragButton::mouseReleaseEvent(QMouseEvent *event)
{
QPushButton::mouseReleaseEvent(event);
dragging_ = false;
} }
} }
+9 -2
View File
@@ -1,7 +1,7 @@
/*** /***
Olive - Non-Linear Video Editor Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team Copyright (C) 2023 Olive Studios LLC
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -34,11 +34,18 @@ public:
DragButton(QWidget* parent = nullptr); DragButton(QWidget* parent = nullptr);
signals: signals:
void MousePressed(); void DragStarted();
protected: protected:
virtual void mousePressEvent(QMouseEvent* event) override; virtual void mousePressEvent(QMouseEvent* event) override;
virtual void mouseMoveEvent(QMouseEvent* event) override;
virtual void mouseReleaseEvent(QMouseEvent* event) override;
private:
bool dragging_;
}; };
} }
@@ -127,11 +127,11 @@ PlaybackControls::PlaybackControls(QWidget *parent) :
av_btn_layout->setContentsMargins(0, 0, 0, 0); av_btn_layout->setContentsMargins(0, 0, 0, 0);
video_drag_btn_ = new DragButton(); video_drag_btn_ = new DragButton();
connect(video_drag_btn_, &QPushButton::clicked, this, &PlaybackControls::VideoClicked); connect(video_drag_btn_, &QPushButton::clicked, this, &PlaybackControls::VideoClicked);
connect(video_drag_btn_, &DragButton::MousePressed, this, &PlaybackControls::VideoPressed); connect(video_drag_btn_, &DragButton::DragStarted, this, &PlaybackControls::VideoDragged);
av_btn_layout->addWidget(video_drag_btn_); av_btn_layout->addWidget(video_drag_btn_);
audio_drag_btn_ = new DragButton(); audio_drag_btn_ = new DragButton();
connect(audio_drag_btn_, &QPushButton::clicked, this, &PlaybackControls::AudioClicked); connect(audio_drag_btn_, &QPushButton::clicked, this, &PlaybackControls::AudioClicked);
connect(audio_drag_btn_, &DragButton::MousePressed, this, &PlaybackControls::AudioPressed); connect(audio_drag_btn_, &DragButton::DragStarted, this, &PlaybackControls::AudioDragged);
av_btn_layout->addWidget(audio_drag_btn_); av_btn_layout->addWidget(audio_drag_btn_);
lower_control_layout->addWidget(av_btn_widget); lower_control_layout->addWidget(av_btn_widget);
@@ -112,9 +112,9 @@ signals:
void VideoClicked(); void VideoClicked();
void AudioPressed(); void AudioDragged();
void VideoPressed(); void VideoDragged();
void TimeChanged(const rational& t); void TimeChanged(const rational& t);
+14 -2
View File
@@ -36,8 +36,10 @@ FootageViewerWidget::FootageViewerWidget(QWidget *parent) :
connect(display_widget(), &ViewerDisplayWidget::DragStarted, this, &FootageViewerWidget::StartFootageDrag); connect(display_widget(), &ViewerDisplayWidget::DragStarted, this, &FootageViewerWidget::StartFootageDrag);
controls_->SetAudioVideoDragButtonsVisible(true); controls_->SetAudioVideoDragButtonsVisible(true);
connect(controls_, &PlaybackControls::VideoPressed, this, &FootageViewerWidget::StartVideoDrag); connect(controls_, &PlaybackControls::VideoClicked, this, &FootageViewerWidget::VideoButtonClicked);
connect(controls_, &PlaybackControls::AudioPressed, this, &FootageViewerWidget::StartAudioDrag); connect(controls_, &PlaybackControls::AudioClicked, this, &FootageViewerWidget::AudioButtonClicked);
connect(controls_, &PlaybackControls::VideoDragged, this, &FootageViewerWidget::StartVideoDrag);
connect(controls_, &PlaybackControls::AudioDragged, this, &FootageViewerWidget::StartAudioDrag);
override_workarea_ = new TimelineWorkArea(this); override_workarea_ = new TimelineWorkArea(this);
} }
@@ -108,4 +110,14 @@ void FootageViewerWidget::StartAudioDrag()
StartFootageDragInternal(false, true); StartFootageDragInternal(false, true);
} }
void FootageViewerWidget::VideoButtonClicked()
{
this->SetWaveformMode(kWFAutomatic);
}
void FootageViewerWidget::AudioButtonClicked()
{
this->SetWaveformMode(kWFWaveformOnly);
}
} }
+4
View File
@@ -47,6 +47,10 @@ private slots:
void StartAudioDrag(); void StartAudioDrag();
void VideoButtonClicked();
void AudioButtonClicked();
}; };
} }
+2 -2
View File
@@ -218,6 +218,8 @@ protected:
RenderTicketPtr GetSingleFrame(const rational &t, bool dry = false); RenderTicketPtr GetSingleFrame(const rational &t, bool dry = false);
void SetWaveformMode(WaveformMode wf);
private: private:
int64_t GetTimestamp() const int64_t GetTimestamp() const
{ {
@@ -270,8 +272,6 @@ private:
void CloseAudioProcessor(); void CloseAudioProcessor();
void SetWaveformMode(WaveformMode wf);
void DetectMulticamNode(const rational &time); void DetectMulticamNode(const rational &time);
bool IsVideoVisible() const; bool IsVideoVisible() const;