viewer: provide UI to set preview resolution
Previews don't need to be rendered full resolution, particularly since the preview is hardly ever 1:1 size of the sequence. The functionality to render at lower resolutions already existed, but there was no UI for it. This commit implements UI to set the resolution divider on the viewer.
This commit is contained in:
@@ -73,6 +73,7 @@ void Config::SetDefaults()
|
||||
config_map_["AddDefaultEffectsToClips"] = true;
|
||||
config_map_["AutoscaleByDefault"] = false;
|
||||
config_map_["Autoscroll"] = AutoScroll::kPage;
|
||||
config_map_["DefaultViewerDivider"] = 2;
|
||||
|
||||
config_map_["DiskCachePath"] = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
|
||||
config_map_["DiskCacheSize"] = 20.0;
|
||||
|
||||
@@ -32,11 +32,14 @@
|
||||
#include "project/item/sequence/sequence.h"
|
||||
#include "project/project.h"
|
||||
#include "render/pixelservice.h"
|
||||
#include "widget/menu/menu.h"
|
||||
|
||||
ViewerWidget::ViewerWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
viewer_node_(nullptr),
|
||||
playback_speed_(0)
|
||||
playback_speed_(0),
|
||||
color_menu_enabled_(true),
|
||||
divider_(Config::Current()["DefaultViewerDivider"].toInt())
|
||||
{
|
||||
// Set up main layout
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
@@ -47,6 +50,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
|
||||
layout->addWidget(sizer_);
|
||||
|
||||
gl_widget_ = new ViewerGLWidget();
|
||||
connect(gl_widget_, &ViewerGLWidget::customContextMenuRequested, this, &ViewerWidget::ShowContextMenu);
|
||||
sizer_->SetWidget(gl_widget_);
|
||||
|
||||
// Create time ruler
|
||||
@@ -190,7 +194,7 @@ ViewerOutput *ViewerWidget::GetConnectedViewer() const
|
||||
|
||||
void ViewerWidget::SetColorMenuEnabled(bool enabled)
|
||||
{
|
||||
gl_widget_->SetColorMenuEnabled(enabled);
|
||||
color_menu_enabled_ = enabled;
|
||||
}
|
||||
|
||||
void ViewerWidget::SetOverrideSize(int width, int height)
|
||||
@@ -297,13 +301,74 @@ void ViewerWidget::UpdateRendererParameters()
|
||||
video_renderer_->SetParameters(VideoRenderingParams(viewer_node_->video_params(),
|
||||
PixelService::instance()->GetConfiguredFormatForMode(render_mode),
|
||||
render_mode,
|
||||
2));
|
||||
divider_));
|
||||
audio_renderer_->SetParameters(AudioRenderingParams(viewer_node_->audio_params(),
|
||||
SampleFormat::GetConfiguredFormatForMode(render_mode)));
|
||||
|
||||
video_renderer_->InvalidateCache(0, viewer_node_->Length());
|
||||
}
|
||||
|
||||
void ViewerWidget::ShowContextMenu(const QPoint &pos)
|
||||
{
|
||||
QMenu menu;
|
||||
|
||||
// Color options
|
||||
if (gl_widget_->color_manager() && color_menu_enabled_) {
|
||||
QStringList displays = gl_widget_->color_manager()->ListAvailableDisplays();
|
||||
QMenu* ocio_display_menu = menu.addMenu(tr("Display"));
|
||||
connect(ocio_display_menu, &QMenu::triggered, this, &ViewerWidget::ColorDisplayChanged);
|
||||
foreach (const QString& d, displays) {
|
||||
QAction* action = ocio_display_menu->addAction(d);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(gl_widget_->ocio_display() == d);
|
||||
action->setData(d);
|
||||
}
|
||||
|
||||
QStringList views = gl_widget_->color_manager()->ListAvailableViews(gl_widget_->ocio_display());
|
||||
QMenu* ocio_view_menu = menu.addMenu(tr("View"));
|
||||
connect(ocio_view_menu, &QMenu::triggered, this, &ViewerWidget::ColorViewChanged);
|
||||
foreach (const QString& v, views) {
|
||||
QAction* action = ocio_view_menu->addAction(v);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(gl_widget_->ocio_view() == v);
|
||||
action->setData(v);
|
||||
}
|
||||
|
||||
QStringList looks = gl_widget_->color_manager()->ListAvailableLooks();
|
||||
QMenu* ocio_look_menu = menu.addMenu(tr("Look"));
|
||||
connect(ocio_look_menu, &QMenu::triggered, this, &ViewerWidget::ColorLookChanged);
|
||||
QAction* no_look_action = ocio_look_menu->addAction(tr("(None)"));
|
||||
no_look_action->setCheckable(true);
|
||||
no_look_action->setChecked(gl_widget_->ocio_look().isEmpty());
|
||||
foreach (const QString& l, looks) {
|
||||
QAction* action = ocio_look_menu->addAction(l);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(gl_widget_->ocio_look() == l);
|
||||
action->setData(l);
|
||||
}
|
||||
|
||||
menu.addSeparator();
|
||||
}
|
||||
|
||||
// Playback resolution
|
||||
QMenu* playback_resolution_menu = menu.addMenu(tr("Resolution"));
|
||||
playback_resolution_menu->addAction(tr("Full"))->setData(1);
|
||||
playback_resolution_menu->addAction(tr("1/2"))->setData(2);
|
||||
playback_resolution_menu->addAction(tr("1/4"))->setData(4);
|
||||
playback_resolution_menu->addAction(tr("1/8"))->setData(8);
|
||||
playback_resolution_menu->addAction(tr("1/16"))->setData(16);
|
||||
connect(playback_resolution_menu, &QMenu::triggered, this, &ViewerWidget::SetDividerFromMenu);
|
||||
|
||||
foreach (QAction* a, playback_resolution_menu->actions()) {
|
||||
a->setCheckable(true);
|
||||
if (a->data() == divider_) {
|
||||
a->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
menu.exec(mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void ViewerWidget::RulerTimeChange(int64_t i)
|
||||
{
|
||||
Pause();
|
||||
@@ -461,3 +526,32 @@ void ViewerWidget::resizeEvent(QResizeEvent *event)
|
||||
// Set scrollbar page step to the width
|
||||
scrollbar_->setPageStep(event->size().width());
|
||||
}
|
||||
|
||||
void ViewerWidget::ColorDisplayChanged(QAction* action)
|
||||
{
|
||||
SetOCIODisplay(action->data().toString());
|
||||
}
|
||||
|
||||
void ViewerWidget::ColorViewChanged(QAction *action)
|
||||
{
|
||||
SetOCIOView(action->data().toString());
|
||||
}
|
||||
|
||||
void ViewerWidget::ColorLookChanged(QAction *action)
|
||||
{
|
||||
SetOCIOLook(action->data().toString());
|
||||
}
|
||||
|
||||
void ViewerWidget::SetDividerFromMenu(QAction *action)
|
||||
{
|
||||
int divider = action->data().toInt();
|
||||
|
||||
if (divider <= 0) {
|
||||
qWarning() << "Tried to set invalid divider:" << divider;
|
||||
return;
|
||||
}
|
||||
|
||||
divider_ = divider;
|
||||
|
||||
UpdateRendererParameters();
|
||||
}
|
||||
|
||||
@@ -67,6 +67,12 @@ public:
|
||||
|
||||
ViewerOutput* GetConnectedViewer() const;
|
||||
|
||||
/**
|
||||
* @brief Enable or disable the color management menu
|
||||
*
|
||||
* While the Viewer is _always_ color managed, In some contexts, the color management may be controlled from an
|
||||
* external UI making the menu unnecessary.
|
||||
*/
|
||||
void SetColorMenuEnabled(bool enabled);
|
||||
|
||||
void SetOverrideSize(int width, int height);
|
||||
@@ -173,6 +179,10 @@ private:
|
||||
|
||||
int64_t last_time_;
|
||||
|
||||
bool color_menu_enabled_;
|
||||
|
||||
int divider_;
|
||||
|
||||
private slots:
|
||||
void RulerTimeChange(int64_t);
|
||||
|
||||
@@ -187,6 +197,25 @@ private slots:
|
||||
|
||||
void UpdateRendererParameters();
|
||||
|
||||
void ShowContextMenu(const QPoint& pos);
|
||||
|
||||
/**
|
||||
* @brief Slot called whenever this viewer's OCIO display setting has changed
|
||||
*/
|
||||
void ColorDisplayChanged(QAction* action);
|
||||
|
||||
/**
|
||||
* @brief Slot called whenever this viewer's OCIO view setting has changed
|
||||
*/
|
||||
void ColorViewChanged(QAction* action);
|
||||
|
||||
/**
|
||||
* @brief Slot called whenever this viewer's OCIO look setting has changed
|
||||
*/
|
||||
void ColorLookChanged(QAction* action);
|
||||
|
||||
void SetDividerFromMenu(QAction* action);
|
||||
|
||||
};
|
||||
|
||||
#endif // VIEWER_WIDGET_H
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "viewerglwidget.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QOpenGLContext>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLTexture>
|
||||
@@ -32,11 +31,9 @@ ViewerGLWidget::ViewerGLWidget(QWidget *parent) :
|
||||
QOpenGLWidget(parent),
|
||||
texture_(0),
|
||||
ocio_lut_(0),
|
||||
color_manager_(nullptr),
|
||||
color_menu_enabled_(true)
|
||||
color_manager_(nullptr)
|
||||
{
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu(const QPoint&)));
|
||||
}
|
||||
|
||||
ViewerGLWidget::~ViewerGLWidget()
|
||||
@@ -44,11 +41,6 @@ ViewerGLWidget::~ViewerGLWidget()
|
||||
ContextCleanup();
|
||||
}
|
||||
|
||||
void ViewerGLWidget::SetColorMenuEnabled(bool enabled)
|
||||
{
|
||||
color_menu_enabled_ = enabled;
|
||||
}
|
||||
|
||||
void ViewerGLWidget::ConnectColorManager(ColorManager *color_manager)
|
||||
{
|
||||
if (color_manager_ != nullptr) {
|
||||
@@ -96,6 +88,26 @@ void ViewerGLWidget::SetOCIOLook(const QString &look)
|
||||
update();
|
||||
}
|
||||
|
||||
ColorManager *ViewerGLWidget::color_manager() const
|
||||
{
|
||||
return color_manager_;
|
||||
}
|
||||
|
||||
const QString &ViewerGLWidget::ocio_display() const
|
||||
{
|
||||
return ocio_display_;
|
||||
}
|
||||
|
||||
const QString &ViewerGLWidget::ocio_view() const
|
||||
{
|
||||
return ocio_view_;
|
||||
}
|
||||
|
||||
const QString &ViewerGLWidget::ocio_look() const
|
||||
{
|
||||
return ocio_look_;
|
||||
}
|
||||
|
||||
void ViewerGLWidget::SetTexture(OpenGLTexturePtr tex)
|
||||
{
|
||||
// Update the texture
|
||||
@@ -213,60 +225,3 @@ void ViewerGLWidget::ContextCleanup()
|
||||
|
||||
doneCurrent();
|
||||
}
|
||||
|
||||
void ViewerGLWidget::ShowContextMenu(const QPoint &pos)
|
||||
{
|
||||
QMenu menu;
|
||||
|
||||
if (color_menu_enabled_) {
|
||||
QStringList displays = color_manager_->ListAvailableDisplays();
|
||||
QMenu* ocio_display_menu = menu.addMenu(tr("Display"));
|
||||
connect(ocio_display_menu, SIGNAL(triggered(QAction*)), this, SLOT(ColorDisplayChanged(QAction*)));
|
||||
foreach (const QString& d, displays) {
|
||||
QAction* action = ocio_display_menu->addAction(d);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(ocio_display_ == d);
|
||||
action->setData(d);
|
||||
}
|
||||
|
||||
QStringList views = color_manager_->ListAvailableViews(ocio_display_);
|
||||
QMenu* ocio_view_menu = menu.addMenu(tr("View"));
|
||||
connect(ocio_view_menu, SIGNAL(triggered(QAction*)), this, SLOT(ColorViewChanged(QAction*)));
|
||||
foreach (const QString& v, views) {
|
||||
QAction* action = ocio_view_menu->addAction(v);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(ocio_view_ == v);
|
||||
action->setData(v);
|
||||
}
|
||||
|
||||
QStringList looks = color_manager_->ListAvailableLooks();
|
||||
QMenu* ocio_look_menu = menu.addMenu(tr("Look"));
|
||||
connect(ocio_look_menu, SIGNAL(triggered(QAction*)), this, SLOT(ColorLookChanged(QAction*)));
|
||||
QAction* no_look_action = ocio_look_menu->addAction(tr("(None)"));
|
||||
no_look_action->setCheckable(true);
|
||||
no_look_action->setChecked(ocio_look_.isEmpty());
|
||||
foreach (const QString& l, looks) {
|
||||
QAction* action = ocio_look_menu->addAction(l);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(ocio_look_ == l);
|
||||
action->setData(l);
|
||||
}
|
||||
}
|
||||
|
||||
menu.exec(mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void ViewerGLWidget::ColorDisplayChanged(QAction* action)
|
||||
{
|
||||
SetOCIODisplay(action->data().toString());
|
||||
}
|
||||
|
||||
void ViewerGLWidget::ColorViewChanged(QAction *action)
|
||||
{
|
||||
SetOCIOView(action->data().toString());
|
||||
}
|
||||
|
||||
void ViewerGLWidget::ColorLookChanged(QAction *action)
|
||||
{
|
||||
SetOCIOLook(action->data().toString());
|
||||
}
|
||||
|
||||
@@ -77,14 +77,6 @@ public:
|
||||
*/
|
||||
ViewerGLWidget& operator=(ViewerGLWidget&& other) = delete;
|
||||
|
||||
/**
|
||||
* @brief Enable or disable the color management menu
|
||||
*
|
||||
* While the Viewer is _always_ color managed, In some contexts, the color management may be controlled from an
|
||||
* external UI making the menu unnecessary.
|
||||
*/
|
||||
void SetColorMenuEnabled(bool enabled);
|
||||
|
||||
/**
|
||||
* @brief Connect a ColorManager (ColorManagers usually belong to the Project)
|
||||
*/
|
||||
@@ -135,6 +127,12 @@ public slots:
|
||||
*/
|
||||
void SetOCIOLook(const QString& look);
|
||||
|
||||
ColorManager* color_manager() const;
|
||||
|
||||
const QString& ocio_display() const;
|
||||
const QString& ocio_view() const;
|
||||
const QString& ocio_look() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Initialize function to set up the OpenGL context upon its construction
|
||||
@@ -208,39 +206,17 @@ private:
|
||||
*/
|
||||
QMatrix4x4 matrix_;
|
||||
|
||||
bool color_menu_enabled_;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Slot to connect just before the OpenGL context is destroyed to clean up resources
|
||||
*/
|
||||
void ContextCleanup();
|
||||
|
||||
/**
|
||||
* @brief Show context menu
|
||||
*/
|
||||
void ShowContextMenu(const QPoint& pos);
|
||||
|
||||
/**
|
||||
* @brief Sets all color settings to the defaults pertaining to this configuration
|
||||
*/
|
||||
void RefreshColorPipeline();
|
||||
|
||||
/**
|
||||
* @brief Slot called whenever this viewer's OCIO display setting has changed
|
||||
*/
|
||||
void ColorDisplayChanged(QAction* action);
|
||||
|
||||
/**
|
||||
* @brief Slot called whenever this viewer's OCIO view setting has changed
|
||||
*/
|
||||
void ColorViewChanged(QAction* action);
|
||||
|
||||
/**
|
||||
* @brief Slot called whenever this viewer's OCIO look setting has changed
|
||||
*/
|
||||
void ColorLookChanged(QAction* action);
|
||||
|
||||
};
|
||||
|
||||
#endif // VIEWERGLWIDGET_H
|
||||
|
||||
Reference in New Issue
Block a user