paysages: Qt GUI (WIP)

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@215 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-01-05 19:41:10 +00:00 committed by ThunderK
parent 1fcbb37f17
commit 08344579e5
8 changed files with 27 additions and 9 deletions

View file

@ -1,5 +1,7 @@
#include "baseform.h"
#include "inputdouble.h"
#include "inputcolor.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
@ -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));
}

View file

@ -4,6 +4,7 @@
#include <QWidget>
#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;

View file

@ -7,3 +7,8 @@ BaseInput::BaseInput(QWidget* form, QString label):
{
_label = new QLabel(label);
}
void BaseInput::applyValue()
{
emit(valueChanged());
}

View file

@ -18,7 +18,7 @@ public slots:
virtual void revert() = 0;
protected slots:
virtual void applyValue() = 0;
virtual void applyValue();
signals:
void valueChanged();

View file

@ -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();

View file

@ -1,20 +1,21 @@
#include "inputcolor.h"
#include <QLabel>
#include <QPushButton>
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()

View file

@ -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_

View file

@ -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()