colorpicker: implemented color management
Also moves some items to ColorManager from Project for better accessibility and re-uses some widgets in ExportDialog for improved code.
This commit is contained in:
@@ -20,6 +20,8 @@ set(OLIVE_SOURCES
|
||||
dialog/color/colordialog.cpp
|
||||
dialog/color/colorpreviewbox.h
|
||||
dialog/color/colorpreviewbox.cpp
|
||||
dialog/color/colorspacechooser.h
|
||||
dialog/color/colorspacechooser.cpp
|
||||
dialog/color/colorvalueswidget.h
|
||||
dialog/color/colorvalueswidget.cpp
|
||||
PARENT_SCOPE
|
||||
|
||||
@@ -29,15 +29,25 @@ ColorDialog::ColorDialog(ColorManager* color_manager, Color start, QWidget *pare
|
||||
hsv_value_gradient_->setFixedWidth(QFontMetricsWidth(fontMetrics(), QStringLiteral("HHH")));
|
||||
wheel_layout->addWidget(hsv_value_gradient_);
|
||||
|
||||
ColorValuesWidget* cvw = new ColorValuesWidget();
|
||||
splitter->addWidget(cvw);
|
||||
QWidget* value_area = new QWidget();
|
||||
QVBoxLayout* value_layout = new QVBoxLayout(value_area);
|
||||
value_layout->setSpacing(0);
|
||||
splitter->addWidget(value_area);
|
||||
|
||||
color_values_widget_ = new ColorValuesWidget();
|
||||
value_layout->addWidget(color_values_widget_);
|
||||
|
||||
ColorSpaceChooser* chooser = new ColorSpaceChooser(color_manager_);
|
||||
value_layout->addWidget(chooser);
|
||||
|
||||
splitter->setSizes({INT_MAX, 0});
|
||||
|
||||
connect(color_wheel_, &ColorWheelWidget::SelectedColorChanged, cvw, &ColorValuesWidget::SetColor);
|
||||
connect(color_wheel_, &ColorWheelWidget::SelectedColorChanged, color_values_widget_, &ColorValuesWidget::SetColor);
|
||||
connect(color_wheel_, &ColorWheelWidget::SelectedColorChanged, hsv_value_gradient_, &ColorGradientWidget::SetSelectedColor);
|
||||
connect(hsv_value_gradient_, &ColorGradientWidget::SelectedColorChanged, cvw, &ColorValuesWidget::SetColor);
|
||||
connect(hsv_value_gradient_, &ColorGradientWidget::SelectedColorChanged, color_values_widget_, &ColorValuesWidget::SetColor);
|
||||
connect(hsv_value_gradient_, &ColorGradientWidget::SelectedColorChanged, color_wheel_, &ColorWheelWidget::SetSelectedColor);
|
||||
connect(color_values_widget_, &ColorValuesWidget::ColorChanged, hsv_value_gradient_, &ColorGradientWidget::SetSelectedColor);
|
||||
connect(color_values_widget_, &ColorValuesWidget::ColorChanged, color_wheel_, &ColorWheelWidget::SetSelectedColor);
|
||||
|
||||
connect(color_wheel_, &ColorWheelWidget::DiameterChanged, hsv_value_gradient_, &ColorGradientWidget::setFixedHeight);
|
||||
|
||||
@@ -48,10 +58,36 @@ ColorDialog::ColorDialog(ColorManager* color_manager, Color start, QWidget *pare
|
||||
|
||||
color_wheel_->SetSelectedColor(start);
|
||||
hsv_value_gradient_->SetSelectedColor(start);
|
||||
cvw->SetColor(start);
|
||||
color_values_widget_->SetColor(start);
|
||||
|
||||
connect(chooser, &ColorSpaceChooser::ColorSpaceChanged, this, &ColorDialog::ColorSpaceChanged);
|
||||
ColorSpaceChanged(chooser->input(), chooser->display(), chooser->view(), chooser->look());
|
||||
}
|
||||
|
||||
const Color &ColorDialog::GetSelectedColor() const
|
||||
Color ColorDialog::GetSelectedColor() const
|
||||
{
|
||||
return color_wheel_->GetSelectedColor();
|
||||
Color selected = color_wheel_->GetSelectedColor();
|
||||
|
||||
// Convert to linear and return a linear color
|
||||
if (to_linear_processor_) {
|
||||
return to_linear_processor_->ConvertColor(selected);
|
||||
}
|
||||
|
||||
// Fallback if no processor is available
|
||||
return selected;
|
||||
}
|
||||
|
||||
void ColorDialog::ColorSpaceChanged(const QString &input, const QString &display, const QString &view, const QString &look)
|
||||
{
|
||||
ColorProcessorPtr to_linear_processor_ = ColorProcessor::Create(color_manager_->GetConfig(), input, OCIO::ROLE_SCENE_LINEAR);
|
||||
|
||||
ColorProcessorPtr to_display = ColorProcessor::Create(color_manager_->GetConfig(),
|
||||
OCIO::ROLE_SCENE_LINEAR,
|
||||
display,
|
||||
view,
|
||||
look);
|
||||
|
||||
color_wheel_->SetColorProcessor(to_linear_processor_, to_display);
|
||||
hsv_value_gradient_->SetColorProcessor(to_linear_processor_, to_display);
|
||||
color_values_widget_->preview_box()->SetColorProcessor(to_linear_processor_, to_display);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "colorspacechooser.h"
|
||||
#include "colorvalueswidget.h"
|
||||
#include "render/color.h"
|
||||
#include "render/colormanager.h"
|
||||
@@ -15,7 +16,7 @@ class ColorDialog : public QDialog
|
||||
public:
|
||||
ColorDialog(ColorManager* color_manager, Color start = Color(1.0f, 1.0f, 1.0f), QWidget* parent = nullptr);
|
||||
|
||||
const Color& GetSelectedColor() const;
|
||||
Color GetSelectedColor() const;
|
||||
|
||||
private:
|
||||
ColorManager* color_manager_;
|
||||
@@ -24,6 +25,13 @@ private:
|
||||
|
||||
ColorGradientWidget* hsv_value_gradient_;
|
||||
|
||||
ColorValuesWidget* color_values_widget_;
|
||||
|
||||
ColorProcessorPtr to_linear_processor_;
|
||||
|
||||
private slots:
|
||||
void ColorSpaceChanged(const QString& input, const QString& display, const QString& view, const QString& look);
|
||||
|
||||
};
|
||||
|
||||
#endif // COLORDIALOG_H
|
||||
|
||||
@@ -7,6 +7,14 @@ ColorPreviewBox::ColorPreviewBox(QWidget *parent) :
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPreviewBox::SetColorProcessor(ColorProcessorPtr to_linear, ColorProcessorPtr to_display)
|
||||
{
|
||||
to_linear_processor_ = to_linear;
|
||||
to_display_processor_ = to_display;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void ColorPreviewBox::SetColor(const Color &c)
|
||||
{
|
||||
color_ = c;
|
||||
@@ -17,14 +25,18 @@ void ColorPreviewBox::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
QWidget::paintEvent(e);
|
||||
|
||||
QColor c;
|
||||
|
||||
// Color management
|
||||
if (to_linear_processor_ && to_display_processor_) {
|
||||
c = to_display_processor_->ConvertColor(to_linear_processor_->ConvertColor(color_)).toQColor();
|
||||
} else {
|
||||
c = color_.toQColor();
|
||||
}
|
||||
|
||||
QPainter p(this);
|
||||
|
||||
p.setPen(Qt::black);
|
||||
|
||||
QColor c;
|
||||
c.setRedF(color_.red());
|
||||
c.setGreenF(color_.green());
|
||||
c.setBlueF(color_.blue());
|
||||
p.setBrush(c);
|
||||
|
||||
p.drawRect(rect());
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <QWidget>
|
||||
|
||||
#include "render/color.h"
|
||||
#include "render/colorprocessor.h"
|
||||
|
||||
class ColorPreviewBox : public QWidget
|
||||
{
|
||||
@@ -11,6 +12,8 @@ class ColorPreviewBox : public QWidget
|
||||
public:
|
||||
ColorPreviewBox(QWidget* parent = nullptr);
|
||||
|
||||
void SetColorProcessor(ColorProcessorPtr to_linear, ColorProcessorPtr to_display);
|
||||
|
||||
public slots:
|
||||
void SetColor(const Color& c);
|
||||
|
||||
@@ -20,6 +23,10 @@ protected:
|
||||
private:
|
||||
Color color_;
|
||||
|
||||
ColorProcessorPtr to_linear_processor_;
|
||||
|
||||
ColorProcessorPtr to_display_processor_;
|
||||
|
||||
};
|
||||
|
||||
#endif // COLORPREVIEWBOX_H
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
#include "colorspacechooser.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
|
||||
ColorSpaceChooser::ColorSpaceChooser(ColorManager* color_manager, bool enable_input_field, QWidget *parent):
|
||||
QGroupBox(parent),
|
||||
color_manager_(color_manager)
|
||||
{
|
||||
QGridLayout* layout = new QGridLayout(this);
|
||||
|
||||
setWindowTitle(tr("Color Management"));
|
||||
|
||||
int row = 0;
|
||||
|
||||
if (enable_input_field) {
|
||||
layout->addWidget(new QLabel(tr("Input:")), row, 0);
|
||||
|
||||
input_combobox_ = new QComboBox();
|
||||
layout->addWidget(input_combobox_, row, 1);
|
||||
|
||||
QStringList input_spaces = color_manager->ListAvailableInputColorspaces();
|
||||
|
||||
foreach (const QString& s, input_spaces) {
|
||||
input_combobox_->addItem(s);
|
||||
}
|
||||
|
||||
if (!color_manager_->GetDefaultInputColorSpace().isEmpty()) {
|
||||
input_combobox_->setCurrentText(color_manager_->GetDefaultInputColorSpace());
|
||||
}
|
||||
|
||||
connect(input_combobox_, &QComboBox::currentTextChanged, this, &ColorSpaceChooser::ComboBoxChanged);
|
||||
|
||||
row++;
|
||||
} else {
|
||||
input_combobox_ = nullptr;
|
||||
}
|
||||
|
||||
{
|
||||
layout->addWidget(new QLabel(tr("Display:")), row, 0);
|
||||
|
||||
display_combobox_ = new QComboBox();
|
||||
layout->addWidget(display_combobox_, row, 1);
|
||||
|
||||
QStringList display_spaces = color_manager->ListAvailableDisplays();
|
||||
|
||||
foreach (const QString& s, display_spaces) {
|
||||
display_combobox_->addItem(s);
|
||||
}
|
||||
|
||||
display_combobox_->setCurrentText(color_manager_->GetDefaultDisplay());
|
||||
|
||||
connect(display_combobox_, &QComboBox::currentTextChanged, this, &ColorSpaceChooser::ComboBoxChanged);
|
||||
connect(display_combobox_, &QComboBox::currentTextChanged, this, &ColorSpaceChooser::UpdateViews);
|
||||
}
|
||||
|
||||
row++;
|
||||
|
||||
{
|
||||
layout->addWidget(new QLabel(tr("View:")), row, 0);
|
||||
|
||||
view_combobox_ = new QComboBox();
|
||||
layout->addWidget(view_combobox_, row, 1);
|
||||
|
||||
UpdateViews(display_combobox_->currentText());
|
||||
|
||||
connect(view_combobox_, &QComboBox::currentTextChanged, this, &ColorSpaceChooser::ComboBoxChanged);
|
||||
}
|
||||
|
||||
row++;
|
||||
|
||||
{
|
||||
layout->addWidget(new QLabel(tr("Look:")), row, 0);
|
||||
|
||||
look_combobox_ = new QComboBox();
|
||||
layout->addWidget(look_combobox_, row, 1);
|
||||
|
||||
QStringList looks = color_manager->ListAvailableLooks();
|
||||
|
||||
foreach (const QString& s, looks) {
|
||||
look_combobox_->addItem(s);
|
||||
}
|
||||
|
||||
connect(look_combobox_, &QComboBox::currentTextChanged, this, &ColorSpaceChooser::ComboBoxChanged);
|
||||
}
|
||||
}
|
||||
|
||||
QString ColorSpaceChooser::input() const
|
||||
{
|
||||
if (input_combobox_) {
|
||||
return input_combobox_->currentText();
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString ColorSpaceChooser::display() const
|
||||
{
|
||||
return display_combobox_->currentText();
|
||||
}
|
||||
|
||||
QString ColorSpaceChooser::view() const
|
||||
{
|
||||
return view_combobox_->currentText();
|
||||
}
|
||||
|
||||
QString ColorSpaceChooser::look() const
|
||||
{
|
||||
return look_combobox_->currentText();
|
||||
}
|
||||
|
||||
void ColorSpaceChooser::UpdateViews(const QString& s)
|
||||
{
|
||||
QString v = view_combobox_->currentText();
|
||||
|
||||
view_combobox_->clear();
|
||||
|
||||
QStringList views = color_manager_->ListAvailableViews(s);
|
||||
|
||||
foreach (const QString& s, views) {
|
||||
view_combobox_->addItem(s);
|
||||
}
|
||||
|
||||
if (views.contains(v)) {
|
||||
// If we have the view we had before, set it again
|
||||
view_combobox_->setCurrentText(v);
|
||||
} else {
|
||||
// Otherwise reset to default view for this display
|
||||
view_combobox_->setCurrentText(color_manager_->GetDefaultView(s));
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSpaceChooser::ComboBoxChanged()
|
||||
{
|
||||
if (input_combobox_) {
|
||||
emit ColorSpaceChanged(input(), display(), view(), look());
|
||||
}
|
||||
|
||||
emit DisplayColorSpaceChanged(display(), view(), look());
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef COLORSPACECHOOSER_H
|
||||
#define COLORSPACECHOOSER_H
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QGroupBox>
|
||||
|
||||
#include "render/colormanager.h"
|
||||
|
||||
class ColorSpaceChooser : public QGroupBox
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorSpaceChooser(ColorManager* color_manager, bool enable_input_field = true, QWidget* parent = nullptr);
|
||||
|
||||
QString input() const;
|
||||
QString display() const;
|
||||
QString view() const;
|
||||
QString look() const;
|
||||
|
||||
signals:
|
||||
void ColorSpaceChanged(const QString& input, const QString& display, const QString& view, const QString& look);
|
||||
|
||||
void DisplayColorSpaceChanged(const QString& display, const QString& view, const QString& look);
|
||||
|
||||
private slots:
|
||||
void UpdateViews(const QString &s);
|
||||
|
||||
private:
|
||||
ColorManager* color_manager_;
|
||||
|
||||
QComboBox* input_combobox_;
|
||||
|
||||
QComboBox* display_combobox_;
|
||||
|
||||
QComboBox* view_combobox_;
|
||||
|
||||
QComboBox* look_combobox_;
|
||||
|
||||
private slots:
|
||||
void ComboBoxChanged();
|
||||
|
||||
};
|
||||
|
||||
#endif // COLORSPACECHOOSER_H
|
||||
@@ -44,6 +44,11 @@ Color ColorValuesWidget::GetColor() const
|
||||
blue_slider_->GetValue());
|
||||
}
|
||||
|
||||
ColorPreviewBox *ColorValuesWidget::preview_box() const
|
||||
{
|
||||
return preview_;
|
||||
}
|
||||
|
||||
void ColorValuesWidget::SetColor(const Color &c)
|
||||
{
|
||||
red_slider_->SetValue(c.red());
|
||||
@@ -58,5 +63,16 @@ FloatSlider *ColorValuesWidget::CreateColorSlider()
|
||||
fs->SetMinimum(0);
|
||||
fs->SetDragMultiplier(0.01);
|
||||
fs->SetMaximum(1);
|
||||
fs->SetDecimalPlaces(3);
|
||||
connect(fs, &FloatSlider::ValueChanged, this, &ColorValuesWidget::SliderChanged);
|
||||
return fs;
|
||||
}
|
||||
|
||||
void ColorValuesWidget::SliderChanged()
|
||||
{
|
||||
Color c(red_slider_->GetValue(), green_slider_->GetValue(), blue_slider_->GetValue());
|
||||
|
||||
preview_->SetColor(c);
|
||||
|
||||
emit ColorChanged(c);
|
||||
}
|
||||
|
||||
@@ -15,11 +15,16 @@ public:
|
||||
|
||||
Color GetColor() const;
|
||||
|
||||
ColorPreviewBox* preview_box() const;
|
||||
|
||||
public slots:
|
||||
void SetColor(const Color& c);
|
||||
|
||||
signals:
|
||||
void ColorChanged(const Color& c);
|
||||
|
||||
private:
|
||||
static FloatSlider* CreateColorSlider();
|
||||
FloatSlider* CreateColorSlider();
|
||||
|
||||
ColorPreviewBox* preview_;
|
||||
|
||||
@@ -27,6 +32,9 @@ private:
|
||||
FloatSlider* green_slider_;
|
||||
FloatSlider* blue_slider_;
|
||||
|
||||
private slots:
|
||||
void SliderChanged();
|
||||
|
||||
};
|
||||
|
||||
#endif // COLORVALUESWIDGET_H
|
||||
|
||||
@@ -177,9 +177,10 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, QWidget *parent) :
|
||||
connect(video_tab_->scaling_method_combobox(), SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateViewerDimensions()));
|
||||
connect(video_tab_->maintain_aspect_checkbox(), SIGNAL(toggled(bool)), this, SLOT(ResolutionChanged()));
|
||||
connect(video_tab_->codec_combobox(), SIGNAL(currentIndexChanged(int)), this, SLOT(VideoCodecChanged()));
|
||||
connect(video_tab_, SIGNAL(DisplayChanged(const QString&)), preview_viewer_, SLOT(SetOCIODisplay(const QString&)));
|
||||
connect(video_tab_, SIGNAL(ViewChanged(const QString&)), preview_viewer_, SLOT(SetOCIOView(const QString&)));
|
||||
connect(video_tab_, SIGNAL(LookChanged(const QString&)), preview_viewer_, SLOT(SetOCIOLook(const QString&)));
|
||||
connect(video_tab_,
|
||||
&ExportVideoTab::DisplayColorSpaceChanged,
|
||||
preview_viewer_,
|
||||
static_cast<void (ViewerWidget::*)(const QString&, const QString&, const QString&)>(&ViewerWidget::SetOCIOParameters));
|
||||
|
||||
// Set viewer to view the node
|
||||
preview_viewer_->ConnectViewerNode(viewer_node_);
|
||||
|
||||
@@ -60,17 +60,17 @@ void ExportVideoTab::set_frame_rate(const rational &frame_rate)
|
||||
|
||||
QString ExportVideoTab::CurrentOCIODisplay()
|
||||
{
|
||||
return display_combobox_->currentData().toString();
|
||||
return color_space_chooser_->display();
|
||||
}
|
||||
|
||||
QString ExportVideoTab::CurrentOCIOView()
|
||||
{
|
||||
return views_combobox_->currentData().toString();
|
||||
return color_space_chooser_->view();
|
||||
}
|
||||
|
||||
QString ExportVideoTab::CurrentOCIOLook()
|
||||
{
|
||||
return looks_combobox_->currentData().toString();
|
||||
return color_space_chooser_->look();
|
||||
}
|
||||
|
||||
CodecSection *ExportVideoTab::GetCodecSection() const
|
||||
@@ -153,47 +153,9 @@ QWidget* ExportVideoTab::SetupResolutionSection()
|
||||
|
||||
QWidget* ExportVideoTab::SetupColorSection()
|
||||
{
|
||||
int row = 0;
|
||||
|
||||
QGroupBox* color_group = new QGroupBox();
|
||||
color_group->setTitle(tr("Color Management"));
|
||||
|
||||
QGridLayout* color_layout = new QGridLayout(color_group);
|
||||
|
||||
color_layout->addWidget(new QLabel(tr("Display:")), row, 0);
|
||||
|
||||
QStringList displays = color_manager_->ListAvailableDisplays();
|
||||
display_combobox_ = new QComboBox();
|
||||
foreach (const QString& display, displays) {
|
||||
display_combobox_->addItem(display, display);
|
||||
}
|
||||
connect(display_combobox_, SIGNAL(currentIndexChanged(int)), this, SLOT(ColorDisplayChanged()));
|
||||
color_layout->addWidget(display_combobox_, row, 1);
|
||||
|
||||
row++;
|
||||
|
||||
views_combobox_ = new QComboBox();
|
||||
color_layout->addWidget(new QLabel(tr("View:")), row, 0);
|
||||
color_layout->addWidget(views_combobox_, row, 1);
|
||||
connect(views_combobox_, SIGNAL(currentIndexChanged(int)), this, SLOT(ColorViewChanged()));
|
||||
|
||||
row++;
|
||||
|
||||
QStringList looks = color_manager_->ListAvailableLooks();
|
||||
looks_combobox_ = new QComboBox();
|
||||
looks_combobox_->addItem(tr("(None)"), QString());
|
||||
foreach (const QString& look, looks) {
|
||||
looks_combobox_->addItem(look, look);
|
||||
}
|
||||
connect(looks_combobox_, SIGNAL(currentIndexChanged(int)), this, SLOT(ColorLookChanged()));
|
||||
color_layout->addWidget(new QLabel(tr("Look:")), row, 0);
|
||||
color_layout->addWidget(looks_combobox_, row, 1);
|
||||
|
||||
row++;
|
||||
|
||||
ColorDisplayChanged();
|
||||
|
||||
return color_group;
|
||||
color_space_chooser_ = new ColorSpaceChooser(color_manager_, false);
|
||||
connect(color_space_chooser_, &ColorSpaceChooser::DisplayColorSpaceChanged, this, &ExportVideoTab::DisplayColorSpaceChanged);
|
||||
return color_space_chooser_;
|
||||
}
|
||||
|
||||
QWidget *ExportVideoTab::SetupCodecSection()
|
||||
@@ -224,28 +186,6 @@ QWidget *ExportVideoTab::SetupCodecSection()
|
||||
return codec_group;
|
||||
}
|
||||
|
||||
void ExportVideoTab::ColorDisplayChanged()
|
||||
{
|
||||
views_combobox_->clear();
|
||||
|
||||
QStringList views = color_manager_->ListAvailableViews(display_combobox_->currentData().toString());
|
||||
foreach (const QString& view, views) {
|
||||
views_combobox_->addItem(view, view);
|
||||
}
|
||||
|
||||
emit DisplayChanged(display_combobox_->currentData().toString());
|
||||
}
|
||||
|
||||
void ExportVideoTab::ColorViewChanged()
|
||||
{
|
||||
emit ViewChanged(views_combobox_->currentData().toString());
|
||||
}
|
||||
|
||||
void ExportVideoTab::ColorLookChanged()
|
||||
{
|
||||
emit LookChanged(looks_combobox_->currentData().toString());
|
||||
}
|
||||
|
||||
void ExportVideoTab::MaintainAspectRatioChanged(bool val)
|
||||
{
|
||||
scaling_method_combobox_->setEnabled(!val);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <QWidget>
|
||||
|
||||
#include "common/rational.h"
|
||||
#include "dialog/color/colorspacechooser.h"
|
||||
#include "dialog/export/codec/h264section.h"
|
||||
#include "dialog/export/codec/imagesection.h"
|
||||
#include "render/colormanager.h"
|
||||
@@ -43,9 +44,7 @@ public:
|
||||
H264Section* h264_section() const;
|
||||
|
||||
signals:
|
||||
void DisplayChanged(const QString& display);
|
||||
void ViewChanged(const QString& view);
|
||||
void LookChanged(const QString& look);
|
||||
void DisplayColorSpaceChanged(const QString& display, const QString& view, const QString& look);
|
||||
|
||||
private:
|
||||
QWidget* SetupResolutionSection();
|
||||
@@ -61,22 +60,16 @@ private:
|
||||
ImageSection* image_section_;
|
||||
H264Section* h264_section_;
|
||||
|
||||
ColorSpaceChooser* color_space_chooser_;
|
||||
|
||||
IntegerSlider* width_slider_;
|
||||
IntegerSlider* height_slider_;
|
||||
|
||||
QComboBox* display_combobox_;
|
||||
QComboBox* views_combobox_;
|
||||
QComboBox* looks_combobox_;
|
||||
|
||||
QList<rational> frame_rates_;
|
||||
|
||||
ColorManager* color_manager_;
|
||||
|
||||
private slots:
|
||||
void ColorDisplayChanged();
|
||||
void ColorViewChanged();
|
||||
void ColorLookChanged();
|
||||
|
||||
void MaintainAspectRatioChanged(bool val);
|
||||
|
||||
};
|
||||
|
||||
@@ -80,7 +80,7 @@ void Project::Save(QXmlStreamWriter *writer) const
|
||||
|
||||
writer->writeTextElement("config", ocio_config_);
|
||||
|
||||
writer->writeTextElement("default", default_input_colorspace_);
|
||||
writer->writeTextElement("default", default_input_colorspace());
|
||||
|
||||
writer->writeEndElement(); // colormanagement
|
||||
|
||||
@@ -136,12 +136,12 @@ void Project::set_ocio_config(const QString &ocio_config)
|
||||
|
||||
const QString &Project::default_input_colorspace() const
|
||||
{
|
||||
return default_input_colorspace_;
|
||||
return color_manager_.GetDefaultInputColorSpace();
|
||||
}
|
||||
|
||||
void Project::set_default_input_colorspace(const QString &colorspace)
|
||||
{
|
||||
default_input_colorspace_ = colorspace;
|
||||
color_manager_.SetDefaultInputColorSpace(colorspace);
|
||||
}
|
||||
|
||||
ColorManager *Project::color_manager()
|
||||
|
||||
@@ -75,7 +75,6 @@ private:
|
||||
QString filename_;
|
||||
|
||||
QString ocio_config_;
|
||||
QString default_input_colorspace_;
|
||||
|
||||
ColorManager color_manager_;
|
||||
|
||||
|
||||
@@ -98,6 +98,16 @@ QStringList ColorManager::ListAvailableInputColorspaces()
|
||||
return ListAvailableInputColorspaces(config_);
|
||||
}
|
||||
|
||||
const QString &ColorManager::GetDefaultInputColorSpace() const
|
||||
{
|
||||
return default_input_color_space_;
|
||||
}
|
||||
|
||||
void ColorManager::SetDefaultInputColorSpace(const QString &s)
|
||||
{
|
||||
default_input_color_space_ = s;
|
||||
}
|
||||
|
||||
QStringList ColorManager::ListAvailableInputColorspaces(OCIO::ConstConfigRcPtr config)
|
||||
{
|
||||
QStringList spaces;
|
||||
|
||||
@@ -36,6 +36,10 @@ public:
|
||||
|
||||
QStringList ListAvailableInputColorspaces();
|
||||
|
||||
const QString& GetDefaultInputColorSpace() const;
|
||||
|
||||
void SetDefaultInputColorSpace(const QString& s);
|
||||
|
||||
static QStringList ListAvailableInputColorspaces(OCIO::ConstConfigRcPtr config);
|
||||
|
||||
enum OCIOMethod {
|
||||
@@ -63,6 +67,9 @@ private:
|
||||
|
||||
template<typename T>
|
||||
static void AssociateAlphaInternal(AlphaAction action, T* data, int pix_count);
|
||||
|
||||
QString default_input_color_space_;
|
||||
|
||||
};
|
||||
|
||||
#endif // COLORSERVICE_H
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
#include "dialog/color/colordialog.h"
|
||||
|
||||
ColorButton::ColorButton(QWidget *parent) :
|
||||
QPushButton(parent)
|
||||
ColorButton::ColorButton(ColorManager* color_manager, QWidget *parent) :
|
||||
QPushButton(parent),
|
||||
color_manager_(color_manager)
|
||||
{
|
||||
color_ = Color(1.0f, 1.0f, 1.0f);
|
||||
|
||||
@@ -14,7 +15,7 @@ ColorButton::ColorButton(QWidget *parent) :
|
||||
|
||||
void ColorButton::ShowColorDialog()
|
||||
{
|
||||
ColorDialog cd(nullptr, color_, this);
|
||||
ColorDialog cd(color_manager_, color_, this);
|
||||
|
||||
if (cd.exec() == QDialog::Accepted) {
|
||||
color_ = cd.GetSelectedColor();
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
#include <QPushButton>
|
||||
|
||||
#include "render/color.h"
|
||||
#include "render/colormanager.h"
|
||||
|
||||
class ColorButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorButton(QWidget* parent = nullptr);
|
||||
ColorButton(ColorManager* color_manager, QWidget* parent = nullptr);
|
||||
|
||||
signals:
|
||||
void ColorChanged();
|
||||
@@ -20,6 +21,8 @@ private slots:
|
||||
private:
|
||||
void UpdateColor();
|
||||
|
||||
ColorManager* color_manager_;
|
||||
|
||||
Color color_;
|
||||
|
||||
};
|
||||
|
||||
@@ -40,8 +40,7 @@ void ColorGradientWidget::paintEvent(QPaintEvent *e)
|
||||
}
|
||||
|
||||
for (int i=0;i<max;i++) {
|
||||
Color c = LerpColor(start_, end_, i, max);
|
||||
p.setPen(c.toQColor());
|
||||
p.setPen(GetManagedColor(LerpColor(start_, end_, i, max)).toQColor());
|
||||
|
||||
if (orientation_ == Qt::Horizontal) {
|
||||
p.drawLine(i, 0, i, height());
|
||||
@@ -56,20 +55,22 @@ void ColorGradientWidget::paintEvent(QPaintEvent *e)
|
||||
p.setBrush(Qt::NoBrush);
|
||||
|
||||
if (orientation_ == Qt::Horizontal) {
|
||||
p.drawRect(qRound(width() * (1.0 - val_)) - selector_radius, 0, selector_radius * 2, height());
|
||||
p.drawRect(qRound(width() * (1.0 - val_)) - selector_radius, 0, selector_radius * 2, height() - 1);
|
||||
} else {
|
||||
p.drawRect(0, qRound(height() * (1.0 - val_)) - selector_radius, width(), selector_radius * 2);
|
||||
p.drawRect(0, qRound(height() * (1.0 - val_)) - selector_radius, width() - 1, selector_radius * 2);
|
||||
}
|
||||
}
|
||||
|
||||
void ColorGradientWidget::SelectedColorChangedEvent(const Color &c)
|
||||
void ColorGradientWidget::SelectedColorChangedEvent(const Color &c, bool external)
|
||||
{
|
||||
float hue, sat;
|
||||
|
||||
c.toHsv(&hue, &sat, &val_);
|
||||
|
||||
start_ = Color::fromHsv(hue, sat, 1.0);
|
||||
end_ = Color::fromHsv(hue, sat, 0.0);
|
||||
if (external) {
|
||||
start_ = Color::fromHsv(hue, sat, 1.0);
|
||||
end_ = Color::fromHsv(hue, sat, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
Color ColorGradientWidget::LerpColor(const Color &a, const Color &b, int i, int max)
|
||||
|
||||
@@ -15,11 +15,13 @@ protected:
|
||||
|
||||
virtual void paintEvent(QPaintEvent* e) override;
|
||||
|
||||
virtual void SelectedColorChangedEvent(const Color& c) override;
|
||||
virtual void SelectedColorChangedEvent(const Color& c, bool external) override;
|
||||
|
||||
private:
|
||||
static Color LerpColor(const Color& a, const Color& b, int i, int max);
|
||||
|
||||
QPixmap cached_gradient_;
|
||||
|
||||
Qt::Orientation orientation_;
|
||||
|
||||
Color start_;
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
#include "render/backend/opengl/openglrenderfunctions.h"
|
||||
|
||||
ColorSwatchWidget::ColorSwatchWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
QWidget(parent),
|
||||
to_linear_processor_(nullptr),
|
||||
to_display_processor_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -14,18 +16,26 @@ const Color &ColorSwatchWidget::GetSelectedColor() const
|
||||
return selected_color_;
|
||||
}
|
||||
|
||||
void ColorSwatchWidget::SetColorProcessor(ColorProcessorPtr to_linear, ColorProcessorPtr to_display)
|
||||
{
|
||||
to_linear_processor_ = to_linear;
|
||||
to_display_processor_ = to_display;
|
||||
|
||||
// Force full update
|
||||
SelectedColorChangedEvent(GetSelectedColor(), true);
|
||||
update();
|
||||
}
|
||||
|
||||
void ColorSwatchWidget::SetSelectedColor(const Color &c)
|
||||
{
|
||||
selected_color_ = c;
|
||||
SelectedColorChangedEvent(c);
|
||||
update();
|
||||
SetSelectedColorInternal(c, true);
|
||||
}
|
||||
|
||||
void ColorSwatchWidget::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
QWidget::mousePressEvent(e);
|
||||
|
||||
SetSelectedColor(GetColorFromScreenPos(e->pos()));
|
||||
SetSelectedColorInternal(GetColorFromScreenPos(e->pos()), false);
|
||||
emit SelectedColorChanged(GetSelectedColor());
|
||||
}
|
||||
|
||||
@@ -34,12 +44,12 @@ void ColorSwatchWidget::mouseMoveEvent(QMouseEvent *e)
|
||||
QWidget::mouseMoveEvent(e);
|
||||
|
||||
if (e->buttons() & Qt::LeftButton) {
|
||||
SetSelectedColor(GetColorFromScreenPos(e->pos()));
|
||||
SetSelectedColorInternal(GetColorFromScreenPos(e->pos()), false);
|
||||
emit SelectedColorChanged(GetSelectedColor());
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSwatchWidget::SelectedColorChangedEvent(const Color &)
|
||||
void ColorSwatchWidget::SelectedColorChangedEvent(const Color &, bool)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -53,3 +63,19 @@ Qt::GlobalColor ColorSwatchWidget::GetUISelectorColor() const
|
||||
return Qt::white;
|
||||
}
|
||||
}
|
||||
|
||||
Color ColorSwatchWidget::GetManagedColor(const Color &input) const
|
||||
{
|
||||
if (to_linear_processor_ && to_display_processor_) {
|
||||
return to_display_processor_->ConvertColor(to_linear_processor_->ConvertColor(input));
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
void ColorSwatchWidget::SetSelectedColorInternal(const Color &c, bool external)
|
||||
{
|
||||
selected_color_ = c;
|
||||
SelectedColorChangedEvent(c, external);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "render/backend/opengl/openglshader.h"
|
||||
#include "render/color.h"
|
||||
#include "render/colorprocessor.h"
|
||||
|
||||
class ColorSwatchWidget : public QWidget
|
||||
{
|
||||
@@ -14,6 +15,8 @@ public:
|
||||
|
||||
const Color& GetSelectedColor() const;
|
||||
|
||||
void SetColorProcessor(ColorProcessorPtr to_linear, ColorProcessorPtr to_display);
|
||||
|
||||
public slots:
|
||||
void SetSelectedColor(const Color& c);
|
||||
|
||||
@@ -27,13 +30,21 @@ protected:
|
||||
|
||||
virtual Color GetColorFromScreenPos(const QPoint& p) const = 0;
|
||||
|
||||
virtual void SelectedColorChangedEvent(const Color& c);
|
||||
virtual void SelectedColorChangedEvent(const Color& c, bool external);
|
||||
|
||||
Qt::GlobalColor GetUISelectorColor() const;
|
||||
|
||||
Color GetManagedColor(const Color& input) const;
|
||||
|
||||
private:
|
||||
void SetSelectedColorInternal(const Color& c, bool external);
|
||||
|
||||
Color selected_color_;
|
||||
|
||||
ColorProcessorPtr to_linear_processor_;
|
||||
|
||||
ColorProcessorPtr to_display_processor_;
|
||||
|
||||
};
|
||||
|
||||
#endif // COLORSWATCHWIDGET_H
|
||||
|
||||
@@ -49,7 +49,7 @@ void ColorWheelWidget::paintEvent(QPaintEvent *e)
|
||||
Triangle tri = GetTriangleFromCoords(center, j, i);
|
||||
|
||||
if (tri.hypotenuse <= radius) {
|
||||
QColor c = GetColorFromTriangle(tri).toQColor();
|
||||
QColor c = GetManagedColor(GetColorFromTriangle(tri)).toQColor();
|
||||
|
||||
// Very basic antialiasing around the edges of the wheel
|
||||
qreal alpha = qMin(1.0, radius - tri.hypotenuse);
|
||||
@@ -93,10 +93,12 @@ void ColorWheelWidget::paintEvent(QPaintEvent *e)
|
||||
p.drawEllipse(GetCoordsFromColor(GetSelectedColor()), selector_radius, selector_radius);
|
||||
}
|
||||
|
||||
void ColorWheelWidget::SelectedColorChangedEvent(const Color &c)
|
||||
void ColorWheelWidget::SelectedColorChangedEvent(const Color &c, bool external)
|
||||
{
|
||||
force_redraw_ = true;
|
||||
val_ = c.value();
|
||||
if (external) {
|
||||
force_redraw_ = true;
|
||||
val_ = c.value();
|
||||
}
|
||||
}
|
||||
|
||||
int ColorWheelWidget::GetDiameter() const
|
||||
|
||||
@@ -23,7 +23,7 @@ protected:
|
||||
|
||||
virtual void paintEvent(QPaintEvent* e) override;
|
||||
|
||||
virtual void SelectedColorChangedEvent(const Color& c) override;
|
||||
virtual void SelectedColorChangedEvent(const Color& c, bool external) override;
|
||||
|
||||
private:
|
||||
int GetDiameter() const;
|
||||
|
||||
@@ -94,7 +94,8 @@ void NodeParamViewWidgetBridge::CreateWidgets()
|
||||
break;
|
||||
case NodeParam::kColor:
|
||||
{
|
||||
ColorButton* color_button = new ColorButton();
|
||||
// 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;
|
||||
|
||||
Reference in New Issue
Block a user