style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
@@ -37,12 +37,12 @@ ColorGradientWidget::ColorGradientWidget(Qt::Orientation orientation,
|
||||
{
|
||||
}
|
||||
|
||||
Color ColorGradientWidget::GetColorFromScreenPos(const QPoint &p) const
|
||||
Color ColorGradientWidget::get_color_from_screen_pos(const QPoint &p) const
|
||||
{
|
||||
if (orientation_ == Qt::Horizontal) {
|
||||
return LerpColor(start_, end_, p.x(), width());
|
||||
return lerp_color(start_, end_, p.x(), width());
|
||||
} else {
|
||||
return LerpColor(start_, end_, p.y(), height());
|
||||
return lerp_color(start_, end_, p.y(), height());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,8 +64,8 @@ void ColorGradientWidget::paintEvent(QPaintEvent *e)
|
||||
}
|
||||
|
||||
for (int i = 0; i < max; i++) {
|
||||
p.setPen(QtUtils::toQColor(
|
||||
GetManagedColor(LerpColor(start_, end_, i, max))));
|
||||
p.setPen(QtUtils::to_q_color(
|
||||
get_managed_color(lerp_color(start_, end_, i, max))));
|
||||
|
||||
if (orientation_ == Qt::Horizontal) {
|
||||
p.drawLine(i, 0, i, height());
|
||||
@@ -76,7 +76,7 @@ void ColorGradientWidget::paintEvent(QPaintEvent *e)
|
||||
|
||||
// Draw selector
|
||||
int selector_radius = qMax(2, min / 8);
|
||||
p.setPen(QPen(GetUISelectorColor(), qMax(1, selector_radius / 2)));
|
||||
p.setPen(QPen(get_ui_selector_color(), qMax(1, selector_radius / 2)));
|
||||
p.setBrush(Qt::NoBrush);
|
||||
|
||||
float clamped_val = std::clamp(val_, 0.0f, 1.0f);
|
||||
@@ -95,15 +95,15 @@ void ColorGradientWidget::SelectedColorChangedEvent(const Color &c,
|
||||
{
|
||||
float hue, sat;
|
||||
|
||||
c.toHsv(&hue, &sat, &val_);
|
||||
c.to_hsv(&hue, &sat, &val_);
|
||||
|
||||
if (external) {
|
||||
start_ = Color::fromHsv(hue, sat, 1.0);
|
||||
end_ = Color::fromHsv(hue, sat, 0.0);
|
||||
start_ = Color::from_hsv(hue, sat, 1.0);
|
||||
end_ = Color::from_hsv(hue, sat, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
Color ColorGradientWidget::LerpColor(const Color &a, const Color &b, int i,
|
||||
Color ColorGradientWidget::lerp_color(const Color &a, const Color &b, int i,
|
||||
int max)
|
||||
{
|
||||
float t =
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORGRADIENTGLWIDGET_H
|
||||
#define COLORGRADIENTGLWIDGET_H
|
||||
#ifndef OAK_COLORGRADIENTGLWIDGET_H
|
||||
#define OAK_COLORGRADIENTGLWIDGET_H
|
||||
|
||||
#include "colorswatchwidget.h"
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
ColorGradientWidget(Qt::Orientation orientation, QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
virtual Color GetColorFromScreenPos(const QPoint &p) const override;
|
||||
virtual Color get_color_from_screen_pos(const QPoint &p) const override;
|
||||
|
||||
virtual void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
@@ -41,7 +41,7 @@ protected:
|
||||
bool external) override;
|
||||
|
||||
private:
|
||||
static Color LerpColor(const Color &a, const Color &b, int i, int max);
|
||||
static Color lerp_color(const Color &a, const Color &b, int i, int max);
|
||||
|
||||
QPixmap cached_gradient_;
|
||||
|
||||
@@ -56,4 +56,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORGRADIENTGLWIDGET_H
|
||||
#endif // OAK_COLORGRADIENTGLWIDGET_H
|
||||
|
||||
@@ -35,7 +35,7 @@ ColorPreviewBox::ColorPreviewBox(QWidget *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPreviewBox::SetColorProcessor(ColorProcessorPtr to_ref,
|
||||
void ColorPreviewBox::set_color_processor(ColorProcessorPtr to_ref,
|
||||
ColorProcessorPtr to_display)
|
||||
{
|
||||
to_ref_processor_ = to_ref;
|
||||
@@ -44,7 +44,7 @@ void ColorPreviewBox::SetColorProcessor(ColorProcessorPtr to_ref,
|
||||
update();
|
||||
}
|
||||
|
||||
void ColorPreviewBox::SetColor(const Color &c)
|
||||
void ColorPreviewBox::set_color(const Color &c)
|
||||
{
|
||||
color_ = c;
|
||||
update();
|
||||
@@ -58,10 +58,10 @@ void ColorPreviewBox::paintEvent(QPaintEvent *e)
|
||||
|
||||
// Color management
|
||||
if (to_ref_processor_ && to_display_processor_) {
|
||||
c = QtUtils::toQColor(to_display_processor_->ConvertColor(
|
||||
to_ref_processor_->ConvertColor(color_)));
|
||||
c = QtUtils::to_q_color(to_display_processor_->convert_color(
|
||||
to_ref_processor_->convert_color(color_)));
|
||||
} else {
|
||||
c = QtUtils::toQColor(color_);
|
||||
c = QtUtils::to_q_color(color_);
|
||||
}
|
||||
|
||||
QPainter p(this);
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORPREVIEWBOX_H
|
||||
#define COLORPREVIEWBOX_H
|
||||
#ifndef OAK_COLORPREVIEWBOX_H
|
||||
#define OAK_COLORPREVIEWBOX_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
@@ -34,11 +34,11 @@ class ColorPreviewBox : public QWidget {
|
||||
public:
|
||||
ColorPreviewBox(QWidget *parent = nullptr);
|
||||
|
||||
void SetColorProcessor(ColorProcessorPtr to_ref,
|
||||
void set_color_processor(ColorProcessorPtr to_ref,
|
||||
ColorProcessorPtr to_display);
|
||||
|
||||
public slots:
|
||||
void SetColor(const Color &c);
|
||||
void set_color(const Color &c);
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *e) override;
|
||||
@@ -53,4 +53,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORPREVIEWBOX_H
|
||||
#endif // OAK_COLORPREVIEWBOX_H
|
||||
|
||||
@@ -56,19 +56,19 @@ ColorSpaceChooser::ColorSpaceChooser(ColorManager *color_manager,
|
||||
input_combobox_ = new QComboBox();
|
||||
layout->addWidget(input_combobox_, row, 1);
|
||||
|
||||
QStringList input_spaces = color_manager->ListAvailableColorspaces();
|
||||
QStringList input_spaces = color_manager->list_available_colorspaces();
|
||||
|
||||
foreach (const QString &s, input_spaces) {
|
||||
input_combobox_->addItem(s);
|
||||
}
|
||||
|
||||
if (!color_manager_->GetDefaultInputColorSpace().isEmpty()) {
|
||||
if (!color_manager_->get_default_input_color_space().isEmpty()) {
|
||||
input_combobox_->setCurrentText(
|
||||
color_manager_->GetDefaultInputColorSpace());
|
||||
color_manager_->get_default_input_color_space());
|
||||
}
|
||||
|
||||
connect(input_combobox_, &QComboBox::currentTextChanged, this,
|
||||
&ColorSpaceChooser::ComboBoxChanged);
|
||||
&ColorSpaceChooser::combo_box_changed);
|
||||
|
||||
row++;
|
||||
} else {
|
||||
@@ -82,17 +82,17 @@ ColorSpaceChooser::ColorSpaceChooser(ColorManager *color_manager,
|
||||
display_combobox_ = new QComboBox();
|
||||
layout->addWidget(display_combobox_, row, 1);
|
||||
|
||||
QStringList display_spaces = color_manager->ListAvailableDisplays();
|
||||
QStringList display_spaces = color_manager->list_available_displays();
|
||||
|
||||
foreach (const QString &s, display_spaces) {
|
||||
display_combobox_->addItem(s);
|
||||
}
|
||||
|
||||
display_combobox_->setCurrentText(
|
||||
color_manager_->GetDefaultDisplay());
|
||||
color_manager_->get_default_display());
|
||||
|
||||
connect(display_combobox_, &QComboBox::currentTextChanged, this,
|
||||
&ColorSpaceChooser::ComboBoxChanged);
|
||||
&ColorSpaceChooser::combo_box_changed);
|
||||
}
|
||||
|
||||
row++;
|
||||
@@ -103,10 +103,10 @@ ColorSpaceChooser::ColorSpaceChooser(ColorManager *color_manager,
|
||||
view_combobox_ = new QComboBox();
|
||||
layout->addWidget(view_combobox_, row, 1);
|
||||
|
||||
UpdateViews(display_combobox_->currentText());
|
||||
update_views(display_combobox_->currentText());
|
||||
|
||||
connect(view_combobox_, &QComboBox::currentTextChanged, this,
|
||||
&ColorSpaceChooser::ComboBoxChanged);
|
||||
&ColorSpaceChooser::combo_box_changed);
|
||||
}
|
||||
|
||||
row++;
|
||||
@@ -117,7 +117,7 @@ ColorSpaceChooser::ColorSpaceChooser(ColorManager *color_manager,
|
||||
look_combobox_ = new QComboBox();
|
||||
layout->addWidget(look_combobox_, row, 1);
|
||||
|
||||
QStringList looks = color_manager->ListAvailableLooks();
|
||||
QStringList looks = color_manager->list_available_looks();
|
||||
|
||||
look_combobox_->addItem(tr("(None)"), QString());
|
||||
|
||||
@@ -126,7 +126,7 @@ ColorSpaceChooser::ColorSpaceChooser(ColorManager *color_manager,
|
||||
}
|
||||
|
||||
connect(look_combobox_, &QComboBox::currentTextChanged, this,
|
||||
&ColorSpaceChooser::ComboBoxChanged);
|
||||
&ColorSpaceChooser::combo_box_changed);
|
||||
}
|
||||
} else {
|
||||
display_combobox_ = nullptr;
|
||||
@@ -155,12 +155,12 @@ ColorTransform ColorSpaceChooser::output() const
|
||||
|
||||
void ColorSpaceChooser::set_input(const QString &s)
|
||||
{
|
||||
input_combobox_->setCurrentText(color_manager_->GetCompliantColorSpace(s));
|
||||
input_combobox_->setCurrentText(color_manager_->get_compliant_color_space(s));
|
||||
}
|
||||
|
||||
void ColorSpaceChooser::set_output(const ColorTransform &out)
|
||||
{
|
||||
ColorTransform compliant = color_manager_->GetCompliantColorSpace(out);
|
||||
ColorTransform compliant = color_manager_->get_compliant_color_space(out);
|
||||
|
||||
display_combobox_->setCurrentText(compliant.display());
|
||||
view_combobox_->setCurrentText(compliant.view());
|
||||
@@ -172,13 +172,13 @@ void ColorSpaceChooser::set_output(const ColorTransform &out)
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSpaceChooser::UpdateViews(const QString &display)
|
||||
void ColorSpaceChooser::update_views(const QString &display)
|
||||
{
|
||||
QString v = view_combobox_->currentText();
|
||||
|
||||
view_combobox_->clear();
|
||||
|
||||
QStringList views = color_manager_->ListAvailableViews(display);
|
||||
QStringList views = color_manager_->list_available_views(display);
|
||||
|
||||
foreach (const QString &s, views) {
|
||||
view_combobox_->addItem(s);
|
||||
@@ -189,26 +189,26 @@ void ColorSpaceChooser::UpdateViews(const QString &display)
|
||||
view_combobox_->setCurrentText(v);
|
||||
} else {
|
||||
// Otherwise reset to default view for this display
|
||||
view_combobox_->setCurrentText(color_manager_->GetDefaultView(display));
|
||||
view_combobox_->setCurrentText(color_manager_->get_default_view(display));
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSpaceChooser::ComboBoxChanged()
|
||||
void ColorSpaceChooser::combo_box_changed()
|
||||
{
|
||||
if (sender() == display_combobox_) {
|
||||
UpdateViews(display_combobox_->currentText());
|
||||
update_views(display_combobox_->currentText());
|
||||
}
|
||||
|
||||
if (input_combobox_) {
|
||||
emit InputColorSpaceChanged(input());
|
||||
emit input_color_space_changed(input());
|
||||
}
|
||||
|
||||
if (display_combobox_) {
|
||||
emit OutputColorSpaceChanged(output());
|
||||
emit output_color_space_changed(output());
|
||||
}
|
||||
|
||||
if (input_combobox_ && display_combobox_) {
|
||||
emit ColorSpaceChanged(input(), output());
|
||||
emit color_space_changed(input(), output());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORSPACECHOOSER_H
|
||||
#define COLORSPACECHOOSER_H
|
||||
#ifndef OAK_COLORSPACECHOOSER_H
|
||||
#define OAK_COLORSPACECHOOSER_H
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QGroupBox>
|
||||
@@ -45,14 +45,14 @@ public:
|
||||
void set_output(const ColorTransform &out);
|
||||
|
||||
signals:
|
||||
void InputColorSpaceChanged(const QString &input);
|
||||
void input_color_space_changed(const QString &input);
|
||||
|
||||
void OutputColorSpaceChanged(const ColorTransform &out);
|
||||
void output_color_space_changed(const ColorTransform &out);
|
||||
|
||||
void ColorSpaceChanged(const QString &input, const ColorTransform &out);
|
||||
void color_space_changed(const QString &input, const ColorTransform &out);
|
||||
|
||||
private slots:
|
||||
void UpdateViews(const QString &display);
|
||||
void update_views(const QString &display);
|
||||
|
||||
private:
|
||||
ColorManager *color_manager_;
|
||||
@@ -66,9 +66,9 @@ private:
|
||||
QComboBox *look_combobox_;
|
||||
|
||||
private slots:
|
||||
void ComboBoxChanged();
|
||||
void combo_box_changed();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORSPACECHOOSER_H
|
||||
#endif // OAK_COLORSPACECHOOSER_H
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const int kDefaultColorCount = 16;
|
||||
const Color kDefaultColors[kDefaultColorCount] = {
|
||||
const int k_default_color_count = 16;
|
||||
const Color k_default_colors[k_default_color_count] = {
|
||||
Color(1.0, 1.0, 1.0), Color(1.0, 1.0, 0.0), Color(1.0, 0.5, 0.0),
|
||||
Color(1.0, 0.0, 0.0), Color(1.0, 0.0, 1.0), Color(0.5, 0.0, 1.0),
|
||||
Color(0.0, 0.0, 1.0), Color(0.0, 0.5, 1.0), Color(0.0, 1.0, 0.0),
|
||||
@@ -44,8 +44,8 @@ ColorSwatchChooser::ColorSwatchChooser(ColorManager *manager, QWidget *parent)
|
||||
{
|
||||
auto layout = new QGridLayout(this);
|
||||
|
||||
for (int x = 0; x < kColCount; x++) {
|
||||
for (int y = 0; y < kRowCount; y++) {
|
||||
for (int x = 0; x < k_col_count; x++) {
|
||||
for (int y = 0; y < k_row_count; y++) {
|
||||
// Create button
|
||||
auto b = new ColorButton(manager, false);
|
||||
b->setFixedWidth(b->sizeHint().height() / 2 * 3);
|
||||
@@ -53,85 +53,85 @@ ColorSwatchChooser::ColorSwatchChooser(ColorManager *manager, QWidget *parent)
|
||||
layout->addWidget(b, y, x);
|
||||
|
||||
// Save button in buttons array
|
||||
int btn_index = x + kColCount * y;
|
||||
int btn_index = x + k_col_count * y;
|
||||
buttons_[btn_index] = b;
|
||||
|
||||
// Set default color
|
||||
SetDefaultColor(btn_index);
|
||||
set_default_color(btn_index);
|
||||
|
||||
// Connect clicks
|
||||
connect(b, &ColorButton::clicked, this,
|
||||
&ColorSwatchChooser::HandleButtonClick);
|
||||
&ColorSwatchChooser::handle_button_click);
|
||||
connect(b, &ColorButton::customContextMenuRequested, this,
|
||||
&ColorSwatchChooser::HandleContextMenu);
|
||||
&ColorSwatchChooser::handle_context_menu);
|
||||
}
|
||||
}
|
||||
|
||||
LoadSwatches();
|
||||
load_swatches();
|
||||
}
|
||||
|
||||
void ColorSwatchChooser::SetDefaultColor(int index)
|
||||
void ColorSwatchChooser::set_default_color(int index)
|
||||
{
|
||||
if (index < kDefaultColorCount) {
|
||||
buttons_[index]->SetColor(kDefaultColors[index]);
|
||||
if (index < k_default_color_count) {
|
||||
buttons_[index]->set_color(k_default_colors[index]);
|
||||
} else {
|
||||
buttons_[index]->SetColor(Color(1.0, 1.0, 1.0));
|
||||
buttons_[index]->set_color(Color(1.0, 1.0, 1.0));
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSwatchChooser::HandleButtonClick()
|
||||
void ColorSwatchChooser::handle_button_click()
|
||||
{
|
||||
auto b = static_cast<ColorButton *>(sender());
|
||||
|
||||
emit ColorClicked(b->GetColor());
|
||||
SetCurrentColor(b->GetColor());
|
||||
emit color_clicked(b->get_color());
|
||||
set_current_color(b->get_color());
|
||||
}
|
||||
|
||||
void ColorSwatchChooser::HandleContextMenu()
|
||||
void ColorSwatchChooser::handle_context_menu()
|
||||
{
|
||||
Menu m(this);
|
||||
|
||||
auto save_action = m.addAction(tr("Save Color Here"));
|
||||
connect(save_action, &QAction::triggered, this,
|
||||
&ColorSwatchChooser::SaveCurrentColor);
|
||||
&ColorSwatchChooser::save_current_color);
|
||||
|
||||
m.addSeparator();
|
||||
|
||||
auto reset_action = m.addAction(tr("Reset To Default"));
|
||||
connect(reset_action, &QAction::triggered, this,
|
||||
&ColorSwatchChooser::ResetMenuButton);
|
||||
&ColorSwatchChooser::reset_menu_button);
|
||||
|
||||
menu_btn_ = static_cast<ColorButton *>(sender());
|
||||
|
||||
m.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void ColorSwatchChooser::SaveCurrentColor()
|
||||
void ColorSwatchChooser::save_current_color()
|
||||
{
|
||||
menu_btn_->SetColor(current_);
|
||||
menu_btn_->set_color(current_);
|
||||
|
||||
SaveSwatches();
|
||||
save_swatches();
|
||||
}
|
||||
|
||||
void ColorSwatchChooser::ResetMenuButton()
|
||||
void ColorSwatchChooser::reset_menu_button()
|
||||
{
|
||||
for (int i = 0; i < kBtnCount; i++) {
|
||||
for (int i = 0; i < k_btn_count; i++) {
|
||||
if (buttons_[i] == menu_btn_) {
|
||||
SetDefaultColor(i);
|
||||
set_default_color(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString ColorSwatchChooser::GetSwatchFilename()
|
||||
QString ColorSwatchChooser::get_swatch_filename()
|
||||
{
|
||||
return QDir(FileFunctions::GetConfigurationLocation())
|
||||
return QDir(FileFunctions::get_configuration_location())
|
||||
.filePath(QStringLiteral("swatch"));
|
||||
}
|
||||
|
||||
void ColorSwatchChooser::LoadSwatches()
|
||||
void ColorSwatchChooser::load_swatches()
|
||||
{
|
||||
QFile f(GetSwatchFilename());
|
||||
QFile f(get_swatch_filename());
|
||||
if (f.open(QFile::ReadOnly)) {
|
||||
QDataStream d(&f);
|
||||
|
||||
@@ -140,7 +140,7 @@ void ColorSwatchChooser::LoadSwatches()
|
||||
|
||||
if (version == 1) {
|
||||
int index = 0;
|
||||
while (index < kBtnCount && !d.atEnd()) {
|
||||
while (index < k_btn_count && !d.atEnd()) {
|
||||
Color::DataType r;
|
||||
QString s;
|
||||
ManagedColor c;
|
||||
@@ -173,7 +173,7 @@ void ColorSwatchChooser::LoadSwatches()
|
||||
c.set_color_output(ColorTransform(s));
|
||||
}
|
||||
|
||||
buttons_[index]->SetColor(c);
|
||||
buttons_[index]->set_color(c);
|
||||
|
||||
index++;
|
||||
}
|
||||
@@ -183,9 +183,9 @@ void ColorSwatchChooser::LoadSwatches()
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSwatchChooser::SaveSwatches()
|
||||
void ColorSwatchChooser::save_swatches()
|
||||
{
|
||||
QString fn = GetSwatchFilename();
|
||||
QString fn = get_swatch_filename();
|
||||
QFile f(fn);
|
||||
|
||||
if (f.open(QFile::WriteOnly)) {
|
||||
@@ -194,8 +194,8 @@ void ColorSwatchChooser::SaveSwatches()
|
||||
const uint version = 1;
|
||||
d << version;
|
||||
|
||||
for (int i = 0; i < kBtnCount; i++) {
|
||||
const ManagedColor &c = buttons_[i]->GetColor();
|
||||
for (int i = 0; i < k_btn_count; i++) {
|
||||
const ManagedColor &c = buttons_[i]->get_color();
|
||||
d << c.red();
|
||||
d << c.green();
|
||||
d << c.blue();
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORSWATCHCHOOSER_H
|
||||
#define COLORSWATCHCHOOSER_H
|
||||
#ifndef OAK_COLORSWATCHCHOOSER_H
|
||||
#define OAK_COLORSWATCHCHOOSER_H
|
||||
|
||||
#include "node/color/colormanager/colormanager.h"
|
||||
#include "widget/colorbutton/colorbutton.h"
|
||||
@@ -34,40 +34,40 @@ public:
|
||||
ColorSwatchChooser(ColorManager *manager, QWidget *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void SetCurrentColor(const ManagedColor &c)
|
||||
void set_current_color(const ManagedColor &c)
|
||||
{
|
||||
current_ = c;
|
||||
}
|
||||
|
||||
signals:
|
||||
void ColorClicked(const ManagedColor &c);
|
||||
void color_clicked(const ManagedColor &c);
|
||||
|
||||
private:
|
||||
void SetDefaultColor(int index);
|
||||
void set_default_color(int index);
|
||||
|
||||
static QString GetSwatchFilename();
|
||||
static QString get_swatch_filename();
|
||||
|
||||
void LoadSwatches();
|
||||
void SaveSwatches();
|
||||
void load_swatches();
|
||||
void save_swatches();
|
||||
|
||||
static const int kRowCount = 4;
|
||||
static const int kColCount = 8;
|
||||
static const int kBtnCount = kRowCount * kColCount;
|
||||
ColorButton *buttons_[kBtnCount];
|
||||
static const int k_row_count = 4;
|
||||
static const int k_col_count = 8;
|
||||
static const int k_btn_count = k_row_count * k_col_count;
|
||||
ColorButton *buttons_[k_btn_count];
|
||||
|
||||
ManagedColor current_;
|
||||
ColorButton *menu_btn_;
|
||||
|
||||
private slots:
|
||||
void HandleButtonClick();
|
||||
void handle_button_click();
|
||||
|
||||
void HandleContextMenu();
|
||||
void handle_context_menu();
|
||||
|
||||
void SaveCurrentColor();
|
||||
void save_current_color();
|
||||
|
||||
void ResetMenuButton();
|
||||
void reset_menu_button();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORSWATCHCHOOSER_H
|
||||
#endif // OAK_COLORSWATCHCHOOSER_H
|
||||
|
||||
@@ -35,33 +35,33 @@ ColorSwatchWidget::ColorSwatchWidget(QWidget *parent)
|
||||
{
|
||||
}
|
||||
|
||||
const Color &ColorSwatchWidget::GetSelectedColor() const
|
||||
const Color &ColorSwatchWidget::get_selected_color() const
|
||||
{
|
||||
return selected_color_;
|
||||
}
|
||||
|
||||
void ColorSwatchWidget::SetColorProcessor(ColorProcessorPtr to_linear,
|
||||
void ColorSwatchWidget::set_color_processor(ColorProcessorPtr to_linear,
|
||||
ColorProcessorPtr to_display)
|
||||
{
|
||||
to_linear_processor_ = to_linear;
|
||||
to_display_processor_ = to_display;
|
||||
|
||||
// Force full update
|
||||
SelectedColorChangedEvent(GetSelectedColor(), true);
|
||||
SelectedColorChangedEvent(get_selected_color(), true);
|
||||
update();
|
||||
}
|
||||
|
||||
void ColorSwatchWidget::SetSelectedColor(const Color &c)
|
||||
void ColorSwatchWidget::set_selected_color(const Color &c)
|
||||
{
|
||||
SetSelectedColorInternal(c, true);
|
||||
set_selected_color_internal(c, true);
|
||||
}
|
||||
|
||||
void ColorSwatchWidget::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
QWidget::mousePressEvent(e);
|
||||
|
||||
SetSelectedColorInternal(GetColorFromScreenPos(e->pos()), false);
|
||||
emit SelectedColorChanged(GetSelectedColor());
|
||||
set_selected_color_internal(get_color_from_screen_pos(e->pos()), false);
|
||||
emit selected_color_changed(get_selected_color());
|
||||
}
|
||||
|
||||
void ColorSwatchWidget::mouseMoveEvent(QMouseEvent *e)
|
||||
@@ -69,8 +69,8 @@ void ColorSwatchWidget::mouseMoveEvent(QMouseEvent *e)
|
||||
QWidget::mouseMoveEvent(e);
|
||||
|
||||
if (e->buttons() & Qt::LeftButton) {
|
||||
SetSelectedColorInternal(GetColorFromScreenPos(e->pos()), false);
|
||||
emit SelectedColorChanged(GetSelectedColor());
|
||||
set_selected_color_internal(get_color_from_screen_pos(e->pos()), false);
|
||||
emit selected_color_changed(get_selected_color());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,22 +78,22 @@ void ColorSwatchWidget::SelectedColorChangedEvent(const Color &, bool)
|
||||
{
|
||||
}
|
||||
|
||||
Qt::GlobalColor ColorSwatchWidget::GetUISelectorColor() const
|
||||
Qt::GlobalColor ColorSwatchWidget::get_ui_selector_color() const
|
||||
{
|
||||
return ColorCoding::GetUISelectorColor(GetSelectedColor());
|
||||
return ColorCoding::get_ui_selector_color(get_selected_color());
|
||||
}
|
||||
|
||||
Color ColorSwatchWidget::GetManagedColor(const Color &input) const
|
||||
Color ColorSwatchWidget::get_managed_color(const Color &input) const
|
||||
{
|
||||
if (to_linear_processor_ && to_display_processor_) {
|
||||
return to_display_processor_->ConvertColor(
|
||||
to_linear_processor_->ConvertColor(input));
|
||||
return to_display_processor_->convert_color(
|
||||
to_linear_processor_->convert_color(input));
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
void ColorSwatchWidget::SetSelectedColorInternal(const Color &c, bool external)
|
||||
void ColorSwatchWidget::set_selected_color_internal(const Color &c, bool external)
|
||||
{
|
||||
selected_color_ = c;
|
||||
SelectedColorChangedEvent(c, external);
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORSWATCHWIDGET_H
|
||||
#define COLORSWATCHWIDGET_H
|
||||
#ifndef OAK_COLORSWATCHWIDGET_H
|
||||
#define OAK_COLORSWATCHWIDGET_H
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
|
||||
@@ -34,32 +34,32 @@ class ColorSwatchWidget : public QWidget {
|
||||
public:
|
||||
ColorSwatchWidget(QWidget *parent = nullptr);
|
||||
|
||||
const Color &GetSelectedColor() const;
|
||||
const Color &get_selected_color() const;
|
||||
|
||||
void SetColorProcessor(ColorProcessorPtr to_linear,
|
||||
void set_color_processor(ColorProcessorPtr to_linear,
|
||||
ColorProcessorPtr to_display);
|
||||
|
||||
public slots:
|
||||
void SetSelectedColor(const Color &c);
|
||||
void set_selected_color(const Color &c);
|
||||
|
||||
signals:
|
||||
void SelectedColorChanged(const Color &c);
|
||||
void selected_color_changed(const Color &c);
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent *e) override;
|
||||
|
||||
virtual void mouseMoveEvent(QMouseEvent *e) override;
|
||||
|
||||
virtual Color GetColorFromScreenPos(const QPoint &p) const = 0;
|
||||
virtual Color get_color_from_screen_pos(const QPoint &p) const = 0;
|
||||
|
||||
virtual void SelectedColorChangedEvent(const Color &c, bool external);
|
||||
|
||||
Qt::GlobalColor GetUISelectorColor() const;
|
||||
Qt::GlobalColor get_ui_selector_color() const;
|
||||
|
||||
Color GetManagedColor(const Color &input) const;
|
||||
Color get_managed_color(const Color &input) const;
|
||||
|
||||
private:
|
||||
void SetSelectedColorInternal(const Color &c, bool external);
|
||||
void set_selected_color_internal(const Color &c, bool external);
|
||||
|
||||
Color selected_color_;
|
||||
|
||||
@@ -70,4 +70,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORSWATCHWIDGET_H
|
||||
#endif // OAK_COLORSWATCHWIDGET_H
|
||||
|
||||
@@ -55,14 +55,14 @@ ColorValuesWidget::ColorValuesWidget(ColorManager *manager, QWidget *parent)
|
||||
preview_layout->addWidget(preview_);
|
||||
|
||||
color_picker_btn_ = new QPushButton();
|
||||
color_picker_btn_->setIcon(icon::ColorPicker);
|
||||
color_picker_btn_->setIcon(icon::color_picker);
|
||||
color_picker_btn_->setFixedWidth(
|
||||
color_picker_btn_->sizeHint().height());
|
||||
color_picker_btn_->setCheckable(true);
|
||||
connect(color_picker_btn_, &QPushButton::toggled, this,
|
||||
&ColorValuesWidget::ColorPickedBtnToggled);
|
||||
connect(Core::instance(), &Core::ColorPickerColorEmitted, this,
|
||||
&ColorValuesWidget::SetReferenceColor);
|
||||
&ColorValuesWidget::color_picked_btn_toggled);
|
||||
connect(Core::instance(), &Core::color_picker_color_emitted, this,
|
||||
&ColorValuesWidget::set_reference_color);
|
||||
preview_layout->addWidget(color_picker_btn_);
|
||||
|
||||
layout->addLayout(preview_layout);
|
||||
@@ -74,33 +74,33 @@ ColorValuesWidget::ColorValuesWidget(ColorManager *manager, QWidget *parent)
|
||||
|
||||
input_tab_ = new ColorValuesTab(true);
|
||||
tabs->addTab(input_tab_, tr("Input"));
|
||||
connect(input_tab_, &ColorValuesTab::ColorChanged, this,
|
||||
&ColorValuesWidget::UpdateValuesFromInput);
|
||||
connect(input_tab_, &ColorValuesTab::ColorChanged, this,
|
||||
&ColorValuesWidget::ColorChanged);
|
||||
connect(input_tab_, &ColorValuesTab::ColorChanged, preview_,
|
||||
&ColorPreviewBox::SetColor);
|
||||
connect(input_tab_, &ColorValuesTab::color_changed, this,
|
||||
&ColorValuesWidget::update_values_from_input);
|
||||
connect(input_tab_, &ColorValuesTab::color_changed, this,
|
||||
&ColorValuesWidget::color_changed);
|
||||
connect(input_tab_, &ColorValuesTab::color_changed, preview_,
|
||||
&ColorPreviewBox::set_color);
|
||||
|
||||
reference_tab_ = new ColorValuesTab();
|
||||
tabs->addTab(reference_tab_, tr("Reference"));
|
||||
connect(reference_tab_, &ColorValuesTab::ColorChanged, this,
|
||||
&ColorValuesWidget::UpdateValuesFromRef);
|
||||
connect(reference_tab_, &ColorValuesTab::color_changed, this,
|
||||
&ColorValuesWidget::update_values_from_ref);
|
||||
|
||||
display_tab_ = new ColorValuesTab();
|
||||
tabs->addTab(display_tab_, tr("Display"));
|
||||
connect(display_tab_, &ColorValuesTab::ColorChanged, this,
|
||||
&ColorValuesWidget::UpdateValuesFromDisplay);
|
||||
connect(display_tab_, &ColorValuesTab::color_changed, this,
|
||||
&ColorValuesWidget::update_values_from_display);
|
||||
|
||||
layout->addWidget(tabs);
|
||||
}
|
||||
}
|
||||
|
||||
Color ColorValuesWidget::GetColor() const
|
||||
Color ColorValuesWidget::get_color() const
|
||||
{
|
||||
return reference_tab_->GetColor();
|
||||
return reference_tab_->get_color();
|
||||
}
|
||||
|
||||
void ColorValuesWidget::SetColorProcessor(ColorProcessorPtr input_to_ref,
|
||||
void ColorValuesWidget::set_color_processor(ColorProcessorPtr input_to_ref,
|
||||
ColorProcessorPtr ref_to_display,
|
||||
ColorProcessorPtr display_to_ref,
|
||||
ColorProcessorPtr ref_to_input)
|
||||
@@ -110,9 +110,9 @@ void ColorValuesWidget::SetColorProcessor(ColorProcessorPtr input_to_ref,
|
||||
display_to_ref_ = display_to_ref;
|
||||
ref_to_input_ = ref_to_input;
|
||||
|
||||
UpdateValuesFromInput();
|
||||
update_values_from_input();
|
||||
|
||||
preview_->SetColorProcessor(input_to_ref_, ref_to_display_);
|
||||
preview_->set_color_processor(input_to_ref_, ref_to_display_);
|
||||
}
|
||||
|
||||
bool ColorValuesWidget::eventFilter(QObject *watcher, QEvent *event)
|
||||
@@ -129,7 +129,7 @@ bool ColorValuesWidget::eventFilter(QObject *watcher, QEvent *event)
|
||||
}
|
||||
|
||||
if (use_this_color) {
|
||||
picker_end_color_ = GetColor();
|
||||
picker_end_color_ = get_color();
|
||||
}
|
||||
color_picker_btn_->setChecked(false);
|
||||
return true;
|
||||
@@ -145,101 +145,101 @@ bool ColorValuesWidget::eventFilter(QObject *watcher, QEvent *event)
|
||||
return QWidget::eventFilter(watcher, event);
|
||||
}
|
||||
|
||||
void ColorValuesWidget::SetColor(const Color &c)
|
||||
void ColorValuesWidget::set_color(const Color &c)
|
||||
{
|
||||
input_tab_->SetColor(c);
|
||||
preview_->SetColor(c);
|
||||
input_tab_->set_color(c);
|
||||
preview_->set_color(c);
|
||||
|
||||
UpdateValuesFromInput();
|
||||
update_values_from_input();
|
||||
}
|
||||
|
||||
void ColorValuesWidget::SetReferenceColor(const Color &c)
|
||||
void ColorValuesWidget::set_reference_color(const Color &c)
|
||||
{
|
||||
reference_tab_->SetColor(c);
|
||||
reference_tab_->set_color(c);
|
||||
|
||||
UpdateValuesFromRef();
|
||||
update_values_from_ref();
|
||||
}
|
||||
|
||||
void ColorValuesWidget::UpdateValuesFromInput()
|
||||
void ColorValuesWidget::update_values_from_input()
|
||||
{
|
||||
UpdateRefFromInput();
|
||||
UpdateDisplayFromRef();
|
||||
update_ref_from_input();
|
||||
update_display_from_ref();
|
||||
}
|
||||
|
||||
void ColorValuesWidget::UpdateValuesFromRef()
|
||||
void ColorValuesWidget::update_values_from_ref()
|
||||
{
|
||||
UpdateInputFromRef();
|
||||
UpdateDisplayFromRef();
|
||||
update_input_from_ref();
|
||||
update_display_from_ref();
|
||||
}
|
||||
|
||||
void ColorValuesWidget::UpdateValuesFromDisplay()
|
||||
void ColorValuesWidget::update_values_from_display()
|
||||
{
|
||||
UpdateRefFromDisplay();
|
||||
UpdateInputFromRef();
|
||||
update_ref_from_display();
|
||||
update_input_from_ref();
|
||||
}
|
||||
|
||||
void ColorValuesWidget::ColorPickedBtnToggled(bool e)
|
||||
void ColorValuesWidget::color_picked_btn_toggled(bool e)
|
||||
{
|
||||
Core::instance()->RequestPixelSamplingInViewers(e);
|
||||
Core::instance()->request_pixel_sampling_in_viewers(e);
|
||||
|
||||
if (e) {
|
||||
qApp->installEventFilter(this);
|
||||
|
||||
// Store current color in case it needs to be restored
|
||||
picker_end_color_ = GetColor();
|
||||
picker_end_color_ = get_color();
|
||||
} else {
|
||||
qApp->removeEventFilter(this);
|
||||
|
||||
// Restore original color (or use overridden color from eventFilter)
|
||||
SetReferenceColor(picker_end_color_);
|
||||
emit ColorChanged(input_tab_->GetColor());
|
||||
set_reference_color(picker_end_color_);
|
||||
emit color_changed(input_tab_->get_color());
|
||||
}
|
||||
}
|
||||
|
||||
void ColorValuesWidget::UpdateInputFromRef()
|
||||
void ColorValuesWidget::update_input_from_ref()
|
||||
{
|
||||
if (ref_to_input_) {
|
||||
input_tab_->SetColor(
|
||||
ref_to_input_->ConvertColor(reference_tab_->GetColor()));
|
||||
input_tab_->set_color(
|
||||
ref_to_input_->convert_color(reference_tab_->get_color()));
|
||||
} else {
|
||||
input_tab_->SetColor(reference_tab_->GetColor());
|
||||
input_tab_->set_color(reference_tab_->get_color());
|
||||
}
|
||||
|
||||
preview_->SetColor(input_tab_->GetColor());
|
||||
emit ColorChanged(input_tab_->GetColor());
|
||||
preview_->set_color(input_tab_->get_color());
|
||||
emit color_changed(input_tab_->get_color());
|
||||
}
|
||||
|
||||
void ColorValuesWidget::UpdateDisplayFromRef()
|
||||
void ColorValuesWidget::update_display_from_ref()
|
||||
{
|
||||
if (ref_to_display_) {
|
||||
display_tab_->SetColor(
|
||||
ref_to_display_->ConvertColor(reference_tab_->GetColor()));
|
||||
display_tab_->set_color(
|
||||
ref_to_display_->convert_color(reference_tab_->get_color()));
|
||||
} else {
|
||||
display_tab_->SetColor(reference_tab_->GetColor());
|
||||
display_tab_->set_color(reference_tab_->get_color());
|
||||
}
|
||||
}
|
||||
|
||||
void ColorValuesWidget::UpdateRefFromInput()
|
||||
void ColorValuesWidget::update_ref_from_input()
|
||||
{
|
||||
if (input_to_ref_) {
|
||||
reference_tab_->SetColor(
|
||||
input_to_ref_->ConvertColor(input_tab_->GetColor()));
|
||||
reference_tab_->set_color(
|
||||
input_to_ref_->convert_color(input_tab_->get_color()));
|
||||
} else {
|
||||
reference_tab_->SetColor(input_tab_->GetColor());
|
||||
reference_tab_->set_color(input_tab_->get_color());
|
||||
}
|
||||
}
|
||||
|
||||
void ColorValuesWidget::UpdateRefFromDisplay()
|
||||
void ColorValuesWidget::update_ref_from_display()
|
||||
{
|
||||
if (display_to_ref_) {
|
||||
reference_tab_->SetColor(
|
||||
display_to_ref_->ConvertColor(display_tab_->GetColor()));
|
||||
reference_tab_->set_color(
|
||||
display_to_ref_->convert_color(display_tab_->get_color()));
|
||||
} else {
|
||||
reference_tab_->SetColor(display_tab_->GetColor());
|
||||
reference_tab_->set_color(display_tab_->get_color());
|
||||
}
|
||||
}
|
||||
|
||||
const double ColorValuesTab::kLegacyMultiplier = 255.0;
|
||||
const double ColorValuesTab::k_legacy_multiplier = 255.0;
|
||||
|
||||
ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
@@ -251,9 +251,9 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent)
|
||||
if (with_legacy_option) {
|
||||
legacy_box_ = new QCheckBox(tr("Use legacy (8-bit) values"));
|
||||
legacy_box_->setChecked(
|
||||
OLIVE_CONFIG("UseLegacyColorInInputTab").toBool());
|
||||
OAK_CONFIG("UseLegacyColorInInputTab").toBool());
|
||||
connect(legacy_box_, &QCheckBox::clicked, this,
|
||||
&ColorValuesTab::LegacyChanged);
|
||||
&ColorValuesTab::legacy_changed);
|
||||
layout->addWidget(legacy_box_, row, 0, 1, 2);
|
||||
row++;
|
||||
} else {
|
||||
@@ -264,7 +264,7 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent)
|
||||
|
||||
layout->addWidget(new QLabel(tr("Red")), row, 0);
|
||||
|
||||
red_slider_ = CreateColorSlider();
|
||||
red_slider_ = create_color_slider();
|
||||
sliders_[0] = red_slider_;
|
||||
layout->addWidget(red_slider_, row, 1);
|
||||
|
||||
@@ -272,7 +272,7 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent)
|
||||
|
||||
layout->addWidget(new QLabel(tr("Green")), row, 0);
|
||||
|
||||
green_slider_ = CreateColorSlider();
|
||||
green_slider_ = create_color_slider();
|
||||
sliders_[1] = green_slider_;
|
||||
layout->addWidget(green_slider_, row, 1);
|
||||
|
||||
@@ -280,7 +280,7 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent)
|
||||
|
||||
layout->addWidget(new QLabel(tr("Blue")), row, 0);
|
||||
|
||||
blue_slider_ = CreateColorSlider();
|
||||
blue_slider_ = create_color_slider();
|
||||
sliders_[2] = blue_slider_;
|
||||
layout->addWidget(blue_slider_, row, 1);
|
||||
|
||||
@@ -290,112 +290,112 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent)
|
||||
layout->addWidget(hex_lbl_, row, 0);
|
||||
|
||||
hex_slider_ = new StringSlider();
|
||||
connect(hex_slider_, &StringSlider::ValueChanged, this,
|
||||
&ColorValuesTab::HexChanged);
|
||||
connect(hex_slider_, &StringSlider::value_changed, this,
|
||||
&ColorValuesTab::hex_changed);
|
||||
layout->addWidget(hex_slider_, row, 1);
|
||||
|
||||
if (legacy_box_) {
|
||||
LegacyChanged(AreSlidersLegacyValues());
|
||||
legacy_changed(are_sliders_legacy_values());
|
||||
}
|
||||
}
|
||||
|
||||
Color ColorValuesTab::GetColor() const
|
||||
Color ColorValuesTab::get_color() const
|
||||
{
|
||||
return Color(GetRed(), GetGreen(), GetBlue());
|
||||
return Color(get_red(), get_green(), get_blue());
|
||||
}
|
||||
|
||||
void ColorValuesTab::SetColor(const Color &c)
|
||||
void ColorValuesTab::set_color(const Color &c)
|
||||
{
|
||||
SetRed(c.red());
|
||||
SetGreen(c.green());
|
||||
SetBlue(c.blue());
|
||||
set_red(c.red());
|
||||
set_green(c.green());
|
||||
set_blue(c.blue());
|
||||
}
|
||||
|
||||
double ColorValuesTab::GetRed() const
|
||||
double ColorValuesTab::get_red() const
|
||||
{
|
||||
return GetValueInternal(red_slider_);
|
||||
return get_value_internal(red_slider_);
|
||||
}
|
||||
|
||||
double ColorValuesTab::GetGreen() const
|
||||
double ColorValuesTab::get_green() const
|
||||
{
|
||||
return GetValueInternal(green_slider_);
|
||||
return get_value_internal(green_slider_);
|
||||
}
|
||||
|
||||
double ColorValuesTab::GetBlue() const
|
||||
double ColorValuesTab::get_blue() const
|
||||
{
|
||||
return GetValueInternal(blue_slider_);
|
||||
return get_value_internal(blue_slider_);
|
||||
}
|
||||
|
||||
void ColorValuesTab::SetRed(double r)
|
||||
void ColorValuesTab::set_red(double r)
|
||||
{
|
||||
SetValueInternal(red_slider_, r);
|
||||
set_value_internal(red_slider_, r);
|
||||
}
|
||||
|
||||
void ColorValuesTab::SetGreen(double g)
|
||||
void ColorValuesTab::set_green(double g)
|
||||
{
|
||||
SetValueInternal(green_slider_, g);
|
||||
set_value_internal(green_slider_, g);
|
||||
}
|
||||
|
||||
void ColorValuesTab::SetBlue(double b)
|
||||
void ColorValuesTab::set_blue(double b)
|
||||
{
|
||||
SetValueInternal(blue_slider_, b);
|
||||
set_value_internal(blue_slider_, b);
|
||||
}
|
||||
|
||||
double ColorValuesTab::GetValueInternal(FloatSlider *slider) const
|
||||
double ColorValuesTab::get_value_internal(FloatSlider *slider) const
|
||||
{
|
||||
double d = slider->GetValue();
|
||||
double d = slider->get_value();
|
||||
|
||||
if (AreSlidersLegacyValues()) {
|
||||
d /= kLegacyMultiplier;
|
||||
if (are_sliders_legacy_values()) {
|
||||
d /= k_legacy_multiplier;
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
void ColorValuesTab::SetValueInternal(FloatSlider *slider, double v)
|
||||
void ColorValuesTab::set_value_internal(FloatSlider *slider, double v)
|
||||
{
|
||||
if (AreSlidersLegacyValues()) {
|
||||
v *= kLegacyMultiplier;
|
||||
if (are_sliders_legacy_values()) {
|
||||
v *= k_legacy_multiplier;
|
||||
}
|
||||
|
||||
slider->SetValue(v);
|
||||
UpdateHex();
|
||||
slider->set_value(v);
|
||||
update_hex();
|
||||
}
|
||||
|
||||
FloatSlider *ColorValuesTab::CreateColorSlider()
|
||||
FloatSlider *ColorValuesTab::create_color_slider()
|
||||
{
|
||||
FloatSlider *fs = new FloatSlider();
|
||||
fs->SetLadderElementCount(1);
|
||||
connect(fs, &FloatSlider::ValueChanged, this,
|
||||
&ColorValuesTab::SliderChanged);
|
||||
fs->set_ladder_element_count(1);
|
||||
connect(fs, &FloatSlider::value_changed, this,
|
||||
&ColorValuesTab::slider_changed);
|
||||
return fs;
|
||||
}
|
||||
|
||||
void ColorValuesTab::SliderChanged()
|
||||
void ColorValuesTab::slider_changed()
|
||||
{
|
||||
emit ColorChanged(GetColor());
|
||||
UpdateHex();
|
||||
emit color_changed(get_color());
|
||||
update_hex();
|
||||
}
|
||||
|
||||
void ColorValuesTab::LegacyChanged(bool legacy)
|
||||
void ColorValuesTab::legacy_changed(bool legacy)
|
||||
{
|
||||
OLIVE_CONFIG("UseLegacyColorInInputTab") = legacy;
|
||||
OAK_CONFIG("UseLegacyColorInInputTab") = legacy;
|
||||
|
||||
double legacy_multiplier = legacy ? kLegacyMultiplier :
|
||||
1.0 / kLegacyMultiplier;
|
||||
double legacy_multiplier = legacy ? k_legacy_multiplier :
|
||||
1.0 / k_legacy_multiplier;
|
||||
int decimal_places = legacy ? 0 : 5;
|
||||
double drag_multiplier = legacy ? 1.0 : 0.01;
|
||||
|
||||
foreach (FloatSlider *s, sliders_) {
|
||||
s->SetValue(s->GetValue() * legacy_multiplier);
|
||||
s->SetDecimalPlaces(decimal_places);
|
||||
s->SetDragMultiplier(drag_multiplier);
|
||||
s->set_value(s->get_value() * legacy_multiplier);
|
||||
s->set_decimal_places(decimal_places);
|
||||
s->set_drag_multiplier(drag_multiplier);
|
||||
}
|
||||
|
||||
UpdateHex();
|
||||
update_hex();
|
||||
}
|
||||
|
||||
QString RGBValToString(double d)
|
||||
QString rgb_val_to_string(double d)
|
||||
{
|
||||
QString s = QString::number(d);
|
||||
|
||||
@@ -406,33 +406,33 @@ QString RGBValToString(double d)
|
||||
return s;
|
||||
}
|
||||
|
||||
void ColorValuesTab::UpdateHex()
|
||||
void ColorValuesTab::update_hex()
|
||||
{
|
||||
if (AreSlidersLegacyValues()) {
|
||||
double r = red_slider_->GetValue();
|
||||
double g = green_slider_->GetValue();
|
||||
double b = blue_slider_->GetValue();
|
||||
if (are_sliders_legacy_values()) {
|
||||
double r = red_slider_->get_value();
|
||||
double g = green_slider_->get_value();
|
||||
double b = blue_slider_->get_value();
|
||||
|
||||
if (r > kLegacyMultiplier || g > kLegacyMultiplier ||
|
||||
b > kLegacyMultiplier) {
|
||||
hex_slider_->SetValue(tr("(Invalid)"));
|
||||
if (r > k_legacy_multiplier || g > k_legacy_multiplier ||
|
||||
b > k_legacy_multiplier) {
|
||||
hex_slider_->set_value(tr("(Invalid)"));
|
||||
} else {
|
||||
uint32_t rgb = (uint8_t(r) << 16) | (uint8_t(g) << 8) | uint8_t(b);
|
||||
|
||||
hex_slider_->SetValue(QStringLiteral("%1")
|
||||
hex_slider_->set_value(QStringLiteral("%1")
|
||||
.arg(rgb, 6, 16, QLatin1Char('0'))
|
||||
.toUpper());
|
||||
}
|
||||
} else {
|
||||
hex_slider_->SetValue(
|
||||
hex_slider_->set_value(
|
||||
QStringLiteral("rgb(%1, %2, %3)")
|
||||
.arg(RGBValToString(red_slider_->GetValue()),
|
||||
RGBValToString(green_slider_->GetValue()),
|
||||
RGBValToString(blue_slider_->GetValue())));
|
||||
.arg(rgb_val_to_string(red_slider_->get_value()),
|
||||
rgb_val_to_string(green_slider_->get_value()),
|
||||
rgb_val_to_string(blue_slider_->get_value())));
|
||||
}
|
||||
}
|
||||
|
||||
bool ParseRGBString(QString s, double *r, double *g, double *b)
|
||||
bool parse_rgb_string(QString s, double *r, double *g, double *b)
|
||||
{
|
||||
// Trim whitespace
|
||||
s = s.trimmed();
|
||||
@@ -463,7 +463,7 @@ bool ParseRGBString(QString s, double *r, double *g, double *b)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ColorValuesTab::HexChanged(const QString &s)
|
||||
void ColorValuesTab::hex_changed(const QString &s)
|
||||
{
|
||||
bool ok;
|
||||
uint32_t hex = s.toULong(&ok, 16);
|
||||
@@ -477,40 +477,40 @@ void ColorValuesTab::HexChanged(const QString &s)
|
||||
uint32_t g = (hex & 0x00FF00) >> 8;
|
||||
uint32_t b = (hex & 0x0000FF);
|
||||
|
||||
if (AreSlidersLegacyValues()) {
|
||||
red_slider_->SetValue(r);
|
||||
green_slider_->SetValue(g);
|
||||
blue_slider_->SetValue(b);
|
||||
if (are_sliders_legacy_values()) {
|
||||
red_slider_->set_value(r);
|
||||
green_slider_->set_value(g);
|
||||
blue_slider_->set_value(b);
|
||||
} else {
|
||||
red_slider_->SetValue(double(r) / kLegacyMultiplier);
|
||||
green_slider_->SetValue(double(g) / kLegacyMultiplier);
|
||||
blue_slider_->SetValue(double(b) / kLegacyMultiplier);
|
||||
red_slider_->set_value(double(r) / k_legacy_multiplier);
|
||||
green_slider_->set_value(double(g) / k_legacy_multiplier);
|
||||
blue_slider_->set_value(double(b) / k_legacy_multiplier);
|
||||
}
|
||||
|
||||
emit ColorChanged(GetColor());
|
||||
emit color_changed(get_color());
|
||||
} else {
|
||||
// Attempt to parse rgb/rgba
|
||||
double r, g, b;
|
||||
if (ParseRGBString(s, &r, &g, &b)) {
|
||||
if (AreSlidersLegacyValues()) {
|
||||
red_slider_->SetValue(r * kLegacyMultiplier);
|
||||
green_slider_->SetValue(g * kLegacyMultiplier);
|
||||
blue_slider_->SetValue(b * kLegacyMultiplier);
|
||||
if (parse_rgb_string(s, &r, &g, &b)) {
|
||||
if (are_sliders_legacy_values()) {
|
||||
red_slider_->set_value(r * k_legacy_multiplier);
|
||||
green_slider_->set_value(g * k_legacy_multiplier);
|
||||
blue_slider_->set_value(b * k_legacy_multiplier);
|
||||
} else {
|
||||
red_slider_->SetValue(r);
|
||||
green_slider_->SetValue(g);
|
||||
blue_slider_->SetValue(b);
|
||||
red_slider_->set_value(r);
|
||||
green_slider_->set_value(g);
|
||||
blue_slider_->set_value(b);
|
||||
}
|
||||
|
||||
emit ColorChanged(GetColor());
|
||||
emit color_changed(get_color());
|
||||
}
|
||||
}
|
||||
|
||||
// Conform string to our formatting
|
||||
UpdateHex();
|
||||
update_hex();
|
||||
}
|
||||
|
||||
bool ColorValuesTab::AreSlidersLegacyValues() const
|
||||
bool ColorValuesTab::are_sliders_legacy_values() const
|
||||
{
|
||||
return legacy_box_ && legacy_box_->isChecked();
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORVALUESWIDGET_H
|
||||
#define COLORVALUESWIDGET_H
|
||||
#ifndef OAK_COLORVALUESWIDGET_H
|
||||
#define OAK_COLORVALUESWIDGET_H
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
@@ -39,29 +39,29 @@ class ColorValuesTab : public QWidget {
|
||||
public:
|
||||
ColorValuesTab(bool with_legacy_option = false, QWidget *parent = nullptr);
|
||||
|
||||
Color GetColor() const;
|
||||
Color get_color() const;
|
||||
|
||||
void SetColor(const Color &c);
|
||||
void set_color(const Color &c);
|
||||
|
||||
double GetRed() const;
|
||||
double GetGreen() const;
|
||||
double GetBlue() const;
|
||||
void SetRed(double r);
|
||||
void SetGreen(double g);
|
||||
void SetBlue(double b);
|
||||
double get_red() const;
|
||||
double get_green() const;
|
||||
double get_blue() const;
|
||||
void set_red(double r);
|
||||
void set_green(double g);
|
||||
void set_blue(double b);
|
||||
|
||||
signals:
|
||||
void ColorChanged(const Color &c);
|
||||
void color_changed(const Color &c);
|
||||
|
||||
private:
|
||||
static const double kLegacyMultiplier;
|
||||
static const double k_legacy_multiplier;
|
||||
|
||||
double GetValueInternal(FloatSlider *slider) const;
|
||||
void SetValueInternal(FloatSlider *slider, double v);
|
||||
double get_value_internal(FloatSlider *slider) const;
|
||||
void set_value_internal(FloatSlider *slider, double v);
|
||||
|
||||
bool AreSlidersLegacyValues() const;
|
||||
bool are_sliders_legacy_values() const;
|
||||
|
||||
FloatSlider *CreateColorSlider();
|
||||
FloatSlider *create_color_slider();
|
||||
|
||||
FloatSlider *red_slider_;
|
||||
FloatSlider *green_slider_;
|
||||
@@ -75,13 +75,13 @@ private:
|
||||
QCheckBox *legacy_box_;
|
||||
|
||||
private slots:
|
||||
void SliderChanged();
|
||||
void slider_changed();
|
||||
|
||||
void LegacyChanged(bool e);
|
||||
void legacy_changed(bool e);
|
||||
|
||||
void UpdateHex();
|
||||
void update_hex();
|
||||
|
||||
void HexChanged(const QString &s);
|
||||
void hex_changed(const QString &s);
|
||||
};
|
||||
|
||||
class ColorValuesWidget : public QWidget {
|
||||
@@ -89,36 +89,36 @@ class ColorValuesWidget : public QWidget {
|
||||
public:
|
||||
ColorValuesWidget(ColorManager *manager, QWidget *parent = nullptr);
|
||||
|
||||
Color GetColor() const;
|
||||
Color get_color() const;
|
||||
|
||||
void SetColorProcessor(ColorProcessorPtr input_to_ref,
|
||||
void set_color_processor(ColorProcessorPtr input_to_ref,
|
||||
ColorProcessorPtr ref_to_display,
|
||||
ColorProcessorPtr display_to_ref,
|
||||
ColorProcessorPtr ref_to_input);
|
||||
|
||||
virtual bool eventFilter(QObject *watcher, QEvent *event) override;
|
||||
|
||||
void IgnorePickFrom(QWidget *w)
|
||||
void ignore_pick_from(QWidget *w)
|
||||
{
|
||||
ignore_pick_from_.append(w);
|
||||
}
|
||||
|
||||
public slots:
|
||||
void SetColor(const Color &c);
|
||||
void set_color(const Color &c);
|
||||
|
||||
void SetReferenceColor(const Color &c);
|
||||
void set_reference_color(const Color &c);
|
||||
|
||||
signals:
|
||||
void ColorChanged(const Color &c);
|
||||
void color_changed(const Color &c);
|
||||
|
||||
private:
|
||||
void UpdateInputFromRef();
|
||||
void update_input_from_ref();
|
||||
|
||||
void UpdateDisplayFromRef();
|
||||
void update_display_from_ref();
|
||||
|
||||
void UpdateRefFromInput();
|
||||
void update_ref_from_input();
|
||||
|
||||
void UpdateRefFromDisplay();
|
||||
void update_ref_from_display();
|
||||
|
||||
ColorManager *manager_;
|
||||
|
||||
@@ -145,15 +145,15 @@ private:
|
||||
QVector<QWidget *> ignore_pick_from_;
|
||||
|
||||
private slots:
|
||||
void UpdateValuesFromInput();
|
||||
void update_values_from_input();
|
||||
|
||||
void UpdateValuesFromRef();
|
||||
void update_values_from_ref();
|
||||
|
||||
void UpdateValuesFromDisplay();
|
||||
void update_values_from_display();
|
||||
|
||||
void ColorPickedBtnToggled(bool e);
|
||||
void color_picked_btn_toggled(bool e);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORVALUESWIDGET_H
|
||||
#endif // OAK_COLORVALUESWIDGET_H
|
||||
|
||||
@@ -39,23 +39,23 @@ ColorWheelWidget::ColorWheelWidget(QWidget *parent)
|
||||
{
|
||||
}
|
||||
|
||||
Color ColorWheelWidget::GetColorFromScreenPos(const QPoint &p) const
|
||||
Color ColorWheelWidget::get_color_from_screen_pos(const QPoint &p) const
|
||||
{
|
||||
return GetColorFromTriangle(GetTriangleFromCoords(rect().center(), p));
|
||||
return get_color_from_triangle(get_triangle_from_coords(rect().center(), p));
|
||||
}
|
||||
|
||||
void ColorWheelWidget::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
ColorSwatchWidget::resizeEvent(e);
|
||||
|
||||
emit DiameterChanged(GetDiameter());
|
||||
emit diameter_changed(get_diameter());
|
||||
}
|
||||
|
||||
void ColorWheelWidget::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
ColorSwatchWidget::paintEvent(e);
|
||||
|
||||
int diameter = GetDiameter();
|
||||
int diameter = get_diameter();
|
||||
|
||||
// Half diameter
|
||||
int radius = diameter / 2;
|
||||
@@ -70,11 +70,11 @@ void ColorWheelWidget::paintEvent(QPaintEvent *e)
|
||||
|
||||
for (int i = 0; i < diameter; i++) {
|
||||
for (int j = 0; j < diameter; j++) {
|
||||
Triangle tri = GetTriangleFromCoords(center, j, i);
|
||||
Triangle tri = get_triangle_from_coords(center, j, i);
|
||||
|
||||
if (tri.hypotenuse <= radius) {
|
||||
Color managed = GetManagedColor(GetColorFromTriangle(tri));
|
||||
QColor c = QtUtils::toQColor(managed);
|
||||
Color managed = get_managed_color(get_color_from_triangle(tri));
|
||||
QColor c = QtUtils::to_q_color(managed);
|
||||
|
||||
// Very basic antialiasing around the edges of the wheel
|
||||
qreal alpha = qMin(1.0, radius - tri.hypotenuse);
|
||||
@@ -110,10 +110,10 @@ void ColorWheelWidget::paintEvent(QPaintEvent *e)
|
||||
// Really rough algorithm for determining whether the selector UI should be white or black
|
||||
|
||||
int selector_radius = qMax(1, radius / 32);
|
||||
p.setPen(QPen(GetUISelectorColor(), qMax(1, selector_radius / 4)));
|
||||
p.setPen(QPen(get_ui_selector_color(), qMax(1, selector_radius / 4)));
|
||||
p.setBrush(Qt::NoBrush);
|
||||
|
||||
p.drawEllipse(GetCoordsFromColor(GetSelectedColor()), selector_radius,
|
||||
p.drawEllipse(get_coords_from_color(get_selected_color()), selector_radius,
|
||||
selector_radius);
|
||||
}
|
||||
|
||||
@@ -125,25 +125,25 @@ void ColorWheelWidget::SelectedColorChangedEvent(const Color &c, bool external)
|
||||
}
|
||||
}
|
||||
|
||||
int ColorWheelWidget::GetDiameter() const
|
||||
int ColorWheelWidget::get_diameter() const
|
||||
{
|
||||
return qMin(width(), height());
|
||||
}
|
||||
|
||||
qreal ColorWheelWidget::GetRadius() const
|
||||
qreal ColorWheelWidget::get_radius() const
|
||||
{
|
||||
return GetDiameter() * 0.5;
|
||||
return get_diameter() * 0.5;
|
||||
}
|
||||
|
||||
ColorWheelWidget::Triangle
|
||||
ColorWheelWidget::GetTriangleFromCoords(const QPoint ¢er,
|
||||
ColorWheelWidget::get_triangle_from_coords(const QPoint ¢er,
|
||||
const QPoint &p) const
|
||||
{
|
||||
return GetTriangleFromCoords(center, p.y(), p.x());
|
||||
return get_triangle_from_coords(center, p.y(), p.x());
|
||||
}
|
||||
|
||||
ColorWheelWidget::Triangle
|
||||
ColorWheelWidget::GetTriangleFromCoords(const QPoint ¢er, qreal y,
|
||||
ColorWheelWidget::get_triangle_from_coords(const QPoint ¢er, qreal y,
|
||||
qreal x) const
|
||||
{
|
||||
qreal opposite = y - center.y();
|
||||
@@ -153,21 +153,21 @@ ColorWheelWidget::GetTriangleFromCoords(const QPoint ¢er, qreal y,
|
||||
return { opposite, adjacent, hypotenuse };
|
||||
}
|
||||
|
||||
Color ColorWheelWidget::GetColorFromTriangle(
|
||||
Color ColorWheelWidget::get_color_from_triangle(
|
||||
const ColorWheelWidget::Triangle &tri) const
|
||||
{
|
||||
qreal hue = qAtan2(tri.opposite, tri.adjacent) * M_180_OVER_PI + 180.0;
|
||||
qreal sat = qMin(1.0, (tri.hypotenuse / GetRadius()));
|
||||
qreal sat = qMin(1.0, (tri.hypotenuse / get_radius()));
|
||||
|
||||
return Color::fromHsv(hue, sat, val_);
|
||||
return Color::from_hsv(hue, sat, val_);
|
||||
}
|
||||
|
||||
QPoint ColorWheelWidget::GetCoordsFromColor(const Color &c) const
|
||||
QPoint ColorWheelWidget::get_coords_from_color(const Color &c) const
|
||||
{
|
||||
float hue, sat, val;
|
||||
c.toHsv(&hue, &sat, &val);
|
||||
c.to_hsv(&hue, &sat, &val);
|
||||
|
||||
qreal hypotenuse = sat * GetRadius();
|
||||
qreal hypotenuse = sat * get_radius();
|
||||
|
||||
qreal radian_angle = (hue - 180.0) / M_180_OVER_PI;
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORWHEELWIDGET_H
|
||||
#define COLORWHEELWIDGET_H
|
||||
#ifndef OAK_COLORWHEELWIDGET_H
|
||||
#define OAK_COLORWHEELWIDGET_H
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
|
||||
@@ -35,10 +35,10 @@ public:
|
||||
ColorWheelWidget(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void DiameterChanged(int radius);
|
||||
void diameter_changed(int radius);
|
||||
|
||||
protected:
|
||||
virtual Color GetColorFromScreenPos(const QPoint &p) const override;
|
||||
virtual Color get_color_from_screen_pos(const QPoint &p) const override;
|
||||
|
||||
virtual void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
@@ -48,9 +48,9 @@ protected:
|
||||
bool external) override;
|
||||
|
||||
private:
|
||||
int GetDiameter() const;
|
||||
int get_diameter() const;
|
||||
|
||||
qreal GetRadius() const;
|
||||
qreal get_radius() const;
|
||||
|
||||
struct Triangle {
|
||||
qreal opposite;
|
||||
@@ -58,12 +58,12 @@ private:
|
||||
qreal hypotenuse;
|
||||
};
|
||||
|
||||
Triangle GetTriangleFromCoords(const QPoint ¢er, const QPoint &p) const;
|
||||
Triangle GetTriangleFromCoords(const QPoint ¢er, qreal y,
|
||||
Triangle get_triangle_from_coords(const QPoint ¢er, const QPoint &p) const;
|
||||
Triangle get_triangle_from_coords(const QPoint ¢er, qreal y,
|
||||
qreal x) const;
|
||||
|
||||
Color GetColorFromTriangle(const Triangle &tri) const;
|
||||
QPoint GetCoordsFromColor(const Color &c) const;
|
||||
Color get_color_from_triangle(const Triangle &tri) const;
|
||||
QPoint get_coords_from_color(const Color &c) const;
|
||||
|
||||
QPixmap cached_wheel_;
|
||||
|
||||
@@ -74,4 +74,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORWHEELWIDGET_H
|
||||
#endif // OAK_COLORWHEELWIDGET_H
|
||||
|
||||
Reference in New Issue
Block a user