diff options
Diffstat (limited to 'src/gui/widgets')
35 files changed, 158 insertions, 135 deletions
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 9411c2249..ecb92f876 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -99,13 +99,16 @@ void AvatarListBox::draw(Graphics *graphics) return; } + const Widget *const parent = mParent; + if (!parent) + return; + AvatarListModel *const model = static_cast<AvatarListModel *const>( mListModel); updateAlpha(); Font *const font = getFont(); const int fontHeight = getFont()->getHeight(); - const Widget *const parent = mParent; const std::string name = player_node->getName(); // Draw the list elements @@ -155,7 +158,7 @@ void AvatarListBox::draw(Graphics *graphics) a->getHp(), a->getMaxHp()); } const bool isPoison = a->getPoison(); - if (a->getMaxHp() && (isPoison || parent)) + if (a->getMaxHp()) { const int themeColor = (isPoison ? Theme::PROG_HP_POISON : Theme::PROG_HP); @@ -182,28 +185,25 @@ void AvatarListBox::draw(Graphics *graphics) a->getDamageHp()); } - if (parent) - { - const int themeColor = (a->getPoison() - ? Theme::PROG_HP_POISON : Theme::PROG_HP); - Color color = Theme::getProgressColor(themeColor, 1); - color.a = 80; - graphics->setColor(color); - graphics->fillRectangle(Rect(mPadding, y + mPadding, - parent->getWidth() * a->getDamageHp() / 1024 - - 2 * mPadding, fontHeight)); + const int themeColor = (a->getPoison() + ? Theme::PROG_HP_POISON : Theme::PROG_HP); + Color color = Theme::getProgressColor(themeColor, 1); + color.a = 80; + graphics->setColor(color); + graphics->fillRectangle(Rect(mPadding, y + mPadding, + parent->getWidth() * a->getDamageHp() / 1024 + - 2 * mPadding, fontHeight)); - if (a->getLevel() > 1) - { - graphics->setColor(mForegroundColor); - int minHp = 40 + ((a->getLevel() - 1) * 5); - if (minHp < 0) - minHp = 40; - - graphics->drawLine(parent->getWidth()*minHp / 1024 - + mPadding, y + mPadding, - parent->getWidth() * minHp / 1024, y + fontHeight); - } + if (a->getLevel() > 1) + { + graphics->setColor(mForegroundColor); + int minHp = 40 + ((a->getLevel() - 1) * 5); + if (minHp < 0) + minHp = 40; + + graphics->drawLine(parent->getWidth()*minHp / 1024 + + mPadding, y + mPadding, + parent->getWidth() * minHp / 1024, y + fontHeight); } } else @@ -307,8 +307,7 @@ void AvatarListBox::draw(Graphics *graphics) if (useCaching) graphics->drawTileCollection(&vertexes); - if (parent) - setWidth(parent->getWidth() - 10); + setWidth(parent->getWidth() - 10); BLOCK_END("AvatarListBox::draw") } diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp index 00386a725..4803373f2 100644 --- a/src/gui/widgets/basiccontainer.cpp +++ b/src/gui/widgets/basiccontainer.cpp @@ -298,7 +298,7 @@ void BasicContainer::drawChildren(Graphics* graphics) FOR_EACH (WidgetListConstIterator, iter, mWidgets) { Widget *const widget = *iter; - if (widget->isVisible()) + if (widget->isVisibleLocal()) { // If the widget has a frame, // draw it before drawing the widget diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 054a338aa..b1f41e23e 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -127,7 +127,6 @@ Button::Button(const Widget2 *const widget) : mYOffset(0), mImageWidth(0), mImageHeight(0), - mRedraw(true), mStick(false), mPressed(false) { @@ -169,7 +168,6 @@ Button::Button(const Widget2 *const widget, mYOffset(0), mImageWidth(0), mImageHeight(0), - mRedraw(true), mStick(false), mPressed(false) { @@ -217,7 +215,6 @@ Button::Button(const Widget2 *const widget, mYOffset(0), mImageWidth(imageWidth), mImageHeight(imageHeight), - mRedraw(true), mStick(false), mPressed(false) { @@ -265,7 +262,6 @@ Button::Button(const Widget2 *const widget, mYOffset(0), mImageWidth(imageWidth), mImageHeight(imageHeight), - mRedraw(true), mStick(false), mPressed(false) { @@ -313,7 +309,6 @@ Button::Button(const Widget2 *const widget, mYOffset(0), mImageWidth(0), mImageHeight(0), - mRedraw(true), mStick(false), mPressed(false) { diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 57a024195..015faf009 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -335,7 +335,6 @@ class Button final : public Widget, int mYOffset; int mImageWidth; int mImageHeight; - bool mRedraw; bool mStick; bool mPressed; }; diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 06dcecab0..765ff13ec 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -189,7 +189,7 @@ void CheckBox::drawBox(Graphics *const graphics) const ImageRect &rect = mSkin->getBorder(); int index = 0; - if (mEnabled && isVisible()) + if (mEnabled && mVisible) { if (mSelected) { diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 6ae892c81..3e77a65a5 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -28,6 +28,8 @@ #include "input/inputmanager.h" +#include "render/opengldebug.h" + #include "resources/image.h" #include "resources/imagehelper.h" #include "resources/resourcemanager.h" @@ -111,6 +113,7 @@ void Desktop::widgetResized(const Event &event A_UNUSED) void Desktop::draw(Graphics *graphics) { BLOCK_START("Desktop::draw") + GLDEBUG_START("Desktop::draw") const Rect &rect = mDimension; const int width = rect.width; @@ -144,6 +147,7 @@ void Desktop::draw(Graphics *graphics) } Container::draw(graphics); + GLDEBUG_END() BLOCK_END("Desktop::draw") } diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index 789d3e1aa..cbdd50cab 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -42,8 +42,7 @@ EmotePage::EmotePage(const Widget2 *const widget) : mEmotes(ResourceManager::getInstance()->getImageSet( "graphics/sprites/chatemotes.png", emoteWidth, emoteHeight)), mVertexes(new ImageCollection), - mSelectedIndex(-1), - mRedraw(true) + mSelectedIndex(-1) { addMouseListener(this); addWidgetListener(this); diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h index 769e004bc..6aca546ca 100644 --- a/src/gui/widgets/emotepage.h +++ b/src/gui/widgets/emotepage.h @@ -58,7 +58,6 @@ class EmotePage final : public Widget, ImageSet *mEmotes; ImageCollection *mVertexes; int mSelectedIndex; - bool mRedraw; }; #endif // GUI_WIDGETS_EMOTEPAGE_H diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index c41e32854..341204505 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -275,7 +275,7 @@ void ListBox::mouseWheelMovedDown(MouseEvent &event A_UNUSED) void ListBox::mousePressed(MouseEvent &event) { mPressedIndex = getSelectionByMouse(event.getY()); - if (mPressedIndex != -1) + if (mMouseConsume && mPressedIndex != -1) event.consume(); } diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 2116de113..3c10a721f 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -43,8 +43,7 @@ Popup::Popup(const std::string &name, mMinHeight(40), mMaxWidth(mainGraphics->mWidth), mMaxHeight(mainGraphics->mHeight), - mVertexes(new ImageCollection), - mRedraw(true) + mVertexes(new ImageCollection) { logger->log("Popup::Popup(\"%s\")", name.c_str()); diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 01247cf61..5067b4658 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -187,7 +187,6 @@ class Popup : public Container, int mMaxHeight; /**< Maximum popup height */ ImageCollection *mVertexes; - bool mRedraw; }; #endif // GUI_WIDGETS_POPUP_H diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index fa0616fd2..c203f59c6 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -43,6 +43,8 @@ PopupList::PopupList(DropDown *const widget, mModal(modal) { mListBox->postInit(); + mListBox->setMouseConsume(false); + mScrollArea->setMouseConsume(false); mAllowLogic = false; setFocusable(true); diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index ea4ef11bd..4c82fe20c 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -56,8 +56,7 @@ ProgressBar::ProgressBar(const Widget2 *const widget, mFillPadding(3), mFillImage(false), mSmoothProgress(true), - mSmoothColorChange(true), - mRedraw(true) + mSmoothColorChange(true) { mBackgroundColor = Theme::getProgressColor(backColor >= 0 ? backColor : 0, mProgress); diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index fef9bf11d..e45bc4abb 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -159,7 +159,6 @@ class ProgressBar final : public Widget, bool mFillImage; bool mSmoothProgress; bool mSmoothColorChange; - bool mRedraw; }; #endif // GUI_WIDGETS_PROGRESSBAR_H diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 643517f77..27be9434b 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -176,7 +176,7 @@ void RadioButton::drawBox(Graphics* graphics) const ImageRect &rect = mSkin->getBorder(); int index = 0; - if (mEnabled && isVisible()) + if (mEnabled && mVisible) { if (mSelected) { diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 2efa144c9..b748e30a1 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -131,8 +131,7 @@ ScrollArea::ScrollArea(Widget2 *const widget2, mIsVerticalMarkerDragged(false), mIsHorizontalMarkerDragged(false), mOpaque(true), - mHasMouse(false), - mRedraw(true) + mHasMouse(false) { setContent(widget); addMouseListener(this); @@ -866,7 +865,7 @@ void ScrollArea::mouseReleased(MouseEvent& event) } mClickX = 0; mClickY = 0; - if (dx || dy) + if (mMouseConsume && (dx || dy)) event.consume(); } } @@ -876,7 +875,8 @@ void ScrollArea::mouseReleased(MouseEvent& event) mRightButtonPressed = false; mIsHorizontalMarkerDragged = false; mIsVerticalMarkerDragged = false; - event.consume(); + if (mMouseConsume) + event.consume(); mRedraw = true; } diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index d3d71b65a..0d540c399 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -586,7 +586,6 @@ class ScrollArea final : public BasicContainer, bool mOpaque; bool mHasMouse; - bool mRedraw; }; #endif // GUI_WIDGETS_SCROLLAREA_H 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/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index 49be84b88..e789c863d 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -42,8 +42,7 @@ ShortcutContainer::ShortcutContainer(Widget2 *const widget) : mBoxHeight(1), mGridWidth(1), mGridHeight(1), - mVertexes(new ImageCollection), - mRedraw(true) + mVertexes(new ImageCollection) { mAllowLogic = false; } diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 81392097b..d4d4ac4bf 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -93,9 +93,6 @@ class ShortcutContainer : public Widget, void drawBackground(Graphics *g); - void setRedraw(bool b) - { mRedraw = b; } - protected: /** * Constructor. Initializes the shortcut container. @@ -121,7 +118,6 @@ class ShortcutContainer : public Widget, int mGridWidth; int mGridHeight; ImageCollection *mVertexes; - bool mRedraw; }; #endif // GUI_WIDGETS_SHORTCUTCONTAINER_H diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index e440631ad..a08d94440 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -91,38 +91,38 @@ 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), mVertexes(new ImageCollection), mMarkerLength(10), - mHasMouse(false), - mRedraw(true) + mHasMouse(false) { init(); } 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), mVertexes(new ImageCollection), mMarkerLength(10), - mHasMouse(false), - mRedraw(true) + mHasMouse(false) { init(); } @@ -368,7 +368,6 @@ void Slider::mousePressed(MouseEvent &event) setValue(markerPositionToValue(x - mMarkerLength / 2)); else setValue(markerPositionToValue(height - y - mMarkerLength / 2)); - distributeActionEvent(); } } @@ -450,18 +449,13 @@ void Slider::setValue(const double value) { mRedraw = true; if (value > mScaleEnd) - { mValue = mScaleEnd; - return; - } - - if (value < mScaleStart) - { + else if (value < mScaleStart) mValue = mScaleStart; - return; - } - - mValue = value; + else + mValue = value; + mValue = static_cast<int>((mValue - mScaleStart) / mStepLength) + * mStepLength + mScaleStart; } double Slider::markerPositionToValue(const int v) const diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index 164048020..3cd43493e 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) @@ -349,7 +351,6 @@ class Slider final : public Widget, int mMarkerLength; bool mHasMouse; - bool mRedraw; }; #endif // GUI_WIDGETS_SLIDER_H diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index cf55fa10b..cd439a95a 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -570,7 +570,7 @@ void TabbedArea::adjustTabPositions() maxTabHeight = tab->getHeight(); } - int x = (mEnableScrollButtons && mArrowButton[0]->isVisible()) + int x = (mEnableScrollButtons && mArrowButton[0]->isVisibleLocal()) ? mArrowButton[0]->getWidth() : 0; for (size_t i = mTabScrollIndex; i < sz; ++i) { 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_input.cpp b/src/gui/widgets/tabs/setup_input.cpp index a29e0d797..74ee7a3dc 100644 --- a/src/gui/widgets/tabs/setup_input.cpp +++ b/src/gui/widgets/tabs/setup_input.cpp @@ -212,7 +212,7 @@ void Setup_Input::cancel() void Setup_Input::action(const ActionEvent &event) { - const std::string id = event.getId(); + const std::string &id = event.getId(); if (event.getSource() == mKeyList) { 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/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index c2a6c0207..e31bc9ef1 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -113,7 +113,6 @@ Tab::Tab(const Widget2 *const widget) : mVertexes(new ImageCollection), mImage(nullptr), mMode(0), - mRedraw(true), mHasMouse(false) { init(); diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index a0afa6fcd..4a88a5400 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -228,7 +228,6 @@ class Tab : public BasicContainer, ImageCollection *mVertexes; Image *mImage; int mMode; - bool mRedraw; protected: bool mHasMouse; diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp index aa3e6254b..43c8df92f 100644 --- a/src/gui/widgets/widget.cpp +++ b/src/gui/widgets/widget.cpp @@ -107,7 +107,9 @@ Widget::Widget(const Widget2 *const widget) : mTabIn(true), mTabOut(true), mEnabled(true), - mAllowLogic(true) + mAllowLogic(true), + mMouseConsume(true), + mRedraw(true) { mWidgets.push_back(this); mWidgetsSet.insert(this); @@ -349,6 +351,12 @@ void Widget::setFont(Font *const font) fontChanged(); } +void Widget::distributeWindowResizeEvent() +{ + FOR_EACH (std::list<Widget*>::const_iterator, iter, mWidgets) + (*iter)->windowResized(); +} + bool Widget::widgetExists(const Widget* widget) { return mWidgetsSet.find(const_cast<Widget*>(widget)) @@ -504,3 +512,8 @@ void Widget::showPart(const Rect &rectangle) if (mParent) mParent->showWidgetPart(this, rectangle); } + +void Widget::windowResized() +{ + mRedraw = true; +} diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h index de5a79502..f3e2fdb66 100644 --- a/src/gui/widgets/widget.h +++ b/src/gui/widgets/widget.h @@ -399,6 +399,9 @@ class Widget : public Widget2 bool isVisible() const A_WARN_UNUSED { return mVisible && (!mParent || mParent->isVisible()); } + bool isVisibleLocal() const A_WARN_UNUSED + { return mVisible; } + /** * Sets the base color of the widget. * @@ -1006,9 +1009,22 @@ class Widget : public Widget2 */ virtual void showPart(const Rect &rectangle); - bool isAllowLogic() const + bool isAllowLogic() const A_WARN_UNUSED { return mAllowLogic; } + void setMouseConsume(const bool b) + { mMouseConsume = b; } + + bool isMouseConsume() const A_WARN_UNUSED + { return mMouseConsume; } + + void setRedraw(const bool b) + { mRedraw = b; } + + static void distributeWindowResizeEvent(); + + void windowResized(); + protected: /** * Distributes an action event to all action listeners @@ -1219,6 +1235,10 @@ class Widget : public Widget2 bool mAllowLogic; + bool mMouseConsume; + + bool mRedraw; + /** * Holds the global font used by the widget. */ diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 9e032f75b..c7212314d 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -109,7 +109,6 @@ Window::Window(const std::string &caption, const bool modal, mDefaultY(0), mDefaultWidth(0), mDefaultHeight(0), - mRedraw(true), mLastRedraw(true), mGrip(nullptr), mParent(parent), @@ -1218,13 +1217,6 @@ bool Window::isResizeAllowed(const MouseEvent &event) const return false; } -int Window::getGuiAlpha() const -{ - const float alpha = std::max(client->getGuiAlpha(), - theme->getMinimumOpacity()); - return static_cast<int>(alpha * 255.0F); -} - Layout &Window::getLayout() { if (!mLayout) diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index dfd1f63b7..1795f2843 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -448,11 +448,6 @@ class Window : public BasicContainer2, */ void setModal(const bool modal); - /** - * Gets the alpha value used by the window, in a GUIChan usable format. - */ - int getGuiAlpha() const A_WARN_UNUSED; - Rect getWindowArea() const A_WARN_UNUSED; bool isResizeAllowed(const MouseEvent &event) const A_WARN_UNUSED; @@ -633,7 +628,6 @@ class Window : public BasicContainer2, int mDefaultY; /**< Default window Y position */ int mDefaultWidth; /**< Default window width */ int mDefaultHeight; /**< Default window height */ - bool mRedraw; bool mLastRedraw; private: |