From fc549f113f8e5de5ecb9d26f0d28c934de9ad84f Mon Sep 17 00:00:00 2001 From: "ardi@ist-einmalig.de" Date: Mon, 4 May 2009 19:06:16 +0000 Subject: [PATCH] Adds a second drawing-pass for drawing tooltips. Now tooltips allways on top and no more overlapped by other buttons. --- source/libwiigui/gui.h | 3 +++ source/libwiigui/gui_button.cpp | 20 +++++++++++++++++++- source/libwiigui/gui_element.cpp | 7 +++++++ source/libwiigui/gui_window.cpp | 10 ++++++++++ source/menu.cpp | 1 + 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/source/libwiigui/gui.h b/source/libwiigui/gui.h index 3459042a..64f1f6d0 100644 --- a/source/libwiigui/gui.h +++ b/source/libwiigui/gui.h @@ -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); diff --git a/source/libwiigui/gui_button.cpp b/source/libwiigui/gui_button.cpp index 7729c135..11940bf1 100644 --- a/source/libwiigui/gui_button.cpp +++ b/source/libwiigui/gui_button.cpp @@ -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; diff --git a/source/libwiigui/gui_element.cpp b/source/libwiigui/gui_element.cpp index 778c70d9..3f5d2d9f 100644 --- a/source/libwiigui/gui_element.cpp +++ b/source/libwiigui/gui_element.cpp @@ -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. diff --git a/source/libwiigui/gui_window.cpp b/source/libwiigui/gui_window.cpp index b8abea49..a889608d 100644 --- a/source/libwiigui/gui_window.cpp +++ b/source/libwiigui/gui_window.cpp @@ -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) diff --git a/source/menu.cpp b/source/menu.cpp index 5f6cc7ae..dd4c7acd 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -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!