summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/basiccontainer.cpp2
-rw-r--r--src/gui/widgets/characterdisplay.cpp6
-rw-r--r--src/gui/widgets/characterviewnormal.cpp2
-rw-r--r--src/gui/widgets/characterviewsmall.cpp6
-rw-r--r--src/gui/widgets/chatinput.h14
-rw-r--r--src/gui/widgets/checkbox.cpp2
-rw-r--r--src/gui/widgets/dropdown.cpp2
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp6
-rw-r--r--src/gui/widgets/itemcontainer.cpp4
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp2
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp18
-rw-r--r--src/gui/widgets/popup.cpp6
-rw-r--r--src/gui/widgets/popup.h2
-rw-r--r--src/gui/widgets/popuplist.cpp13
-rw-r--r--src/gui/widgets/radiobutton.cpp2
-rw-r--r--src/gui/widgets/selldialog.cpp6
-rw-r--r--src/gui/widgets/selldialog.h4
-rw-r--r--src/gui/widgets/shoplistbox.cpp2
-rw-r--r--src/gui/widgets/skillinfo.cpp12
-rw-r--r--src/gui/widgets/skillinfo.h5
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp8
-rw-r--r--src/gui/widgets/tabbedarea.cpp8
-rw-r--r--src/gui/widgets/virtshortcutcontainer.cpp6
-rw-r--r--src/gui/widgets/widget.cpp8
-rw-r--r--src/gui/widgets/widget.h13
-rw-r--r--src/gui/widgets/window.cpp23
-rw-r--r--src/gui/widgets/window.h7
27 files changed, 103 insertions, 86 deletions
diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp
index e8f29ff9b..bcf30a27f 100644
--- a/src/gui/widgets/basiccontainer.cpp
+++ b/src/gui/widgets/basiccontainer.cpp
@@ -220,7 +220,7 @@ Widget *BasicContainer::getWidgetAt(int x, int y)
void BasicContainer::logic()
{
BLOCK_START("BasicContainer::logic")
- if (!mVisible)
+ if (mVisible == Visible_false)
{
BLOCK_END("BasicContainer::logic")
return;
diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp
index de4b4bc00..df0032990 100644
--- a/src/gui/widgets/characterdisplay.cpp
+++ b/src/gui/widgets/characterdisplay.cpp
@@ -113,12 +113,12 @@ void CharacterDisplay::update()
void CharacterDisplay::widgetHidden(const Event &event A_UNUSED)
{
- textPopup->setVisible(false);
+ textPopup->setVisible(Visible_false);
}
void CharacterDisplay::mouseExited(MouseEvent &event A_UNUSED)
{
- textPopup->setVisible(false);
+ textPopup->setVisible(Visible_false);
}
void CharacterDisplay::mouseMoved(MouseEvent &event A_UNUSED)
@@ -140,7 +140,7 @@ void CharacterDisplay::mouseMoved(MouseEvent &event A_UNUSED)
}
else
{
- textPopup->setVisible(false);
+ textPopup->setVisible(Visible_false);
}
}
diff --git a/src/gui/widgets/characterviewnormal.cpp b/src/gui/widgets/characterviewnormal.cpp
index a4b9271e3..c28723004 100644
--- a/src/gui/widgets/characterviewnormal.cpp
+++ b/src/gui/widgets/characterviewnormal.cpp
@@ -41,7 +41,7 @@ CharacterViewNormal::CharacterViewNormal(CharSelectDialog *const widget,
{
CharacterDisplay *const character = *it;
add(character);
- character->setVisible(true);
+ character->setVisible(Visible_true);
}
const size_t sz = mCharacterEntries->size();
if (mSelected >= 0 && mSelected < static_cast<signed>(sz))
diff --git a/src/gui/widgets/characterviewsmall.cpp b/src/gui/widgets/characterviewsmall.cpp
index fd9240936..36749022a 100644
--- a/src/gui/widgets/characterviewsmall.cpp
+++ b/src/gui/widgets/characterviewsmall.cpp
@@ -52,7 +52,7 @@ CharacterViewSmall::CharacterViewSmall(CharSelectDialog *const widget,
{
mSelected = 0;
mSelectedEntry = (*mCharacterEntries)[mSelected];
- mSelectedEntry->setVisible(true);
+ mSelectedEntry->setVisible(Visible_true);
mNumber->setCaption(strprintf("%d / %d", mSelected + 1, sz));
mNumber->adjustSize();
}
@@ -82,7 +82,7 @@ void CharacterViewSmall::show(const int i)
if (sz <= 0)
return;
if (mSelectedEntry)
- mSelectedEntry->setVisible(false);
+ mSelectedEntry->setVisible(Visible_false);
if (i >= sz)
mSelected = 0;
else if (i < 0)
@@ -90,7 +90,7 @@ void CharacterViewSmall::show(const int i)
else
mSelected = i;
mSelectedEntry = (*mCharacterEntries)[mSelected];
- mSelectedEntry->setVisible(true);
+ mSelectedEntry->setVisible(Visible_true);
mNumber->setCaption(strprintf("%d / %d", mSelected + 1, sz));
mNumber->adjustSize();
}
diff --git a/src/gui/widgets/chatinput.h b/src/gui/widgets/chatinput.h
index b1a22d3fb..592299312 100644
--- a/src/gui/widgets/chatinput.h
+++ b/src/gui/widgets/chatinput.h
@@ -23,6 +23,8 @@
#ifndef GUI_WIDGETS_CHATINPUT_H
#define GUI_WIDGETS_CHATINPUT_H
+#include "enums/simpletypes/visible.h"
+
#include "gui/windows/chatwindow.h"
#include "configuration.h"
@@ -44,7 +46,7 @@ class ChatInput final : public TextField
mWindow(window),
mFocusGaining(false)
{
- setVisible(false);
+ setVisible(Visible_false);
addFocusListener(this);
}
@@ -59,7 +61,7 @@ class ChatInput final : public TextField
TextField::focusLost(event);
if (mFocusGaining || !config.getBoolValue("protectChatFocus"))
{
- processVisible(false);
+ processVisible(Visible_false);
if (chatWindow)
chatWindow->updateVisibility();
mFocusGaining = false;
@@ -70,12 +72,12 @@ class ChatInput final : public TextField
mFocusGaining = false;
}
- void processVisible(const bool n)
+ void processVisible(const Visible n)
{
- if (!mWindow || isVisible() == n)
+ if (!mWindow || isVisible() == (n == Visible_true))
return;
- if (!n)
+ if (n == Visible_false)
mFocusGaining = true;
setVisible(n);
if (config.getBoolValue("hideChatInput")
@@ -92,7 +94,7 @@ class ChatInput final : public TextField
void unprotectFocus()
{ mFocusGaining = true; }
- void setVisible(bool visible)
+ void setVisible(Visible visible)
{
TextField::setVisible(visible);
}
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index 27e7d563b..90192c74a 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -218,7 +218,7 @@ void CheckBox::drawBox(Graphics *const graphics)
const ImageRect &rect = mSkin->getBorder();
int index = 0;
- if (mEnabled && mVisible)
+ if (mEnabled && mVisible == Visible_true)
{
if (mSelected)
{
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index a16381c2a..db5caf6f7 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -373,7 +373,7 @@ void DropDown::hideDrop(bool event)
{
if (event)
distributeActionEvent();
- mPopup->setVisible(false);
+ mPopup->setVisible(Visible_false);
}
void DropDown::mousePressed(MouseEvent& event)
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 97f012e89..05037cd51 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -248,7 +248,7 @@ void EmoteShortcutContainer::mouseMoved(MouseEvent &event)
if (index == -1)
return;
- textPopup->setVisible(false);
+ textPopup->setVisible(Visible_false);
if (static_cast<size_t>(index) < mEmoteImg.size() && mEmoteImg[index])
{
@@ -261,11 +261,11 @@ void EmoteShortcutContainer::mouseMoved(MouseEvent &event)
void EmoteShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
if (textPopup)
- textPopup->setVisible(false);
+ textPopup->setVisible(Visible_false);
}
void EmoteShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
if (textPopup)
- textPopup->setVisible(false);
+ textPopup->setVisible(Visible_false);
}
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index ee95f1e61..9024f74be 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -683,13 +683,13 @@ void ItemContainer::mouseMoved(MouseEvent &event)
}
else
{
- itemPopup->setVisible(false);
+ itemPopup->setVisible(Visible_false);
}
}
void ItemContainer::mouseExited(MouseEvent &event A_UNUSED)
{
- itemPopup->setVisible(false);
+ itemPopup->setVisible(Visible_false);
}
void ItemContainer::widgetResized(const Event &event A_UNUSED)
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index 7008602de..70b4e19e5 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -116,7 +116,7 @@ void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event)
itemPopup->setItem(itemInfo, color, true);
if (itemPopup->isPopupVisible())
{
- itemPopup->setVisible(false);
+ itemPopup->setVisible(Visible_false);
}
else if (viewport)
{
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index a0c807963..6a2aa4c93 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -545,7 +545,7 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
if (itemId < SPELL_MIN_ID)
{
- spellPopup->setVisible(false);
+ spellPopup->setVisible(Visible_false);
Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
@@ -559,12 +559,12 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
}
else
{
- itemPopup->setVisible(false);
+ itemPopup->setVisible(Visible_false);
}
}
else if (itemId < SKILL_MIN_ID && spellManager)
{
- itemPopup->setVisible(false);
+ itemPopup->setVisible(Visible_false);
const TextCommand *const spell = spellManager->getSpellByItem(itemId);
if (spell && viewport)
{
@@ -573,12 +573,12 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
}
else
{
- spellPopup->setVisible(false);
+ spellPopup->setVisible(Visible_false);
}
}
else if (skillDialog)
{
- itemPopup->setVisible(false);
+ itemPopup->setVisible(Visible_false);
}
}
@@ -586,15 +586,15 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
void ItemShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
if (itemPopup)
- itemPopup->setVisible(false);
+ itemPopup->setVisible(Visible_false);
if (spellPopup)
- spellPopup->setVisible(false);
+ spellPopup->setVisible(Visible_false);
}
void ItemShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
if (itemPopup)
- itemPopup->setVisible(false);
+ itemPopup->setVisible(Visible_false);
if (spellPopup)
- spellPopup->setVisible(false);
+ spellPopup->setVisible(Visible_false);
}
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 1f064329d..181d6a46b 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -74,7 +74,7 @@ Popup::Popup(const std::string &name,
windowContainer->add(this);
// Popups are invisible by default
- setVisible(false);
+ setVisible(Visible_false);
}
Popup::~Popup()
@@ -241,7 +241,7 @@ void Popup::position(const int x, const int y)
posY = y - height - distance;
setPosition(posX, posY);
- setVisible(true);
+ setVisible(Visible_true);
requestMoveToTop();
mRedraw = true;
}
@@ -258,7 +258,7 @@ void Popup::mouseMoved(MouseEvent &event A_UNUSED)
void Popup::hide()
{
- setVisible(false);
+ setVisible(Visible_false);
mRedraw = true;
}
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index d1dbb4829..fb00930bb 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -171,7 +171,7 @@ class Popup notfinal : public Container,
void widgetMoved(const Event &event) override final;
bool isPopupVisible() const
- { return mVisible; }
+ { return mVisible == Visible_true; }
virtual void postInit()
{ mInit = true; }
diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp
index d8c1d79dc..17f026388 100644
--- a/src/gui/widgets/popuplist.cpp
+++ b/src/gui/widgets/popuplist.cpp
@@ -88,7 +88,7 @@ void PopupList::show(int x, int y)
if (mainGraphics->mHeight < (y + height + 5))
y = mainGraphics->mHeight - height;
setPosition(x, y);
- setVisible(true);
+ setVisible(Visible_true);
requestMoveToTop();
if (mModal == Modal_true)
requestModalFocus();
@@ -154,7 +154,7 @@ void PopupList::mouseReleased(MouseEvent& event)
return;
if (mDropDown)
mDropDown->updateSelection();
- setVisible(false);
+ setVisible(Visible_false);
if (mModal == Modal_true)
releaseModalFocus();
}
@@ -162,15 +162,18 @@ void PopupList::mouseReleased(MouseEvent& event)
void PopupList::focusGained(const Event& event)
{
const Widget *const source = event.getSource();
- if (!mVisible || source == this || source == mListBox
- || source == mScrollArea || source == mDropDown)
+ if (mVisible == Visible_false ||
+ source == this ||
+ source == mListBox ||
+ source == mScrollArea ||
+ source == mDropDown)
{
return;
}
if (mDropDown)
mDropDown->updateSelection();
- setVisible(false);
+ setVisible(Visible_false);
if (mModal == Modal_true)
releaseModalFocus();
}
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index 30749da66..f1730b367 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -187,7 +187,7 @@ void RadioButton::drawBox(Graphics* graphics)
const ImageRect &rect = mSkin->getBorder();
int index = 0;
- if (mEnabled && mVisible)
+ if (mEnabled && mVisible == Visible_true)
{
if (mSelected)
{
diff --git a/src/gui/widgets/selldialog.cpp b/src/gui/widgets/selldialog.cpp
index 5422ea3b0..3864fd46c 100644
--- a/src/gui/widgets/selldialog.cpp
+++ b/src/gui/widgets/selldialog.cpp
@@ -159,7 +159,7 @@ void SellDialog::postInit()
loadWindowState();
instances.push_back(this);
- setVisible(true);
+ setVisible(Visible_true);
enableVisibleSound(true);
}
@@ -327,11 +327,11 @@ void SellDialog::updateButtonsAndLabels()
item->update();
}
-void SellDialog::setVisible(bool visible)
+void SellDialog::setVisible(Visible visible)
{
Window::setVisible(visible);
- if (visible)
+ if (visible == Visible_true)
{
if (mShopItemList)
mShopItemList->requestFocus();
diff --git a/src/gui/widgets/selldialog.h b/src/gui/widgets/selldialog.h
index 1d0bed7e1..439042a10 100644
--- a/src/gui/widgets/selldialog.h
+++ b/src/gui/widgets/selldialog.h
@@ -23,6 +23,8 @@
#ifndef GUI_WIDGETS_SELLDIALOG_H
#define GUI_WIDGETS_SELLDIALOG_H
+#include "enums/simpletypes/visible.h"
+
#include "gui/widgets/window.h"
#include "listeners/actionlistener.h"
@@ -88,7 +90,7 @@ class SellDialog notfinal : public Window,
/**
* Sets the visibility of this window.
*/
- void setVisible(bool visible) override final;
+ void setVisible(Visible visible) override final;
void addItem(const int id,
const int type,
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 63a295c1e..a5e5937ef 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -223,7 +223,7 @@ void ShopListBox::mouseMoved(MouseEvent &event)
}
else
{
- itemPopup->setVisible(false);
+ itemPopup->setVisible(Visible_false);
}
}
}
diff --git a/src/gui/widgets/skillinfo.cpp b/src/gui/widgets/skillinfo.cpp
index 80783a4b2..d16994bae 100644
--- a/src/gui/widgets/skillinfo.cpp
+++ b/src/gui/widgets/skillinfo.cpp
@@ -59,8 +59,8 @@ SkillInfo::SkillInfo() :
type(SkillType::Unknown),
owner(SkillOwner::Player),
modifiable(Modifiable_false),
- visible(false),
- alwaysVisible(false)
+ visible(Visible_false),
+ alwaysVisible(Visible_false)
{
dataMap[0] = new SkillData();
data = dataMap[0];
@@ -80,17 +80,17 @@ void SkillInfo::update()
if (modifiable == Modifiable_false && baseLevel == 0 && exp.second == 0)
{
- if (visible)
+ if (visible == Visible_true)
{
- visible = false;
+ visible = Visible_false;
if (model)
model->updateVisibilities();
}
return;
}
- const bool updateVisibility = !visible;
- visible = true;
+ const bool updateVisibility = (visible == Visible_false);
+ visible = Visible_true;
if (baseLevel == 0)
{
diff --git a/src/gui/widgets/skillinfo.h b/src/gui/widgets/skillinfo.h
index 8919ed30a..e2679713d 100644
--- a/src/gui/widgets/skillinfo.h
+++ b/src/gui/widgets/skillinfo.h
@@ -24,6 +24,7 @@
#define GUI_WIDGETS_SKILLINFO_H
#include "enums/simpletypes/modifiable.h"
+#include "enums/simpletypes/visible.h"
#include "gui/color.h"
@@ -69,8 +70,8 @@ struct SkillInfo final
SkillType::SkillType type;
SkillOwner::Type owner;
Modifiable modifiable;
- bool visible;
- bool alwaysVisible;
+ Visible visible;
+ Visible alwaysVisible;
SkillInfo();
A_DELETE_COPY(SkillInfo)
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 5a0de0995..7971e0d33 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -336,7 +336,7 @@ void SpellShortcutContainer::mouseMoved(MouseEvent &event)
return;
const int itemId = getItemByIndex(index);
- spellPopup->setVisible(false);
+ spellPopup->setVisible(Visible_false);
const TextCommand *const spell = spellManager->getSpell(itemId);
if (spell && !spell->isEmpty())
{
@@ -345,20 +345,20 @@ void SpellShortcutContainer::mouseMoved(MouseEvent &event)
}
else
{
- spellPopup->setVisible(false);
+ spellPopup->setVisible(Visible_false);
}
}
void SpellShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
if (spellPopup)
- spellPopup->setVisible(false);
+ spellPopup->setVisible(Visible_false);
}
void SpellShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
if (spellPopup)
- spellPopup->setVisible(false);
+ spellPopup->setVisible(Visible_false);
}
int SpellShortcutContainer::getItemByIndex(const int index) const
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index eb70c8012..e00123af6 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -646,13 +646,13 @@ void TabbedArea::updateArrowEnableState()
- mArrowButton[0]->getWidth()
- mArrowButton[1]->getWidth() - mRightMargin)
{
- mArrowButton[0]->setVisible(true);
- mArrowButton[1]->setVisible(true);
+ mArrowButton[0]->setVisible(Visible_true);
+ mArrowButton[1]->setVisible(Visible_true);
}
else
{
- mArrowButton[0]->setVisible(false);
- mArrowButton[1]->setVisible(false);
+ mArrowButton[0]->setVisible(Visible_false);
+ mArrowButton[1]->setVisible(Visible_false);
mTabScrollIndex = 0;
}
diff --git a/src/gui/widgets/virtshortcutcontainer.cpp b/src/gui/widgets/virtshortcutcontainer.cpp
index 138d3f5a6..30dbe3770 100644
--- a/src/gui/widgets/virtshortcutcontainer.cpp
+++ b/src/gui/widgets/virtshortcutcontainer.cpp
@@ -365,18 +365,18 @@ void VirtShortcutContainer::mouseMoved(MouseEvent &event)
}
else
{
- itemPopup->setVisible(false);
+ itemPopup->setVisible(Visible_false);
}
}
void VirtShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
if (itemPopup)
- itemPopup->setVisible(false);
+ itemPopup->setVisible(Visible_false);
}
void VirtShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
if (itemPopup)
- itemPopup->setVisible(false);
+ itemPopup->setVisible(Visible_false);
}
diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp
index f6f3854f4..3be80c772 100644
--- a/src/gui/widgets/widget.cpp
+++ b/src/gui/widgets/widget.cpp
@@ -99,7 +99,7 @@ Widget::Widget(const Widget2 *const widget) :
mCurrentFont(nullptr),
mFrameSize(0),
mFocusable(false),
- mVisible(true),
+ mVisible(Visible_true),
mTabIn(true),
mTabOut(true),
mEnabled(true),
@@ -217,12 +217,12 @@ void Widget::requestMoveToBottom()
mParent->moveToBottom(this);
}
-void Widget::setVisible(bool visible)
+void Widget::setVisible(Visible visible)
{
- if (!visible && isFocused() && mFocusHandler)
+ if (visible == Visible_false && isFocused() && mFocusHandler)
mFocusHandler->focusNone();
- if (visible)
+ if (visible == Visible_true)
distributeShownEvent();
else
distributeHiddenEvent();
diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h
index 2c8c121e0..3abc8d232 100644
--- a/src/gui/widgets/widget.h
+++ b/src/gui/widgets/widget.h
@@ -64,10 +64,11 @@
#ifndef GUI_WIDGETS_WIDGET_H
#define GUI_WIDGETS_WIDGET_H
-#include <list>
+#include "enums/simpletypes/visible.h"
#include "gui/widgets/widget2.h"
+#include <list>
#include "localconsts.h"
class ActionListener;
@@ -387,7 +388,7 @@ class Widget notfinal : public Widget2
* @see isVisible
* @since 0.1.0
*/
- void setVisible(bool visible);
+ void setVisible(Visible visible);
/**
* Checks if the widget is visible.
@@ -397,10 +398,12 @@ class Widget notfinal : public Widget2
* @since 0.1.0
*/
bool isVisible() const A_WARN_UNUSED
- { return mVisible && (!mParent || mParent->isVisible()); }
+ { return mVisible == Visible_true &&
+ (!mParent || mParent->isVisible());
+ }
bool isVisibleLocal() const A_WARN_UNUSED
- { return mVisible; }
+ { return mVisible == Visible_true; }
/**
* Sets the base color of the widget.
@@ -1216,7 +1219,7 @@ class Widget notfinal : public Widget2
/**
* True if the widget visible, false otherwise.
*/
- bool mVisible;
+ Visible mVisible;
/**
* True if the widget has tab in enabled, false otherwise.
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index f4921e7ca..a48b2c062 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -221,7 +221,7 @@ Window::Window(const std::string &caption,
}
// Windows are invisible by default
- setVisible(false);
+ setVisible(Visible_false);
addWidgetListener(this);
mForegroundColor = getThemeColor(Theme::WINDOW);
@@ -737,27 +737,32 @@ void Window::setStickyButtonLock(const bool lock)
mStickyButton = lock;
}
-void Window::setVisible(bool visible)
+void Window::setVisible(Visible visible)
{
setVisible(visible, false);
}
-void Window::setVisible(const bool visible, const bool forceSticky)
+void Window::setVisible(const Visible visible, const bool forceSticky)
{
if (visible == mVisible)
return;
// Check if the window is off screen...
- if (visible)
+ if (visible == Visible_true)
ensureOnScreen();
else
mResizeHandles = 0;
if (mStickyButtonLock)
+ {
BasicContainer2::setVisible(visible);
+ }
else
- BasicContainer2::setVisible((!forceSticky && mSticky) || visible);
- if (visible)
+ {
+ BasicContainer2::setVisible(fromBool((!forceSticky && mSticky) ||
+ visible == Visible_true, Visible));
+ }
+ if (visible == Visible_true)
{
if (mPlayVisibleSound)
soundManager.playGuiSound(SOUND_SHOW_WINDOW);
@@ -852,7 +857,7 @@ void Window::mousePressed(MouseEvent &event)
void Window::close()
{
- setVisible(false);
+ setVisible(Visible_false);
}
void Window::mouseReleased(MouseEvent &event A_UNUSED)
@@ -1044,8 +1049,8 @@ void Window::loadWindowState()
if (mSaveVisible)
{
- setVisible(config.getValueBool(name
- + "Visible", mDefaultVisible));
+ setVisible(fromBool(config.getValueBool(name
+ + "Visible", mDefaultVisible), Visible));
}
if (mStickyButton)
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index 102aedf73..f6e777e03 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -67,6 +67,7 @@
#define GUI_WIDGETS_WINDOW_H
#include "enums/simpletypes/modal.h"
+#include "enums/simpletypes/visible.h"
#include "listeners/mouselistener.h"
#include "listeners/widgetlistener.h"
@@ -257,13 +258,13 @@ class Window notfinal : public BasicContainer2,
* Overloads window setVisible by Guichan to allow sticky window
* handling.
*/
- virtual void setVisible(bool visible);
+ virtual void setVisible(Visible visible);
/**
* Overloads window setVisible by Guichan to allow sticky window
* handling, or not, if you force the sticky state.
*/
- void setVisible(const bool visible, const bool forceSticky);
+ void setVisible(const Visible visible, const bool forceSticky);
/**
* Returns whether the window is visible by default.
@@ -466,7 +467,7 @@ class Window notfinal : public BasicContainer2,
{ mPlayVisibleSound = b; }
bool isWindowVisible() const A_WARN_UNUSED
- { return mVisible; }
+ { return mVisible == Visible_true; }
/**
* Sets the padding of the window. The padding is the distance between the