From 80a900d1057e8e81dd4dba182d5591fc626820b1 Mon Sep 17 00:00:00 2001
From: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date: Tue, 27 Sep 2022 18:22:47 -0700
Subject: [PATCH] multicam: show highlight around selected source
---
app/node/input/multicam/multicamnode.cpp | 16 ++++--
app/node/input/multicam/multicamnode.h | 7 +++
app/widget/multicam/CMakeLists.txt | 2 +
app/widget/multicam/multicamdisplay.cpp | 63 ++++++++++++++++++++++++
app/widget/multicam/multicamdisplay.h | 47 ++++++++++++++++++
app/widget/multicam/multicamwidget.cpp | 29 ++++++++++-
app/widget/multicam/multicamwidget.h | 27 ++++++++--
app/widget/viewer/viewer.cpp | 4 +-
app/widget/viewer/viewer.h | 6 ++-
app/widget/viewer/viewerdisplay.h | 37 +++++++-------
10 files changed, 207 insertions(+), 31 deletions(-)
create mode 100644 app/widget/multicam/multicamdisplay.cpp
create mode 100644 app/widget/multicam/multicamdisplay.h
diff --git a/app/node/input/multicam/multicamnode.cpp b/app/node/input/multicam/multicamnode.cpp
index 16edb4ac2..b468af862 100644
--- a/app/node/input/multicam/multicamnode.cpp
+++ b/app/node/input/multicam/multicamnode.cpp
@@ -45,7 +45,7 @@ Node::ActiveElements MultiCamNode::GetActiveElementsAtTime(const QString &input,
{
if (input == kSourcesInput && !monitor_) {
Node::ActiveElements a;
- a.add(GetStandardValue(kCurrentInput).toInt());
+ a.add(GetCurrentSource());
return a;
} else {
return super::GetActiveElementsAtTime(input, r);
@@ -137,9 +137,9 @@ void MultiCamNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
job.SetShaderID(QStringLiteral("%1,%2").arg(QString::number(rows), QString::number(cols)));
- for (size_t i=0; i.
+
+***/
+
+#include "multicamdisplay.h"
+
+namespace olive {
+
+#define super ViewerDisplayWidget
+
+MulticamDisplay::MulticamDisplay(QWidget *parent) :
+ super(parent),
+ node_(nullptr)
+{
+}
+
+void MulticamDisplay::OnPaint()
+{
+ super::OnPaint();
+
+ if (node_) {
+ QPainter p(paint_device());
+
+ p.setPen(QPen(Qt::yellow, fontMetrics().height()/4));
+ p.setBrush(Qt::NoBrush);
+
+ int rows, cols;
+ node_->GetRowsAndColumns(&rows, &cols);
+
+ int multi = std::max(rows, cols);
+ int cell_width = width() / multi;
+ int cell_height = height() / multi;
+
+ int col, row;
+ node_->IndexToRowCols(node_->GetCurrentSource(), rows, cols, &row, &col);
+
+ QRect r(cell_width * col, cell_height * row, cell_width, cell_height);
+ p.drawRect(GenerateWorldTransform().mapRect(r));
+ }
+}
+
+void MulticamDisplay::SetMulticamNode(MultiCamNode *n)
+{
+ node_ = n;
+}
+
+}
diff --git a/app/widget/multicam/multicamdisplay.h b/app/widget/multicam/multicamdisplay.h
new file mode 100644
index 000000000..2898142d1
--- /dev/null
+++ b/app/widget/multicam/multicamdisplay.h
@@ -0,0 +1,47 @@
+/***
+
+ Olive - Non-Linear Video Editor
+ Copyright (C) 2022 Olive Team
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+***/
+
+#ifndef MULTICAMDISPLAY_H
+#define MULTICAMDISPLAY_H
+
+#include "node/input/multicam/multicamnode.h"
+#include "widget/viewer/viewerdisplay.h"
+
+namespace olive {
+
+class MulticamDisplay : public ViewerDisplayWidget
+{
+ Q_OBJECT
+public:
+ explicit MulticamDisplay(QWidget *parent = nullptr);
+
+ void SetMulticamNode(MultiCamNode *n);
+
+protected:
+ virtual void OnPaint() override;
+
+private:
+ MultiCamNode *node_;
+
+};
+
+}
+
+#endif // MULTICAMDISPLAY_H
diff --git a/app/widget/multicam/multicamwidget.cpp b/app/widget/multicam/multicamwidget.cpp
index ab423ed1d..3ff424011 100644
--- a/app/widget/multicam/multicamwidget.cpp
+++ b/app/widget/multicam/multicamwidget.cpp
@@ -1,3 +1,23 @@
+/***
+
+ Olive - Non-Linear Video Editor
+ Copyright (C) 2022 Olive Team
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+***/
+
#include "multicamwidget.h"
#include "widget/nodeparamview/nodeparamviewundo.h"
@@ -6,14 +26,21 @@ namespace olive {
#define super ViewerWidget
MulticamWidget::MulticamWidget(QWidget *parent) :
- super{parent},
+ super{new MulticamDisplay(), parent},
node_(nullptr)
{
auto_cacher()->SetMulticamMode(true);
+ auto_cacher()->SetIgnoreCacheRequests(true);
connect(display_widget(), &ViewerDisplayWidget::DragStarted, this, &MulticamWidget::DisplayClicked);
}
+void MulticamWidget::SetMulticamNode(MultiCamNode *n)
+{
+ node_ = n;
+ static_cast(display_widget())->SetMulticamNode(n);
+}
+
RenderTicketPtr MulticamWidget::GetSingleFrame(const rational &t, bool dry)
{
if (node_) {
diff --git a/app/widget/multicam/multicamwidget.h b/app/widget/multicam/multicamwidget.h
index f53e77e9c..b80414c97 100644
--- a/app/widget/multicam/multicamwidget.h
+++ b/app/widget/multicam/multicamwidget.h
@@ -1,8 +1,28 @@
+/***
+
+ Olive - Non-Linear Video Editor
+ Copyright (C) 2022 Olive Team
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+***/
+
#ifndef MULTICAMWIDGET_H
#define MULTICAMWIDGET_H
+#include "multicamdisplay.h"
#include "node/input/multicam/multicamnode.h"
-#include "render/previewautocacher.h"
#include "widget/viewer/viewer.h"
namespace olive {
@@ -13,10 +33,7 @@ class MulticamWidget : public ViewerWidget
public:
explicit MulticamWidget(QWidget *parent = nullptr);
- void SetMulticamNode(MultiCamNode *n)
- {
- node_ = n;
- }
+ void SetMulticamNode(MultiCamNode *n);
protected:
virtual RenderTicketPtr GetSingleFrame(const rational &t, bool dry = false) override;
diff --git a/app/widget/viewer/viewer.cpp b/app/widget/viewer/viewer.cpp
index d45955f9f..bdf28a4de 100644
--- a/app/widget/viewer/viewer.cpp
+++ b/app/widget/viewer/viewer.cpp
@@ -62,7 +62,7 @@ const rational ViewerWidget::kAudioPlaybackInterval = rational(1, 4);
const rational kVideoPlaybackInterval = rational(1, 2);
-ViewerWidget::ViewerWidget(QWidget *parent) :
+ViewerWidget::ViewerWidget(ViewerDisplayWidget *display, QWidget *parent) :
super(false, true, parent),
playback_speed_(0),
color_menu_enabled_(true),
@@ -85,7 +85,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
sizer_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
layout->addWidget(sizer_);
- display_widget_ = new ViewerDisplayWidget();
+ display_widget_ = display;
display_widget_->SetShowWidgetBackground(true);
playback_devices_.append(display_widget_);
connect(display_widget_, &ViewerDisplayWidget::customContextMenuRequested, this, &ViewerWidget::ShowContextMenu);
diff --git a/app/widget/viewer/viewer.h b/app/widget/viewer/viewer.h
index fe3e44ed4..400853652 100644
--- a/app/widget/viewer/viewer.h
+++ b/app/widget/viewer/viewer.h
@@ -57,7 +57,9 @@ public:
kWFViewerAndWaveform
};
- ViewerWidget(QWidget* parent = nullptr);
+ ViewerWidget(QWidget* parent = nullptr) :
+ ViewerWidget(new ViewerDisplayWidget(), parent)
+ {}
virtual ~ViewerWidget() override;
@@ -159,6 +161,8 @@ signals:
void ColorManagerChanged(ColorManager* color_manager);
protected:
+ ViewerWidget(ViewerDisplayWidget *display, QWidget* parent = nullptr);
+
virtual void TimebaseChangedEvent(const rational &) override;
virtual void TimeChangedEvent(const rational &time) override;
diff --git a/app/widget/viewer/viewerdisplay.h b/app/widget/viewer/viewerdisplay.h
index d11ef585a..077ea6023 100644
--- a/app/widget/viewer/viewerdisplay.h
+++ b/app/widget/viewer/viewerdisplay.h
@@ -226,6 +226,25 @@ signals:
void CreateAddableAt(const QRectF &rect);
+protected:
+ QTransform GenerateWorldTransform();
+
+ QTransform GenerateDisplayTransform();
+
+ QTransform GenerateGizmoTransform(NodeTraverser >, const TimeRange &range);
+ QTransform GenerateGizmoTransform()
+ {
+ NodeTraverser t;
+ t.SetCacheVideoParams(gizmo_params_);
+ return GenerateGizmoTransform(t, GenerateGizmoTime());
+ }
+
+ TimeRange GenerateGizmoTime()
+ {
+ rational node_time = GetGizmoTime();
+ return TimeRange(node_time, node_time + gizmo_params_.frame_rate_as_time_base());
+ }
+
protected slots:
/**
* @brief Paint function to display the texture (received in SetTexture()) on screen.
@@ -249,24 +268,6 @@ private:
void UpdateMatrix();
- QTransform GenerateWorldTransform();
-
- QTransform GenerateDisplayTransform();
-
- QTransform GenerateGizmoTransform(NodeTraverser >, const TimeRange &range);
- QTransform GenerateGizmoTransform()
- {
- NodeTraverser t;
- t.SetCacheVideoParams(gizmo_params_);
- return GenerateGizmoTransform(t, GenerateGizmoTime());
- }
-
- TimeRange GenerateGizmoTime()
- {
- rational node_time = GetGizmoTime();
- return TimeRange(node_time, node_time + gizmo_params_.frame_rate_as_time_base());
- }
-
NodeGizmo *TryGizmoPress(const NodeValueRow &row, const QPointF &p);
void OpenTextGizmo(TextGizmo *text, QMouseEvent *event = nullptr);