added option to disable color management menu on viewer
While the Viewer is _always_ color managed, In some contexts, the color management may be controlled from an external UI making the menu unnecessary.
This commit is contained in:
@@ -93,12 +93,12 @@ void ViewerWidget::SetTimebase(const rational &r)
|
||||
playback_timer_.setInterval(qFloor(r.toDouble()));
|
||||
}
|
||||
|
||||
const double &ViewerWidget::scale()
|
||||
const double &ViewerWidget::scale() const
|
||||
{
|
||||
return ruler_->scale();
|
||||
}
|
||||
|
||||
rational ViewerWidget::GetTime()
|
||||
rational ViewerWidget::GetTime() const
|
||||
{
|
||||
return olive::timestamp_to_time(ruler_->GetTime(), time_base_);
|
||||
}
|
||||
@@ -123,7 +123,7 @@ void ViewerWidget::TogglePlayPause()
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewerWidget::IsPlaying()
|
||||
bool ViewerWidget::IsPlaying() const
|
||||
{
|
||||
return playback_timer_.isActive();
|
||||
}
|
||||
@@ -171,6 +171,11 @@ ViewerOutput *ViewerWidget::GetConnectedViewer() const
|
||||
return viewer_node_;
|
||||
}
|
||||
|
||||
void ViewerWidget::SetColorMenuEnabled(bool enabled)
|
||||
{
|
||||
gl_widget_->SetColorMenuEnabled(enabled);
|
||||
}
|
||||
|
||||
void ViewerWidget::SetTexture(OpenGLTexturePtr tex)
|
||||
{
|
||||
if (tex == nullptr) {
|
||||
@@ -337,6 +342,26 @@ void ViewerWidget::ShuttleRight()
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWidget::SetOCIOParameters(const QString &display, const QString &view, const QString &look)
|
||||
{
|
||||
gl_widget_->SetOCIOParameters(display, view, look);
|
||||
}
|
||||
|
||||
void ViewerWidget::SetOCIODisplay(const QString &display)
|
||||
{
|
||||
gl_widget_->SetOCIODisplay(display);
|
||||
}
|
||||
|
||||
void ViewerWidget::SetOCIOView(const QString &view)
|
||||
{
|
||||
gl_widget_->SetOCIOView(view);
|
||||
}
|
||||
|
||||
void ViewerWidget::SetOCIOLook(const QString &look)
|
||||
{
|
||||
gl_widget_->SetOCIOLook(look);
|
||||
}
|
||||
|
||||
void ViewerWidget::PlaybackTimerUpdate()
|
||||
{
|
||||
int64_t real_time = QDateTime::currentMSecsSinceEpoch() - start_msec_;
|
||||
|
||||
@@ -51,9 +51,9 @@ public:
|
||||
|
||||
void SetTimeRulerEnabled(bool enabled);
|
||||
|
||||
const double& scale();
|
||||
const double& scale() const;
|
||||
|
||||
rational GetTime();
|
||||
rational GetTime() const;
|
||||
|
||||
void SetScale(const double& scale_);
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
|
||||
void TogglePlayPause();
|
||||
|
||||
bool IsPlaying();
|
||||
bool IsPlaying() const;
|
||||
|
||||
void ConnectViewerNode(ViewerOutput* node);
|
||||
|
||||
@@ -69,6 +69,8 @@ public:
|
||||
|
||||
ViewerOutput* GetConnectedViewer() const;
|
||||
|
||||
void SetColorMenuEnabled(bool enabled);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Set the texture to draw and draw it
|
||||
@@ -99,6 +101,29 @@ public slots:
|
||||
|
||||
void ShuttleRight();
|
||||
|
||||
void SetOCIOParameters(const QString& display, const QString& view, const QString& look);
|
||||
|
||||
/**
|
||||
* @brief Externally set the OCIO display to use
|
||||
*
|
||||
* This value must be a valid display in the current OCIO configuration.
|
||||
*/
|
||||
void SetOCIODisplay(const QString& display);
|
||||
|
||||
/**
|
||||
* @brief Externally set the OCIO view to use
|
||||
*
|
||||
* This value must be a valid display in the current OCIO configuration.
|
||||
*/
|
||||
void SetOCIOView(const QString& view);
|
||||
|
||||
/**
|
||||
* @brief Externally set the OCIO look to use (use empty string if none)
|
||||
*
|
||||
* This value must be a valid display in the current OCIO configuration.
|
||||
*/
|
||||
void SetOCIOLook(const QString& look);
|
||||
|
||||
signals:
|
||||
void TimeChanged(const int64_t&);
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
ViewerGLWidget::ViewerGLWidget(QWidget *parent) :
|
||||
QOpenGLWidget(parent),
|
||||
texture_(0),
|
||||
ocio_lut_(0)
|
||||
ocio_lut_(0),
|
||||
color_menu_enabled_(true)
|
||||
{
|
||||
connect(ColorManager::instance(), SIGNAL(ConfigChanged()), this, SLOT(RefreshColorPipeline()));
|
||||
|
||||
@@ -44,6 +45,11 @@ ViewerGLWidget::~ViewerGLWidget()
|
||||
ContextCleanup();
|
||||
}
|
||||
|
||||
void ViewerGLWidget::SetColorMenuEnabled(bool enabled)
|
||||
{
|
||||
color_menu_enabled_ = enabled;
|
||||
}
|
||||
|
||||
void ViewerGLWidget::SetOCIODisplay(const QString &display)
|
||||
{
|
||||
ocio_display_ = display;
|
||||
@@ -74,6 +80,15 @@ void ViewerGLWidget::SetTexture(GLuint tex)
|
||||
update();
|
||||
}
|
||||
|
||||
void ViewerGLWidget::SetOCIOParameters(const QString &display, const QString &view, const QString &look)
|
||||
{
|
||||
ocio_display_ = display;
|
||||
ocio_view_ = view;
|
||||
ocio_look_ = look;
|
||||
SetupColorProcessor();
|
||||
update();
|
||||
}
|
||||
|
||||
void ViewerGLWidget::initializeGL()
|
||||
{
|
||||
SetupColorProcessor();
|
||||
@@ -126,6 +141,10 @@ void ViewerGLWidget::RefreshColorPipeline()
|
||||
|
||||
void ViewerGLWidget::SetupColorProcessor()
|
||||
{
|
||||
if (!context()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ClearOCIOLutTexture();
|
||||
|
||||
// (Re)create color processor
|
||||
@@ -161,37 +180,39 @@ void ViewerGLWidget::ShowContextMenu(const QPoint &pos)
|
||||
{
|
||||
QMenu menu;
|
||||
|
||||
QStringList displays = ColorManager::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);
|
||||
}
|
||||
if (color_menu_enabled_) {
|
||||
QStringList displays = ColorManager::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 = ColorManager::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 views = ColorManager::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 = ColorManager::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);
|
||||
QStringList looks = ColorManager::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));
|
||||
|
||||
@@ -76,6 +76,26 @@ 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);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Set the texture to draw and draw it
|
||||
*
|
||||
* Use this function to update the viewer.
|
||||
*
|
||||
* @param tex
|
||||
*/
|
||||
void SetTexture(GLuint tex);
|
||||
|
||||
void SetOCIOParameters(const QString& display, const QString& view, const QString& look);
|
||||
|
||||
/**
|
||||
* @brief Externally set the OCIO display to use
|
||||
*
|
||||
@@ -97,16 +117,6 @@ public:
|
||||
*/
|
||||
void SetOCIOLook(const QString& look);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Set the texture to draw and draw it
|
||||
*
|
||||
* Use this function to update the viewer.
|
||||
*
|
||||
* @param tex
|
||||
*/
|
||||
void SetTexture(GLuint tex);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Initialize function to set up the OpenGL context upon its construction
|
||||
@@ -170,6 +180,8 @@ private:
|
||||
*/
|
||||
ColorProcessorPtr color_service_;
|
||||
|
||||
bool color_menu_enabled_;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Slot to connect just before the OpenGL context is destroyed to clean up resources
|
||||
|
||||
Reference in New Issue
Block a user