diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2005-08-16 17:40:27 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2005-08-16 17:40:27 +0000 |
commit | 30967d7adb6b2aefb83b91b1136fe676770d7d44 (patch) | |
tree | 9174d483a0bb5fb09c6f130c6bfa3d5bdfa1f51d /src | |
parent | f6fabeacc35b67ca0a44bf50cf6ca7d2378c289d (diff) | |
download | mana-30967d7adb6b2aefb83b91b1136fe676770d7d44.tar.gz mana-30967d7adb6b2aefb83b91b1136fe676770d7d44.tar.bz2 mana-30967d7adb6b2aefb83b91b1136fe676770d7d44.tar.xz mana-30967d7adb6b2aefb83b91b1136fe676770d7d44.zip |
Bugfixing and simplifying the resize code. Still a little bit buggy. (We were working on the same thing Elven, ;)
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/window.cpp | 54 | ||||
-rw-r--r-- | src/gui/window.h | 4 |
2 files changed, 11 insertions, 47 deletions
diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 67bd224f..5c18194c 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -120,6 +120,7 @@ Window::~Window() delete border.grid[6]; delete border.grid[7]; delete border.grid[8]; + resizeGrip->decRef(); } config.removeListener("guialpha", this); @@ -143,13 +144,10 @@ void Window::draw(gcn::Graphics* graphics) if (resizable) { dynamic_cast<Graphics*>(graphics)->drawImage(Window::resizeGrip, - x + getWidth() - 18, - y + getHeight() - 15); + x + getWidth() - resizeGrip->getWidth(), + y + getHeight() - resizeGrip->getHeight()); } - - - // Draw title if (title) { graphics->setFont(getFont()); @@ -249,17 +247,13 @@ void Window::mousePress(int x, int y, int button) // border, and is a candidate for a resize. if (getResizable() && button == 1 && getGripDimension().isPointInRect(x, y) && + hasMouse() && !(mMouseDrag && y > (int)getPadding())) { mMouseResize = true; mMouseXOffset = x; mMouseYOffset = y; - // Determine which borders are being dragged - mLeftBorderDrag = false;//(x < 10); - mTopBorderDrag = false;//(y < 10);*/ - mRightBorderDrag = true;//(x >= getWidth() - 10); - mBottomBorderDrag = true;//(y >= getHeight() - 10); } } @@ -274,27 +268,9 @@ void Window::mouseMotion(int x, int y) // Change the dimension according to dragging and moving if (mMouseResize && getResizable()) { - if (mLeftBorderDrag) - { - newDim.x += dx; - newDim.width -= dx; - } - - if (mTopBorderDrag) - { - newDim.y += dy; - newDim.height -= dy; - } - - if (mBottomBorderDrag) - { - newDim.height += dy; - } - - if (mRightBorderDrag) - { - newDim.width += dx; - } + // We're dragging bottom right + newDim.height += dy; + newDim.width += dx; } else if (mMouseDrag && isMovable()) { @@ -366,12 +342,6 @@ void Window::mouseMotion(int x, int y) Ycorrection = maxWinHeight - newDim.height; } - if (mLeftBorderDrag) newDim.x -= Xcorrection; - newDim.width += Xcorrection; - - if (mTopBorderDrag) newDim.y -= Ycorrection; - newDim.height += Ycorrection; - // Snap window to edges //if (x < snapSize) x = 0; //if (y < snapSize) y = 0; @@ -379,12 +349,9 @@ void Window::mouseMotion(int x, int y) //if (y + winHeight + snapSize > screen->h) y = screen->h - winHeight; // Update mouse offset when dragging bottom or right border - if (mBottomBorderDrag) + if (mMouseResize) { mMouseYOffset += newDim.height - getHeight(); - } - if (mRightBorderDrag) - { mMouseXOffset += newDim.width - getWidth(); } @@ -423,9 +390,10 @@ void Window::optionChanged(const std::string &name) } } -gcn::Rectangle Window::getGripDimension () { +gcn::Rectangle Window::getGripDimension () +{ int x, y; getAbsolutePosition(x, y); - return gcn::Rectangle(getWidth() - 18, getHeight() - 15, getWidth(), + return gcn::Rectangle(getWidth() - resizeGrip->getWidth(), getHeight() - resizeGrip->getHeight(), getWidth(), getHeight()); } diff --git a/src/gui/window.h b/src/gui/window.h index e9567762..be9c9ea1 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -172,10 +172,6 @@ class Window : public gcn::Window, public ConfigListener bool resizable; /**< Window can be resized */ bool mMouseResize; /**< Window is being resized */ - bool mTopBorderDrag; /**< Top border is being dragged */ - bool mLeftBorderDrag; /**< Left border is being dragged */ - bool mRightBorderDrag; /**< Right border is being dragged */ - bool mBottomBorderDrag; /**< Bottom border is being dragged */ int minWinWidth; /**< Minimum window width */ int minWinHeight; /**< Minimum window height */ |