summaryrefslogtreecommitdiff
path: root/src/game/GameView.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-07-18 19:34:58 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-07-18 19:34:58 (GMT)
commitdd0e6e7f4ddc5a1a9c25111275187b767d51bdb4 (patch)
tree79213c37eab4ad4715a00d53029fd6d6c865bc73 /src/game/GameView.cpp
parent26dbd547d3a3662c62e7b3ecadae5609f1726df4 (diff)
downloadpowder-dd0e6e7f4ddc5a1a9c25111275187b767d51bdb4.zip
powder-dd0e6e7f4ddc5a1a9c25111275187b767d51bdb4.tar.gz
Add descriptions to toolbuttons, add Tooltips to Button, ToolTip event for Windows
Diffstat (limited to 'src/game/GameView.cpp')
-rw-r--r--src/game/GameView.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index 8fee0ed..763312d 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -36,7 +36,8 @@ GameView::GameView():
drawSnap(false),
toolTip(""),
infoTip(""),
- infoTipPresence(0)
+ infoTipPresence(0),
+ toolTipPosition(-1, -1)
{
int currentX = 1;
@@ -435,7 +436,7 @@ void GameView::NotifyToolListChanged(GameModel * sender)
for(int i = 0; i < toolList.size(); i++)
{
//ToolButton * tempButton = new ToolButton(ui::Point(XRES+1, currentY), ui::Point(28, 15), toolList[i]->GetName());
- ToolButton * tempButton = new ToolButton(ui::Point(currentX, YRES+1), ui::Point(30, 18), toolList[i]->GetName());
+ ToolButton * tempButton = new ToolButton(ui::Point(currentX, YRES+1), ui::Point(30, 18), toolList[i]->GetName(), toolList[i]->GetDescription());
//currentY -= 17;
currentX -= 31;
tempButton->SetActionCallback(new ToolAction(this, toolList[i]));
@@ -742,6 +743,12 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
}
}
+void GameView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip)
+{
+ this->toolTip = toolTip;
+ toolTipPosition = ui::Point(Size.X-27-Graphics::textwidth((char*)toolTip.c_str()), Size.Y-MENUSIZE-10);
+}
+
void GameView::OnMouseWheel(int x, int y, int d)
{
if(!d)
@@ -1253,6 +1260,11 @@ void GameView::OnDraw()
int infoTipAlpha = (infoTipPresence>50?50:infoTipPresence)*5;
g->drawtext((XRES-Graphics::textwidth((char*)infoTip.c_str()))/2, (YRES/2)-2, (char*)infoTip.c_str(), 255, 255, 255, infoTipAlpha);
}
+
+ if(toolTipPosition.X!=-1 && toolTipPosition.Y!=-1 && toolTip.length())
+ {
+ g->drawtext(toolTipPosition.X, toolTipPosition.Y, (char*)toolTip.c_str(), 255, 255, 255, 255);
+ }
}
ui::Point GameView::lineSnapCoords(ui::Point point1, ui::Point point2)