diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/panorama/controls/tooltip.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'public/panorama/controls/tooltip.h')
| -rw-r--r-- | public/panorama/controls/tooltip.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/public/panorama/controls/tooltip.h b/public/panorama/controls/tooltip.h new file mode 100644 index 0000000..31071b3 --- /dev/null +++ b/public/panorama/controls/tooltip.h @@ -0,0 +1,81 @@ +//=========== Copyright Valve Corporation, All rights reserved. ===============// +// +// Purpose: +//=============================================================================// + +#ifndef PANORAMA_TOOLTIP_H +#define PANORAMA_TOOLTIP_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "panel2d.h" +#include "../uievent.h" +#include "label.h" + +namespace panorama +{ + +DECLARE_PANEL_EVENT0( TooltipVisible ); + +//----------------------------------------------------------------------------- +// Purpose: Top level panel for a tooltip +//----------------------------------------------------------------------------- +class CTooltip : public CPanel2D +{ + DECLARE_PANEL2D( CTooltip, CPanel2D ); + +public: + CTooltip( IUIWindow *pParent, const char *pchName ); + CTooltip( CPanel2D *pParent, const char *pchName ); + virtual ~CTooltip(); + + void SetTooltipTarget( const CPanelPtr< IUIPanel >& targetPanelPtr ); + + // Get/set tooltip visibility. This is actually determined by a .css class, + // so that transitions can be supported + bool IsTooltipVisible() const; + void SetTooltipVisible( bool bVisible ); + + virtual void OnLayoutTraverse( float flFinalWidth, float flFinalHeight ); + + // request the tooltip to do positioning on the next layout + virtual void CalculatePosition() { m_bReposition = true; InvalidateSizeAndPosition(); } + +private: + + void Init(); + void UpdatePosition(); + + bool EventTooltipVisible( const panorama::CPanelPtr< panorama::IUIPanel > &pPanel ); + + bool m_bReposition; + + CPanelPtr< IUIPanel > m_pTooltipTarget; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Simple tooltip that just shows a string of text +//----------------------------------------------------------------------------- +class CTextTooltip : public CTooltip +{ + DECLARE_PANEL2D( CTextTooltip, CTooltip ); + +public: + CTextTooltip( IUIWindow *pParent, const char *pchName ); + CTextTooltip( CPanel2D *pParent, const char *pchName ); + virtual ~CTextTooltip(); + + void SetText( const char *pchText, CLabel::ETextType eTextType = CLabel::k_ETextTypePlain ); + +private: + void Init(); + + CLabel *m_pText; +}; + +} // namespace panorama + +#endif // PANORAMA_TOOLTIP_H
\ No newline at end of file |