summaryrefslogtreecommitdiff
path: root/src/gui/widgets/listbox.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-06-06 23:34:34 +0300
committerAndrei Karas <akaras@inbox.ru>2017-06-07 19:23:40 +0300
commit36ba43d6ea38062b17f7e63ef659962bfc51c64d (patch)
tree190156cb88b13a38a6d13c69ee0742cc078065a1 /src/gui/widgets/listbox.cpp
parentf1518dd8476c968a43fa57cfb06198e290a4f77a (diff)
downloadmanaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.gz
manaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.bz2
manaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.xz
manaverse-36ba43d6ea38062b17f7e63ef659962bfc51c64d.zip
Fix clang-tidy check readability-implicit-bool-cast.
Diffstat (limited to 'src/gui/widgets/listbox.cpp')
-rw-r--r--src/gui/widgets/listbox.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 0095baf1f..9628c2764 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -114,10 +114,10 @@ ListBox::ListBox(const Widget2 *const widget,
mForegroundColor = getThemeColor(ThemeColorId::LISTBOX);
mForegroundColor2 = getThemeColor(ThemeColorId::LISTBOX_OUTLINE);
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load(skin, "listbox.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mItemPadding = mSkin->getOption("itemPadding");
@@ -135,10 +135,10 @@ void ListBox::postInit()
ListBox::~ListBox()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
@@ -153,7 +153,7 @@ void ListBox::updateAlpha()
void ListBox::draw(Graphics *const graphics)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
BLOCK_START("ListBox::draw")
@@ -245,9 +245,15 @@ void ListBox::keyPressed(KeyEvent &event)
else if (action == InputAction::GUI_UP)
{
if (mSelected > 0)
+ {
setSelected(mSelected - 1);
- else if (mSelected == 0 && mWrappingEnabled && getListModel())
+ }
+ else if (mSelected == 0 &&
+ mWrappingEnabled &&
+ getListModel() != nullptr)
+ {
setSelected(getListModel()->getNumberOfElements() - 1);
+ }
event.consume();
}
else if (action == InputAction::GUI_DOWN)
@@ -264,7 +270,7 @@ void ListBox::keyPressed(KeyEvent &event)
setSelected(0);
event.consume();
}
- else if (action == InputAction::GUI_END && getListModel())
+ else if (action == InputAction::GUI_END && (getListModel() != nullptr))
{
setSelected(getListModel()->getNumberOfElements() - 1);
event.consume();
@@ -311,7 +317,7 @@ void ListBox::mouseReleased(MouseEvent &event)
mOldSelected = mSelected;
break;
case 2:
- if (gui)
+ if (gui != nullptr)
gui->resetClickCount();
if (mOldSelected == mSelected)
mouseReleased1(event);
@@ -343,13 +349,13 @@ void ListBox::mouseDragged(MouseEvent &event)
return;
// Make list selection update on drag, but guard against negative y
- if (getRowHeight())
+ if (getRowHeight() != 0u)
setSelected(std::max(0, getSelectionByMouse(event.getY())));
}
void ListBox::refocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
if (isFocusable())
@@ -359,7 +365,7 @@ void ListBox::refocus()
void ListBox::adjustSize()
{
BLOCK_START("ListBox::adjustSize")
- if (mListModel)
+ if (mListModel != nullptr)
{
setHeight(CAST_S32(getRowHeight()) *
mListModel->getNumberOfElements() + 2 * mPadding);
@@ -383,7 +389,7 @@ int ListBox::getSelectionByMouse(const int y) const
void ListBox::setSelected(const int selected)
{
- if (!mListModel)
+ if (mListModel == nullptr)
{
mSelected = -1;
}