Adds a second drawing-pass for drawing tooltips. Now tooltips allways on top and no more overlapped by other buttons.

This commit is contained in:
ardi@ist-einmalig.de 2009-05-04 19:06:16 +00:00
parent 1c632d82a7
commit fc549f113f
5 changed files with 40 additions and 1 deletions

View File

@ -372,6 +372,7 @@ class GuiElement
virtual void Update(GuiTrigger * t);
//!Called constantly to redraw the element
virtual void Draw();
virtual void DrawTooltip();
protected:
//int position2; //! B Scrollbariable
bool visible; //!< Visibility of the element. If false, Draw() is skipped
@ -472,6 +473,7 @@ class GuiWindow : public GuiElement
void MoveSelectionVert(int d);
//!Draws all the elements in this GuiWindow
void Draw();
void DrawTooltip();
//!Updates the window and all elements contains within
//!Allows the GuiWindow and all elements to respond to the input data specified
//!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD
@ -696,6 +698,7 @@ class GuiButton : public GuiElement
void SetToolTip(GuiImage* i, GuiText * t, int x, int y);
//!Constantly called to draw the GuiButton
void Draw();
void DrawTooltip();
//!Constantly called to allow the GuiButton to respond to updated input data
//!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD
void Update(GuiTrigger * t);

View File

@ -173,6 +173,7 @@ void GuiButton::Draw()
}
//draw ToolTip
/*
if(state == STATE_SELECTED && toolTip)
{
if (time2 == 0)
@ -188,10 +189,27 @@ void GuiButton::Draw()
}
}
}
*/
this->UpdateEffects();
}
void GuiButton::DrawTooltip()
{
if(state == STATE_SELECTED && toolTip)
{
if (time2 == 0)
time(&time2);
time(&time1);
if (difftime(time1, time2) >= 2) {
toolTip->Draw();
if (toolTipTxt)
{
toolTipTxt->Draw();
}
}
}
}
void GuiButton::ScrollIsOn(int f)
{
scrollison = f;

View File

@ -563,6 +563,13 @@ void GuiElement::Draw()
{
}
/**
* Draw Tooltips on screen.
*/
void GuiElement::DrawTooltip()
{
}
/**
* Check if a position is inside the GuiElement.
* @param[in] x X position in pixel.

View File

@ -97,7 +97,17 @@ void GuiWindow::Draw()
//Menu_DrawRectangle(0,0,screenwidth,screenheight,(GXColor){0xbe, 0xca, 0xd5, 0x70},1);
Menu_DrawRectangle(0,0,screenwidth,screenheight,(GXColor){0, 0, 0, 0x70},1);
}
void GuiWindow::DrawTooltip()
{
if(_elements.size() == 0 || !this->IsVisible())
return;
for (u8 i = 0; i < _elements.size(); i++)
{
try { _elements.at(i)->DrawTooltip(); }
catch (const std::exception& e) { }
}
}
void GuiWindow::ResetState()
{
if(state != STATE_DISABLED)

View File

@ -1671,6 +1671,7 @@ UpdateGUI (void *arg)
else
{
mainWindow->Draw();
mainWindow->DrawTooltip();
#ifdef HW_RVL
for(int i=3; i >= 0; i--) // so that player 1's cursor appears on top!