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 Blue;
|
||||||
unsigned char Alpha;
|
unsigned char Alpha;
|
||||||
|
|
||||||
DecorationTool(ToolType decoMode_, string name, int r, int g, int b):
|
DecorationTool(ToolType decoMode_, string name, string description, int r, int g, int b):
|
||||||
Tool(0, name, r, g, b),
|
Tool(0, name, description, r, g, b),
|
||||||
decoMode(decoMode_),
|
decoMode(decoMode_),
|
||||||
Red(0),
|
Red(0),
|
||||||
Green(0),
|
Green(0),
|
||||||
|
@ -61,7 +61,7 @@ GameModel::GameModel():
|
|||||||
{
|
{
|
||||||
if(sim->elements[i].MenuSection < 12 && sim->elements[i].Enabled && sim->elements[i].MenuVisible)
|
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);
|
menuList[sim->elements[i].MenuSection]->AddTool(tempTool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,14 +69,14 @@ GameModel::GameModel():
|
|||||||
//Build menu for GOL types
|
//Build menu for GOL types
|
||||||
for(int i = 0; i < NGOL; i++)
|
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);
|
menuList[SC_LIFE]->AddTool(tempTool);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Build other menus from wall data
|
//Build other menus from wall data
|
||||||
for(int i = 0; i < UI_WALLCOUNT; i++)
|
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);
|
menuList[SC_WALL]->AddTool(tempTool);
|
||||||
//sim->wtypes[i]
|
//sim->wtypes[i]
|
||||||
}
|
}
|
||||||
@ -88,17 +88,17 @@ GameModel::GameModel():
|
|||||||
//Build menu for simtools
|
//Build menu for simtools
|
||||||
for(int i = 0; i < sim->tools.size(); i++)
|
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);
|
menuList[SC_TOOL]->AddTool(tempTool);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add decoration tools to menu
|
//Add decoration tools to menu
|
||||||
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendAdd, "ADD", 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", 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", 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", 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", 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", 0, 0, 0));
|
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSet, "SET", "Set colour (No blending)", 0, 0, 0));
|
||||||
|
|
||||||
//Set default brush palette
|
//Set default brush palette
|
||||||
brushList.push_back(new EllipseBrush(ui::Point(4, 4)));
|
brushList.push_back(new EllipseBrush(ui::Point(4, 4)));
|
||||||
|
@ -36,7 +36,8 @@ GameView::GameView():
|
|||||||
drawSnap(false),
|
drawSnap(false),
|
||||||
toolTip(""),
|
toolTip(""),
|
||||||
infoTip(""),
|
infoTip(""),
|
||||||
infoTipPresence(0)
|
infoTipPresence(0),
|
||||||
|
toolTipPosition(-1, -1)
|
||||||
{
|
{
|
||||||
|
|
||||||
int currentX = 1;
|
int currentX = 1;
|
||||||
@ -435,7 +436,7 @@ void GameView::NotifyToolListChanged(GameModel * sender)
|
|||||||
for(int i = 0; i < toolList.size(); i++)
|
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(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;
|
//currentY -= 17;
|
||||||
currentX -= 31;
|
currentX -= 31;
|
||||||
tempButton->SetActionCallback(new ToolAction(this, toolList[i]));
|
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)
|
void GameView::OnMouseWheel(int x, int y, int d)
|
||||||
{
|
{
|
||||||
if(!d)
|
if(!d)
|
||||||
@ -1253,6 +1260,11 @@ void GameView::OnDraw()
|
|||||||
int infoTipAlpha = (infoTipPresence>50?50:infoTipPresence)*5;
|
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);
|
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)
|
ui::Point GameView::lineSnapCoords(ui::Point point1, ui::Point point2)
|
||||||
|
@ -41,6 +41,7 @@ private:
|
|||||||
|
|
||||||
int infoTipPresence;
|
int infoTipPresence;
|
||||||
std::string toolTip;
|
std::string toolTip;
|
||||||
|
ui::Point toolTipPosition;
|
||||||
std::string infoTip;
|
std::string infoTip;
|
||||||
|
|
||||||
queue<ui::Point*> pointQueue;
|
queue<ui::Point*> pointQueue;
|
||||||
@ -119,6 +120,8 @@ public:
|
|||||||
void NotifyToolTipChanged(GameModel * sender);
|
void NotifyToolTipChanged(GameModel * sender);
|
||||||
void NotifyInfoTipChanged(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 OnMouseMove(int x, int y, int dx, int dy);
|
||||||
virtual void OnMouseDown(int x, int y, unsigned button);
|
virtual void OnMouseDown(int x, int y, unsigned button);
|
||||||
virtual void OnMouseUp(int x, int y, unsigned button);
|
virtual void OnMouseUp(int x, int y, unsigned button);
|
||||||
|
@ -12,15 +12,17 @@
|
|||||||
|
|
||||||
using namespace std;
|
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),
|
toolID(id),
|
||||||
toolName(name),
|
toolName(name),
|
||||||
|
toolDescription(description),
|
||||||
colRed(r),
|
colRed(r),
|
||||||
colGreen(g),
|
colGreen(g),
|
||||||
colBlue(b)
|
colBlue(b)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
string Tool::GetName() { return toolName; }
|
string Tool::GetName() { return toolName; }
|
||||||
|
string Tool::GetDescription() { return toolDescription; }
|
||||||
Tool::~Tool() {}
|
Tool::~Tool() {}
|
||||||
void Tool::Click(Simulation * sim, Brush * brush, ui::Point position) { }
|
void Tool::Click(Simulation * sim, Brush * brush, ui::Point position) { }
|
||||||
void Tool::Draw(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) {};
|
void Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {};
|
||||||
|
|
||||||
ElementTool::ElementTool(int id, string name, int r, int g, int b):
|
ElementTool::ElementTool(int id, string name, string description, int r, int g, int b):
|
||||||
Tool(id, name, r, g, b)
|
Tool(id, name, description, r, g, b)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
ElementTool::~ElementTool() {}
|
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):
|
WallTool::WallTool(int id, string name, string description, int r, int g, int b):
|
||||||
Tool(id, name, r, g, b)
|
Tool(id, name, description, r, g, b)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
WallTool::~WallTool() {}
|
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):
|
GolTool::GolTool(int id, string name, string description, int r, int g, int b):
|
||||||
Tool(id, name, r, g, b)
|
Tool(id, name, description, r, g, b)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
GolTool::~GolTool() {}
|
GolTool::~GolTool() {}
|
||||||
|
@ -22,9 +22,11 @@ class Tool
|
|||||||
protected:
|
protected:
|
||||||
int toolID;
|
int toolID;
|
||||||
string toolName;
|
string toolName;
|
||||||
|
string toolDescription;
|
||||||
public:
|
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 GetName();
|
||||||
|
string GetDescription();
|
||||||
virtual ~Tool();
|
virtual ~Tool();
|
||||||
virtual void Click(Simulation * sim, Brush * brush, ui::Point position);
|
virtual void Click(Simulation * sim, Brush * brush, ui::Point position);
|
||||||
virtual void Draw(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:
|
public:
|
||||||
SignTool():
|
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() {}
|
virtual ~SignTool() {}
|
||||||
@ -53,7 +55,7 @@ class PropertyTool: public Tool
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PropertyTool():
|
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() {}
|
virtual ~PropertyTool() {}
|
||||||
@ -67,7 +69,7 @@ public:
|
|||||||
class ElementTool: public Tool
|
class ElementTool: public Tool
|
||||||
{
|
{
|
||||||
public:
|
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 ~ElementTool();
|
||||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
||||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2);
|
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2);
|
||||||
@ -78,7 +80,7 @@ public:
|
|||||||
class WallTool: public Tool
|
class WallTool: public Tool
|
||||||
{
|
{
|
||||||
public:
|
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 ~WallTool();
|
||||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
||||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2);
|
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2);
|
||||||
@ -89,7 +91,7 @@ public:
|
|||||||
class GolTool: public Tool
|
class GolTool: public Tool
|
||||||
{
|
{
|
||||||
public:
|
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 ~GolTool();
|
||||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
||||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2);
|
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2);
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
#include "ToolButton.h"
|
#include "ToolButton.h"
|
||||||
#include "interface/Keys.h"
|
#include "interface/Keys.h"
|
||||||
|
|
||||||
ToolButton::ToolButton(ui::Point position, ui::Point size, std::string text_):
|
ToolButton::ToolButton(ui::Point position, ui::Point size, std::string text_, std::string toolTip):
|
||||||
ui::Button(position, size, text_)
|
ui::Button(position, size, text_, toolTip)
|
||||||
{
|
{
|
||||||
SetSelectionState(-1);
|
SetSelectionState(-1);
|
||||||
Appearance.BorderActive = ui::Colour(255, 0, 0);
|
Appearance.BorderActive = ui::Colour(255, 0, 0);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
class ToolButton: public ui::Button {
|
class ToolButton: public ui::Button {
|
||||||
int currentSelection;
|
int currentSelection;
|
||||||
public:
|
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 OnMouseUp(int x, int y, unsigned int button);
|
||||||
virtual void OnMouseClick(int x, int y, unsigned int button);
|
virtual void OnMouseClick(int x, int y, unsigned int button);
|
||||||
virtual void Draw(const ui::Point& screenPos);
|
virtual void Draw(const ui::Point& screenPos);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
namespace ui {
|
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),
|
Component(position, size),
|
||||||
ButtonText(buttonText),
|
ButtonText(buttonText),
|
||||||
isMouseInside(false),
|
isMouseInside(false),
|
||||||
@ -21,7 +21,8 @@ Button::Button(Point position, Point size, std::string buttonText):
|
|||||||
isTogglable(false),
|
isTogglable(false),
|
||||||
toggle(false),
|
toggle(false),
|
||||||
actionCallback(NULL),
|
actionCallback(NULL),
|
||||||
Enabled(true)
|
Enabled(true),
|
||||||
|
toolTip(toolTip)
|
||||||
{
|
{
|
||||||
TextPosition();
|
TextPosition();
|
||||||
}
|
}
|
||||||
@ -141,6 +142,10 @@ void Button::OnMouseEnter(int x, int y)
|
|||||||
return;
|
return;
|
||||||
if(actionCallback)
|
if(actionCallback)
|
||||||
actionCallback->MouseEnterCallback(this);
|
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
|
class Button : public Component
|
||||||
{
|
{
|
||||||
public:
|
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();
|
virtual ~Button();
|
||||||
|
|
||||||
bool Toggleable;
|
bool Toggleable;
|
||||||
@ -55,6 +55,7 @@ public:
|
|||||||
void SetIcon(Icon icon);
|
void SetIcon(Icon icon);
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
std::string toolTip;
|
||||||
std::string buttonDisplayText;
|
std::string buttonDisplayText;
|
||||||
std::string ButtonText;
|
std::string ButtonText;
|
||||||
|
|
||||||
|
@ -46,6 +46,8 @@ enum ChromeStyle
|
|||||||
// Remove a component from state. NOTE: This WILL free component from memory.
|
// Remove a component from state. NOTE: This WILL free component from memory.
|
||||||
void RemoveComponent(unsigned idx);
|
void RemoveComponent(unsigned idx);
|
||||||
|
|
||||||
|
virtual void ToolTip(Component * sender, ui::Point mousePosition, std::string toolTip) {}
|
||||||
|
|
||||||
virtual void DoInitialized();
|
virtual void DoInitialized();
|
||||||
virtual void DoExit();
|
virtual void DoExit();
|
||||||
virtual void DoTick(float dt);
|
virtual void DoTick(float dt);
|
||||||
|
Loading…
Reference in New Issue
Block a user