2009-05-07 00:36:28 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* libwiigui
|
|
|
|
*
|
|
|
|
* Tantric 2009
|
|
|
|
*
|
|
|
|
* gui_tooltip.cpp
|
|
|
|
*
|
|
|
|
* GUI class definitions
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "gui.h"
|
|
|
|
|
2009-05-08 00:46:54 +02:00
|
|
|
static GuiImageData tooltipLeft(tooltip_left_png);
|
|
|
|
static GuiImageData tooltipTile(tooltip_tile_png);
|
|
|
|
static GuiImageData tooltipRight(tooltip_right_png);
|
2009-05-07 00:36:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor for the GuiTooltip class.
|
|
|
|
*/
|
|
|
|
GuiTooltip::GuiTooltip(const char *t)
|
2009-05-08 00:46:54 +02:00
|
|
|
:
|
|
|
|
leftImage(&tooltipLeft), tileImage(&tooltipTile), rightImage(&tooltipRight)
|
2009-05-07 00:36:28 +02:00
|
|
|
{
|
|
|
|
text = NULL;
|
2009-05-08 00:46:54 +02:00
|
|
|
height = leftImage.GetHeight();
|
|
|
|
leftImage.SetParent(this);
|
|
|
|
tileImage.SetParent(this);
|
|
|
|
rightImage.SetParent(this);
|
2009-05-07 00:36:28 +02:00
|
|
|
SetText(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Destructor for the GuiTooltip class.
|
|
|
|
*/
|
|
|
|
GuiTooltip::~GuiTooltip()
|
|
|
|
{
|
|
|
|
if(text) delete text;
|
|
|
|
}
|
|
|
|
|
2009-05-08 00:46:54 +02:00
|
|
|
float GuiTooltip::GetScale()
|
|
|
|
{
|
|
|
|
float s = scale * scaleDyn;
|
|
|
|
|
|
|
|
// if(parentElement)
|
|
|
|
// s *= parentElement->GetScale();
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2009-05-07 00:36:28 +02:00
|
|
|
/* !Sets the text of the GuiTooltip element
|
|
|
|
* !\param t Text
|
|
|
|
*/
|
|
|
|
void GuiTooltip::SetText(const char * t)
|
|
|
|
{
|
|
|
|
LOCK(this);
|
|
|
|
if(text)
|
|
|
|
{
|
|
|
|
delete text;
|
|
|
|
text = NULL;
|
|
|
|
}
|
2009-05-08 00:46:54 +02:00
|
|
|
int tile_cnt = 0;
|
2009-05-07 00:36:28 +02:00
|
|
|
if(t && (text = new GuiText(t, 22, (GXColor){0, 0, 0, 255})))
|
|
|
|
{
|
|
|
|
text->SetParent(this);
|
2009-05-08 00:46:54 +02:00
|
|
|
tile_cnt = (text->GetTextWidth()-12) /tileImage.GetWidth();
|
|
|
|
if(tile_cnt < 0) tile_cnt = 0;
|
2009-05-07 00:36:28 +02:00
|
|
|
}
|
2009-05-08 00:46:54 +02:00
|
|
|
tileImage.SetPosition(leftImage.GetWidth(), 0);
|
|
|
|
tileImage.SetTile(tile_cnt);
|
|
|
|
rightImage.SetPosition(leftImage.GetWidth() + tile_cnt * tileImage.GetWidth(), 0);
|
|
|
|
width = leftImage.GetWidth() + tile_cnt * tileImage.GetWidth() + rightImage.GetWidth();
|
2009-05-07 00:36:28 +02:00
|
|
|
}
|
|
|
|
|
2009-05-20 22:09:57 +02:00
|
|
|
void GuiTooltip::SetWidescreen(bool){}
|
2009-05-07 00:36:28 +02:00
|
|
|
/*
|
|
|
|
* Draw the Tooltip on screen
|
|
|
|
*/
|
|
|
|
void GuiTooltip::Draw()
|
|
|
|
{
|
|
|
|
LOCK(this);
|
|
|
|
if(!this->IsVisible()) return;
|
|
|
|
|
2009-05-08 00:46:54 +02:00
|
|
|
leftImage.Draw();
|
|
|
|
tileImage.Draw();
|
|
|
|
rightImage.Draw();
|
2009-05-07 00:36:28 +02:00
|
|
|
if(text) text->Draw();
|
|
|
|
|
|
|
|
this->UpdateEffects();
|
|
|
|
}
|