nodes: color management when setting color parameters is now preserved
This commit is contained in:
@@ -28,16 +28,12 @@
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
ColorDialog::ColorDialog(ColorManager* color_manager, Color start, QString input_cs, QWidget *parent) :
|
||||
ColorDialog::ColorDialog(ColorManager* color_manager, const ManagedColor& start, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
color_manager_(color_manager)
|
||||
{
|
||||
setWindowTitle(tr("Select Color"));
|
||||
|
||||
if (input_cs.isEmpty()) {
|
||||
input_cs = color_manager_->GetDefaultInputColorSpace();
|
||||
}
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
QSplitter* splitter = new QSplitter(Qt::Horizontal);
|
||||
@@ -64,7 +60,11 @@ ColorDialog::ColorDialog(ColorManager* color_manager, Color start, QString input
|
||||
value_layout->addWidget(color_values_widget_);
|
||||
|
||||
chooser_ = new ColorSpaceChooser(color_manager_);
|
||||
chooser_->set_input(input_cs);
|
||||
chooser_->set_input(start.color_input());
|
||||
chooser_->set_display(start.color_display());
|
||||
chooser_->set_view(start.color_view());
|
||||
chooser_->set_look(start.color_look());
|
||||
|
||||
value_layout->addWidget(chooser_);
|
||||
|
||||
// Split window 50/50
|
||||
@@ -84,19 +84,27 @@ ColorDialog::ColorDialog(ColorManager* color_manager, Color start, QString input
|
||||
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
layout->addWidget(buttons);
|
||||
|
||||
{
|
||||
Color managed_start;
|
||||
|
||||
if (start.color_input().isEmpty()) {
|
||||
|
||||
managed_start = start;
|
||||
|
||||
} else {
|
||||
|
||||
// Convert reference color to the input space
|
||||
ColorProcessorPtr linear_to_input = ColorProcessor::Create(color_manager_->GetConfig(),
|
||||
ColorProcessorPtr linear_to_input = ColorProcessor::Create(color_manager_,
|
||||
color_manager_->GetReferenceColorSpace(),
|
||||
input_cs);
|
||||
start.color_input());
|
||||
|
||||
Color managed_start = linear_to_input->ConvertColor(start);
|
||||
managed_start = linear_to_input->ConvertColor(start);
|
||||
|
||||
color_wheel_->SetSelectedColor(managed_start);
|
||||
hsv_value_gradient_->SetSelectedColor(managed_start);
|
||||
color_values_widget_->SetColor(managed_start);
|
||||
}
|
||||
|
||||
color_wheel_->SetSelectedColor(managed_start);
|
||||
hsv_value_gradient_->SetSelectedColor(managed_start);
|
||||
color_values_widget_->SetColor(managed_start);
|
||||
|
||||
connect(chooser_, &ColorSpaceChooser::ColorSpaceChanged, this, &ColorDialog::ColorSpaceChanged);
|
||||
ColorSpaceChanged(chooser_->input(), chooser_->display(), chooser_->view(), chooser_->look());
|
||||
|
||||
@@ -104,16 +112,20 @@ ColorDialog::ColorDialog(ColorManager* color_manager, Color start, QString input
|
||||
resize(sizeHint().height() * 2, sizeHint().height());
|
||||
}
|
||||
|
||||
Color ColorDialog::GetSelectedColor() const
|
||||
ManagedColor ColorDialog::GetSelectedColor() const
|
||||
{
|
||||
Color selected = color_wheel_->GetSelectedColor();
|
||||
ManagedColor selected = color_wheel_->GetSelectedColor();
|
||||
|
||||
// Convert to linear and return a linear color
|
||||
if (input_to_ref_processor_) {
|
||||
return input_to_ref_processor_->ConvertColor(selected);
|
||||
selected = input_to_ref_processor_->ConvertColor(selected);
|
||||
}
|
||||
|
||||
// Fallback if no processor is available
|
||||
selected.set_color_input(GetColorSpaceInput());
|
||||
selected.set_color_display(GetColorSpaceDisplay());
|
||||
selected.set_color_view(GetColorSpaceView());
|
||||
selected.set_color_look(GetColorSpaceLook());
|
||||
|
||||
return selected;
|
||||
}
|
||||
|
||||
@@ -139,15 +151,15 @@ QString ColorDialog::GetColorSpaceLook() const
|
||||
|
||||
void ColorDialog::ColorSpaceChanged(const QString &input, const QString &display, const QString &view, const QString &look)
|
||||
{
|
||||
input_to_ref_processor_ = ColorProcessor::Create(color_manager_->GetConfig(), input, color_manager_->GetReferenceColorSpace());
|
||||
input_to_ref_processor_ = ColorProcessor::Create(color_manager_, input, color_manager_->GetReferenceColorSpace());
|
||||
|
||||
ColorProcessorPtr ref_to_display = ColorProcessor::Create(color_manager_->GetConfig(),
|
||||
ColorProcessorPtr ref_to_display = ColorProcessor::Create(color_manager_,
|
||||
color_manager_->GetReferenceColorSpace(),
|
||||
display,
|
||||
view,
|
||||
look);
|
||||
|
||||
ColorProcessorPtr ref_to_input = ColorProcessor::Create(color_manager_->GetConfig(), color_manager_->GetReferenceColorSpace(), input);
|
||||
ColorProcessorPtr ref_to_input = ColorProcessor::Create(color_manager_, color_manager_->GetReferenceColorSpace(), input);
|
||||
|
||||
// FIXME: For some reason, using OCIO::TRANSFORM_DIR_INVERSE (wrapped by ColorProcessor::kInverse) causes OCIO to
|
||||
// crash. We've disabled that functionality for now (also disabling display_tab_ in ColorValuesWidget)
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "colorvalueswidget.h"
|
||||
#include "render/color.h"
|
||||
#include "render/colormanager.h"
|
||||
#include "render/managedcolor.h"
|
||||
#include "widget/colorwheel/colorwheelwidget.h"
|
||||
#include "widget/colorwheel/colorgradientwidget.h"
|
||||
|
||||
@@ -55,14 +56,14 @@ public:
|
||||
*
|
||||
* QWidget parent.
|
||||
*/
|
||||
ColorDialog(ColorManager* color_manager, Color start = Color(1.0f, 1.0f, 1.0f), QString input_cs = QString(), QWidget* parent = nullptr);
|
||||
ColorDialog(ColorManager* color_manager, const ManagedColor &start = Color(1.0f, 1.0f, 1.0f), QWidget* parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Retrieves the color selected by the user
|
||||
*
|
||||
* The color is always returned in the ColorManager's reference space (usually scene linear).
|
||||
*/
|
||||
Color GetSelectedColor() const;
|
||||
ManagedColor GetSelectedColor() const;
|
||||
|
||||
QString GetColorSpaceInput() const;
|
||||
|
||||
|
||||
@@ -135,16 +135,49 @@ QString ColorSpaceChooser::look() const
|
||||
|
||||
void ColorSpaceChooser::set_input(const QString &s)
|
||||
{
|
||||
input_combobox_->setCurrentText(s);
|
||||
if (s.isEmpty()) {
|
||||
input_combobox_->setCurrentText(color_manager_->GetDefaultInputColorSpace());
|
||||
} else {
|
||||
input_combobox_->setCurrentText(s);
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSpaceChooser::UpdateViews(const QString& s)
|
||||
void ColorSpaceChooser::set_display(const QString &s)
|
||||
{
|
||||
if (s.isEmpty()) {
|
||||
display_combobox_->setCurrentText(color_manager_->GetDefaultDisplay());
|
||||
} else {
|
||||
display_combobox_->setCurrentText(s);
|
||||
}
|
||||
|
||||
UpdateViews(display_combobox_->currentText());
|
||||
}
|
||||
|
||||
void ColorSpaceChooser::set_view(const QString &s)
|
||||
{
|
||||
if (s.isEmpty()) {
|
||||
view_combobox_->setCurrentText(color_manager_->GetDefaultView(display_combobox_->currentText()));
|
||||
} else {
|
||||
view_combobox_->setCurrentText(s);
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSpaceChooser::set_look(const QString &s)
|
||||
{
|
||||
if (s.isEmpty()) {
|
||||
look_combobox_->setCurrentIndex(0);
|
||||
} else {
|
||||
look_combobox_->setCurrentText(s);
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSpaceChooser::UpdateViews(const QString& display)
|
||||
{
|
||||
QString v = view_combobox_->currentText();
|
||||
|
||||
view_combobox_->clear();
|
||||
|
||||
QStringList views = color_manager_->ListAvailableViews(s);
|
||||
QStringList views = color_manager_->ListAvailableViews(display);
|
||||
|
||||
foreach (const QString& s, views) {
|
||||
view_combobox_->addItem(s);
|
||||
@@ -155,7 +188,7 @@ void ColorSpaceChooser::UpdateViews(const QString& s)
|
||||
view_combobox_->setCurrentText(v);
|
||||
} else {
|
||||
// Otherwise reset to default view for this display
|
||||
view_combobox_->setCurrentText(color_manager_->GetDefaultView(s));
|
||||
view_combobox_->setCurrentText(color_manager_->GetDefaultView(display));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ public:
|
||||
QString look() const;
|
||||
|
||||
void set_input(const QString& s);
|
||||
void set_display(const QString& s);
|
||||
void set_view(const QString& s);
|
||||
void set_look(const QString& s);
|
||||
|
||||
signals:
|
||||
void ColorSpaceChanged(const QString& input, const QString& display, const QString& view, const QString& look);
|
||||
@@ -47,7 +50,7 @@ signals:
|
||||
void DisplayColorSpaceChanged(const QString& display, const QString& view, const QString& look);
|
||||
|
||||
private slots:
|
||||
void UpdateViews(const QString &s);
|
||||
void UpdateViews(const QString &display);
|
||||
|
||||
private:
|
||||
ColorManager* color_manager_;
|
||||
|
||||
@@ -310,7 +310,7 @@ void ExportDialog::accept()
|
||||
audio_tab_->channel_layout_combobox()->currentData().toULongLong(),
|
||||
SampleFormat::GetConfiguredFormatForMode(render_mode));
|
||||
|
||||
ColorProcessorPtr color_processor = ColorProcessor::Create(color_manager_->GetConfig(),
|
||||
ColorProcessorPtr color_processor = ColorProcessor::Create(color_manager_,
|
||||
color_manager_->GetReferenceColorSpace(),
|
||||
video_tab_->CurrentOCIODisplay(),
|
||||
video_tab_->CurrentOCIOView(),
|
||||
|
||||
+16
-20
@@ -200,6 +200,14 @@ void NodeInput::Load(QXmlStreamReader *reader, XMLNodeData &xml_node_data, const
|
||||
reader->skipCurrentElement();
|
||||
}
|
||||
}
|
||||
} else if (reader->name() == QStringLiteral("csinput")) {
|
||||
set_property(QStringLiteral("col_input"), reader->readElementText());
|
||||
} else if (reader->name() == QStringLiteral("csdisplay")) {
|
||||
set_property(QStringLiteral("col_display"), reader->readElementText());
|
||||
} else if (reader->name() == QStringLiteral("csview")) {
|
||||
set_property(QStringLiteral("col_view"), reader->readElementText());
|
||||
} else if (reader->name() == QStringLiteral("cslook")) {
|
||||
set_property(QStringLiteral("col_look"), reader->readElementText());
|
||||
} else {
|
||||
LoadInternal(reader, xml_node_data, cancelled);
|
||||
}
|
||||
@@ -249,6 +257,14 @@ void NodeInput::Save(QXmlStreamWriter *writer) const
|
||||
|
||||
writer->writeEndElement(); // keyframes
|
||||
|
||||
if (data_type_ == NodeParam::kColor) {
|
||||
// Save color management information
|
||||
writer->writeTextElement(QStringLiteral("csinput"), get_property(QStringLiteral("col_input")).toString());
|
||||
writer->writeTextElement(QStringLiteral("csdisplay"), get_property(QStringLiteral("col_display")).toString());
|
||||
writer->writeTextElement(QStringLiteral("csview"), get_property(QStringLiteral("col_view")).toString());
|
||||
writer->writeTextElement(QStringLiteral("cslook"), get_property(QStringLiteral("col_look")).toString());
|
||||
}
|
||||
|
||||
SaveConnections(writer);
|
||||
|
||||
SaveInternal(writer);
|
||||
@@ -295,12 +311,6 @@ QString NodeInput::ValueToString(const DataType& data_type, const QVariant &valu
|
||||
return value.value<rational>().toString();
|
||||
case kFootage:
|
||||
return QString::number(reinterpret_cast<quintptr>(value.value<StreamPtr>().get()));
|
||||
case kColor:
|
||||
{
|
||||
Color c = value.value<Color>();
|
||||
|
||||
return QStringLiteral("%1,%2,%3,%4").arg(c.red(), c.green(), c.blue(), c.alpha());
|
||||
}
|
||||
default:
|
||||
if (value.canConvert<QString>()) {
|
||||
return value.toString();
|
||||
@@ -323,20 +333,6 @@ QString NodeInput::ValueToString(const DataType& data_type, const QVariant &valu
|
||||
QVariant NodeInput::StringToValue(const DataType& data_type, const QString &string)
|
||||
{
|
||||
switch (data_type) {
|
||||
case kColor:
|
||||
{
|
||||
Color c;
|
||||
|
||||
QStringList s = string.split(',');
|
||||
|
||||
int ele_count = qMin(kRGBAChannels, s.size());
|
||||
|
||||
for (int i=0;i<ele_count;i++) {
|
||||
c.data()[i] = s.at(i).toFloat();
|
||||
}
|
||||
|
||||
return QVariant::fromValue(c);
|
||||
}
|
||||
case kRational:
|
||||
return QVariant::fromValue(rational::fromString(string));
|
||||
default:
|
||||
|
||||
@@ -28,6 +28,8 @@ set(OLIVE_SOURCES
|
||||
render/colorprocessor.cpp
|
||||
render/diskmanager.h
|
||||
render/diskmanager.cpp
|
||||
render/managedcolor.h
|
||||
render/managedcolor.cpp
|
||||
render/pixelformat.h
|
||||
render/pixelformat.cpp
|
||||
render/rendermodes.h
|
||||
|
||||
@@ -71,13 +71,13 @@ void OpenGLColorProcessor::ClearTexture()
|
||||
}
|
||||
}
|
||||
|
||||
OpenGLColorProcessor::OpenGLColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space) :
|
||||
OpenGLColorProcessor::OpenGLColorProcessor(ColorManager* config, const QString &source_space, const QString &dest_space) :
|
||||
ColorProcessor(config, source_space, dest_space),
|
||||
ocio_lut_(0)
|
||||
{
|
||||
}
|
||||
|
||||
OpenGLColorProcessor::OpenGLColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, QString display, QString view, const QString &look, Direction dir) :
|
||||
OpenGLColorProcessor::OpenGLColorProcessor(ColorManager* config, const QString &source_space, QString display, QString view, const QString &look, Direction dir) :
|
||||
ColorProcessor(config, source_space, display, view, look, dir),
|
||||
ocio_lut_(0)
|
||||
{
|
||||
@@ -88,12 +88,12 @@ OpenGLColorProcessor::~OpenGLColorProcessor()
|
||||
ClearTexture();
|
||||
}
|
||||
|
||||
OpenGLColorProcessorPtr OpenGLColorProcessor::Create(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space)
|
||||
OpenGLColorProcessorPtr OpenGLColorProcessor::Create(ColorManager *config, const QString &source_space, const QString &dest_space)
|
||||
{
|
||||
return std::make_shared<OpenGLColorProcessor>(config, source_space, dest_space);
|
||||
}
|
||||
|
||||
OpenGLColorProcessorPtr OpenGLColorProcessor::Create(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &display, const QString &view, const QString &look, Direction dir)
|
||||
OpenGLColorProcessorPtr OpenGLColorProcessor::Create(ColorManager *config, const QString &source_space, const QString &display, const QString &view, const QString &look, Direction dir)
|
||||
{
|
||||
return std::make_shared<OpenGLColorProcessor>(config, source_space, display, view, look, dir);
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ class OpenGLColorProcessor : public QObject, public ColorProcessor
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OpenGLColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space);
|
||||
OpenGLColorProcessor(ColorManager *config, const QString &source_space, const QString &dest_space);
|
||||
|
||||
OpenGLColorProcessor(OCIO::ConstConfigRcPtr config,
|
||||
OpenGLColorProcessor(ColorManager *config,
|
||||
const QString& source_space,
|
||||
QString display,
|
||||
QString view,
|
||||
@@ -44,9 +44,9 @@ public:
|
||||
|
||||
~OpenGLColorProcessor();
|
||||
|
||||
static OpenGLColorProcessorPtr Create(OCIO::ConstConfigRcPtr config, const QString& source_space, const QString& dest_space);
|
||||
static OpenGLColorProcessorPtr Create(ColorManager* config, const QString& source_space, const QString& dest_space);
|
||||
|
||||
static OpenGLColorProcessorPtr Create(OCIO::ConstConfigRcPtr config,
|
||||
static OpenGLColorProcessorPtr Create(ColorManager* config,
|
||||
const QString& source_space,
|
||||
const QString& display,
|
||||
const QString& view,
|
||||
|
||||
@@ -97,7 +97,7 @@ void OpenGLProxy::FrameToValue(FramePtr frame, StreamPtr stream, NodeValueTable*
|
||||
OpenGLColorProcessorPtr color_processor = std::static_pointer_cast<OpenGLColorProcessor>(color_cache_.Get(colorspace_match));
|
||||
|
||||
if (!color_processor) {
|
||||
color_processor = OpenGLColorProcessor::Create(video_stream->footage()->project()->color_manager()->GetConfig(),
|
||||
color_processor = OpenGLColorProcessor::Create(video_stream->footage()->project()->color_manager(),
|
||||
video_stream->colorspace(),
|
||||
video_stream->footage()->project()->color_manager()->GetReferenceColorSpace());
|
||||
color_cache_.Add(colorspace_match, color_processor);
|
||||
|
||||
+2
-2
@@ -50,6 +50,8 @@ public:
|
||||
data_[3] = a;
|
||||
}
|
||||
|
||||
Color(const char *data, const PixelFormat::Format &format);
|
||||
|
||||
/**
|
||||
* @brief Creates a Color struct from hue/saturation/value
|
||||
*
|
||||
@@ -57,8 +59,6 @@ public:
|
||||
*/
|
||||
static Color fromHsv(const float& h, const float& s, const float &v);
|
||||
|
||||
Color(const char *data, const PixelFormat::Format &format);
|
||||
|
||||
const float& red() const {return data_[0];}
|
||||
const float& green() const {return data_[1];}
|
||||
const float& blue() const {return data_[2];}
|
||||
|
||||
@@ -21,28 +21,33 @@
|
||||
#include "colorprocessor.h"
|
||||
|
||||
#include "common/define.h"
|
||||
#include "colormanager.h"
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
ColorProcessor::ColorProcessor(OCIO::ConstConfigRcPtr config, const QString& source_space, const QString& dest_space)
|
||||
ColorProcessor::ColorProcessor(ColorManager *config, const QString& source_space, const QString& dest_space)
|
||||
{
|
||||
processor = config->getProcessor(source_space.toUtf8(),
|
||||
dest_space.toUtf8());
|
||||
processor_ = config->GetConfig()->getProcessor(source_space.toUtf8(),
|
||||
dest_space.toUtf8());
|
||||
}
|
||||
|
||||
ColorProcessor::ColorProcessor(OCIO::ConstConfigRcPtr config,
|
||||
const QString& source_space,
|
||||
ColorProcessor::ColorProcessor(ColorManager *config,
|
||||
QString source_space,
|
||||
QString display,
|
||||
QString view,
|
||||
const QString& look,
|
||||
Direction direction)
|
||||
{
|
||||
if (source_space.isEmpty()) {
|
||||
source_space = config->GetDefaultInputColorSpace();
|
||||
}
|
||||
|
||||
if (display.isEmpty()) {
|
||||
display = config->getDefaultDisplay();
|
||||
display = config->GetDefaultDisplay();
|
||||
}
|
||||
|
||||
if (view.isEmpty()) {
|
||||
view = config->getDefaultView(display.toUtf8());
|
||||
view = config->GetDefaultView(display);
|
||||
}
|
||||
|
||||
// Get current display stats
|
||||
@@ -58,35 +63,35 @@ ColorProcessor::ColorProcessor(OCIO::ConstConfigRcPtr config,
|
||||
|
||||
OCIO::TransformDirection dir = (direction == kInverse) ? OCIO::TRANSFORM_DIR_INVERSE : OCIO::TRANSFORM_DIR_FORWARD;
|
||||
|
||||
processor = config->getProcessor(transform, dir);
|
||||
processor_ = config->GetConfig()->getProcessor(transform, dir);
|
||||
}
|
||||
|
||||
void ColorProcessor::ConvertFrame(FramePtr f)
|
||||
{
|
||||
OCIO::PackedImageDesc img(reinterpret_cast<float*>(f->data()), f->width(), f->height(), PixelFormat::ChannelCount(f->format()));
|
||||
|
||||
processor->apply(img);
|
||||
processor_->apply(img);
|
||||
}
|
||||
|
||||
Color ColorProcessor::ConvertColor(Color in)
|
||||
{
|
||||
processor->applyRGBA(in.data());
|
||||
processor_->applyRGBA(in.data());
|
||||
return in;
|
||||
}
|
||||
|
||||
ColorProcessorPtr ColorProcessor::Create(OCIO::ConstConfigRcPtr config, const QString& source_space, const QString& dest_space)
|
||||
ColorProcessorPtr ColorProcessor::Create(ColorManager *config, const QString& source_space, const QString& dest_space)
|
||||
{
|
||||
return std::make_shared<ColorProcessor>(config, source_space, dest_space);
|
||||
}
|
||||
|
||||
ColorProcessorPtr ColorProcessor::Create(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &display, const QString &view, const QString &look, Direction direction)
|
||||
ColorProcessorPtr ColorProcessor::Create(ColorManager *config, const QString &source_space, const QString &display, const QString &view, const QString &look, Direction direction)
|
||||
{
|
||||
return std::make_shared<ColorProcessor>(config, source_space, display, view, look, direction);
|
||||
}
|
||||
|
||||
OCIO::ConstProcessorRcPtr ColorProcessor::GetProcessor()
|
||||
{
|
||||
return processor;
|
||||
return processor_;
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace OCIO = OCIO_NAMESPACE::v1;
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
class ColorManager;
|
||||
|
||||
class ColorProcessor;
|
||||
using ColorProcessorPtr = std::shared_ptr<ColorProcessor>;
|
||||
|
||||
@@ -40,9 +42,10 @@ public:
|
||||
kInverse
|
||||
};
|
||||
|
||||
ColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space);
|
||||
ColorProcessor(ColorManager* config, const QString &source_space, const QString &dest_space);
|
||||
|
||||
ColorProcessor(OCIO::ConstConfigRcPtr config, const QString& source_space,
|
||||
ColorProcessor(ColorManager* config,
|
||||
QString source_space,
|
||||
QString display,
|
||||
QString view,
|
||||
const QString& look,
|
||||
@@ -50,9 +53,9 @@ public:
|
||||
|
||||
DISABLE_COPY_MOVE(ColorProcessor)
|
||||
|
||||
static ColorProcessorPtr Create(OCIO::ConstConfigRcPtr config, const QString& source_space, const QString& dest_space);
|
||||
static ColorProcessorPtr Create(ColorManager* config, const QString& source_space, const QString& dest_space);
|
||||
|
||||
static ColorProcessorPtr Create(OCIO::ConstConfigRcPtr config,
|
||||
static ColorProcessorPtr Create(ColorManager* config,
|
||||
const QString& source_space,
|
||||
const QString& display,
|
||||
const QString& view,
|
||||
@@ -66,7 +69,7 @@ public:
|
||||
Color ConvertColor(Color in);
|
||||
|
||||
private:
|
||||
OCIO::ConstProcessorRcPtr processor;
|
||||
OCIO::ConstProcessorRcPtr processor_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/***
|
||||
|
||||
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 "managedcolor.h"
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
ManagedColor::ManagedColor()
|
||||
{
|
||||
}
|
||||
|
||||
ManagedColor::ManagedColor(const float &r, const float &g, const float &b, const float &a) :
|
||||
Color(r, g, b, a)
|
||||
{
|
||||
}
|
||||
|
||||
ManagedColor::ManagedColor(const char *data, const PixelFormat::Format &format) :
|
||||
Color(data, format)
|
||||
{
|
||||
}
|
||||
|
||||
ManagedColor::ManagedColor(const Color &c) :
|
||||
Color(c)
|
||||
{
|
||||
}
|
||||
|
||||
const QString &ManagedColor::color_input() const
|
||||
{
|
||||
return color_input_;
|
||||
}
|
||||
|
||||
void ManagedColor::set_color_input(const QString &color_input)
|
||||
{
|
||||
color_input_ = color_input;
|
||||
}
|
||||
|
||||
const QString &ManagedColor::color_display() const
|
||||
{
|
||||
return color_display_;
|
||||
}
|
||||
|
||||
void ManagedColor::set_color_display(const QString &color_display)
|
||||
{
|
||||
color_display_ = color_display;
|
||||
}
|
||||
|
||||
const QString &ManagedColor::color_view() const
|
||||
{
|
||||
return color_view_;
|
||||
}
|
||||
|
||||
void ManagedColor::set_color_view(const QString &color_view)
|
||||
{
|
||||
color_view_ = color_view;
|
||||
}
|
||||
|
||||
const QString &ManagedColor::color_look() const
|
||||
{
|
||||
return color_look_;
|
||||
}
|
||||
|
||||
void ManagedColor::set_color_look(const QString &color_look)
|
||||
{
|
||||
color_look_ = color_look;
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
@@ -0,0 +1,61 @@
|
||||
/***
|
||||
|
||||
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 MANAGEDCOLOR_H
|
||||
#define MANAGEDCOLOR_H
|
||||
|
||||
#include "color.h"
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
class ManagedColor : public Color
|
||||
{
|
||||
public:
|
||||
ManagedColor();
|
||||
ManagedColor(const float& r, const float& g, const float& b, const float& a = 1.0f);
|
||||
ManagedColor(const char *data, const PixelFormat::Format &format);
|
||||
ManagedColor(const Color& c);
|
||||
|
||||
const QString& color_input() const;
|
||||
void set_color_input(const QString &color_input);
|
||||
|
||||
const QString& color_display() const;
|
||||
void set_color_display(const QString &color_display);
|
||||
|
||||
const QString& color_view() const;
|
||||
void set_color_view(const QString &color_view);
|
||||
|
||||
const QString& color_look() const;
|
||||
void set_color_look(const QString &color_look);
|
||||
|
||||
private:
|
||||
QString color_input_;
|
||||
|
||||
QString color_display_;
|
||||
|
||||
QString color_view_;
|
||||
|
||||
QString color_look_;
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
#endif // MANAGEDCOLOR_H
|
||||
@@ -27,21 +27,22 @@ OLIVE_NAMESPACE_ENTER
|
||||
ColorButton::ColorButton(ColorManager* color_manager, QWidget *parent) :
|
||||
QPushButton(parent),
|
||||
color_manager_(color_manager),
|
||||
color_(1.0f, 1.0f, 1.0f),
|
||||
color_processor_(nullptr)
|
||||
{
|
||||
color_ = Color(1.0f, 1.0f, 1.0f);
|
||||
setAutoFillBackground(true);
|
||||
|
||||
connect(this, &ColorButton::clicked, this, &ColorButton::ShowColorDialog);
|
||||
|
||||
UpdateColor();
|
||||
}
|
||||
|
||||
const Color &ColorButton::GetColor() const
|
||||
const ManagedColor &ColorButton::GetColor() const
|
||||
{
|
||||
return color_;
|
||||
}
|
||||
|
||||
void ColorButton::SetColor(const Color &c)
|
||||
void ColorButton::SetColor(const ManagedColor &c)
|
||||
{
|
||||
color_ = c;
|
||||
|
||||
@@ -50,19 +51,11 @@ void ColorButton::SetColor(const Color &c)
|
||||
|
||||
void ColorButton::ShowColorDialog()
|
||||
{
|
||||
ColorDialog cd(color_manager_, color_, cm_input_, this);
|
||||
ColorDialog cd(color_manager_, color_, this);
|
||||
|
||||
if (cd.exec() == QDialog::Accepted) {
|
||||
color_ = cd.GetSelectedColor();
|
||||
|
||||
cm_input_ = cd.GetColorSpaceInput();
|
||||
|
||||
color_processor_ = ColorProcessor::Create(color_manager_->GetConfig(),
|
||||
cd.GetColorSpaceInput(),
|
||||
cd.GetColorSpaceDisplay(),
|
||||
cd.GetColorSpaceView(),
|
||||
cd.GetColorSpaceLook());
|
||||
|
||||
UpdateColor();
|
||||
|
||||
emit ColorChanged(color_);
|
||||
@@ -71,15 +64,15 @@ void ColorButton::ShowColorDialog()
|
||||
|
||||
void ColorButton::UpdateColor()
|
||||
{
|
||||
QColor managed;
|
||||
color_processor_ = ColorProcessor::Create(color_manager_,
|
||||
color_.color_input(),
|
||||
color_.color_display(),
|
||||
color_.color_view(),
|
||||
color_.color_look());
|
||||
|
||||
if (color_processor_) {
|
||||
managed = color_processor_->ConvertColor(color_).toQColor();
|
||||
} else {
|
||||
managed = color_.toQColor();
|
||||
}
|
||||
QColor managed = color_processor_->ConvertColor(color_).toQColor();
|
||||
|
||||
setStyleSheet(QStringLiteral("ColorButton {background: %1;}").arg(managed.name()));
|
||||
setStyleSheet(QStringLiteral("%1--ColorButton {background: %2;}").arg(MACRO_VAL_AS_STR(OLIVE_NAMESPACE), managed.name()));
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
#include "render/color.h"
|
||||
#include "render/colormanager.h"
|
||||
#include "render/managedcolor.h"
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
@@ -34,13 +34,13 @@ class ColorButton : public QPushButton
|
||||
public:
|
||||
ColorButton(ColorManager* color_manager, QWidget* parent = nullptr);
|
||||
|
||||
const Color& GetColor() const;
|
||||
const ManagedColor& GetColor() const;
|
||||
|
||||
public slots:
|
||||
void SetColor(const Color& c);
|
||||
void SetColor(const ManagedColor& c);
|
||||
|
||||
signals:
|
||||
void ColorChanged(const Color& c);
|
||||
void ColorChanged(const ManagedColor& c);
|
||||
|
||||
private slots:
|
||||
void ShowColorDialog();
|
||||
@@ -50,9 +50,7 @@ private:
|
||||
|
||||
ColorManager* color_manager_;
|
||||
|
||||
Color color_;
|
||||
|
||||
QString cm_input_;
|
||||
ManagedColor color_;
|
||||
|
||||
ColorProcessorPtr color_processor_;
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ void NodeParamViewWidgetBridge::WidgetCallback()
|
||||
case NodeParam::kColor:
|
||||
{
|
||||
// Sender is a ColorButton
|
||||
Color c = static_cast<ColorButton*>(sender())->GetColor();
|
||||
ManagedColor c = static_cast<ColorButton*>(sender())->GetColor();
|
||||
|
||||
QUndoCommand* command = new QUndoCommand();
|
||||
|
||||
@@ -359,6 +359,13 @@ void NodeParamViewWidgetBridge::WidgetCallback()
|
||||
SetInputValueInternal(c.blue(), 2, command);
|
||||
SetInputValueInternal(c.alpha(), 3, command);
|
||||
|
||||
input_->blockSignals(true);
|
||||
input_->set_property(QStringLiteral("col_input"), c.color_input());
|
||||
input_->set_property(QStringLiteral("col_display"), c.color_display());
|
||||
input_->set_property(QStringLiteral("col_view"), c.color_view());
|
||||
input_->set_property(QStringLiteral("col_look"), c.color_look());
|
||||
input_->blockSignals(false);
|
||||
|
||||
Core::instance()->undo_stack()->pushIfHasChildren(command);
|
||||
break;
|
||||
}
|
||||
@@ -461,7 +468,14 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues()
|
||||
break;
|
||||
case NodeParam::kColor:
|
||||
{
|
||||
static_cast<ColorButton*>(widgets_.first())->SetColor(input_->get_value_at_time(node_time).value<Color>());
|
||||
ManagedColor mc = input_->get_value_at_time(node_time).value<Color>();
|
||||
|
||||
mc.set_color_input(input_->get_property(QStringLiteral("col_input")).toString());
|
||||
mc.set_color_display(input_->get_property(QStringLiteral("col_display")).toString());
|
||||
mc.set_color_view(input_->get_property(QStringLiteral("col_view")).toString());
|
||||
mc.set_color_look(input_->get_property(QStringLiteral("col_look")).toString());
|
||||
|
||||
static_cast<ColorButton*>(widgets_.first())->SetColor(mc);
|
||||
break;
|
||||
}
|
||||
case NodeParam::kText:
|
||||
|
||||
@@ -404,7 +404,7 @@ void ViewerGLWidget::SetupColorProcessor()
|
||||
|
||||
try {
|
||||
|
||||
color_service_ = OpenGLColorProcessor::Create(color_manager_->GetConfig(),
|
||||
color_service_ = OpenGLColorProcessor::Create(color_manager_,
|
||||
color_manager_->GetReferenceColorSpace(),
|
||||
ocio_display_,
|
||||
ocio_view_,
|
||||
|
||||
Reference in New Issue
Block a user