diff options
author | Ira Rice <irarice@gmail.com> | 2009-03-10 12:09:53 -0600 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-03-10 12:09:53 -0600 |
commit | 0540c611b48fd8dee14066b13755138192b7084b (patch) | |
tree | 6772eda38f08a77af7717c8f4747aab77061cfcf | |
parent | 9b259c3d502795b2bbbfbe6a275cb503b1fc78b1 (diff) | |
download | mana-0540c611b48fd8dee14066b13755138192b7084b.tar.gz mana-0540c611b48fd8dee14066b13755138192b7084b.tar.bz2 mana-0540c611b48fd8dee14066b13755138192b7084b.tar.xz mana-0540c611b48fd8dee14066b13755138192b7084b.zip |
Allow for offsets for the enumerated position version of
setLocationRelativeTo as well.
Signed-off-by: Ira Rice <irarice@gmail.com>
-rw-r--r-- | src/gui/window.cpp | 31 | ||||
-rw-r--r-- | src/gui/window.h | 3 |
2 files changed, 17 insertions, 17 deletions
diff --git a/src/gui/window.cpp b/src/gui/window.cpp index f1316b4c..bf1ec01c 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -220,51 +220,50 @@ void Window::setLocationRelativeTo(gcn::Widget *widget) getY() + (wy + (widget->getHeight() - getHeight()) / 2 - y)); } -void Window::setLocationRelativeTo(ImageRect::ImagePosition position) +void Window::setLocationRelativeTo(ImageRect::ImagePosition position, + int offsetX, int offsetY) { - int x = 0, y = 0; - if (position == ImageRect::UPPER_LEFT) { } else if (position == ImageRect::UPPER_CENTER) { - x = (windowContainer->getWidth() - getWidth()) / 2; + offsetX += (windowContainer->getWidth() - getWidth()) / 2; } else if (position == ImageRect::UPPER_RIGHT) { - x = windowContainer->getWidth() - getWidth(); + offsetX += windowContainer->getWidth() - getWidth(); } else if (position == ImageRect::LEFT) { - y = (windowContainer->getHeight() - getHeight()) / 2; + offsetY += (windowContainer->getHeight() - getHeight()) / 2; } else if (position == ImageRect::CENTER) { - x = (windowContainer->getWidth() - getWidth()) / 2; - y = (windowContainer->getHeight() - getHeight()) / 2; + offsetX += (windowContainer->getWidth() - getWidth()) / 2; + offsetY += (windowContainer->getHeight() - getHeight()) / 2; } else if (position == ImageRect::RIGHT) { - x = windowContainer->getWidth() - getWidth(); - y = (windowContainer->getHeight() - getHeight()) / 2; + offsetX += windowContainer->getWidth() - getWidth(); + offsetY += (windowContainer->getHeight() - getHeight()) / 2; } else if (position == ImageRect::LOWER_LEFT) { - y = windowContainer->getHeight() - getHeight(); + offsetY += windowContainer->getHeight() - getHeight(); } else if (position == ImageRect::LOWER_CENTER) { - x = (windowContainer->getWidth() - getWidth()) / 2; - y = windowContainer->getHeight() - getHeight(); + offsetX += (windowContainer->getWidth() - getWidth()) / 2; + offsetY += windowContainer->getHeight() - getHeight(); } else if (position == ImageRect::LOWER_RIGHT) { - x = windowContainer->getWidth() - getWidth(); - y = windowContainer->getHeight() - getHeight(); + offsetX += windowContainer->getWidth() - getWidth(); + offsetY += windowContainer->getHeight() - getHeight(); } - setPosition(x, y); + setPosition(offsetX, offsetY); } void Window::setMinWidth(unsigned int width) diff --git a/src/gui/window.h b/src/gui/window.h index c24bde76..4fc6c862 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -92,7 +92,8 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Sets the location relative to the given enumerated position. */ - void setLocationRelativeTo(ImageRect::ImagePosition position); + void setLocationRelativeTo(ImageRect::ImagePosition position, + int offsetX = 0, int offsetY = 0); /** * Sets whether or not the window can be resized. |