summaryrefslogtreecommitdiff
path: root/src/input/touch
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/input/touch
parentf1518dd8476c968a43fa57cfb06198e290a4f77a (diff)
downloadmv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.gz
mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.bz2
mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.xz
mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.zip
Fix clang-tidy check readability-implicit-bool-cast.
Diffstat (limited to 'src/input/touch')
-rw-r--r--src/input/touch/touchactions.cpp4
-rw-r--r--src/input/touch/touchmanager.cpp45
2 files changed, 26 insertions, 23 deletions
diff --git a/src/input/touch/touchactions.cpp b/src/input/touch/touchactions.cpp
index 40fa8bf3d..ae79dd182 100644
--- a/src/input/touch/touchactions.cpp
+++ b/src/input/touch/touchactions.cpp
@@ -58,12 +58,12 @@ static void moveChar(int x, int y)
const int y2 = abs(y);
if (x2 > y2)
{
- if (y2 && x2 * 10 / y2 > diff)
+ if ((y2 != 0) && x2 * 10 / y2 > diff)
y = 0;
}
else
{
- if (x2 && y2 * 10 / x2 > diff)
+ if ((x2 != 0) && y2 * 10 / x2 > diff)
x = 0;
}
diff --git a/src/input/touch/touchmanager.cpp b/src/input/touch/touchmanager.cpp
index add16a929..e9c378ef7 100644
--- a/src/input/touch/touchmanager.cpp
+++ b/src/input/touch/touchmanager.cpp
@@ -130,7 +130,7 @@ void TouchManager::loadTouchItem(TouchItem **restrict item,
const TouchFuncPtr fOut) restrict2
{
*item = nullptr;
- if (!theme)
+ if (theme == nullptr)
return;
ImageRect *images = new ImageRect;
for (int f = 0; f < 9; f ++)
@@ -143,10 +143,10 @@ void TouchManager::loadTouchItem(TouchItem **restrict item,
icon = Theme::getImageFromThemeXml(imageName, "");
Skin *const skin = theme->loadSkinRect(*images, name, "");
- if (skin)
+ if (skin != nullptr)
{
Image *const image = images->grid[0];
- if (image)
+ if (image != nullptr)
{
if (x == -1)
x = skin->getOption("x", 10);
@@ -208,13 +208,13 @@ void TouchManager::draw() restrict2
FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
const TouchItem *const item = *it;
- if (item && item->images && (mShow ||
+ if ((item != nullptr) && (item->images != nullptr) && (mShow ||
(item == mKeyboard && mShowKeyboard)))
{
mainGraphics->calcWindow(mVertexes, item->x, item->y,
item->width, item->height, *item->images);
const Image *const icon = item->icon;
- if (icon)
+ if (icon != nullptr)
{
mainGraphics->calcTileCollection(mVertexes, icon,
item->x + (item->width - icon->mBounds.w) / 2,
@@ -233,13 +233,13 @@ void TouchManager::safeDraw() restrict2
FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
const TouchItem *const item = *it;
- if (item && item->images && (mShow ||
+ if ((item != nullptr) && (item->images != nullptr) && (mShow ||
(item == mKeyboard && mShowKeyboard)))
{
mainGraphics->drawImageRect(item->x, item->y,
item->width, item->height, *item->images);
const Image *const icon = item->icon;
- if (icon)
+ if (icon != nullptr)
{
mainGraphics->drawImage(icon,
item->x + (item->width - icon->mBounds.w) / 2,
@@ -252,7 +252,7 @@ void TouchManager::safeDraw() restrict2
void TouchManager::drawText() restrict2
{
- if (!gui)
+ if (gui == nullptr)
return;
Font *const font = boldFont;
@@ -262,7 +262,7 @@ void TouchManager::drawText() restrict2
FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
const TouchItem *const item = *it;
- if (item && mShow && !item->text.empty())
+ if ((item != nullptr) && mShow && !item->text.empty())
{
const std::string str = item->text;
const int textX = (item->rect.width - font->getWidth(str))
@@ -285,15 +285,18 @@ bool TouchManager::processEvent(const MouseInput &mouseInput) restrict2
FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
const TouchItem *const item = *it;
- if (!item || (!mShow && (item != mKeyboard || !mShowKeyboard)))
+ if (item == nullptr ||
+ (!mShow && (item != mKeyboard || !mShowKeyboard)))
+ {
continue;
+ }
const Rect &rect = item->rect;
if (rect.isPointInRect(x, y))
{
MouseInput event = mouseInput;
event.setX(event.getTouchX() - item->x);
event.setY(event.getTouchY() - item->y);
- if (item->funcAll)
+ if (item->funcAll != nullptr)
item->funcAll(event);
switch (mouseInput.getType())
@@ -301,13 +304,13 @@ bool TouchManager::processEvent(const MouseInput &mouseInput) restrict2
case MouseEventType::PRESSED:
if (!item->eventPressed.empty())
executeAction(item->eventPressed);
- else if (item->funcPressed)
+ else if (item->funcPressed != nullptr)
item->funcPressed(event);
break;
case MouseEventType::RELEASED:
if (!item->eventReleased.empty())
executeAction(item->eventReleased);
- else if (item->funcReleased)
+ else if (item->funcReleased != nullptr)
item->funcReleased(event);
break;
default:
@@ -323,7 +326,7 @@ bool TouchManager::processEvent(const MouseInput &mouseInput) restrict2
}
return true;
}
- else if (item->funcOut)
+ else if (item->funcOut != nullptr)
{
item->funcOut(mouseInput);
}
@@ -350,7 +353,7 @@ void TouchManager::resize(const int width, const int height) restrict2
FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
TouchItem *const item = *it;
- if (!item)
+ if (item == nullptr)
continue;
switch (item->type)
@@ -381,13 +384,13 @@ void TouchManager::resize(const int width, const int height) restrict2
void TouchManager::unload(TouchItem *restrict const item)
{
- if (item)
+ if (item != nullptr)
{
- if (item->images)
+ if (item->images != nullptr)
{
Theme::unloadRect(*item->images);
delete2(item->images);
- if (item->icon)
+ if (item->icon != nullptr)
{
item->icon->decRef();
item->icon = nullptr;
@@ -402,7 +405,7 @@ void TouchManager::unloadTouchItem(TouchItem *restrict *unloadItem) restrict2
FOR_EACH (TouchItemVectorIter, it, mObjects)
{
TouchItem *item = *it;
- if (item && *unloadItem == item)
+ if ((item != nullptr) && *unloadItem == item)
{
mObjects.erase(it);
unload(item);
@@ -421,11 +424,11 @@ void TouchManager::loadPad() restrict2
void TouchManager::loadButtons() restrict2
{
const int sz = (mButtonsSize + 1) * 50;
- if (!theme)
+ if (theme == nullptr)
return;
Skin *const skin = theme->load("dbutton.xml", "");
- if (skin)
+ if (skin != nullptr)
{
const int x = skin->getOption("x", 10);
const int y = skin->getOption("y", 10);