From f677e2a536d84c1db5145db80b9e9a7540cfbb6d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 5 Feb 2014 12:50:59 +0300 Subject: add slider list setup control for int value. --- src/gui/widgets/setupitem.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/gui/widgets/setupitem.h | 30 ++++++++++++++++++++++++++++-- 2 files changed, 65 insertions(+), 2 deletions(-) (limited to 'src/gui/widgets') diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index b9ea91f76..a34447516 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -1139,3 +1139,40 @@ void SetupItemSound::action(const gcn::ActionEvent &event) SetupItemSliderList::action(event); } } + +SetupItemSliderInt::SetupItemSliderInt(const std::string &restrict text, + const std::string &restrict description, + const std::string &restrict keyName, + SetupTabScroll *restrict const parent, + const std::string &restrict eventName, + gcn::ListModel *restrict const model, + const int min, + const int width, + const bool onTheFly, + const bool mainConfig) : + SetupItemSliderList(text, description, keyName, parent, eventName, + model, width, onTheFly, mainConfig), + mMin(min) +{ + createControls(); +} + +void SetupItemSliderInt::addMoreControls() +{ +} + +void SetupItemSliderInt::fromWidget() +{ + if (!mSlider) + return; + + mValue = toString(mSlider->getSelected() + mMin); +} + +void SetupItemSliderInt::toWidget() +{ + if (!mSlider) + return; + + mSlider->setSelected(atoi(mValue.c_str()) - mMin); +} diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 689f62fdf..c72bb39ef 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -466,9 +466,9 @@ class SetupItemSliderList : public SetupItem void createControls(); - void fromWidget() override final; + void fromWidget() override; - void toWidget() override final; + void toWidget() override; virtual void action(const gcn::ActionEvent &event) override; @@ -528,4 +528,30 @@ class SetupItemSound final : public SetupItemSliderList Button *mButton; }; +class SetupItemSliderInt final : public SetupItemSliderList +{ + public: + SetupItemSliderInt(const std::string &restrict text, + const std::string &restrict description, + const std::string &restrict keyName, + SetupTabScroll *restrict const parent, + const std::string &restrict eventName, + gcn::ListModel *restrict const model, + const int min, + const int width = 150, + const bool onTheFly = false, + const bool mainConfig = true); + + A_DELETE_COPY(SetupItemSliderInt) + + void addMoreControls() override final; + + void fromWidget() override final; + + void toWidget() override final; + + protected: + int mMin; +}; + #endif // GUI_WIDGETS_SETUPITEM_H -- cgit v1.2.3-60-g2f50