diff options
| author | Bryan Hoyle <starfoxprime@gmail.com> | 2012-06-23 01:00:44 (GMT) |
|---|---|---|
| committer | Bryan Hoyle <starfoxprime@gmail.com> | 2012-06-23 01:00:44 (GMT) |
| commit | 83c51307c442fa668c5a39c4e1816928ed17b522 (patch) | |
| tree | 80ed0785a1fb2ae2c628292313139d917c0bcc65 /src/game/GameView.cpp | |
| parent | 009de99f02a7d5e62cf78ff405596ad50d8273d5 (diff) | |
| download | powder-83c51307c442fa668c5a39c4e1816928ed17b522.zip powder-83c51307c442fa668c5a39c4e1816928ed17b522.tar.gz | |
Scrollbar added
Diffstat (limited to 'src/game/GameView.cpp')
| -rw-r--r-- | src/game/GameView.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index 179afb9..61a4dbc 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -33,6 +33,7 @@ GameView::GameView(): mousePosition(0, 0), lastOffset(0) { + int currentX = 1; //Set up UI class SearchAction : public ui::ButtonAction @@ -45,6 +46,8 @@ GameView::GameView(): v->c->OpenSearch(); } }; + scrollBar = new ui::Button(ui::Point(XRES+50,YRES+50), ui::Point(50, 3), ""); + AddComponent(scrollBar); searchButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(17, 15)); //Open searchButton->SetIcon(IconOpen); currentX+=18; @@ -824,6 +827,7 @@ void GameView::OnTick(float dt) lastLogEntry -= 0.16*dt; } + void GameView::DoMouseMove(int x, int y, int dx, int dy) { if(c->MouseMove(x, y, dx, dy)) @@ -832,14 +836,24 @@ void GameView::DoMouseMove(int x, int y, int dx, int dy) if(toolButtons.size()) { int totalWidth = (toolButtons[0]->Size.X+1)*toolButtons.size(); + int scrollSize = (int)(((float)(XRES-15))/((float)totalWidth) * ((float)XRES-15)); + if (scrollSize>XRES) + scrollSize = XRES; + scrollBar->Position.Y = toolButtons[0]->Position.Y + 19; if(totalWidth > XRES-15) { int mouseX = x; if(mouseX > XRES) mouseX = XRES; + float frac = (float)mouseX/((float)XRES-15); + scrollBar->Position.X = (int)(frac*(float)(XRES-scrollSize)); + scrollBar->Appearance.BackgroundInactive = ui::Colour(255, 255, 255); + scrollBar->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; + scrollBar->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; + 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 if(toolButtons[0]->Position.Y < y && toolButtons[0]->Position.Y+toolButtons[0]->Size.Y > y) { @@ -853,6 +867,11 @@ void GameView::DoMouseMove(int x, int y, int dx, int dy) } } } + else + { + scrollBar->Position.X = 0; + } + scrollBar->Size.X=scrollSize; } } |
