blob: 31071b31832e8ef05563f79cde6974f50f5b01a4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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
|