summaryrefslogtreecommitdiff
path: root/src/game/GameView.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-06-22 23:48:01 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-06-22 23:48:01 (GMT)
commit009de99f02a7d5e62cf78ff405596ad50d8273d5 (patch)
tree3398170f76174126399c06018023f3199e9d5459 /src/game/GameView.cpp
parent6352888c68a3b66dfbdab008c30a3c2fd0b40785 (diff)
downloadpowder-009de99f02a7d5e62cf78ff405596ad50d8273d5.zip
powder-009de99f02a7d5e62cf78ff405596ad50d8273d5.tar.gz
Prevent tool buttons being drawn off the edge of the window when scrollable
Diffstat (limited to 'src/game/GameView.cpp')
-rw-r--r--src/game/GameView.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index bfd8236..179afb9 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -497,7 +497,13 @@ void GameView::setToolButtonOffset(int offset)
for(vector<ToolButton*>::iterator iter = toolButtons.begin(), end = toolButtons.end(); iter!=end; ++iter)
{
- (*iter)->Position.X -= offset;
+ ToolButton * button = *iter;
+ button->Position.X -= offset;
+ if(button->Position.X <= 0 || (button->Position.X+button->Size.X) > XRES-2) {
+ button->Visible = false;
+ } else {
+ button->Visible = true;
+ }
}
}
@@ -826,12 +832,12 @@ void GameView::DoMouseMove(int x, int y, int dx, int dy)
if(toolButtons.size())
{
int totalWidth = (toolButtons[0]->Size.X+1)*toolButtons.size();
- if(totalWidth > XRES-10)
+ if(totalWidth > XRES-15)
{
int mouseX = x;
if(mouseX > XRES)
mouseX = XRES;
- float overflow = totalWidth-(XRES-10), mouseLocation = float(XRES)/float(mouseX-(XRES));
+ float overflow = totalWidth-(XRES-15), mouseLocation = float(XRES)/float(mouseX-(XRES));
setToolButtonOffset(overflow/mouseLocation);
//Ensure that mouseLeave events are make their way to the buttons should they move from underneith the mouse pointer