diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-04-02 13:20:23 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-04-02 13:20:23 +0300 |
commit | 39a3fd884d6d585825d9f80a578c6f466a856ec3 (patch) | |
tree | ee0184c30b08dd452ae9e4e523a9bb6aa291f33b /src/gui | |
parent | 35278ed7f80ed8a02785573d510c36b38998debe (diff) | |
download | manaverse-39a3fd884d6d585825d9f80a578c6f466a856ec3.tar.gz manaverse-39a3fd884d6d585825d9f80a578c6f466a856ec3.tar.bz2 manaverse-39a3fd884d6d585825d9f80a578c6f466a856ec3.tar.xz manaverse-39a3fd884d6d585825d9f80a578c6f466a856ec3.zip |
Set correct step in sliders.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/widgets/setupitem.cpp | 30 | ||||
-rw-r--r-- | src/gui/widgets/setupitem.h | 38 | ||||
-rw-r--r-- | src/gui/widgets/slider.cpp | 10 | ||||
-rw-r--r-- | src/gui/widgets/slider.h | 8 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_audio.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_colors.cpp | 10 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_video.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_visual.cpp | 8 | ||||
-rw-r--r-- | src/gui/windows/buydialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/charcreatedialog.cpp | 5 | ||||
-rw-r--r-- | src/gui/windows/itemamountwindow.cpp | 4 | ||||
-rw-r--r-- | src/gui/windows/selldialog.cpp | 2 |
12 files changed, 78 insertions, 51 deletions
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 4c32b0572..87bc2baa5 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -713,8 +713,11 @@ SetupItemSlider::SetupItemSlider(const std::string &restrict text, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const double min, const double max, - const int width, const bool onTheFly, + const double min, + const double max, + const double step, + const int width, + const bool onTheFly, const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), mHorizont(nullptr), @@ -722,6 +725,7 @@ SetupItemSlider::SetupItemSlider(const std::string &restrict text, mSlider(nullptr), mMin(min), mMax(max), + mStep(step), mWidth(width), mOnTheFly(onTheFly) { @@ -734,7 +738,9 @@ SetupItemSlider::SetupItemSlider(const std::string &restrict text, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const double min, const double max, + const double min, + const double max, + const double step, const std::string &restrict def, const int width, const bool onTheFly, @@ -745,6 +751,7 @@ SetupItemSlider::SetupItemSlider(const std::string &restrict text, mSlider(nullptr), mMin(min), mMax(max), + mStep(step), mWidth(width), mOnTheFly(onTheFly) { @@ -766,7 +773,7 @@ void SetupItemSlider::createControls() mHorizont = new HorizontContainer(this, 32, 2); mLabel = new Label(this, mText); - mSlider = new Slider(this, mMin, mMax); + mSlider = new Slider(this, mMin, mMax, mStep); mSlider->setActionEventId(mEventName); mSlider->addActionListener(mParent); mSlider->setValue(atof(mValue.c_str())); @@ -823,7 +830,9 @@ SetupItemSlider2::SetupItemSlider2(const std::string &restrict text, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const int min, const int max, + const int min, + const int max, + const int step, SetupItemNames *restrict const values, const bool onTheFly, const bool mainConfig, @@ -836,6 +845,7 @@ SetupItemSlider2::SetupItemSlider2(const std::string &restrict text, mValues(values), mMin(min), mMax(max), + mStep(step), mInvertValue(0), mInvert(false), mOnTheFly(onTheFly), @@ -850,10 +860,13 @@ SetupItemSlider2::SetupItemSlider2(const std::string &restrict text, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const int min, const int max, + const int min, + const int max, + const int step, SetupItemNames *restrict const values, const std::string &restrict def, - const bool onTheFly, const bool mainConfig, + const bool onTheFly, + const bool mainConfig, const bool doNotAlign) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), mHorizont(nullptr), @@ -863,6 +876,7 @@ SetupItemSlider2::SetupItemSlider2(const std::string &restrict text, mValues(values), mMin(min), mMax(max), + mStep(step), mInvertValue(0), mInvert(false), mOnTheFly(onTheFly), @@ -890,7 +904,7 @@ void SetupItemSlider2::createControls() mLabel = new Label(this, mText); mLabel2 = new Label(this, ""); mLabel2->setWidth(width); - mSlider = new Slider(this, mMin, mMax); + mSlider = new Slider(this, mMin, mMax, mStep); mSlider->setActionEventId(mEventName); mSlider->addActionListener(mParent); mSlider->setValue(atof(mValue.c_str())); diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 7dee860be..03681ad90 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -350,19 +350,25 @@ class SetupItemSlider final : public SetupItem const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const double min, const double max, - const int width = 150, const bool onTheFly = false, - const bool mainConfig = true); + const double min, + const double max, + const double step, + const int width, + const bool onTheFly, + const bool mainConfig); SetupItemSlider(const std::string &restrict text, const std::string &restrict description, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const double min, const double max, - const std::string &restrict def, const int width = 150, - const bool onTheFly = false, - const bool mainConfig = true); + const double min, + const double max, + const double step, + const std::string &restrict def, + const int width, + const bool onTheFly, + const bool mainConfig); A_DELETE_COPY(SetupItemSlider) @@ -386,6 +392,7 @@ class SetupItemSlider final : public SetupItem Slider *mSlider; double mMin; double mMax; + double mStep; int mWidth; bool mOnTheFly; }; @@ -402,23 +409,23 @@ class SetupItemSlider2 final : public SetupItem const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const int min, const int max, + const int min, const int max, const int step, SetupItemNames *restrict const values, - const bool onTheFly = false, - const bool mainConfig = true, - const bool doNotAlign = false); + const bool onTheFly, + const bool mainConfig, + const bool doNotAlign); SetupItemSlider2(const std::string &restrict text, const std::string &restrict description, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const int min, const int max, + const int min, const int max, const int step, SetupItemNames *restrict const values, const std::string &restrict def, - const bool onTheFly = false, - const bool mainConfig = true, - const bool doNotAlign = false); + const bool onTheFly, + const bool mainConfig, + const bool doNotAlign); A_DELETE_COPY(SetupItemSlider2) @@ -448,6 +455,7 @@ class SetupItemSlider2 final : public SetupItem SetupItemNames *mValues; int mMin; int mMax; + int mStep; int mInvertValue; bool mInvert; bool mOnTheFly; diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 66265a919..6119fc624 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -91,12 +91,13 @@ static std::string const data[2] = }; Slider::Slider(Widget2 *const widget, - const double scaleEnd) : + const double scaleEnd, + const double stepLength) : Widget(widget), MouseListener(), KeyListener(), mValue(0), - mStepLength(scaleEnd / 10), + mStepLength(stepLength), mScaleStart(0), mScaleEnd(scaleEnd), mOrientation(HORIZONTAL), @@ -110,12 +111,13 @@ Slider::Slider(Widget2 *const widget, Slider::Slider(Widget2 *const widget, const double scaleStart, - const double scaleEnd) : + const double scaleEnd, + const double stepLength) : Widget(widget), MouseListener(), KeyListener(), mValue(scaleStart), - mStepLength((scaleEnd - scaleStart) / 10), + mStepLength(stepLength), mScaleStart(scaleStart), mScaleEnd(scaleEnd), mOrientation(HORIZONTAL), diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index 164048020..fe59119f5 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -98,15 +98,17 @@ class Slider final : public Widget, /** * Constructor with scale start equal to 0. */ - explicit Slider(Widget2 *const widget, - const double scaleEnd = 1.0); + Slider(Widget2 *const widget, + const double scaleEnd, + const double stepLength); /** * Constructor. */ Slider(Widget2 *const widget, const double scaleStart, - const double scaleEnd); + const double scaleEnd, + const double stepLength); A_DELETE_COPY(Slider) diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp index 89a9594c1..707a4f2b9 100644 --- a/src/gui/widgets/tabs/setup_audio.cpp +++ b/src/gui/widgets/tabs/setup_audio.cpp @@ -73,11 +73,13 @@ Setup_Audio::Setup_Audio(const Widget2 *const widget) : // TRANSLATORS: settings option new SetupItemSlider(_("Sfx volume"), "", "sfxVolume", - this, "sfxVolumeEvent", 0, soundManager.getMaxVolume(), 150, true); + this, "sfxVolumeEvent", 0, soundManager.getMaxVolume(), 1, + 150, true, true); // TRANSLATORS: settings option new SetupItemSlider(_("Music volume"), "", "musicVolume", - this, "musicVolumeEvent", 0, soundManager.getMaxVolume(), 150, true); + this, "musicVolumeEvent", 0, soundManager.getMaxVolume(), 1, + 150, true, true); // TRANSLATORS: settings option new SetupItemCheckBox(_("Enable music fade out"), "", @@ -97,7 +99,7 @@ Setup_Audio::Setup_Audio(const Widget2 *const widget) : mChannelsList->push_back(_("surround+center+lfe")); // TRANSLATORS: settings option new SetupItemSlider2(_("Audio channels"), "", "audioChannels", this, - "audioChannels", 1, 4, mChannelsList); + "audioChannels", 1, 4, 1, mChannelsList, false, true, false); // TRANSLATORS: settings group diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 00537ad05..53260ff01 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -61,23 +61,23 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : mSelected(-1), // TRANSLATORS: colors tab. label. mGradTypeLabel(new Label(this, _("Type:"))), - mGradTypeSlider(new Slider(this, 0, 3)), + mGradTypeSlider(new Slider(this, 0.0, 3.0, 1.0)), mGradTypeText(new Label(this)), // TRANSLATORS: colors tab. label. mGradDelayLabel(new Label(this, _("Delay:"))), - mGradDelaySlider(new Slider(this, 20, 100)), + mGradDelaySlider(new Slider(this, 20.0, 100.0, 1.0)), mGradDelayText(new TextField(this)), // TRANSLATORS: colors tab. label. mRedLabel(new Label(this, _("Red:"))), - mRedSlider(new Slider(this, 0, 255)), + mRedSlider(new Slider(this, 0.0, 255.0, 1.0)), mRedText(new TextField(this)), // TRANSLATORS: colors tab. label. mGreenLabel(new Label(this, _("Green:"))), - mGreenSlider(new Slider(this, 0, 255)), + mGreenSlider(new Slider(this, 0.0, 255.0, 1.0)), mGreenText(new TextField(this)), // TRANSLATORS: colors tab. label. mBlueLabel(new Label(this, _("Blue:"))), - mBlueSlider(new Slider(this, 0, 255)), + mBlueSlider(new Slider(this, 0.0, 255.0, 1.0)), mBlueText(new TextField(this)) { mColorBox->postInit(); diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index dfe14fa2c..7d6ac9fc3 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -192,9 +192,9 @@ Setup_Video::Setup_Video(const Widget2 *const widget) : mOpenGLDropDown(new DropDown(widget, mOpenGLListModel)), // TRANSLATORS: video settings checkbox mFpsCheckBox(new CheckBox(this, _("FPS limit:"))), - mFpsSlider(new Slider(this, 2, 160)), + mFpsSlider(new Slider(this, 2.0, 160.0, 1.0)), mFpsLabel(new Label(this)), - mAltFpsSlider(new Slider(this, 2, 160)), + mAltFpsSlider(new Slider(this, 2.0, 160.0, 1.0)), // TRANSLATORS: video settings label mAltFpsLabel(new Label(this, _("Alt FPS limit: "))), #if !defined(ANDROID) && !defined(__APPLE__) diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp index eb6591f9f..fa4e2f4ef 100644 --- a/src/gui/widgets/tabs/setup_visual.cpp +++ b/src/gui/widgets/tabs/setup_visual.cpp @@ -139,7 +139,7 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) : // TRANSLATORS: settings option new SetupItemSlider(_("Gui opacity"), "", "guialpha", - this, "guialphaEvent", 0.1, 1.0, 150, true); + this, "guialphaEvent", 0.1, 1.0, 0.1, 150, true, true); mSpeachList->fillFromArray(&speachList[0], speachListSize); // TRANSLATORS: settings option @@ -164,8 +164,8 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) : // TRANSLATORS: particle details mParticleList->push_back(_("max")); (new SetupItemSlider2(_("Particle detail"), "", "particleEmitterSkip", - this, "particleEmitterSkipEvent", 0, 3, - mParticleList, true))->setInvertValue(3); + this, "particleEmitterSkipEvent", 0, 3, 1, + mParticleList, true, true, false))->setInvertValue(3); mParticleTypeList->fillFromArray(&particleTypeList[0], particleTypeListSize); @@ -183,7 +183,7 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) : // TRANSLATORS: settings option new SetupItemSlider(_("Gamma"), "", "gamma", - this, "gammeEvent", 1, 20, 350, true); + this, "gammeEvent", 1, 20, 1, 350, true, true); // TRANSLATORS: settings group diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index 8bece77ef..e86bf344e 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -224,7 +224,7 @@ void BuyDialog::init() getOptionBool("showbackground"), "buy_background.xml"); mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); - mSlider = new Slider(this, 1.0); + mSlider = new Slider(this, 1.0, 1.0); mQuantityLabel = new Label(this, strprintf( "%d / %d", mAmountItems, mMaxItems)); mQuantityLabel->setAlignment(Graphics::CENTER); diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 42bbb4b88..f0a9781f2 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -514,9 +514,8 @@ void CharCreateDialog::setAttributes(const StringVect &labels, mAttributeLabel[i]->adjustSize(); add(mAttributeLabel[i]); - mAttributeSlider[i] = new Slider(this, min, max); - mAttributeSlider[i]->setDimension(Rect(140, y + i * 24, - 150, 12)); + mAttributeSlider[i] = new Slider(this, min, max, 1.0); + mAttributeSlider[i]->setDimension(Rect(140, y + i * 24, 150, 12)); mAttributeSlider[i]->setActionEventId("statslider"); mAttributeSlider[i]->addActionListener(this); add(mAttributeSlider[i]); diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 472057060..9c2e039f9 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -100,7 +100,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent, mItem(item), mItemIcon(new Icon(this, item ? item->getImage() : nullptr)), mItemPopup(new ItemPopup), - mItemAmountSlide(new Slider(this, 1.0, maxRange)), + mItemAmountSlide(new Slider(this, 1.0, maxRange, 1.0)), mItemPriceSlide(nullptr), mItemDropDown(nullptr), mItemsModal(nullptr), @@ -136,7 +136,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent, mItemPriceTextField->setWidth(35); mItemPriceTextField->addKeyListener(this); - mItemPriceSlide = new Slider(this, 1.0, 10000000); + mItemPriceSlide = new Slider(this, 1.0, 10000000, 1.0); mItemPriceSlide->setHeight(10); mItemPriceSlide->setActionEventId("slidePrice"); mItemPriceSlide->addActionListener(this); diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index 604caa72e..1b9f1ec85 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -100,7 +100,7 @@ void SellDialog::init() getOptionBool("showbackground"), "sell_background.xml"); mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); - mSlider = new Slider(this, 1.0); + mSlider = new Slider(this, 1.0, 1.0); mQuantityLabel = new Label(this, strprintf( "%d / %d", mAmountItems, mMaxItems)); |