diff --git a/gui_qt/baseform.cpp b/gui_qt/baseform.cpp index 95b5f87..1a55164 100644 --- a/gui_qt/baseform.cpp +++ b/gui_qt/baseform.cpp @@ -1,5 +1,7 @@ #include "baseform.h" + #include "inputdouble.h" +#include "inputcolor.h" #include #include @@ -79,3 +81,8 @@ void BaseForm::addInputDouble(QString label, double* value, double min, double m { addInput(new InputDouble(form, label, value, min, max, small_step, large_step)); } + +void BaseForm::addInputColor(QString label, Color* value) +{ + addInput(new InputColor(form, label, value)); +} diff --git a/gui_qt/baseform.h b/gui_qt/baseform.h index 625864e..6348dfc 100644 --- a/gui_qt/baseform.h +++ b/gui_qt/baseform.h @@ -4,6 +4,7 @@ #include #include "preview.h" #include "baseinput.h" +#include "../lib_paysages/shared/types.h" class BaseForm:public QWidget { @@ -20,6 +21,7 @@ protected: void addPreview(Preview* preview, QString label); void addInput(BaseInput* input); void addInputDouble(QString label, double* value, double min, double max, double small_step, double large_step); + void addInputColor(QString label, Color* value); private: QWidget* previews; diff --git a/gui_qt/baseinput.cpp b/gui_qt/baseinput.cpp index 44d0f33..b2d5f5c 100644 --- a/gui_qt/baseinput.cpp +++ b/gui_qt/baseinput.cpp @@ -7,3 +7,8 @@ BaseInput::BaseInput(QWidget* form, QString label): { _label = new QLabel(label); } + +void BaseInput::applyValue() +{ + emit(valueChanged()); +} diff --git a/gui_qt/baseinput.h b/gui_qt/baseinput.h index 223e946..cfebde1 100644 --- a/gui_qt/baseinput.h +++ b/gui_qt/baseinput.h @@ -18,7 +18,7 @@ public slots: virtual void revert() = 0; protected slots: - virtual void applyValue() = 0; + virtual void applyValue(); signals: void valueChanged(); diff --git a/gui_qt/formwater.cpp b/gui_qt/formwater.cpp index cd9c42f..03c08c1 100644 --- a/gui_qt/formwater.cpp +++ b/gui_qt/formwater.cpp @@ -132,8 +132,10 @@ FormWater::FormWater(QWidget *parent) : addPreview(previewColor, QString("Color preview")); addInputDouble("Height", &_definition.height, -20.0, 20.0, 0.1, 1.0); + addInputColor("Surface color", &_definition.main_color); addInputDouble("Transparency", &_definition.transparency, 0.0, 1.0, 0.001, 0.1); addInputDouble("Reflection", &_definition.reflection, 0.0, 1.0, 0.001, 0.1); + addInputColor("Depth color", &_definition.depth_color); addInputDouble("Depth filtering", &_definition.transparency_depth, 0.0, 100.0, 0.5, 5.0); revertConfig(); diff --git a/gui_qt/inputcolor.cpp b/gui_qt/inputcolor.cpp index f5e2d84..a80279a 100644 --- a/gui_qt/inputcolor.cpp +++ b/gui_qt/inputcolor.cpp @@ -1,20 +1,21 @@ #include "inputcolor.h" #include +#include -InputColor::InputColor(QWidget* form, QString label, Color color): +InputColor::InputColor(QWidget* form, QString label, Color* value): BaseInput(form, label), - _color(color) + _value(value) { setObjectName("_inputcolor_"); - _preview = new QLabel(form); - _control = new QLabel(form); + _preview = new QWidget(form); + _control = new QPushButton("Edit", form); } void InputColor::applyValue() { - emit(valueChanged()); + BaseInput::applyValue(); } void InputColor::revert() diff --git a/gui_qt/inputcolor.h b/gui_qt/inputcolor.h index f998e96..33090a6 100644 --- a/gui_qt/inputcolor.h +++ b/gui_qt/inputcolor.h @@ -11,7 +11,7 @@ class InputColor:public BaseInput Q_OBJECT public: - InputColor(QWidget* form, QString label, Color value); + InputColor(QWidget* form, QString label, Color* value); public slots: virtual void revert(); @@ -20,7 +20,7 @@ protected slots: virtual void applyValue(); private: - Color _color; + Color* _value; }; #endif // _GUI_QT_INPUTCOLOR_H_ diff --git a/gui_qt/inputdouble.cpp b/gui_qt/inputdouble.cpp index 1840702..73e5864 100644 --- a/gui_qt/inputdouble.cpp +++ b/gui_qt/inputdouble.cpp @@ -31,7 +31,8 @@ void InputDouble::applyValue() { *value = ((double)slider->value()) * small_step; ((QLabel*)_preview)->setText(QString("%1").arg(*value)); - emit(valueChanged()); + + BaseInput::applyValue(); } void InputDouble::revert()