From 4b85289ac7d550a07dc40a00600e8f1976e5fce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Mon, 1 Oct 2012 15:36:41 +0000 Subject: [PATCH] paysages : InputInt now honor its small_step value. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@431 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- TODO | 1 - gui_qt/inputint.cpp | 41 +++++++---------------------------------- gui_qt/inputint.h | 10 +++------- 3 files changed, 10 insertions(+), 42 deletions(-) diff --git a/TODO b/TODO index e554acb..e680d85 100644 --- a/TODO +++ b/TODO @@ -9,7 +9,6 @@ Technology Preview 2 : - Finalize Preetham's model usage => Apply model to atmosphere (aerial perspective) => Find a proper model for night sky (maybe Shirley) -- InputInt doesn't honor small_step. - Keep skydome lights in cache for a render. - Add buttons to restore "auto" default values in tabs and dialogs (with several auto presets). - Clouds should keep distance to ground. diff --git a/gui_qt/inputint.cpp b/gui_qt/inputint.cpp index 091d83f..016e8bf 100644 --- a/gui_qt/inputint.cpp +++ b/gui_qt/inputint.cpp @@ -3,54 +3,27 @@ #include InputInt::InputInt(QWidget* form, QString label, int* value, int min, int max, int small_step, int large_step): - BaseInput(form, label) + InputDouble(form, label, &_dvalue, (double)min, (double)max, (double)small_step, (double)large_step) { _value = value; - _min = min; - _max = max; - _small_step = small_step; - _large_step = large_step; - - _slider = new QSlider(form); - - _slider->setOrientation(Qt::Horizontal); - _slider->setMinimumWidth(150); - _slider->setMaximumWidth(400); - - _slider->setMinimum(min); - _slider->setMaximum(max); - _slider->setValue(*value); - - _slider->setTickInterval(large_step); - _slider->setTickPosition(QSlider::TicksBelow); - - connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue())); - - _preview = new QLabel(form); - ((QLabel*)_preview)->setAlignment(Qt::AlignCenter); - _control = _slider; + _dvalue = (double)(*value); } void InputInt::updatePreview() { - ((QLabel*)_preview)->setText(QString("%1").arg(*_value)); - - BaseInput::updatePreview(); + ((QLabel*)_preview)->setText(QString("%1").arg(_dvalue, 0, 'f', 0)); } void InputInt::applyValue() { - *_value = (int)_slider->value(); + *_value = (int)_dvalue; - BaseInput::applyValue(); + InputDouble::applyValue(); } void InputInt::revert() { - if (*_value != _slider->value()) - { - _slider->setValue(*_value); - } + _dvalue = (double)(*_value); - BaseInput::revert(); + InputDouble::revert(); } diff --git a/gui_qt/inputint.h b/gui_qt/inputint.h index 9c6e942..493e00d 100644 --- a/gui_qt/inputint.h +++ b/gui_qt/inputint.h @@ -3,9 +3,9 @@ #include #include -#include "baseinput.h" +#include "inputdouble.h" -class InputInt:public BaseInput +class InputInt:public InputDouble { Q_OBJECT @@ -18,12 +18,8 @@ public slots: virtual void revert(); private: - QSlider* _slider; int* _value; - int _min; - int _max; - int _small_step; - int _large_step; + double _dvalue; }; #endif