-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KnobGuiColor: replace QColorDialog with ColorSelector (#657)
* Gui: Added QtColorTriangle from Qt Solutions Maintained in Natron under the GNU Lesser General Public 2.1 license. Updated to work in Qt4 and Qt5. * Gui/ScaleSliderQWidget: support custom slider color * Gui: added ColorSelectorWidget * Gui/KnobGuiColor: replace QColorDialog with ColorSelectorWidget * Gui/ColorSelectorWidget: added tooltips * Gui/ColorSelectorWidget: added hsv sliders * Gui/ColorSelectorWidget: minor ui * Gui/ColorSelectorWidget: ui changes * Gui/ColorSelectorWidget: hsv slider fix forgot to set slider value when spinbox changed.
- Loading branch information
Showing
10 changed files
with
2,797 additions
and
112 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
/* ***** BEGIN LICENSE BLOCK ***** | ||
* This file is part of Natron <https://natrongithub.github.io/>, | ||
* (C) 2018-2021 The Natron developers | ||
* (C) 2013-2018 INRIA and Alexandre Gauthier-Foichat | ||
* | ||
* Natron 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 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Natron 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 Natron. If not, see <http://www.gnu.org/licenses/gpl-2.0.html> | ||
* ***** END LICENSE BLOCK ***** */ | ||
|
||
#ifndef Gui_ColorSelectorWidget_h | ||
#define Gui_ColorSelectorWidget_h | ||
|
||
#include "Global/Macros.h" | ||
|
||
CLANG_DIAG_OFF(deprecated) | ||
CLANG_DIAG_OFF(uninitialized) | ||
#include <QWidget> | ||
#include <QColor> | ||
#include "Gui/QtColorTriangle.h" // from Qt Solutions | ||
#include <QMouseEvent> | ||
#include <QEvent> | ||
#include <QStackedWidget> | ||
CLANG_DIAG_ON(deprecated) | ||
CLANG_DIAG_ON(uninitialized) | ||
|
||
#include "Gui/ScaleSliderQWidget.h" | ||
#include "Gui/SpinBox.h" | ||
#include "Gui/LineEdit.h" | ||
#include "Gui/Button.h" | ||
|
||
NATRON_NAMESPACE_ENTER | ||
|
||
class ColorSelectorWidget : public QWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
explicit ColorSelectorWidget(QWidget *parent = NULL); | ||
void getColor(float *r, float *g, float *b, float *a); | ||
|
||
Q_SIGNALS: | ||
|
||
void colorChanged(float r, float g, float b, float a); | ||
void updateColor(); | ||
|
||
public Q_SLOTS: | ||
|
||
void setColor(float r, float g, float b, float a); | ||
|
||
private: | ||
|
||
SpinBox *_spinR; | ||
SpinBox *_spinG; | ||
SpinBox *_spinB; | ||
SpinBox *_spinH; | ||
SpinBox *_spinS; | ||
SpinBox *_spinV; | ||
SpinBox *_spinA; | ||
|
||
ScaleSliderQWidget *_slideR; | ||
ScaleSliderQWidget *_slideG; | ||
ScaleSliderQWidget *_slideB; | ||
ScaleSliderQWidget *_slideH; | ||
ScaleSliderQWidget *_slideS; | ||
ScaleSliderQWidget *_slideV; | ||
ScaleSliderQWidget *_slideA; | ||
|
||
QtColorTriangle *_triangle; | ||
|
||
LineEdit *_hex; | ||
|
||
Button *_button; | ||
|
||
QStackedWidget *_stack; | ||
|
||
void setRedChannel(float value); | ||
void setGreenChannel(float value); | ||
void setBlueChannel(float value); | ||
void setHueChannel(float value); | ||
void setSaturationChannel(float value); | ||
void setValueChannel(float value); | ||
void setAlphaChannel(float value); | ||
void setTriangle(float r, float g, float b, float a); | ||
void setHex(const QColor &color); | ||
|
||
void announceColorChange(); | ||
|
||
void setTriangleSize(); | ||
|
||
private Q_SLOTS: | ||
|
||
void handleTriangleColorChanged(const QColor &color, bool announce = true); | ||
|
||
void manageColorRGBChanged(bool announce = true); | ||
void manageColorHSVChanged(bool announce = true); | ||
void manageColorAlphaChanged(bool announce = true); | ||
|
||
void handleSpinRChanged(double value); | ||
void handleSpinGChanged(double value); | ||
void handleSpinBChanged(double value); | ||
void handleSpinHChanged(double value); | ||
void handleSpinSChanged(double value); | ||
void handleSpinVChanged(double value); | ||
void handleSpinAChanged(double value); | ||
|
||
void handleHexChanged(); | ||
|
||
void handleSliderRMoved(double value); | ||
void handleSliderGMoved(double value); | ||
void handleSliderBMoved(double value); | ||
void handleSliderHMoved(double value); | ||
void handleSliderSMoved(double value); | ||
void handleSliderVMoved(double value); | ||
void handleSliderAMoved(double value); | ||
|
||
void setSliderHColor(); | ||
void setSliderSColor(); | ||
void setSliderVColor(); | ||
|
||
void handleButtonClicked(bool checked); | ||
|
||
// workaround for QToolButton+QWidgetAction | ||
// triggered signal(s) are never emitted!? | ||
bool event(QEvent*e) override | ||
{ | ||
if (e->type() == QEvent::Show) { | ||
Q_EMIT updateColor(); | ||
} | ||
return QWidget::event(e); | ||
} | ||
|
||
// https://bugreports.qt.io/browse/QTBUG-47406 | ||
void mousePressEvent(QMouseEvent *e) override | ||
{ | ||
e->accept(); | ||
} | ||
void mouseReleaseEvent(QMouseEvent *e) override | ||
{ | ||
e->accept(); | ||
} | ||
}; | ||
|
||
NATRON_NAMESPACE_EXIT | ||
|
||
#endif // Gui_ColorSelectorWidget_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.