Commit 024e44d2 authored by Julius Künzel's avatar Julius Künzel
Browse files

Re-use NegQColor

Recognized thanks to new CI
parent 685536b3
......@@ -21,87 +21,6 @@
#include <qmath.h>
#include <utility>
NegQColor NegQColor::fromHsvF(qreal h, qreal s, qreal l, qreal a)
{
NegQColor color;
color.qcolor = QColor::fromHsvF(h, s, l < 0 ? -l : l, a);
color.sign_r = l < 0 ? -1 : 1;
color.sign_g = l < 0 ? -1 : 1;
color.sign_b = l < 0 ? -1 : 1;
return color;
}
NegQColor NegQColor::fromRgbF(qreal r, qreal g, qreal b, qreal a)
{
NegQColor color;
color.qcolor = QColor::fromRgbF(r < 0 ? -r : r, g < 0 ? -g : g, b < 0 ? -b : b, a);
color.sign_r = r < 0 ? -1 : 1;
color.sign_g = g < 0 ? -1 : 1;
color.sign_b = b < 0 ? -1 : 1;
return color;
}
qreal NegQColor::redF() const
{
return qcolor.redF() * sign_r;
}
void NegQColor::setRedF(qreal val)
{
sign_r = val < 0 ? -1 : 1;
qcolor.setRedF(val * sign_r);
}
qreal NegQColor::greenF() const
{
return qcolor.greenF() * sign_g;
}
void NegQColor::setGreenF(qreal val)
{
sign_g = val < 0 ? -1 : 1;
qcolor.setGreenF(val * sign_g);
}
qreal NegQColor::blueF() const
{
return qcolor.blueF() * sign_b;
}
void NegQColor::setBlueF(qreal val)
{
sign_b = val < 0 ? -1 : 1;
qcolor.setBlueF(val * sign_b);
}
qreal NegQColor::valueF() const
{
return qcolor.valueF() * sign_g;
}
void NegQColor::setValueF(qreal val)
{
qcolor = QColor::fromHsvF(hueF(), saturationF(), val < 0 ? -val : val, 1.);
sign_r = val < 0 ? -1 : 1;
sign_g = val < 0 ? -1 : 1;
sign_b = val < 0 ? -1 : 1;
}
int NegQColor::hue() const
{
return qcolor.hue();
}
qreal NegQColor::hueF() const
{
return qcolor.hueF();
}
qreal NegQColor::saturationF() const
{
return qcolor.saturationF();
}
WheelContainer::WheelContainer(QString id, QString name, NegQColor color, int unitSize, QWidget *parent)
: QWidget(parent)
, m_id(std::move(id))
......
......@@ -8,6 +8,8 @@
#ifndef COLORWHEELPARAM_H
#define COLORWHEELPARAM_H
#include "utils/negqcolor.h"
#include <QPainter>
#include <QResizeEvent>
#include <QWidget>
......@@ -15,28 +17,6 @@
class QDoubleSpinBox;
class QLabel;
class NegQColor
{
public:
int8_t sign_r = 1;
int8_t sign_g = 1;
int8_t sign_b = 1;
QColor qcolor;
static NegQColor fromHsvF(qreal h, qreal s, qreal l, qreal a = 1.0);
static NegQColor fromRgbF(qreal r, qreal g, qreal b, qreal a = 1.0);
qreal redF() const;
qreal greenF() const;
qreal blueF() const;
qreal valueF() const;
int hue() const;
qreal hueF() const;
qreal saturationF() const;
void setRedF(qreal val);
void setGreenF(qreal val);
void setBlueF(qreal val);
void setValueF(qreal val);
};
class WheelContainer : public QWidget
{
Q_OBJECT
......
......@@ -18,54 +18,6 @@
static const qreal WHEEL_SLIDER_RATIO = 10.0;
NegQColor NegQColor::fromHsvF(qreal h, qreal s, qreal l, qreal a)
{
NegQColor color;
color.qcolor = QColor::fromHsvF(h, s, l < 0 ? -l : l, a);
color.sign_r = l < 0 ? -1 : 1;
color.sign_g = l < 0 ? -1 : 1;
color.sign_b = l < 0 ? -1 : 1;
return color;
}
NegQColor NegQColor::fromRgbF(qreal r, qreal g, qreal b, qreal a)
{
NegQColor color;
color.qcolor = QColor::fromRgbF(r < 0 ? -r : r, g < 0 ? -g : g, b < 0 ? -b : b, a);
color.sign_r = r < 0 ? -1 : 1;
color.sign_g = g < 0 ? -1 : 1;
color.sign_b = b < 0 ? -1 : 1;
return color;
}
qreal NegQColor::redF()
{
return qcolor.redF() * sign_r;
}
qreal NegQColor::greenF()
{
return qcolor.greenF() * sign_g;
}
qreal NegQColor::blueF()
{
return qcolor.blueF() * sign_b;
}
qreal NegQColor::valueF()
{
return qcolor.valueF() * sign_g;
}
int NegQColor::hue()
{
return qcolor.hue();
}
qreal NegQColor::hueF()
{
return qcolor.hueF();
}
qreal NegQColor::saturationF()
{
return qcolor.saturationF();
}
ColorWheelItem::ColorWheelItem(QQuickItem *parent)
: QQuickPaintedItem(parent)
, m_image()
......
......@@ -10,27 +10,11 @@
#ifndef COLORWHEELITEM_H
#define COLORWHEELITEM_H
#include "utils/negqcolor.h"
#include <QImage>
#include <QQuickPaintedItem>
class NegQColor
{
public:
int8_t sign_r = 1;
int8_t sign_g = 1;
int8_t sign_b = 1;
QColor qcolor;
static NegQColor fromHsvF(qreal h, qreal s, qreal l, qreal a = 1.0);
static NegQColor fromRgbF(qreal r, qreal g, qreal b, qreal a = 1.0);
qreal redF();
qreal greenF();
qreal blueF();
qreal valueF();
int hue();
qreal hueF();
qreal saturationF();
};
class ColorWheelItem : public QQuickPaintedItem
{
Q_OBJECT
......
......@@ -3,6 +3,7 @@ set(kdenlive_SRCS
utils/clipboardproxy.cpp
utils/devices.cpp
utils/flowlayout.cpp
utils/negqcolor.cpp
utils/otioconvertions.cpp
utils/thememanager.cpp
utils/thumbnailcache.cpp
......
/*
SPDX-FileCopyrightText: 2017 Dušan Hanuš <hanus@pixelhouse.cz>
SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "negqcolor.h"
NegQColor::NegQColor()
{
}
NegQColor NegQColor::fromHsvF(qreal h, qreal s, qreal l, qreal a)
{
NegQColor color;
color.qcolor = QColor::fromHsvF(h, s, l < 0 ? -l : l, a);
color.sign_r = l < 0 ? -1 : 1;
color.sign_g = l < 0 ? -1 : 1;
color.sign_b = l < 0 ? -1 : 1;
return color;
}
NegQColor NegQColor::fromRgbF(qreal r, qreal g, qreal b, qreal a)
{
NegQColor color;
color.qcolor = QColor::fromRgbF(r < 0 ? -r : r, g < 0 ? -g : g, b < 0 ? -b : b, a);
color.sign_r = r < 0 ? -1 : 1;
color.sign_g = g < 0 ? -1 : 1;
color.sign_b = b < 0 ? -1 : 1;
return color;
}
qreal NegQColor::redF() const
{
return qcolor.redF() * sign_r;
}
void NegQColor::setRedF(qreal val)
{
sign_r = val < 0 ? -1 : 1;
qcolor.setRedF(val * sign_r);
}
qreal NegQColor::greenF() const
{
return qcolor.greenF() * sign_g;
}
void NegQColor::setGreenF(qreal val)
{
sign_g = val < 0 ? -1 : 1;
qcolor.setGreenF(val * sign_g);
}
qreal NegQColor::blueF() const
{
return qcolor.blueF() * sign_b;
}
void NegQColor::setBlueF(qreal val)
{
sign_b = val < 0 ? -1 : 1;
qcolor.setBlueF(val * sign_b);
}
void NegQColor::setValueF(qreal val)
{
qcolor = QColor::fromHsvF(hueF(), saturationF(), val < 0 ? -val : val, 1.);
sign_r = val < 0 ? -1 : 1;
sign_g = val < 0 ? -1 : 1;
sign_b = val < 0 ? -1 : 1;
}
qreal NegQColor::valueF() const
{
return qcolor.valueF() * sign_g;
}
int NegQColor::hue() const
{
return qcolor.hue();
}
qreal NegQColor::hueF() const
{
return qcolor.hueF();
}
qreal NegQColor::saturationF() const
{
return qcolor.saturationF();
}
/*
SPDX-FileCopyrightText: 2017 Dušan Hanuš <hanus@pixelhouse.cz>
SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#ifndef NEGQCOLOR_H
#define NEGQCOLOR_H
#include <QtGlobal>
#include <QColor>
class QColor;
class NegQColor
{
public:
NegQColor();
int8_t sign_r = 1;
int8_t sign_g = 1;
int8_t sign_b = 1;
QColor qcolor;
static NegQColor fromHsvF(qreal h, qreal s, qreal l, qreal a = 1.0);
static NegQColor fromRgbF(qreal r, qreal g, qreal b, qreal a = 1.0);
qreal redF() const;
void setRedF(qreal val);
qreal greenF() const;
void setGreenF(qreal val);
qreal blueF() const;
void setBlueF(qreal val);
qreal valueF() const;
void setValueF(qreal val);
int hue() const;
qreal hueF() const;
qreal saturationF() const;
};
#endif // NEGQCOLOR_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment