diff options
author | José Ávila <linux@javila.net> | 2005-06-06 21:30:37 +0000 |
---|---|---|
committer | José Ávila <linux@javila.net> | 2005-06-06 21:30:37 +0000 |
commit | 8e9df978f664ee4b415ab672e9eba5037d62af5e (patch) | |
tree | c57e17cd4505d2ea12123a83212f1479db9f79fa /src/gui/window.cpp | |
parent | 821241e469bcf649d1c1e04e8bdb4b462b21daa4 (diff) | |
download | mana-8e9df978f664ee4b415ab672e9eba5037d62af5e.tar.gz mana-8e9df978f664ee4b415ab672e9eba5037d62af5e.tar.bz2 mana-8e9df978f664ee4b415ab672e9eba5037d62af5e.tar.xz mana-8e9df978f664ee4b415ab672e9eba5037d62af5e.zip |
Fixed resizing window function
Diffstat (limited to 'src/gui/window.cpp')
-rw-r--r-- | src/gui/window.cpp | 95 |
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") |