multicam: show highlight around selected source
This commit is contained in:
@@ -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<arr.size(); i++) {
|
||||
size_t c = i%cols;
|
||||
size_t r = i/cols;
|
||||
for (int i=0; i<int(arr.size()); i++) {
|
||||
int c, r;
|
||||
IndexToRowCols(i, rows, cols, &r, &c);
|
||||
job.Insert(QStringLiteral("tex_%1_%2").arg(QString::number(r), QString::number(c)), arr[i]);
|
||||
}
|
||||
|
||||
@@ -147,6 +147,14 @@ void MultiCamNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
}
|
||||
}
|
||||
|
||||
void MultiCamNode::IndexToRowCols(int index, int total_rows, int total_cols, int *row, int *col)
|
||||
{
|
||||
Q_UNUSED(total_rows)
|
||||
|
||||
*col = index%total_cols;
|
||||
*row = index/total_cols;
|
||||
}
|
||||
|
||||
void MultiCamNode::Retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
|
||||
@@ -31,6 +31,11 @@ public:
|
||||
|
||||
void SetMonitorMode(bool e) { monitor_ = e; }
|
||||
|
||||
int GetCurrentSource() const
|
||||
{
|
||||
return GetStandardValue(kCurrentInput).toInt();
|
||||
}
|
||||
|
||||
int GetSourceCount() const
|
||||
{
|
||||
return InputArraySize(kSourcesInput);
|
||||
@@ -42,6 +47,8 @@ public:
|
||||
return GetRowsAndColumns(GetSourceCount(), rows, cols);
|
||||
}
|
||||
|
||||
static void IndexToRowCols(int index, int total_rows, int total_cols, int *row, int *col);
|
||||
|
||||
static int RowsColsToIndex(int row, int col, int total_rows, int total_cols)
|
||||
{
|
||||
return col + row * total_cols;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
widget/multicam/multicamdisplay.cpp
|
||||
widget/multicam/multicamdisplay.h
|
||||
widget/multicam/multicamwidget.cpp
|
||||
widget/multicam/multicamwidget.h
|
||||
PARENT_SCOPE
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/***
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#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
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#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<MulticamDisplay*>(display_widget())->SetMulticamNode(n);
|
||||
}
|
||||
|
||||
RenderTicketPtr MulticamWidget::GetSingleFrame(const rational &t, bool dry)
|
||||
{
|
||||
if (node_) {
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user