Add descriptions to toolbuttons, add Tooltips to Button, ToolTip event for Windows
This commit is contained in:
parent
26dbd547d3
commit
dd0e6e7f4d
@ -16,8 +16,8 @@ public:
|
||||
unsigned char Blue;
|
||||
unsigned char Alpha;
|
||||
|
||||
DecorationTool(ToolType decoMode_, string name, int r, int g, int b):
|
||||
Tool(0, name, r, g, b),
|
||||
DecorationTool(ToolType decoMode_, string name, string description, int r, int g, int b):
|
||||
Tool(0, name, description, r, g, b),
|
||||
decoMode(decoMode_),
|
||||
Red(0),
|
||||
Green(0),
|
||||
|
@ -61,7 +61,7 @@ GameModel::GameModel():
|
||||
{
|
||||
if(sim->elements[i].MenuSection < 12 && sim->elements[i].Enabled && sim->elements[i].MenuVisible)
|
||||
{
|
||||
Tool * tempTool = new ElementTool(i, sim->elements[i].Name, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour));
|
||||
Tool * tempTool = new ElementTool(i, sim->elements[i].Name, sim->elements[i].Description, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour));
|
||||
menuList[sim->elements[i].MenuSection]->AddTool(tempTool);
|
||||
}
|
||||
}
|
||||
@ -69,14 +69,14 @@ GameModel::GameModel():
|
||||
//Build menu for GOL types
|
||||
for(int i = 0; i < NGOL; i++)
|
||||
{
|
||||
Tool * tempTool = new GolTool(i, sim->gmenu[i].name, PIXR(sim->gmenu[i].colour), PIXG(sim->gmenu[i].colour), PIXB(sim->gmenu[i].colour));
|
||||
Tool * tempTool = new GolTool(i, sim->gmenu[i].name, std::string(sim->gmenu[i].description), PIXR(sim->gmenu[i].colour), PIXG(sim->gmenu[i].colour), PIXB(sim->gmenu[i].colour));
|
||||
menuList[SC_LIFE]->AddTool(tempTool);
|
||||
}
|
||||
|
||||
//Build other menus from wall data
|
||||
for(int i = 0; i < UI_WALLCOUNT; i++)
|
||||
{
|
||||
Tool * tempTool = new WallTool(i, "", PIXR(sim->wtypes[i].colour), PIXG(sim->wtypes[i].colour), PIXB(sim->wtypes[i].colour));
|
||||
Tool * tempTool = new WallTool(i, "", std::string(sim->wtypes[i].descs), PIXR(sim->wtypes[i].colour), PIXG(sim->wtypes[i].colour), PIXB(sim->wtypes[i].colour));
|
||||
menuList[SC_WALL]->AddTool(tempTool);
|
||||
//sim->wtypes[i]
|
||||
}
|
||||
@ -88,17 +88,17 @@ GameModel::GameModel():
|
||||
//Build menu for simtools
|
||||
for(int i = 0; i < sim->tools.size(); i++)
|
||||
{
|
||||
Tool * tempTool = new Tool(i, sim->tools[i]->Name, PIXR(sim->tools[i]->Colour), PIXG(sim->tools[i]->Colour), PIXB(sim->tools[i]->Colour));
|
||||
Tool * tempTool = new Tool(i, sim->tools[i]->Name, sim->tools[i]->Description, PIXR(sim->tools[i]->Colour), PIXG(sim->tools[i]->Colour), PIXB(sim->tools[i]->Colour));
|
||||
menuList[SC_TOOL]->AddTool(tempTool);
|
||||
}
|
||||
|
||||
//Add decoration tools to menu
|
||||
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendAdd, "ADD", 0, 0, 0));
|
||||
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendRemove, "SUB", 0, 0, 0));
|
||||
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendMultiply, "MUL", 0, 0, 0));
|
||||
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendDivide, "DIV", 0, 0, 0));
|
||||
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSmudge, "SMDG", 0, 0, 0));
|
||||
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSet, "SET", 0, 0, 0));
|
||||
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendAdd, "ADD", "Colour blending: Add", 0, 0, 0));
|
||||
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendRemove, "SUB", "Colour blending: Subtract", 0, 0, 0));
|
||||
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendMultiply, "MUL", "Colour blending: Multiply", 0, 0, 0));
|
||||
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendDivide, "DIV", "Colour blending: Divide" , 0, 0, 0));
|
||||
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSmudge, "SMDG", "Smudge colour", 0, 0, 0));
|
||||
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSet, "SET", "Set colour (No blending)", 0, 0, 0));
|
||||
|
||||
//Set default brush palette
|
||||
brushList.push_back(new EllipseBrush(ui::Point(4, 4)));
|
||||
|
@ -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)
|
||||
|
@ -41,8 +41,9 @@ private:
|
||||
|
||||
int infoTipPresence;
|
||||
std::string toolTip;
|
||||
ui::Point toolTipPosition;
|
||||
std::string infoTip;
|
||||
|
||||
|
||||
queue<ui::Point*> pointQueue;
|
||||
GameController * c;
|
||||
Renderer * ren;
|
||||
@ -119,6 +120,8 @@ public:
|
||||
void NotifyToolTipChanged(GameModel * sender);
|
||||
void NotifyInfoTipChanged(GameModel * sender);
|
||||
|
||||
virtual void ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip);
|
||||
|
||||
virtual void OnMouseMove(int x, int y, int dx, int dy);
|
||||
virtual void OnMouseDown(int x, int y, unsigned button);
|
||||
virtual void OnMouseUp(int x, int y, unsigned button);
|
||||
|
@ -12,15 +12,17 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
Tool::Tool(int id, string name, int r, int g, int b):
|
||||
Tool::Tool(int id, string name, string description, int r, int g, int b):
|
||||
toolID(id),
|
||||
toolName(name),
|
||||
toolDescription(description),
|
||||
colRed(r),
|
||||
colGreen(g),
|
||||
colBlue(b)
|
||||
{
|
||||
}
|
||||
string Tool::GetName() { return toolName; }
|
||||
string Tool::GetDescription() { return toolDescription; }
|
||||
Tool::~Tool() {}
|
||||
void Tool::Click(Simulation * sim, Brush * brush, ui::Point position) { }
|
||||
void Tool::Draw(Simulation * sim, Brush * brush, ui::Point position) {
|
||||
@ -34,8 +36,8 @@ void Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Po
|
||||
}
|
||||
void Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {};
|
||||
|
||||
ElementTool::ElementTool(int id, string name, int r, int g, int b):
|
||||
Tool(id, name, r, g, b)
|
||||
ElementTool::ElementTool(int id, string name, string description, int r, int g, int b):
|
||||
Tool(id, name, description, r, g, b)
|
||||
{
|
||||
}
|
||||
ElementTool::~ElementTool() {}
|
||||
@ -53,8 +55,8 @@ void ElementTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position)
|
||||
}
|
||||
|
||||
|
||||
WallTool::WallTool(int id, string name, int r, int g, int b):
|
||||
Tool(id, name, r, g, b)
|
||||
WallTool::WallTool(int id, string name, string description, int r, int g, int b):
|
||||
Tool(id, name, description, r, g, b)
|
||||
{
|
||||
}
|
||||
WallTool::~WallTool() {}
|
||||
@ -72,8 +74,8 @@ void WallTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
|
||||
}
|
||||
|
||||
|
||||
GolTool::GolTool(int id, string name, int r, int g, int b):
|
||||
Tool(id, name, r, g, b)
|
||||
GolTool::GolTool(int id, string name, string description, int r, int g, int b):
|
||||
Tool(id, name, description, r, g, b)
|
||||
{
|
||||
}
|
||||
GolTool::~GolTool() {}
|
||||
|
@ -22,9 +22,11 @@ class Tool
|
||||
protected:
|
||||
int toolID;
|
||||
string toolName;
|
||||
string toolDescription;
|
||||
public:
|
||||
Tool(int id, string name, int r, int g, int b);
|
||||
Tool(int id, string name, string description, int r, int g, int b);
|
||||
string GetName();
|
||||
string GetDescription();
|
||||
virtual ~Tool();
|
||||
virtual void Click(Simulation * sim, Brush * brush, ui::Point position);
|
||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
||||
@ -38,7 +40,7 @@ class SignTool: public Tool
|
||||
{
|
||||
public:
|
||||
SignTool():
|
||||
Tool(0, "SIGN", 0, 0, 0)
|
||||
Tool(0, "SIGN", "Sign. Click a sign to edit or anywhere else to create a new one", 0, 0, 0)
|
||||
{
|
||||
}
|
||||
virtual ~SignTool() {}
|
||||
@ -53,7 +55,7 @@ class PropertyTool: public Tool
|
||||
{
|
||||
public:
|
||||
PropertyTool():
|
||||
Tool(0, "PROP", 0, 0, 0)
|
||||
Tool(0, "PROP", "Property Edit. Click to alter the properties of elements in the field", 0, 0, 0)
|
||||
{
|
||||
}
|
||||
virtual ~PropertyTool() {}
|
||||
@ -67,7 +69,7 @@ public:
|
||||
class ElementTool: public Tool
|
||||
{
|
||||
public:
|
||||
ElementTool(int id, string name, int r, int g, int b);
|
||||
ElementTool(int id, string name, string description, int r, int g, int b);
|
||||
virtual ~ElementTool();
|
||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2);
|
||||
@ -78,7 +80,7 @@ public:
|
||||
class WallTool: public Tool
|
||||
{
|
||||
public:
|
||||
WallTool(int id, string name, int r, int g, int b);
|
||||
WallTool(int id, string name, string description, int r, int g, int b);
|
||||
virtual ~WallTool();
|
||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2);
|
||||
@ -89,7 +91,7 @@ public:
|
||||
class GolTool: public Tool
|
||||
{
|
||||
public:
|
||||
GolTool(int id, string name, int r, int g, int b);
|
||||
GolTool(int id, string name, string description, int r, int g, int b);
|
||||
virtual ~GolTool();
|
||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2);
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include "ToolButton.h"
|
||||
#include "interface/Keys.h"
|
||||
|
||||
ToolButton::ToolButton(ui::Point position, ui::Point size, std::string text_):
|
||||
ui::Button(position, size, text_)
|
||||
ToolButton::ToolButton(ui::Point position, ui::Point size, std::string text_, std::string toolTip):
|
||||
ui::Button(position, size, text_, toolTip)
|
||||
{
|
||||
SetSelectionState(-1);
|
||||
Appearance.BorderActive = ui::Colour(255, 0, 0);
|
||||
|
@ -13,7 +13,7 @@
|
||||
class ToolButton: public ui::Button {
|
||||
int currentSelection;
|
||||
public:
|
||||
ToolButton(ui::Point position, ui::Point size, std::string text_);
|
||||
ToolButton(ui::Point position, ui::Point size, std::string text_, std::string toolTip = "");
|
||||
virtual void OnMouseUp(int x, int y, unsigned int button);
|
||||
virtual void OnMouseClick(int x, int y, unsigned int button);
|
||||
virtual void Draw(const ui::Point& screenPos);
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
Button::Button(Point position, Point size, std::string buttonText):
|
||||
Button::Button(Point position, Point size, std::string buttonText, std::string toolTip):
|
||||
Component(position, size),
|
||||
ButtonText(buttonText),
|
||||
isMouseInside(false),
|
||||
@ -21,7 +21,8 @@ Button::Button(Point position, Point size, std::string buttonText):
|
||||
isTogglable(false),
|
||||
toggle(false),
|
||||
actionCallback(NULL),
|
||||
Enabled(true)
|
||||
Enabled(true),
|
||||
toolTip(toolTip)
|
||||
{
|
||||
TextPosition();
|
||||
}
|
||||
@ -141,6 +142,10 @@ void Button::OnMouseEnter(int x, int y)
|
||||
return;
|
||||
if(actionCallback)
|
||||
actionCallback->MouseEnterCallback(this);
|
||||
if(toolTip.length()>0 && GetParentWindow())
|
||||
{
|
||||
GetParentWindow()->ToolTip(this, ui::Point(x, y), toolTip);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
class Button : public Component
|
||||
{
|
||||
public:
|
||||
Button(Point position = Point(0, 0), Point size = Point(0, 0), std::string buttonText = "");
|
||||
Button(Point position = Point(0, 0), Point size = Point(0, 0), std::string buttonText = "", std::string toolTip = "");
|
||||
virtual ~Button();
|
||||
|
||||
bool Toggleable;
|
||||
@ -55,6 +55,7 @@ public:
|
||||
void SetIcon(Icon icon);
|
||||
protected:
|
||||
|
||||
std::string toolTip;
|
||||
std::string buttonDisplayText;
|
||||
std::string ButtonText;
|
||||
|
||||
|
@ -46,6 +46,8 @@ enum ChromeStyle
|
||||
// Remove a component from state. NOTE: This WILL free component from memory.
|
||||
void RemoveComponent(unsigned idx);
|
||||
|
||||
virtual void ToolTip(Component * sender, ui::Point mousePosition, std::string toolTip) {}
|
||||
|
||||
virtual void DoInitialized();
|
||||
virtual void DoExit();
|
||||
virtual void DoTick(float dt);
|
||||
|
Loading…
Reference in New Issue
Block a user