Line data Source code
1 : /* Copyright (C) 2026 Wildfire Games. 2 : * This file is part of 0 A.D. 3 : * 4 : * 0 A.D. is free software: you can redistribute it and/or modify 5 : * it under the terms of the GNU General Public License as published by 6 : * the Free Software Foundation, either version 2 of the License, or 7 : * (at your option) any later version. 8 : * 9 : * 0 A.D. is distributed in the hope that it will be useful, 10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 : * GNU General Public License for more details. 13 : * 14 : * You should have received a copy of the GNU General Public License 15 : * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 : */ 17 : 18 : #ifndef INCLUDED_CTOOLTIP 19 : #define INCLUDED_CTOOLTIP 20 : 21 : #include "gui/CGUISetting.h" 22 : #include "gui/CGUISprite.h" 23 : #include "gui/ObjectBases/IGUIObject.h" 24 : #include "gui/ObjectBases/IGUITextOwner.h" 25 : #include "gui/SettingTypes/CGUIColor.h" 26 : #include "gui/SettingTypes/CGUIString.h" 27 : #include "maths/Vector2D.h" 28 : #include "ps/CStr.h" 29 : 30 : class CGUI; 31 : enum class EVAlign; 32 : 33 : /** 34 : * Dynamic tooltips. Similar to CText. 35 : */ 36 : class CTooltip : public IGUIObject, public IGUITextOwner 37 : { 38 0 : GUI_OBJECT(CTooltip) 39 : 40 : public: 41 : CTooltip(CGUI& pGUI); 42 : 43 0 : const CStr& GetUsedObject() const { return m_UseObject; } 44 0 : std::int32_t GetTooltipDelay() const { return m_Delay; } 45 0 : bool ShouldHideObject() const { return m_HideObject; } 46 0 : void SetMousePos(const CVector2D& vec) { m_MousePos.Set(vec, true); } 47 : 48 : protected: 49 : void SetupText(); 50 : 51 : /** 52 : * @see IGUIObject#HandleSizeChanged() 53 : */ 54 : void HandleSizeChanged(); 55 : 56 : /** 57 : * @see IGUIObject#HandleMessage() 58 : */ 59 : virtual void HandleMessage(SGUIMessage& Message); 60 : 61 : virtual void Draw(CCanvas2D& canvas); 62 : 63 : virtual float GetBufferedZ() const; 64 : 65 : CGUISimpleSetting<float> m_BufferZone; 66 : CGUISimpleSetting<CGUIString> m_Caption; 67 : CGUISimpleSetting<CStrW> m_Font; 68 : CGUISimpleSetting<CGUISpriteInstance> m_Sprite; 69 : CGUISimpleSetting<std::int32_t> m_Delay; 70 : CGUISimpleSetting<CGUIColor> m_TextColor; 71 : CGUISimpleSetting<float> m_MaxWidth; 72 : CGUISimpleSetting<CVector2D> m_Offset; 73 : CGUISimpleSetting<EVAlign> m_Anchor; 74 : CGUISimpleSetting<bool> m_Independent; 75 : CGUISimpleSetting<CVector2D> m_MousePos; 76 : CGUISimpleSetting<CStr> m_UseObject; 77 : CGUISimpleSetting<bool> m_HideObject; 78 : }; 79 : 80 : #endif // INCLUDED_CTOOLTIP