summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2025-03-31 12:51:05 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2025-03-31 12:51:05 +0200
commit83339662e47270f2b38e7430775090f409348ae2 (patch)
treef94dc53b75f2e65650905cbdbc7f3280d9c6def9 /src
parent80f76c3aae438f7b9a7c1359c3f37aac460f934b (diff)
downloadmana-83339662e47270f2b38e7430775090f409348ae2.tar.gz
mana-83339662e47270f2b38e7430775090f409348ae2.tar.bz2
mana-83339662e47270f2b38e7430775090f409348ae2.tar.xz
mana-83339662e47270f2b38e7430775090f409348ae2.zip
GUI: De-hardcode the window title offsets
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/window.cpp16
-rw-r--r--src/gui/widgets/window.h7
-rw-r--r--src/resources/theme.cpp2
-rw-r--r--src/resources/theme.h2
4 files changed, 18 insertions, 9 deletions
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index fe31c4b0..15267019 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -127,13 +127,18 @@ void Window::drawFrame(gcn::Graphics *graphics)
WidgetState state(this);
state.width += getFrameSize() * 2;
state.height += getFrameSize() * 2;
- theme->drawSkin(g, SkinType::Window, state);
+
+ auto &skin = theme->getSkin(SkinType::Window);
+ skin.draw(g, state);
if (mShowTitle)
{
g->setColor(Theme::getThemeColor(Theme::TEXT));
g->setFont(getFont());
- g->drawText(getCaption(), 7 + getFrameSize(), 5 + getFrameSize(), gcn::Graphics::LEFT);
+ g->drawText(getCaption(),
+ getFrameSize() + skin.titleOffsetX,
+ getFrameSize() + skin.titleOffsetY,
+ gcn::Graphics::LEFT);
}
}
@@ -655,6 +660,13 @@ int Window::getResizeHandles(gcn::MouseEvent &event)
if (inPadding && event.getSource() == this)
{
+ /**
+ * The width of the resize border. Is independent of the actual window
+ * border width, and determines mostly the size of the corner area
+ * where two borders are moved at the same time.
+ */
+ const int resizeBorderWidth = std::max(mGrip->getWidth(), 10);
+
resizeHandles |= (x >= getWidth() - resizeBorderWidth) ? RIGHT :
(x < resizeBorderWidth) ? LEFT : 0;
resizeHandles |= (y >= getHeight() - resizeBorderWidth) ? BOTTOM :
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index 0e84bcb9..c89ccfdc 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -405,11 +405,4 @@ class Window : public gcn::Window, gcn::WidgetListener
int mDefaultHeight; /**< Default window height */
static int instances; /**< Number of Window instances */
-
- /**
- * The width of the resize border. Is independent of the actual window
- * border width, and determines mostly the size of the corner area
- * where two borders are moved at the same time.
- */
- static const int resizeBorderWidth = 10;
};
diff --git a/src/resources/theme.cpp b/src/resources/theme.cpp
index 70aaff83..01c6b6f1 100644
--- a/src/resources/theme.cpp
+++ b/src/resources/theme.cpp
@@ -465,6 +465,8 @@ void Theme::readSkinNode(XML::Node node)
node.attribute("frameSize", skin.frameSize);
node.attribute("padding", skin.padding);
node.attribute("titleBarHeight", skin.titleBarHeight);
+ node.attribute("titleOffsetX", skin.titleOffsetX);
+ node.attribute("titleOffsetY", skin.titleOffsetY);
for (auto childNode : node.children())
if (childNode.name() == "state")
diff --git a/src/resources/theme.h b/src/resources/theme.h
index 5586f6d0..55092127 100644
--- a/src/resources/theme.h
+++ b/src/resources/theme.h
@@ -143,6 +143,8 @@ class Skin
int frameSize = 0;
int padding = 0;
int titleBarHeight = 0;
+ int titleOffsetX = 0;
+ int titleOffsetY = 0;
private:
std::vector<SkinState> mStates;