ui: use QOpenGLWindow instead of QOpenGLWidget for all panels
This commit is contained in:
@@ -25,9 +25,9 @@ namespace olive {
|
||||
AudioMonitorPanel::AudioMonitorPanel(QWidget *parent) :
|
||||
PanelWidget(QStringLiteral("AudioMonitor"), parent)
|
||||
{
|
||||
audio_monitor_ = new AudioMonitor(this);
|
||||
audio_monitor_ = new AudioMonitor();
|
||||
|
||||
setWidget(audio_monitor_);
|
||||
setWidget(QWidget::createWindowContainer(audio_monitor_));
|
||||
|
||||
Retranslate();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "audiomonitor.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
|
||||
@@ -35,8 +36,7 @@ const int kMaximumSmoothness = 8;
|
||||
|
||||
QVector<AudioMonitor*> AudioMonitor::instances_;
|
||||
|
||||
AudioMonitor::AudioMonitor(QWidget *parent) :
|
||||
QOpenGLWidget(parent),
|
||||
AudioMonitor::AudioMonitor() :
|
||||
waveform_(nullptr),
|
||||
cached_channels_(0)
|
||||
{
|
||||
@@ -125,7 +125,10 @@ void AudioMonitor::SetUpdateLoop(bool e)
|
||||
void AudioMonitor::paintGL()
|
||||
{
|
||||
QPainter p(this);
|
||||
p.fillRect(rect(), palette().window().color());
|
||||
QPalette palette = qApp->palette();
|
||||
QRect geometry(0, 0, width(), height());
|
||||
|
||||
p.fillRect(geometry, palette.window().color());
|
||||
|
||||
if (!params_.channel_count()) {
|
||||
return;
|
||||
@@ -137,12 +140,12 @@ void AudioMonitor::paintGL()
|
||||
int font_height = fm.height();
|
||||
|
||||
// Create rect where decibel markings will go on the side
|
||||
QRect db_labels_rect = rect();
|
||||
QRect db_labels_rect = geometry;
|
||||
db_labels_rect.setWidth(QtUtils::QFontMetricsWidth(p.fontMetrics(), "-00"));
|
||||
db_labels_rect.adjust(0, font_height, 0, 0);
|
||||
|
||||
// Determine rect where the main meter will go
|
||||
QRect full_meter_rect = rect();
|
||||
QRect full_meter_rect = geometry;
|
||||
full_meter_rect.adjust(db_labels_rect.width(), font_height, 0, 0);
|
||||
|
||||
// Width of each channel in the meter
|
||||
@@ -163,7 +166,7 @@ void AudioMonitor::paintGL()
|
||||
// Draw decibel markings
|
||||
QRect last_db_marking_rect;
|
||||
|
||||
cached_painter.setPen(palette().text().color());
|
||||
cached_painter.setPen(palette.text().color());
|
||||
|
||||
for (int i=0;i>=kDecibelMinimum;i-=kDecibelStep) {
|
||||
QString db_label;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#define AUDIOMONITORWIDGET_H
|
||||
|
||||
#include <QFile>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QOpenGLWindow>
|
||||
#include <QTimer>
|
||||
|
||||
#include "audio/audiovisualwaveform.h"
|
||||
@@ -32,11 +32,11 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
class AudioMonitor : public QOpenGLWidget
|
||||
class AudioMonitor : public QOpenGLWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AudioMonitor(QWidget* parent = nullptr);
|
||||
AudioMonitor();
|
||||
|
||||
virtual ~AudioMonitor() override;
|
||||
|
||||
|
||||
@@ -61,11 +61,14 @@ ManagedDisplayWidget::ManagedDisplayWidget(QWidget *parent) :
|
||||
|
||||
// Create OpenGL renderer
|
||||
attached_renderer_ = new OpenGLRenderer(this);
|
||||
|
||||
// Create widget wrapper for OpenGL window
|
||||
wrapper_ = QWidget::createWindowContainer(static_cast<ManagedDisplayWidgetOpenGL*>(inner_widget_));
|
||||
layout->addWidget(wrapper_);
|
||||
} else {
|
||||
inner_widget_ = nullptr;
|
||||
wrapper_ = nullptr;
|
||||
}
|
||||
|
||||
layout->addWidget(inner_widget_);
|
||||
}
|
||||
|
||||
ManagedDisplayWidget::~ManagedDisplayWidget()
|
||||
@@ -253,6 +256,22 @@ void ManagedDisplayWidget::doneCurrent()
|
||||
}
|
||||
}
|
||||
|
||||
QPaintDevice *ManagedDisplayWidget::paint_device() const
|
||||
{
|
||||
if (RenderManager::instance()->backend() == RenderManager::kOpenGL) {
|
||||
return static_cast<ManagedDisplayWidgetOpenGL*>(inner_widget_);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::SetInnerMouseTracking(bool e)
|
||||
{
|
||||
if (wrapper_) {
|
||||
wrapper_->setMouseTracking(e);
|
||||
}
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::update()
|
||||
{
|
||||
if (RenderManager::instance()->backend() == RenderManager::kOpenGL) {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QOpenGLContext>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QOpenGLWindow>
|
||||
|
||||
#include "node/color/colormanager/colormanager.h"
|
||||
#include "render/renderer.h"
|
||||
@@ -31,14 +31,11 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
class ManagedDisplayWidgetOpenGL : public QOpenGLWidget
|
||||
class ManagedDisplayWidgetOpenGL : public QOpenGLWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ManagedDisplayWidgetOpenGL(QWidget* parent = nullptr) :
|
||||
QOpenGLWidget(parent)
|
||||
{
|
||||
}
|
||||
ManagedDisplayWidgetOpenGL() = default;
|
||||
|
||||
signals:
|
||||
void OnInit();
|
||||
@@ -67,7 +64,7 @@ protected:
|
||||
{
|
||||
emit OnMouseMove(e);
|
||||
|
||||
QOpenGLWidget::mouseMoveEvent(e);
|
||||
QOpenGLWindow::mouseMoveEvent(e);
|
||||
}
|
||||
|
||||
private slots:
|
||||
@@ -188,11 +185,26 @@ protected:
|
||||
|
||||
void doneCurrent();
|
||||
|
||||
QWidget* inner_widget() const
|
||||
QWindow* inner_widget() const
|
||||
{
|
||||
return inner_widget_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get inner widget as paint device for QPainter
|
||||
*
|
||||
* NOTE: This will be incompatible with QVulkanWindow so functions using it
|
||||
* will need to be replaced soon.
|
||||
*/
|
||||
QPaintDevice *paint_device() const;
|
||||
|
||||
void SetInnerMouseTracking(bool e);
|
||||
|
||||
QRect GetInnerRect() const
|
||||
{
|
||||
return wrapper_ ? wrapper_->rect() : QRect();
|
||||
}
|
||||
|
||||
protected slots:
|
||||
/**
|
||||
* @brief Called whenever the internal rendering context has been created
|
||||
@@ -223,7 +235,8 @@ private:
|
||||
/**
|
||||
* @brief Main drawing surface abstraction
|
||||
*/
|
||||
QWidget* inner_widget_;
|
||||
QWindow* inner_widget_;
|
||||
QWidget *wrapper_;
|
||||
|
||||
/**
|
||||
* @brief Renderer abstraction
|
||||
|
||||
@@ -91,7 +91,7 @@ void HistogramScope::DrawScope(TexturePtr managed_tex, QVariant pipeline)
|
||||
renderer()->Blit(pipeline_secondary_, shader_job, texture_row_sums_->params());
|
||||
|
||||
// Draw line overlays
|
||||
QPainter p(inner_widget());
|
||||
QPainter p(paint_device());
|
||||
QFont font = p.font();
|
||||
font.setPixelSize(10);
|
||||
QFontMetrics font_metrics = QFontMetrics(font);
|
||||
|
||||
@@ -85,7 +85,7 @@ void WaveformScope::DrawScope(TexturePtr managed_tex, QVariant pipeline)
|
||||
float waveform_end_dim_x = (width() - 1.0) - waveform_start_dim_x;
|
||||
|
||||
// Draw line overlays
|
||||
QPainter p(inner_widget());
|
||||
QPainter p(paint_device());
|
||||
QFont font;
|
||||
font.setPixelSize(10);
|
||||
QFontMetrics font_metrics = QFontMetrics(font);
|
||||
|
||||
@@ -117,7 +117,7 @@ void ViewerDisplayWidget::UpdateCursor()
|
||||
void ViewerDisplayWidget::SetSignalCursorColorEnabled(bool e)
|
||||
{
|
||||
signal_cursor_color_ = e;
|
||||
inner_widget()->setMouseTracking(e);
|
||||
SetInnerMouseTracking(e);
|
||||
}
|
||||
|
||||
void ViewerDisplayWidget::SetImage(const QVariant &buffer)
|
||||
@@ -511,7 +511,7 @@ void ViewerDisplayWidget::OnPaint()
|
||||
TimeRange range = GenerateGizmoTime();
|
||||
gizmo_db_ = gt.GenerateRow(gizmos_, range);
|
||||
|
||||
QPainter p(inner_widget());
|
||||
QPainter p(paint_device());
|
||||
gizmo_last_draw_transform_ = GenerateGizmoTransform(gt, range);
|
||||
p.setWorldTransform(gizmo_last_draw_transform_);
|
||||
|
||||
@@ -525,7 +525,7 @@ void ViewerDisplayWidget::OnPaint()
|
||||
|
||||
// Draw action/title safe areas
|
||||
if (safe_margin_.is_enabled()) {
|
||||
QPainter p(inner_widget());
|
||||
QPainter p(paint_device());
|
||||
p.setWorldTransform(GenerateWorldTransform());
|
||||
|
||||
p.setPen(QPen(Qt::lightGray, 0));
|
||||
@@ -575,7 +575,7 @@ void ViewerDisplayWidget::OnPaint()
|
||||
}
|
||||
|
||||
if (frame_rate_average_count_ >= frame_rate_averages_.size()) {
|
||||
QPainter p(inner_widget());
|
||||
QPainter p(paint_device());
|
||||
|
||||
double average = 0.0;
|
||||
for (int i=0; i<frame_rate_averages_.size(); i++) {
|
||||
@@ -583,10 +583,10 @@ void ViewerDisplayWidget::OnPaint()
|
||||
}
|
||||
average /= double(frame_rate_averages_.size());
|
||||
|
||||
DrawTextWithCrudeShadow(&p, inner_widget()->rect(), tr("%1 FPS").arg(QString::number(average, 'f', 1)));
|
||||
DrawTextWithCrudeShadow(&p, GetInnerRect(), tr("%1 FPS").arg(QString::number(average, 'f', 1)));
|
||||
|
||||
if (frames_skipped_ > 0) {
|
||||
DrawTextWithCrudeShadow(&p, inner_widget()->rect().adjusted(0, p.fontMetrics().height(), 0, 0),
|
||||
DrawTextWithCrudeShadow(&p, GetInnerRect().adjusted(0, p.fontMetrics().height(), 0, 0),
|
||||
tr("%1 frames skipped").arg(frames_skipped_));
|
||||
}
|
||||
}
|
||||
@@ -597,7 +597,7 @@ void ViewerDisplayWidget::OnPaint()
|
||||
const QVector<Track*> &subtitle_tracklist = subtitle_tracks_->track_list(Track::kSubtitle)->GetTracks();
|
||||
|
||||
if (!subtitle_tracklist.empty()) {
|
||||
QPainter p(inner_widget());
|
||||
QPainter p(paint_device());
|
||||
|
||||
QTransform transform = GenerateWorldTransform();
|
||||
QRect bounding_box = transform.mapRect(rect());
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#define VIEWERGLWIDGET_H
|
||||
|
||||
#include <QMatrix4x4>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QRubberBand>
|
||||
|
||||
#include "node/color/colormanager/colormanager.h"
|
||||
|
||||
Reference in New Issue
Block a user