summaryrefslogtreecommitdiff
path: root/src/gui/widgets/window.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-06-03 17:24:53 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-06-09 17:55:39 +0000
commitac0b338b3e026d0d05a447894de9a6a994da82dc (patch)
tree168e0004f0e54cb2fc480485580cd55a46ee3fb5 /src/gui/widgets/window.cpp
parentcdf986b813d267b1d31a28400c0ee38d5e485154 (diff)
downloadmana-ac0b338b3e026d0d05a447894de9a6a994da82dc.tar.gz
mana-ac0b338b3e026d0d05a447894de9a6a994da82dc.tar.bz2
mana-ac0b338b3e026d0d05a447894de9a6a994da82dc.tar.xz
mana-ac0b338b3e026d0d05a447894de9a6a994da82dc.zip
Enable resizing windows from all sides
Previously, the top edge of windows could not be dragged. Now you can also resize windows by their top edge, as well as the top-left and top-right corners.
Diffstat (limited to 'src/gui/widgets/window.cpp')
-rw-r--r--src/gui/widgets/window.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index e09986d2..25ca7684 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -371,6 +371,8 @@ void Window::mousePressed(gcn::MouseEvent &event)
// Handle window resizing
mouseResize = getResizeHandles(event);
+ if (mouseResize)
+ mMoved = false;
}
}
@@ -405,12 +407,15 @@ void Window::mouseMoved(gcn::MouseEvent &event)
switch (resizeHandles)
{
case BOTTOM | RIGHT:
+ case TOP | LEFT:
gui->setCursorType(Cursor::RESIZE_DOWN_RIGHT);
break;
case BOTTOM | LEFT:
+ case TOP | RIGHT:
gui->setCursorType(Cursor::RESIZE_DOWN_LEFT);
break;
case BOTTOM:
+ case TOP:
gui->setCursorType(Cursor::RESIZE_DOWN);
break;
case RIGHT:
@@ -676,14 +681,17 @@ void Window::adjustPositionAfterResize(int oldScreenWidth, int oldScreenHeight)
int Window::getResizeHandles(gcn::MouseEvent &event)
{
int resizeHandles = 0;
- const int y = event.getY();
- if (mGrip && y > (int) mTitleBarHeight)
+ if (mGrip)
{
const int x = event.getX();
+ const int y = event.getY();
+ const int p = getPadding();
+
+ const bool inPadding = (x < p || x > getWidth() - p) ||
+ (y < p || y > getHeight() - p);
- if (!getChildrenArea().isPointInRect(x, y) &&
- event.getSource() == this)
+ if (inPadding && event.getSource() == this)
{
resizeHandles |= (x > getWidth() - resizeBorderWidth) ? RIGHT :
(x < resizeBorderWidth) ? LEFT : 0;