Merge branch 'master' into nodeviewredux

This commit is contained in:
itsmattkc
2020-05-07 03:57:12 +10:00
119 changed files with 2144 additions and 1789 deletions
+2
View File
@@ -31,6 +31,7 @@ add_subdirectory(nodecopypaste)
add_subdirectory(nodeview)
add_subdirectory(nodeparamview)
add_subdirectory(panel)
add_subdirectory(pixelsampler)
add_subdirectory(playbackcontrols)
add_subdirectory(projectexplorer)
add_subdirectory(projecttoolbar)
@@ -41,6 +42,7 @@ add_subdirectory(taskview)
add_subdirectory(timebased)
add_subdirectory(timelinewidget)
add_subdirectory(timeruler)
add_subdirectory(timetarget)
add_subdirectory(toolbar)
add_subdirectory(viewer)
-2
View File
@@ -24,7 +24,5 @@ set(OLIVE_SOURCES
widget/keyframeview/keyframeviewitem.cpp
widget/keyframeview/keyframeviewundo.h
widget/keyframeview/keyframeviewundo.cpp
widget/keyframeview/timetargetobject.h
widget/keyframeview/timetargetobject.cpp
PARENT_SCOPE
)
+1 -1
View File
@@ -23,7 +23,7 @@
#include "keyframeviewitem.h"
#include "node/keyframe.h"
#include "timetargetobject.h"
#include "widget/timetarget/timetarget.h"
#include "widget/curvewidget/beziercontrolpointitem.h"
#include "widget/timelinewidget/view/timelineviewbase.h"
+1 -1
View File
@@ -24,7 +24,7 @@
#include <QGraphicsRectItem>
#include "node/keyframe.h"
#include "timetargetobject.h"
#include "widget/timetarget/timetarget.h"
OLIVE_NAMESPACE_ENTER
+2
View File
@@ -18,6 +18,8 @@ set(OLIVE_SOURCES
${OLIVE_SOURCES}
widget/nodeparamview/nodeparamview.h
widget/nodeparamview/nodeparamview.cpp
widget/nodeparamview/nodeparamviewarraywidget.h
widget/nodeparamview/nodeparamviewarraywidget.cpp
widget/nodeparamview/nodeparamviewconnectedlabel.h
widget/nodeparamview/nodeparamviewconnectedlabel.cpp
widget/nodeparamview/nodeparamviewitem.h
+8 -1
View File
@@ -127,7 +127,7 @@ void NodeParamView::SetNodes(QList<Node *> nodes)
// If we already have item widgets, delete them all now
foreach (NodeParamViewItem* item, items_) {
emit ClosedNode(item->GetNode());
emit FoundGizmos(nullptr);
delete item;
}
items_.clear();
@@ -142,6 +142,8 @@ void NodeParamView::SetNodes(QList<Node *> nodes)
if (!nodes_.isEmpty()) {
// For each node, create a widget
bool found_gizmos = false;
foreach (Node* node, nodes_) {
NodeParamViewItem* item = new NodeParamViewItem(node);
@@ -161,6 +163,11 @@ void NodeParamView::SetNodes(QList<Node *> nodes)
Qt::QueuedConnection);
emit OpenedNode(node);
if (!found_gizmos && node->HasGizmos()) {
emit FoundGizmos(node);
found_gizmos = true;
}
}
ViewerOutput* viewer = nodes_.first()->FindOutputNode<ViewerOutput>();
+2
View File
@@ -55,6 +55,8 @@ signals:
void ClosedNode(Node* n);
void FoundGizmos(Node* n);
protected:
virtual void resizeEvent(QResizeEvent *event) override;
@@ -0,0 +1,55 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 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 "nodeparamviewarraywidget.h"
#include <QHBoxLayout>
OLIVE_NAMESPACE_ENTER
NodeParamViewArrayWidget::NodeParamViewArrayWidget(NodeInputArray* array, QWidget* parent) :
QWidget(parent),
array_(array)
{
QHBoxLayout* layout = new QHBoxLayout(this);
count_lbl_ = new QLabel();
layout->addWidget(count_lbl_, 1);
plus_btn_ = new QPushButton(tr("+"));
layout->addWidget(plus_btn_);
connect(plus_btn_, &QPushButton::clicked, this, &NodeParamViewArrayWidget::AddElement);
connect(array_, &NodeInputArray::SizeChanged, this, &NodeParamViewArrayWidget::UpdateCounter);
UpdateCounter();
}
void NodeParamViewArrayWidget::UpdateCounter()
{
count_lbl_->setText(tr("%1 elements").arg(array_->GetSize()));
}
void NodeParamViewArrayWidget::AddElement()
{
array_->Append();
}
OLIVE_NAMESPACE_EXIT
@@ -0,0 +1,54 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 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 NODEPARAMVIEWARRAYWIDGET_H
#define NODEPARAMVIEWARRAYWIDGET_H
#include <QLabel>
#include <QPushButton>
#include <QWidget>
#include "node/inputarray.h"
OLIVE_NAMESPACE_ENTER
class NodeParamViewArrayWidget : public QWidget
{
Q_OBJECT
public:
NodeParamViewArrayWidget(NodeInputArray* array, QWidget* parent = nullptr);
private:
NodeInputArray* array_;
QLabel* count_lbl_;
QPushButton* plus_btn_;
private slots:
void UpdateCounter();
void AddElement();
};
OLIVE_NAMESPACE_EXIT
#endif // NODEPARAMVIEWARRAYWIDGET_H
@@ -167,6 +167,7 @@ NodeParamViewItemBody::NodeParamViewItemBody(const QVector<NodeInput *> &inputs,
content_layout->addLayout(array_label_layout, row_count, 0);
NodeParamViewItemBody* sub_body = new NodeParamViewItemBody(static_cast<NodeInputArray*>(input)->sub_params());
sub_bodies_.append(sub_body);
sub_body->layout()->setMargin(0);
content_layout->addWidget(sub_body, row_count + 1, 0, 1, max_col + 1);
@@ -25,7 +25,7 @@
#include <QWidget>
#include "node/input.h"
#include "widget/keyframeview/timetargetobject.h"
#include "widget/timetarget/timetarget.h"
OLIVE_NAMESPACE_ENTER
@@ -29,6 +29,7 @@
#include "core.h"
#include "node/node.h"
#include "nodeparamviewarraywidget.h"
#include "nodeparamviewundo.h"
#include "project/item/sequence/sequence.h"
#include "undo/undostack.h"
@@ -67,113 +68,122 @@ const QList<QWidget *> &NodeParamViewWidgetBridge::widgets() const
void NodeParamViewWidgetBridge::CreateWidgets()
{
// We assume the first data type is the "primary" type
switch (input_->data_type()) {
// None of these inputs have applicable UI widgets
case NodeParam::kNone:
case NodeParam::kAny:
case NodeParam::kTexture:
case NodeParam::kMatrix:
case NodeParam::kRational:
case NodeParam::kSamples:
case NodeParam::kDecimal:
case NodeParam::kNumber:
case NodeParam::kString:
case NodeParam::kBuffer:
case NodeParam::kVector:
break;
case NodeParam::kInt:
{
IntegerSlider* slider = new IntegerSlider();
widgets_.append(slider);
connect(slider, &IntegerSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
}
case NodeParam::kFloat:
{
CreateSliders(1);
break;
}
case NodeParam::kVec2:
{
CreateSliders(2);
break;
}
case NodeParam::kVec3:
{
CreateSliders(3);
break;
}
case NodeParam::kVec4:
{
CreateSliders(4);
break;
}
case NodeParam::kCombo:
{
QComboBox* combobox = new QComboBox();
if (input_->IsArray()) {
QStringList items = input_->get_combobox_strings();
foreach (const QString& s, items) {
combobox->addItem(s);
NodeParamViewArrayWidget* w = new NodeParamViewArrayWidget(static_cast<NodeInputArray*>(input_));
widgets_.append(w);
} else {
// We assume the first data type is the "primary" type
switch (input_->data_type()) {
// None of these inputs have applicable UI widgets
case NodeParam::kNone:
case NodeParam::kAny:
case NodeParam::kTexture:
case NodeParam::kMatrix:
case NodeParam::kRational:
case NodeParam::kSamples:
case NodeParam::kDecimal:
case NodeParam::kNumber:
case NodeParam::kString:
case NodeParam::kBuffer:
case NodeParam::kVector:
break;
case NodeParam::kInt:
{
IntegerSlider* slider = new IntegerSlider();
widgets_.append(slider);
connect(slider, &IntegerSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
}
case NodeParam::kFloat:
{
CreateSliders(1);
break;
}
case NodeParam::kVec2:
{
CreateSliders(2);
break;
}
case NodeParam::kVec3:
{
CreateSliders(3);
break;
}
case NodeParam::kVec4:
{
CreateSliders(4);
break;
}
case NodeParam::kCombo:
{
QComboBox* combobox = new QComboBox();
QStringList items = input_->get_combobox_strings();
foreach (const QString& s, items) {
combobox->addItem(s);
}
widgets_.append(combobox);
connect(combobox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
}
case NodeParam::kFile:
// FIXME: File selector
break;
case NodeParam::kColor:
{
// NOTE: Very convoluted way to get back to the project's color manager
ColorButton* color_button = new ColorButton(static_cast<Sequence*>(input_->parentNode()->parent())->project()->color_manager());
widgets_.append(color_button);
connect(color_button, &ColorButton::ColorChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
}
case NodeParam::kText:
{
QLineEdit* line_edit = new QLineEdit();
widgets_.append(line_edit);
connect(line_edit, &QLineEdit::textEdited, this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
}
case NodeParam::kBoolean:
{
QCheckBox* check_box = new QCheckBox();
widgets_.append(check_box);
connect(check_box, &QCheckBox::clicked, this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
}
case NodeParam::kFont:
{
QFontComboBox* font_combobox = new QFontComboBox();
widgets_.append(font_combobox);
break;
}
case NodeParam::kFootage:
{
FootageComboBox* footage_combobox = new FootageComboBox();
footage_combobox->SetRoot(static_cast<Sequence*>(input_->parentNode()->parent())->project()->root());
connect(footage_combobox, &FootageComboBox::FootageChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
widgets_.append(footage_combobox);
break;
}
}
widgets_.append(combobox);
connect(combobox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
}
case NodeParam::kFile:
// FIXME: File selector
break;
case NodeParam::kColor:
{
// NOTE: Very convoluted way to get back to the project's color manager
ColorButton* color_button = new ColorButton(static_cast<Sequence*>(input_->parentNode()->parent())->project()->color_manager());
widgets_.append(color_button);
connect(color_button, &ColorButton::ColorChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
}
case NodeParam::kText:
{
QLineEdit* line_edit = new QLineEdit();
widgets_.append(line_edit);
connect(line_edit, &QLineEdit::textEdited, this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
}
case NodeParam::kBoolean:
{
QCheckBox* check_box = new QCheckBox();
widgets_.append(check_box);
connect(check_box, &QCheckBox::clicked, this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
}
case NodeParam::kFont:
{
QFontComboBox* font_combobox = new QFontComboBox();
widgets_.append(font_combobox);
break;
}
case NodeParam::kFootage:
{
FootageComboBox* footage_combobox = new FootageComboBox();
footage_combobox->SetRoot(static_cast<Sequence*>(input_->parentNode()->parent())->project()->root());
// Check all properties
QHash<QString, QVariant>::const_iterator iterator;
connect(footage_combobox, &FootageComboBox::FootageChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
for (iterator=input_->properties().begin();iterator!=input_->properties().end();iterator++) {
PropertyChanged(iterator.key(), iterator.value());
}
widgets_.append(footage_combobox);
UpdateWidgetValues();
break;
}
}
// Check all properties
QHash<QString, QVariant>::const_iterator iterator;
for (iterator=input_->properties().begin();iterator!=input_->properties().end();iterator++) {
PropertyChanged(iterator.key(), iterator.value());
}
UpdateWidgetValues();
}
void NodeParamViewWidgetBridge::SetInputValue(const QVariant &value, int track)
@@ -413,6 +423,10 @@ void NodeParamViewWidgetBridge::CreateSliders(int count)
void NodeParamViewWidgetBridge::UpdateWidgetValues()
{
if (input_->IsArray()) {
return;
}
rational node_time = GetCurrentTimeAsNodeTime();
// We assume the first data type is the "primary" type
@@ -24,8 +24,8 @@
#include <QObject>
#include "node/input.h"
#include "widget/keyframeview/timetargetobject.h"
#include "widget/slider/sliderbase.h"
#include "widget/timetarget/timetarget.h"
OLIVE_NAMESPACE_ENTER
+22
View File
@@ -0,0 +1,22 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2019 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/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
widget/pixelsampler/pixelsampler.h
widget/pixelsampler/pixelsampler.cpp
PARENT_SCOPE
)
@@ -18,7 +18,7 @@
***/
#include "pixelsamplerwidget.h"
#include "pixelsampler.h"
#include <QVBoxLayout>
+1
View File
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
add_subdirectory(histogram)
add_subdirectory(scopebase)
add_subdirectory(waveform)
set(OLIVE_SOURCES
+1 -182
View File
@@ -29,189 +29,8 @@
OLIVE_NAMESPACE_ENTER
HistogramScope::HistogramScope(QWidget* parent) :
ManagedDisplayWidget(parent),
buffer_(nullptr)
ScopeBase(parent)
{
EnableDefaultContextMenu();
connect(&worker_, &HistogramScopeWorker::Finished, this, &HistogramScope::FinishedProcessing, Qt::QueuedConnection);
worker_.start(QThread::IdlePriority);
}
HistogramScope::~HistogramScope()
{
worker_.Cancel();
worker_.quit();
worker_.wait();
}
void HistogramScope::SetBuffer(Frame* frame)
{
buffer_ = frame;
if (isVisible()) {
StartUpdate();
}
}
void HistogramScope::FinishedProcessing(QVector<double> red, QVector<double> green, QVector<double> blue)
{
red_val_ = red;
green_val_ = green;
blue_val_ = blue;
update();
}
void HistogramScope::paintGL()
{
QVector<QLine> red_lines(red_val_.size());
QVector<QLine> green_lines(green_val_.size());
QVector<QLine> blue_lines(blue_val_.size());
for (int i=0;i<red_lines.size();i++) {
red_lines.replace(i, QLine(i, height() * (1.0 - red_val_.at(i)), i, height()));
green_lines.replace(i, QLine(i, height() * (1.0 - green_val_.at(i)), i, height()));
blue_lines.replace(i, QLine(i, height() * (1.0 - blue_val_.at(i)), i, height()));
}
QPainter p(this);
p.setCompositionMode(QPainter::CompositionMode_Plus);
p.setPen(Qt::red);
p.drawLines(red_lines);
p.setPen(Qt::green);
p.drawLines(green_lines);
p.setPen(Qt::blue);
p.drawLines(blue_lines);
}
void HistogramScope::resizeEvent(QResizeEvent *e)
{
QOpenGLWidget::resizeEvent(e);
StartUpdate();
}
void HistogramScope::ColorProcessorChangedEvent()
{
StartUpdate();
}
void HistogramScope::StartUpdate()
{
if (buffer_) {
worker_.QueueNext(*buffer_, color_service(), width());
} else {
// Update with nothing
red_val_.clear();
green_val_.clear();
blue_val_.clear();
update();
}
}
void HistogramScope::showEvent(QShowEvent* e)
{
ManagedDisplayWidget::showEvent(e);
StartUpdate();
}
HistogramScopeWorker::HistogramScopeWorker() :
cancelled_(false)
{
}
void HistogramScopeWorker::run()
{
while (!cancelled_) {
next_lock_.lock();
while (!next_.is_allocated()) {
next_wait_.wait(&next_lock_);
if (cancelled_){
next_lock_.unlock();
return;
}
}
// Copy values
Frame f = next_;
int w = next_width_;
ColorProcessorPtr processor = next_processor_;
next_.destroy();
next_lock_.unlock();
// Color manage frame
QVector<int> data(w * kRGBChannels, 0);
int max_w = w-1;
for (int x=0;x<f.width();x++) {
for (int y=0;y<f.height();y++) {
Color c = f.get_pixel(x, y);
if (processor) {
c = processor->ConvertColor(c);
}
data[qFloor(clamp(c.red(), 0.0f, 1.0f) * max_w)]++;
data[qFloor(clamp(c.green(), 0.0f, 1.0f) * max_w) + w]++;
data[qFloor(clamp(c.blue(), 0.0f, 1.0f) * max_w) + w * 2]++;
}
}
int max_val = 0;
foreach (const int& i, data) {
if (i > max_val) {
max_val = i;
}
}
if (!max_val) {
// Prevent divide by zero
return;
}
QVector<double> red_lines(w);
QVector<double> green_lines(w);
QVector<double> blue_lines(w);
for (int i=0;i<w;i++) {
red_lines.replace(i, static_cast<double>(data.at(i)) / static_cast<double>(max_val));
green_lines.replace(i, static_cast<double>(data.at(i + w)) / static_cast<double>(max_val));
blue_lines.replace(i, static_cast<double>(data.at(i + w * 2)) / static_cast<double>(max_val));
}
emit Finished(red_lines, green_lines, blue_lines);
}
}
void HistogramScopeWorker::QueueNext(const Frame &f, ColorProcessorPtr processor, int width)
{
next_lock_.lock();
next_ = f;
next_width_ = width;
next_processor_ = processor;
next_wait_.wakeOne();
next_lock_.unlock();
}
void HistogramScopeWorker::Cancel()
{
cancelled_ = true;
next_lock_.lock();
next_wait_.wakeOne();
next_lock_.unlock();
}
OLIVE_NAMESPACE_EXIT
+4 -64
View File
@@ -21,80 +21,20 @@
#ifndef HISTOGRAMSCOPE_H
#define HISTOGRAMSCOPE_H
#include <QMutex>
#include <QThread>
#include <QWaitCondition>
#include "codec/frame.h"
#include "render/colorprocessor.h"
#include "widget/manageddisplay/manageddisplay.h"
#include "widget/scope/scopebase/scopebase.h"
OLIVE_NAMESPACE_ENTER
class HistogramScopeWorker : public QThread
{
Q_OBJECT
public:
HistogramScopeWorker();
// Thread-safe
void QueueNext(const Frame& f, ColorProcessorPtr processor, int width);
// Thread-safe
void Cancel();
protected:
virtual void run() override;
signals:
void Finished(QVector<double> red, QVector<double> green, QVector<double> blue);
private:
QAtomicInt cancelled_;
QMutex next_lock_;
QWaitCondition next_wait_;
Frame next_;
int next_width_;
ColorProcessorPtr next_processor_;
};
class HistogramScope : public ManagedDisplayWidget
class HistogramScope : public ScopeBase
{
Q_OBJECT
public:
HistogramScope(QWidget* parent = nullptr);
virtual ~HistogramScope() override;
public slots:
void SetBuffer(Frame* frame);
protected:
virtual void paintGL() override;
//virtual OpenGLShaderPtr CreateShader() override;
virtual void resizeEvent(QResizeEvent* e) override;
virtual void ColorProcessorChangedEvent() override;
virtual void showEvent(QShowEvent* e) override;
private:
void StartUpdate();
Frame* buffer_;
QVector<double> red_val_;
QVector<double> green_val_;
QVector<double> blue_val_;
HistogramScopeWorker worker_;
private slots:
void FinishedProcessing(QVector<double> red, QVector<double> green, QVector<double> blue);
//virtual void DrawScope() override;
};
+22
View File
@@ -0,0 +1,22 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2019 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/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
widget/scope/scopebase/scopebase.h
widget/scope/scopebase/scopebase.cpp
PARENT_SCOPE
)
+163
View File
@@ -0,0 +1,163 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 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 "scopebase.h"
#include "render/backend/opengl/openglrenderfunctions.h"
OLIVE_NAMESPACE_ENTER
ScopeBase::ScopeBase(QWidget* parent) :
ManagedDisplayWidget(parent),
buffer_(nullptr)
{
EnableDefaultContextMenu();
}
ScopeBase::~ScopeBase()
{
CleanUp();
if (context()) {
disconnect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &ScopeBase::CleanUp);
}
}
void ScopeBase::SetBuffer(Frame *frame)
{
buffer_ = frame;
UploadTextureFromBuffer();
}
void ScopeBase::showEvent(QShowEvent* e)
{
ManagedDisplayWidget::showEvent(e);
UploadTextureFromBuffer();
}
OpenGLShaderPtr ScopeBase::CreateShader()
{
return OpenGLShader::CreateDefault();
}
void ScopeBase::DrawScope()
{
managed_tex().Bind();
OpenGLRenderFunctions::Blit(pipeline());
managed_tex().Release();
}
OpenGLShaderPtr ScopeBase::pipeline()
{
return pipeline_;
}
OpenGLTexture &ScopeBase::managed_tex()
{
return managed_tex_;
}
void ScopeBase::UploadTextureFromBuffer()
{
if (!isVisible()) {
return;
}
if (buffer_) {
makeCurrent();
if (!texture_.IsCreated()
|| texture_.width() != buffer_->width()
|| texture_.height() != buffer_->height()
|| texture_.format() != buffer_->format()) {
texture_.Destroy();
managed_tex_.Destroy();
texture_.Create(context(), buffer_);
managed_tex_.Create(context(), buffer_->video_params());
} else {
texture_.Upload(buffer_);
}
doneCurrent();
}
update();
}
void ScopeBase::CleanUp()
{
makeCurrent();
pipeline_ = nullptr;
texture_.Destroy();
managed_tex_.Destroy();
framebuffer_.Destroy();
doneCurrent();
}
void ScopeBase::initializeGL()
{
ManagedDisplayWidget::initializeGL();
pipeline_ = CreateShader();
framebuffer_.Create(context());
connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &ScopeBase::CleanUp, Qt::DirectConnection);
UploadTextureFromBuffer();
}
void ScopeBase::paintGL()
{
QOpenGLFunctions* f = context()->functions();
f->glClearColor(0, 0, 0, 0);
f->glClear(GL_COLOR_BUFFER_BIT);
if (buffer_ && pipeline() && texture_.IsCreated()) {
// Convert reference frame to display space
framebuffer_.Attach(&managed_tex_);
framebuffer_.Bind();
texture_.Bind();
f->glViewport(0, 0, texture_.width(), texture_.height());
color_service()->ProcessOpenGL();
texture_.Release();
framebuffer_.Release();
framebuffer_.Detach();
f->glViewport(0, 0, width(), height());
DrawScope();
}
}
OLIVE_NAMESPACE_EXIT
+78
View File
@@ -0,0 +1,78 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 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 SCOPEBASE_H
#define SCOPEBASE_H
#include "codec/frame.h"
#include "render/backend/opengl/openglcolorprocessor.h"
#include "render/backend/opengl/openglframebuffer.h"
#include "render/backend/opengl/openglshader.h"
#include "render/backend/opengl/opengltexture.h"
#include "widget/manageddisplay/manageddisplay.h"
OLIVE_NAMESPACE_ENTER
class ScopeBase : public ManagedDisplayWidget
{
public:
ScopeBase(QWidget* parent = nullptr);
virtual ~ScopeBase() override;
public slots:
void SetBuffer(Frame* frame);
protected:
virtual void initializeGL() override;
virtual void paintGL() override;
virtual void showEvent(QShowEvent* e) override;
virtual OpenGLShaderPtr CreateShader();
virtual void DrawScope();
OpenGLShaderPtr pipeline();
OpenGLTexture& managed_tex();
private:
void UploadTextureFromBuffer();
OpenGLShaderPtr pipeline_;
OpenGLTexture texture_;
OpenGLTexture managed_tex_;
OpenGLFramebuffer framebuffer_;
Frame* buffer_;
private slots:
void CleanUp();
};
OLIVE_NAMESPACE_EXIT
#endif // SCOPEBASE_H
+38 -132
View File
@@ -32,59 +32,24 @@
OLIVE_NAMESPACE_ENTER
WaveformScope::WaveformScope(QWidget* parent) :
ManagedDisplayWidget(parent),
buffer_(nullptr)
ScopeBase(parent)
{
EnableDefaultContextMenu();
}
WaveformScope::~WaveformScope()
OpenGLShaderPtr WaveformScope::CreateShader()
{
CleanUp();
OpenGLShaderPtr pipeline = OpenGLShader::Create();
if (context()) {
disconnect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &WaveformScope::CleanUp);
}
pipeline->create();
pipeline->addShaderFromSourceCode(QOpenGLShader::Vertex, OpenGLShader::CodeDefaultVertex());
pipeline->addShaderFromSourceCode(QOpenGLShader::Fragment, Node::ReadFileAsString(":/shaders/rgbwaveform.frag"));
pipeline->link();
return pipeline;
}
void WaveformScope::SetBuffer(Frame *frame)
void WaveformScope::DrawScope()
{
buffer_ = frame;
UploadTextureFromBuffer();
}
void WaveformScope::showEvent(QShowEvent* e)
{
ManagedDisplayWidget::showEvent(e);
UploadTextureFromBuffer();
}
void WaveformScope::initializeGL()
{
ManagedDisplayWidget::initializeGL();
pipeline_ = OpenGLShader::Create();
pipeline_->create();
pipeline_->addShaderFromSourceCode(QOpenGLShader::Vertex, OpenGLShader::CodeDefaultVertex());
pipeline_->addShaderFromSourceCode(QOpenGLShader::Fragment, Node::ReadFileAsString(":/shaders/rgbwaveform.frag"));
pipeline_->link();
framebuffer_.Create(context());
connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &WaveformScope::CleanUp, Qt::DirectConnection);
UploadTextureFromBuffer();
}
void WaveformScope::paintGL()
{
QOpenGLFunctions* f = context()->functions();
f->glClearColor(0, 0, 0, 0);
f->glClear(GL_COLOR_BUFFER_BIT);
float waveform_scale = 0.80f;
float waveform_dim_x = width() * waveform_scale;
float waveform_dim_y = height() * waveform_scale;
@@ -93,66 +58,47 @@ void WaveformScope::paintGL()
float waveform_end_dim_x = width() - waveform_start_dim_x;
float waveform_end_dim_y = height() - waveform_start_dim_y;
if (buffer_ && pipeline_ && texture_.IsCreated()) {
// Convert reference frame to display space
framebuffer_.Attach(&managed_tex_);
framebuffer_.Bind();
// Draw waveform through shader
pipeline()->bind();
pipeline()->setUniformValue("ove_resolution", managed_tex().width(), managed_tex().height());
pipeline()->setUniformValue("ove_viewport", width(), height());
GLfloat luma[3] = {0.0, 0.0, 0.0};
color_manager()->GetDefaultLumaCoefs(luma);
pipeline()->setUniformValue("luma_coeffs", luma[0], luma[1], luma[2]);
texture_.Bind();
// Scale of the waveform relative to the viewport surface.
pipeline()->setUniformValue("waveform_scale", waveform_scale);
pipeline()->setUniformValue(
"waveform_dims", waveform_dim_x, waveform_dim_y);
f->glViewport(0, 0, texture_.width(), texture_.height());
pipeline()->setUniformValue(
"waveform_region",
waveform_start_dim_x, waveform_start_dim_y,
waveform_end_dim_x, waveform_end_dim_y);
color_service()->ProcessOpenGL();
float waveform_start_uv_x = waveform_start_dim_x / width();
float waveform_start_uv_y = waveform_start_dim_y / height();
float waveform_end_uv_x = waveform_end_dim_x / width();
float waveform_end_uv_y = waveform_end_dim_y / height();
pipeline()->setUniformValue(
"waveform_uv",
waveform_start_uv_x, waveform_start_uv_y,
waveform_end_uv_x, waveform_end_uv_y);
texture_.Release();
pipeline()->release();
framebuffer_.Release();
framebuffer_.Detach();
managed_tex().Bind();
// Draw waveform through shader
pipeline_->bind();
pipeline_->setUniformValue("ove_resolution", texture_.width(), texture_.height());
pipeline_->setUniformValue("ove_viewport", width(), height());
GLfloat luma[3] = {0.0, 0.0, 0.0};
color_manager()->GetDefaultLumaCoefs(luma);
pipeline_->setUniformValue("luma_coeffs", luma[0], luma[1], luma[2]);
OpenGLRenderFunctions::Blit(pipeline());
// Scale of the waveform relative to the viewport surface.
pipeline_->setUniformValue("waveform_scale", waveform_scale);
pipeline_->setUniformValue(
"waveform_dims", waveform_dim_x, waveform_dim_y);
pipeline_->setUniformValue(
"waveform_region",
waveform_start_dim_x, waveform_start_dim_y,
waveform_end_dim_x, waveform_end_dim_y);
float waveform_start_uv_x = waveform_start_dim_x / width();
float waveform_start_uv_y = waveform_start_dim_y / height();
float waveform_end_uv_x = waveform_end_dim_x / width();
float waveform_end_uv_y = waveform_end_dim_y / height();
pipeline_->setUniformValue(
"waveform_uv",
waveform_start_uv_x, waveform_start_uv_y,
waveform_end_uv_x, waveform_end_uv_y);
pipeline_->release();
f->glViewport(0, 0, width(), height());
managed_tex_.Bind();
OpenGLRenderFunctions::Blit(pipeline_);
managed_tex_.Release();
}
managed_tex().Release();
// Draw line overlays
QPainter p(this);
QFontMetrics font_metrics = QFontMetrics(QFont());
QString label;
float ire_increment = 0.1f;
float ire_steps = int(1.0 / ire_increment);
int ire_steps = qRound(1.0 / ire_increment);
QVector<QLine> ire_lines(ire_steps + 1);
int font_x_offset = 0;
int font_y_offset = font_metrics.capHeight() / 2.0f;
@@ -179,44 +125,4 @@ void WaveformScope::paintGL()
p.drawLines(ire_lines);
}
void WaveformScope::UploadTextureFromBuffer()
{
if (!isVisible()) {
return;
}
if (buffer_) {
makeCurrent();
if (!texture_.IsCreated()
|| texture_.width() != buffer_->width()
|| texture_.height() != buffer_->height()
|| texture_.format() != buffer_->format()) {
texture_.Destroy();
managed_tex_.Destroy();
texture_.Create(context(), buffer_);
managed_tex_.Create(context(), buffer_->video_params());
} else {
texture_.Upload(buffer_);
}
doneCurrent();
}
update();
}
void WaveformScope::CleanUp()
{
makeCurrent();
pipeline_ = nullptr;
texture_.Destroy();
managed_tex_.Destroy();
framebuffer_.Destroy();
doneCurrent();
}
OLIVE_NAMESPACE_EXIT
+4 -32
View File
@@ -21,48 +21,20 @@
#ifndef WAVEFORMSCOPE_H
#define WAVEFORMSCOPE_H
#include "codec/frame.h"
#include "render/backend/opengl/openglcolorprocessor.h"
#include "render/backend/opengl/openglframebuffer.h"
#include "render/backend/opengl/openglshader.h"
#include "render/backend/opengl/opengltexture.h"
#include "widget/manageddisplay/manageddisplay.h"
#include "widget/scope/scopebase/scopebase.h"
OLIVE_NAMESPACE_ENTER
class WaveformScope : public ManagedDisplayWidget
class WaveformScope : public ScopeBase
{
Q_OBJECT
public:
WaveformScope(QWidget* parent = nullptr);
virtual ~WaveformScope() override;
public slots:
void SetBuffer(Frame* frame);
protected:
virtual void initializeGL() override;
virtual OpenGLShaderPtr CreateShader() override;
virtual void paintGL() override;
virtual void showEvent(QShowEvent* e) override;
private:
void UploadTextureFromBuffer();
OpenGLShaderPtr pipeline_;
OpenGLTexture texture_;
OpenGLTexture managed_tex_;
OpenGLFramebuffer framebuffer_;
Frame* buffer_;
private slots:
void CleanUp();
virtual void DrawScope() override;
};
+33 -17
View File
@@ -22,6 +22,11 @@
#include <QApplication>
#include <QMouseEvent>
#include <QDebug>
#ifdef Q_OS_MAC
#include <ApplicationServices/ApplicationServices.h>
#endif
OLIVE_NAMESPACE_ENTER
@@ -48,40 +53,51 @@ SliderLabel::SliderLabel(QWidget *parent) :
setFocusPolicy(Qt::TabFocus);
}
void SliderLabel::mousePressEvent(QMouseEvent *ev)
void SliderLabel::mousePressEvent(QMouseEvent *)
{
QLabel::mousePressEvent(ev);
emit drag_start();
#if defined(Q_OS_MAC)
CGAssociateMouseAndMouseCursorPosition(false);
CGDisplayHideCursor(kCGDirectMainDisplay);
CGGetLastMouseDelta(nullptr, nullptr);
#else
drag_start_ = QCursor::pos();
static_cast<QGuiApplication*>(QApplication::instance())->setOverrideCursor(Qt::BlankCursor);
emit drag_start();
#endif
}
void SliderLabel::mouseMoveEvent(QMouseEvent *ev)
void SliderLabel::mouseMoveEvent(QMouseEvent *)
{
QLabel::mouseMoveEvent(ev);
QPoint current_pos = QCursor::pos();
int x_mvmt = current_pos.x() - drag_start_.x();
int y_mvmt = drag_start_.y() - current_pos.y();
emit dragged(x_mvmt + y_mvmt);
int32_t x_mvmt, y_mvmt;
// Keep cursor in the same position
#if defined(Q_OS_MAC)
CGGetLastMouseDelta(&x_mvmt, &y_mvmt);
#else
QPoint current_pos = QCursor::pos();
x_mvmt = current_pos.x() - drag_start_.x();
y_mvmt = drag_start_.y() - current_pos.y();
QCursor::setPos(drag_start_);
#endif
emit dragged(x_mvmt + y_mvmt);
}
void SliderLabel::mouseReleaseEvent(QMouseEvent *ev)
void SliderLabel::mouseReleaseEvent(QMouseEvent *)
{
QWidget::mouseReleaseEvent(ev);
#if defined(Q_OS_MAC)
CGAssociateMouseAndMouseCursorPosition(true);
CGDisplayShowCursor(kCGDirectMainDisplay);
#else
static_cast<QGuiApplication*>(QApplication::instance())->restoreOverrideCursor();
#endif
// Emit a clicked signal
emit drag_stop();
static_cast<QGuiApplication*>(QApplication::instance())->restoreOverrideCursor();
}
void SliderLabel::focusInEvent(QFocusEvent *event)
+2
View File
@@ -54,6 +54,8 @@ signals:
private:
QPoint drag_start_;
bool cancel_mm_event_;
};
OLIVE_NAMESPACE_EXIT
+22
View File
@@ -0,0 +1,22 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2019 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/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
widget/timetarget/timetarget.h
widget/timetarget/timetarget.cpp
PARENT_SCOPE
)
@@ -18,7 +18,7 @@
***/
#include "timetargetobject.h"
#include "timetarget.h"
OLIVE_NAMESPACE_ENTER
+2 -2
View File
@@ -20,8 +20,8 @@ set(OLIVE_SOURCES
widget/viewer/audiowaveformview.cpp
widget/viewer/footageviewer.h
widget/viewer/footageviewer.cpp
widget/viewer/pixelsamplerwidget.h
widget/viewer/pixelsamplerwidget.cpp
widget/viewer/gizmotraverser.h
widget/viewer/gizmotraverser.cpp
widget/viewer/viewer.h
widget/viewer/viewer.cpp
widget/viewer/viewerdisplay.h
+39
View File
@@ -0,0 +1,39 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 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 "gizmotraverser.h"
OLIVE_NAMESPACE_ENTER
void GizmoTraverser::FootageProcessingEvent(StreamPtr stream, const TimeRange &/*input_time*/, NodeValueTable *table)
{
if (stream->type() == Stream::kVideo || stream->type() == Stream::kAudio) {
ImageStreamPtr image_stream = std::static_pointer_cast<ImageStream>(stream);
table->Push(NodeParam::kTexture, QSize(image_stream->width(),
image_stream->height()));
} else if (stream->type() == Stream::kAudio) {
// FIXME: Get samples
}
}
OLIVE_NAMESPACE_EXIT
+40
View File
@@ -0,0 +1,40 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 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 GIZMOTRAVERSER_H
#define GIZMOTRAVERSER_H
#include "node/traverser.h"
OLIVE_NAMESPACE_ENTER
class GizmoTraverser : public NodeTraverser
{
public:
GizmoTraverser() = default;
protected:
virtual void FootageProcessingEvent(StreamPtr stream, const TimeRange &input_time, NodeValueTable* table) override;
};
OLIVE_NAMESPACE_EXIT
#endif // GIZMOTRAVERSER_H
+19 -1
View File
@@ -105,6 +105,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
connect(video_renderer_, &VideoRenderBackend::CachedTimeReady, this, &ViewerWidget::RendererCachedTime);
connect(video_renderer_, &VideoRenderBackend::CachedTimeReady, ruler(), &TimeRuler::CacheTimeReady);
connect(video_renderer_, &VideoRenderBackend::RangeInvalidated, ruler(), &TimeRuler::CacheInvalidatedRange);
connect(video_renderer_, &VideoRenderBackend::GeneratedFrame, this, &ViewerWidget::RendererGeneratedFrame);
audio_renderer_ = new AudioBackend(this);
waveform_view_->SetBackend(audio_renderer_);
@@ -130,6 +131,8 @@ void ViewerWidget::TimeChangedEvent(const int64_t &i)
UpdateTextureFromNode(time_set);
PushScrubbedAudio();
main_gl_widget()->SetTime(time_set);
}
last_time_ = i;
@@ -333,6 +336,12 @@ ColorManager *ViewerWidget::color_manager() const
return main_gl_widget()->color_manager();
}
void ViewerWidget::SetGizmos(Node *node)
{
main_gl_widget()->SetTimeTarget(GetConnectedNode());
main_gl_widget()->SetGizmos(node);
}
void ViewerWidget::UpdateTextureFromNode(const rational& time)
{
if (!GetConnectedNode() || time >= GetConnectedNode()->Length()) {
@@ -514,6 +523,13 @@ void ViewerWidget::ContextMenuScopeTriggered(QAction *action)
emit RequestScopePanel(static_cast<ScopePanel::Type>(action->data().toInt()));
}
void ViewerWidget::RendererGeneratedFrame(FramePtr f)
{
foreach (ViewerDisplayWidget* glw, gl_widgets_) {
glw->SetImageFromLoadBuffer(f.get());
}
}
void ViewerWidget::UpdateRendererParameters()
{
if (!GetConnectedNode()) {
@@ -532,6 +548,8 @@ void ViewerWidget::UpdateRendererParameters()
video_renderer_->InvalidateCache(TimeRange(0, GetConnectedNode()->Length()), nullptr);
}
main_gl_widget()->SetVideoParams(vparam);
AudioRenderingParams aparam(GetConnectedNode()->audio_params(),
SampleFormat::kInternalFormat);
@@ -868,7 +886,7 @@ void ViewerWidget::SetZoomFromMenu(QAction *action)
void ViewerWidget::InvalidateVisible(NodeInput* source)
{
video_renderer_->InvalidateCache(TimeRange(GetTime(), GetTime()), source);
video_renderer_->InvalidateVisible(TimeRange(GetTime(), GetTime()), source);
}
OLIVE_NAMESPACE_EXIT
+4
View File
@@ -87,6 +87,8 @@ public:
ColorManager* color_manager() const;
void SetGizmos(Node* node);
public slots:
void Play(bool in_to_out_only);
@@ -234,6 +236,8 @@ private slots:
void ContextMenuScopeTriggered(QAction* action);
void RendererGeneratedFrame(FramePtr f);
};
OLIVE_NAMESPACE_EXIT
+82 -2
View File
@@ -30,6 +30,7 @@
#include <QPainter>
#include "common/define.h"
#include "gizmotraverser.h"
#include "render/backend/opengl/openglrenderfunctions.h"
#include "render/backend/opengl/openglshader.h"
#include "render/pixelformat.h"
@@ -43,7 +44,9 @@ bool ViewerDisplayWidget::nouveau_check_done_ = false;
ViewerDisplayWidget::ViewerDisplayWidget(QWidget *parent) :
ManagedDisplayWidget(parent),
has_image_(false),
signal_cursor_color_(false)
signal_cursor_color_(false),
gizmos_(nullptr),
gizmo_click_(false)
{
}
@@ -161,8 +164,40 @@ void ViewerDisplayWidget::SetSafeMargins(const ViewerSafeMarginInfo &safe_margin
update();
}
void ViewerDisplayWidget::SetGizmos(Node *node)
{
gizmos_ = node;
update();
}
void ViewerDisplayWidget::SetVideoParams(const VideoRenderingParams &params)
{
gizmo_params_ = params;
if (gizmos_) {
update();
}
}
void ViewerDisplayWidget::SetTime(const rational &time)
{
time_ = time;
if (gizmos_) {
update();
}
}
void ViewerDisplayWidget::mousePressEvent(QMouseEvent *event)
{
if (gizmos_) {
if (gizmos_->GizmoPress(GetTexturePosition(event->pos()))) {
gizmo_click_ = true;
return;
}
}
QOpenGLWidget::mousePressEvent(event);
emit DragStarted();
@@ -170,6 +205,11 @@ void ViewerDisplayWidget::mousePressEvent(QMouseEvent *event)
void ViewerDisplayWidget::mouseMoveEvent(QMouseEvent *event)
{
if (gizmo_click_) {
gizmos_->GizmoMove(GetTexturePosition(event->pos()));
return;
}
QOpenGLWidget::mouseMoveEvent(event);
if (signal_cursor_color_) {
@@ -193,6 +233,18 @@ void ViewerDisplayWidget::mouseMoveEvent(QMouseEvent *event)
}
}
void ViewerDisplayWidget::mouseReleaseEvent(QMouseEvent *event)
{
if (gizmo_click_) {
gizmos_->GizmoRelease(GetTexturePosition(event->pos()));
gizmo_click_ = false;
return;
}
QOpenGLWidget::mouseReleaseEvent(event);
}
void ViewerDisplayWidget::initializeGL()
{
ManagedDisplayWidget::initializeGL();
@@ -225,7 +277,7 @@ void ViewerDisplayWidget::paintGL()
f->glClear(GL_COLOR_BUFFER_BIT);
// We only draw if we have a pipeline
if (has_image_ && color_service() && texture_.IsCreated()) {
if (has_image_ && color_service()) {
// Bind retrieved texture
f->glBindTexture(GL_TEXTURE_2D, texture_.texture());
@@ -238,6 +290,18 @@ void ViewerDisplayWidget::paintGL()
}
// Draw gizmos if we have any
if (gizmos_) {
GizmoTraverser gt;
rational node_time = GetAdjustedTime(GetTimeTarget(), gizmos_, time_, NodeParam::kInput);
NodeValueDatabase db = gt.GenerateDatabase(gizmos_, TimeRange(node_time, node_time));
QPainter p(this);
gizmos_->DrawGizmos(db, &p, QVector2D(GetTexturePosition(size())));
}
// Draw action/title safe areas
if (safe_margin_.is_enabled()) {
QPainter p(this);
@@ -271,6 +335,22 @@ void ViewerDisplayWidget::paintGL()
}
}
QPointF ViewerDisplayWidget::GetTexturePosition(const QPoint &screen_pos)
{
return GetTexturePosition(screen_pos.x(), screen_pos.y());
}
QPointF ViewerDisplayWidget::GetTexturePosition(const QSize &size)
{
return GetTexturePosition(size.width(), size.height());
}
QPointF ViewerDisplayWidget::GetTexturePosition(const double &x, const double &y)
{
return QPointF(x / gizmo_params_.width(),
y / gizmo_params_.height());
}
#ifdef Q_OS_LINUX
void ViewerDisplayWidget::ShowNouveauWarning()
{
+26 -3
View File
@@ -23,6 +23,7 @@
#include <QOpenGLWidget>
#include "node/node.h"
#include "render/backend/opengl/openglcolorprocessor.h"
#include "render/backend/opengl/openglframebuffer.h"
#include "render/backend/opengl/openglshader.h"
@@ -31,6 +32,7 @@
#include "render/colormanager.h"
#include "viewersafemargininfo.h"
#include "widget/manageddisplay/manageddisplay.h"
#include "widget/timetarget/timetarget.h"
OLIVE_NAMESPACE_ENTER
@@ -49,7 +51,7 @@ OLIVE_NAMESPACE_ENTER
* the same texture object, use SetTexture() since it will nearly always be faster to just set it than to check *and*
* set it.
*/
class ViewerDisplayWidget : public ManagedDisplayWidget
class ViewerDisplayWidget : public ManagedDisplayWidget, public TimeTargetObject
{
Q_OBJECT
public:
@@ -76,6 +78,10 @@ public:
const ViewerSafeMarginInfo& GetSafeMargin() const;
void SetSafeMargins(const ViewerSafeMarginInfo& safe_margin);
void SetGizmos(Node* node);
void SetVideoParams(const VideoRenderingParams& params);
void SetTime(const rational& time);
public slots:
/**
* @brief Set the transformation matrix to draw with
@@ -123,15 +129,20 @@ signals:
protected:
/**
* @brief Override the mouse press event simply to emit the DragStarted() signal
* @brief Override the mouse press event for the DragStarted() signal and gizmos
*/
virtual void mousePressEvent(QMouseEvent* event) override;
/**
* @brief Override mouse move to provide functionality for
* @brief Override mouse move to signal for the pixel sampler and gizmos
*/
virtual void mouseMoveEvent(QMouseEvent* event) override;
/**
* @brief Override mouse release event for gizmos
*/
virtual void mouseReleaseEvent(QMouseEvent* event) override;
/**
* @brief Initialize function to set up the OpenGL context upon its construction
*
@@ -147,6 +158,10 @@ protected:
virtual void paintGL() override;
private:
QPointF GetTexturePosition(const QPoint& screen_pos);
QPointF GetTexturePosition(const QSize& size);
QPointF GetTexturePosition(const double& x, const double& y);
/**
* @brief Internal reference to the OpenGL texture to draw. Set in SetTexture() and used in paintGL().
*/
@@ -172,6 +187,14 @@ private:
ViewerSafeMarginInfo safe_margin_;
Node* gizmos_;
VideoRenderingParams gizmo_params_;
bool gizmo_click_;
rational time_;
private slots:
/**
* @brief Slot to connect just before the OpenGL context is destroyed to clean up resources