summaryrefslogtreecommitdiff
path: root/src/gui/window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/window.cpp')
-rw-r--r--src/gui/window.cpp95
1 files changed, 80 insertions, 15 deletions
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 980f8270..95965960 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -221,6 +221,40 @@ void Window::add(gcn::Widget *w, int x, int y)
chrome->add(w, x, y);
}
+void Window::mousePress(int x, int y, int button)
+{
+ if (getParent() != NULL)
+ {
+ getParent()->moveToTop(this);
+ }
+
+ if (hasMouse() && button == 1)
+ {
+ mMouseXOffset = x;
+ mMouseYOffset = y;
+
+ if (isMovable() && y < (int)(getTitleBarHeight() + getPadding()))
+ {
+ mMouseDrag = true;
+ }
+
+ if (getResizeable())
+ {
+ if (x > (getWidth() - 2 * getPadding()))
+ {
+ winXResizing = true;
+ mMouseDrag = true;
+ }
+
+ if (y > (getHeight() - 2 * getPadding()))
+ {
+ winYResizing = true;
+ mMouseDrag = true;
+ }
+ }
+ }
+}
+
void Window::mouseMotion(int mx, int my)
{
if (mMouseDrag && isMovable())
@@ -239,27 +273,58 @@ void Window::mouseMotion(int mx, int my)
//if (y < snapSize) y = 0;
//if (x + winWidth + snapSize > screen->w) x = screen->w - winWidth;
//if (y + winHeight + snapSize > screen->h) y = screen->h - winHeight;
-
- if (resizeable && mx > getWidth() - 16) {
- // Resize
- if (mx < minWinWidth)
- mx = minWinWidth;
- if (my < minWinHeight)
- my = minWinHeight;
- if (mx >= maxWinWidth)
- mx = maxWinWidth - 1;
- if (my >= maxWinHeight)
- my = maxWinHeight - 1;
-
- setWidth(mx);
- setHeight(my);
- } else {
+
+ if (getResizeable() &&
+ ((mx > (getWidth() - 16)) || (my > (getHeight() - 16))))
+ {
+ // Resize in X direction
+ if (winXResizing)
+ {
+ if (mx < minWinWidth)
+ {
+ mx = minWinWidth;
+ }
+ else if (mx >= maxWinWidth)
+ {
+ mx = maxWinWidth - 1;
+ }
+
+ setWidth(mx);
+ }
+
+ // Resize in Y direction
+ if (winYResizing)
+ {
+ if (my < minWinHeight)
+ {
+ my = minWinHeight;
+ }
+ else if (my >= maxWinHeight)
+ {
+ my = maxWinHeight - 1;
+ }
+
+ setHeight(my);
+ }
+ }
+ else
+ {
// Move
setPosition(x, y);
}
}
}
+void Window::mouseRelease(int x, int y, int button)
+{
+ if (button == 1)
+ {
+ mMouseDrag = false;
+ winXResizing = false;
+ winYResizing = false;
+ }
+}
+
void Window::optionChanged(const std::string &name)
{
if (name == "guialpha")