summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.cpp17
-rw-r--r--src/gui/gui.h2
-rw-r--r--src/gui/popups/popupmenu.cpp2
-rw-r--r--src/gui/skin.cpp8
-rw-r--r--src/gui/theme.cpp3
-rw-r--r--src/gui/viewport.cpp6
-rw-r--r--src/gui/widgets/characterdisplay.cpp2
-rw-r--r--src/gui/windows/chatwindow.cpp2
8 files changed, 23 insertions, 19 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index ac61261d3..91224b714 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -470,7 +470,7 @@ void Gui::draw()
int mouseX;
int mouseY;
- const MouseStateType button = getMouseState(&mouseX, &mouseY);
+ const MouseStateType button = getMouseState(mouseX, mouseY);
if ((settings.mouseFocused || button & SDL_BUTTON(1))
&& mMouseCursors && mCustomCursor && mMouseCursorAlpha > 0.0F)
@@ -942,7 +942,7 @@ MouseEvent *Gui::createMouseEvent(Window *const widget)
int mouseY = 0;
getAbsolutePosition(widget, x, y);
- getMouseState(&mouseX, &mouseY);
+ getMouseState(mouseX, mouseY);
return new MouseEvent(widget,
MouseEventType::MOVED,
@@ -953,8 +953,11 @@ MouseEvent *Gui::createMouseEvent(Window *const widget)
}
void Gui::getAbsolutePosition(Widget *restrict widget,
- int &restrict x, int &restrict y)
+ int &restrict x,
+ int &restrict y)
{
+ if (!widget)
+ return;
x = 0;
y = 0;
while (widget->getParent())
@@ -1103,12 +1106,12 @@ void Gui::removeDragged(const Widget *const widget)
mFocusHandler->setDraggedWidget(nullptr);
}
-MouseStateType Gui::getMouseState(int *const x, int *const y)
+MouseStateType Gui::getMouseState(int &x, int &y)
{
- const MouseStateType res = SDL_GetMouseState(x, y);
+ const MouseStateType res = SDL_GetMouseState(&x, &y);
const int scale = mainGraphics->getScale();
- (*x) /= scale;
- (*y) /= scale;
+ x /= scale;
+ y /= scale;
return res;
}
diff --git a/src/gui/gui.h b/src/gui/gui.h
index a8b862f63..209c40749 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -226,7 +226,7 @@ class Gui final
int getLastMouseY() const
{ return mLastMouseY; }
- static MouseStateType getMouseState(int *const x, int *const y);
+ static MouseStateType getMouseState(int &x, int &y);
/**
* Sets the top widget. The top widget is the root widget
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 10ae03365..10b1db4ac 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -414,7 +414,7 @@ void PopupMenu::setMousePos()
}
else
{
- Gui::getMouseState(&mX, &mY);
+ Gui::getMouseState(mX, mY);
}
}
diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp
index 5ffd3c7c9..602d7204e 100644
--- a/src/gui/skin.cpp
+++ b/src/gui/skin.cpp
@@ -42,10 +42,10 @@ Skin::Skin(ImageRect *const restrict skin,
mFilePath(filePath),
mName(name),
mBorder(skin),
- mCloseImage(images->grid[0]),
- mCloseImageHighlighted(images->grid[1]),
- mStickyImageUp(images->grid[2]),
- mStickyImageDown(images->grid[3]),
+ mCloseImage(images ? images->grid[0] : nullptr),
+ mCloseImageHighlighted(images ? images->grid[1] : nullptr),
+ mStickyImageUp(images ? images->grid[2] : nullptr),
+ mStickyImageDown(images ? images->grid[3] : nullptr),
mPadding(padding),
mTitlePadding(titlePadding),
mOptions(options)
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 3881311a9..62cc2a03b 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -364,7 +364,8 @@ struct SkinHelper final
Image *image;
ResourceManager *resman;
- bool loadList(const SkinParameter *const params, const size_t size)
+ bool loadList(const SkinParameter *const params,
+ const size_t size) A_NONNULL(2)
{
for (size_t f = 0; f < size; f ++)
{
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 42c002d39..ff7946ed6 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -280,7 +280,7 @@ void Viewport::logic()
BLOCK_START("Viewport::logic")
// Make the player follow the mouse position
// if the mouse is dragged elsewhere than in a window.
- Gui::getMouseState(&mMouseX, &mMouseY);
+ Gui::getMouseState(mMouseX, mMouseY);
BLOCK_END("Viewport::logic")
}
@@ -288,7 +288,7 @@ void Viewport::followMouse()
{
if (!gui)
return;
- const MouseStateType button = Gui::getMouseState(&mMouseX, &mMouseY);
+ const MouseStateType button = Gui::getMouseState(mMouseX, mMouseY);
// If the left button is dragged
if (mPlayerFollowMouse && (button & SDL_BUTTON(1)))
{
@@ -309,7 +309,7 @@ void Viewport::drawDebugPath(Graphics *const graphics)
if (!localPlayer || !userPalette || !actorManager || !mMap || !gui)
return;
- Gui::getMouseState(&mMouseX, &mMouseY);
+ Gui::getMouseState(mMouseX, mMouseY);
static Path debugPath;
static Vector lastMouseDestination = Vector(0.0F, 0.0F);
diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp
index b7af55018..2286b6c14 100644
--- a/src/gui/widgets/characterdisplay.cpp
+++ b/src/gui/widgets/characterdisplay.cpp
@@ -126,7 +126,7 @@ void CharacterDisplay::mouseMoved(MouseEvent &event A_UNUSED)
int mouseX = 0;
int mouseY = 0;
- Gui::getMouseState(&mouseX, &mouseY);
+ Gui::getMouseState(mouseX, mouseY);
const std::string &name = mName->getCaption();
if (!name.empty())
{
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 72b547c2a..3f26cc4dc 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -2103,7 +2103,7 @@ void ChatWindow::updateVisibility()
int mouseY = 0;
int x = 0;
int y = 0;
- Gui::getMouseState(&mouseX, &mouseY);
+ Gui::getMouseState(mouseX, mouseY);
getAbsolutePosition(x, y);
if (mChatInput->isVisible())
{