Menu scrolling
This commit is contained in:
parent
333509842d
commit
6352888c68
@ -30,7 +30,8 @@ GameView::GameView():
|
|||||||
selectPoint1(0, 0),
|
selectPoint1(0, 0),
|
||||||
selectPoint2(0, 0),
|
selectPoint2(0, 0),
|
||||||
placeSaveThumb(NULL),
|
placeSaveThumb(NULL),
|
||||||
mousePosition(0, 0)
|
mousePosition(0, 0),
|
||||||
|
lastOffset(0)
|
||||||
{
|
{
|
||||||
int currentX = 1;
|
int currentX = 1;
|
||||||
//Set up UI
|
//Set up UI
|
||||||
@ -328,6 +329,7 @@ void GameView::NotifyActiveToolsChanged(GameModel * sender)
|
|||||||
void GameView::NotifyToolListChanged(GameModel * sender)
|
void GameView::NotifyToolListChanged(GameModel * sender)
|
||||||
{
|
{
|
||||||
//int currentY = YRES+MENUSIZE-36;
|
//int currentY = YRES+MENUSIZE-36;
|
||||||
|
lastOffset = 0;
|
||||||
int currentX = XRES+BARSIZE-56;
|
int currentX = XRES+BARSIZE-56;
|
||||||
int totalColour;
|
int totalColour;
|
||||||
for(int i = 0; i < menuButtons.size(); i++)
|
for(int i = 0; i < menuButtons.size(); i++)
|
||||||
@ -487,6 +489,18 @@ void GameView::NotifyBrushChanged(GameModel * sender)
|
|||||||
activeBrush = sender->GetBrush();
|
activeBrush = sender->GetBrush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameView::setToolButtonOffset(int offset)
|
||||||
|
{
|
||||||
|
int offset_ = offset;
|
||||||
|
offset = offset-lastOffset;
|
||||||
|
lastOffset = offset_;
|
||||||
|
|
||||||
|
for(vector<ToolButton*>::iterator iter = toolButtons.begin(), end = toolButtons.end(); iter!=end; ++iter)
|
||||||
|
{
|
||||||
|
(*iter)->Position.X -= offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GameView::OnMouseMove(int x, int y, int dx, int dy)
|
void GameView::OnMouseMove(int x, int y, int dx, int dy)
|
||||||
{
|
{
|
||||||
mousePosition = c->PointTranslate(ui::Point(x, y));
|
mousePosition = c->PointTranslate(ui::Point(x, y));
|
||||||
@ -808,6 +822,32 @@ void GameView::DoMouseMove(int x, int y, int dx, int dy)
|
|||||||
{
|
{
|
||||||
if(c->MouseMove(x, y, dx, dy))
|
if(c->MouseMove(x, y, dx, dy))
|
||||||
Window::DoMouseMove(x, y, dx, dy);
|
Window::DoMouseMove(x, y, dx, dy);
|
||||||
|
|
||||||
|
if(toolButtons.size())
|
||||||
|
{
|
||||||
|
int totalWidth = (toolButtons[0]->Size.X+1)*toolButtons.size();
|
||||||
|
if(totalWidth > XRES-10)
|
||||||
|
{
|
||||||
|
int mouseX = x;
|
||||||
|
if(mouseX > XRES)
|
||||||
|
mouseX = XRES;
|
||||||
|
float overflow = totalWidth-(XRES-10), 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)
|
||||||
|
{
|
||||||
|
for(vector<ToolButton*>::iterator iter = toolButtons.begin(), end = toolButtons.end(); iter!=end; ++iter)
|
||||||
|
{
|
||||||
|
ToolButton * button = *iter;
|
||||||
|
if(button->Position.X < x && button->Position.X+button->Size.X > x)
|
||||||
|
button->OnMouseEnter(x, y);
|
||||||
|
else
|
||||||
|
button->OnMouseLeave(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::DoMouseDown(int x, int y, unsigned button)
|
void GameView::DoMouseDown(int x, int y, unsigned button)
|
||||||
|
@ -78,6 +78,8 @@ private:
|
|||||||
|
|
||||||
Particle sample;
|
Particle sample;
|
||||||
|
|
||||||
|
int lastOffset;
|
||||||
|
void setToolButtonOffset(int offset);
|
||||||
void changeColour();
|
void changeColour();
|
||||||
public:
|
public:
|
||||||
GameView();
|
GameView();
|
||||||
|
Loading…
Reference in New Issue
Block a user