OpenBarnyard
 
Loading...
Searching...
No Matches
AGUI2Button Class Reference

#include <AGUI2Button.h>

Inheritance diagram for AGUI2Button:
AGUI2MenuItem AGUI2Element AGUI2ElementNode

Public Member Functions

 AGUI2Button ()
 
 ~AGUI2Button ()
 
void Create (AGUI2Font *a_pFont, TFLOAT a_fWidth, const TWCHAR *a_wszText, TFLOAT a_fGap)
 
void SetImage (const TCHAR *a_szTexSec, TFLOAT a_fScaleX, TFLOAT a_fScaleY)
 
void SetId (TINT a_iID)
 
TINT GetId () const
 
void SetScaleOnFocus (TBOOL a_bScaleOnFocus)
 
void SetFocusedScale (TFLOAT a_fScale)
 
void SetFocusedColour (TUINT a_uiColour)
 
void SetEnabledColour (TUINT a_uiColour)
 
void SetDisabledColour (TUINT a_uiColour)
 
void SetTextShadow (TBOOL a_bEnabled, TUINT32 a_uiColour, TFLOAT a_fAlpha)
 
void SetTextShadowOffset (TFLOAT a_fOffset)
 
void SetTextShadowOffset (TFLOAT a_fOffsetX, TFLOAT a_fOffsetY)
 
AGUI2RectangleGetBackground ()
 
AGUI2TextBoxGetTextBox ()
 
virtual void GetDimensions (TFLOAT &a_rWidth, TFLOAT &a_rHeight) override
 
virtual void SetAlpha (TFLOAT a_fAlpha) override
 
virtual void SetShadowAlpha (TFLOAT a_fAlpha) override
 
virtual void OnFocus () override
 
virtual void OnFocusLost () override
 
virtual void SetEnabled (TBOOL a_bEnabled) override
 
virtual TFLOAT GetFlowVisualOffset () override
 
virtual TFLOAT GetFlowOffset () override
 
- Public Member Functions inherited from AGUI2MenuItem
 AGUI2MenuItem ()
 
 ~AGUI2MenuItem ()
 
void LinkMenuItemBefore (AGUI2MenuItem &a_rLinkAfter)
 
TBOOL IsEnabled () const
 
TBOOL CanFocus () const
 
AGUI2MenuItemGetNextMenuItem () const
 
AGUI2MenuItemGetPrevMenuItem () const
 
virtual void OnUpdate (TFLOAT a_fDeltaTime)
 
virtual COMMANDRESULT OnInputCommand (AGUI2Menu::ACTIONFLAGS &a_rActionFlags)
 
- Public Member Functions inherited from AGUI2Element
 AGUI2Element ()
 
virtual ~AGUI2Element ()=default
 
virtual void Tick (TFLOAT a_fDeltaTime)
 
virtual void PreRender ()
 
virtual void Render ()
 
virtual void PostRender ()
 
virtual TFLOAT GetWidth ()
 
virtual TFLOAT GetHeight ()
 
virtual void SetWidth (TFLOAT a_fWidth)
 
virtual void SetHeight (TFLOAT a_fHeight)
 
virtual void SetDimensions (TFLOAT a_fWidth, TFLOAT a_fHeight)
 
virtual void GetMins (TFLOAT &a_fX, TFLOAT &a_fY)
 
virtual void GetMaxs (TFLOAT &a_fX, TFLOAT &a_fY)
 
virtual void SetColour (TUINT32 a_uiColour)
 
virtual void SetFocus (TBOOL a_bFocused)
 
virtual TBOOL IsPointInside (TFLOAT a_fX, TFLOAT a_fY)
 
void AnchorPos (TFLOAT &a_rX, TFLOAT &a_rY, TFLOAT a_fWidth, TFLOAT a_fHeight)
 
void PivotPos (TFLOAT &a_rX, TFLOAT &a_rY, TFLOAT a_fWidth, TFLOAT a_fHeight)
 
void GetScreenTransform (AGUI2Transform &a_rOutTransform)
 
void GetInvScreenTransform (AGUI2Transform &a_rOutTransform)
 
void Show ()
 
void Hide ()
 
void SetInFront ()
 
void SetRenderBeforeChildren ()
 
TBOOL HasFlags (TUINT32 a_uiFlags) const
 
TBOOL IsVisible () const
 
TBOOL IsFocused () const
 
TBOOL ShouldRenderBeforeChildren ()
 
TBOOL IsInFront () const
 
TFLOAT GetAlpha () const
 
void AddChildTail (AGUI2Element &a_rElement)
 
void AddChildHead (AGUI2Element &a_rElement)
 
void SetTranslation (TFLOAT a_fX, TFLOAT a_fY)
 
void SetTranslation (const Toshi::TVector2 &a_rTranslation)
 
void SetTransform (TFLOAT a_fX, TFLOAT a_fY, float a_fRotAngle=0.0f)
 
void SetAnchor (AGUI2ATTACHMENT a_eAnchor)
 
void SetPivot (AGUI2ATTACHMENT a_ePivot)
 
void SetAttachment (AGUI2ATTACHMENT a_eAnchor, AGUI2ATTACHMENT a_ePivot)
 
t_PostRender SetPostRenderCallback (t_PostRender a_cbNewCallback)
 
AGUI2TransformGetTransform ()
 
AGUI2ElementChildBegin () const
 
AGUI2ElementChildRBegin () const
 
AGUI2ElementGetNextChild (AGUI2Element *a_pCurrentChild)
 
AGUI2ElementGetPrevChild (AGUI2Element *a_pCurrentChild)
 
void RemoveSelf ()
 
void LinkChildBefore (AGUI2Element &a_rNewChildren, AGUI2Element &a_rInsertAfter)
 
- Public Member Functions inherited from AGUI2ElementNode
 AGUI2ElementNode ()
 
virtual ~AGUI2ElementNode ()
 
void Unlink ()
 
void LinkAfter (AGUI2ElementNode &a_rNode)
 
void LinkBefore (AGUI2ElementNode &a_rNode)
 
TBOOL IsLinked () const
 
AGUI2ElementNodeGetNext () const
 
AGUI2ElementNodeGetPrev () const
 

Additional Inherited Members

- Public Types inherited from AGUI2MenuItem
enum  COMMANDRESULT { COMMANDRESULT_NONE , COMMANDRESULT_OK , COMMANDRESULT_CANCEL }
 
- Public Types inherited from AGUI2Element
using t_PostRender = void ( * )()
 
- Public Attributes inherited from AGUI2ElementNode
friend AGUI2Element
 
- Static Public Attributes inherited from AGUI2Element
static TUINT32 s_uiVisibilityMask = 0xFFFFFFFF
 
- Protected Attributes inherited from AGUI2Element
AGUI2Elementm_pParent
 
AGUI2Transform m_oTransform
 
AGUI2ElementNode m_Children
 
AGUI2ATTACHMENT m_eAnchor
 
AGUI2ATTACHMENT m_ePivot
 
TFLOAT m_fWidth
 
TFLOAT m_fHeight
 
TUINT32 m_uiColour
 
TUINT32 m_eFlags
 
t_PostRender m_cbPostRender
 
TUINT32 m_uiVisibilityMask
 
- Protected Attributes inherited from AGUI2ElementNode
AGUI2ElementNodem_pNext
 
AGUI2ElementNodem_pPrev
 

Detailed Description

Definition at line 7 of file AGUI2Button.h.

Constructor & Destructor Documentation

◆ AGUI2Button()

AGUI2Button::AGUI2Button ( )

Definition at line 11 of file AGUI2Button.cpp.

12{
13 m_bScaleOnFocus = TTRUE;
14 m_bFocused = TFALSE;
15 m_fRectangle1Width = 0.0f;
16 m_fRectangle1Height = 0.0f;
17 m_bUseRectangle1 = TFALSE;
18 m_Unk3 = 0;
19 m_uiFocusedColour = 0xffffff80;
20 m_uiEnabledColour = 0xffffffff;
21 m_uiDisabledColour = 0xffc0c0c0;
22 m_fFocusedScale = 1.25f;
23 m_fScale = 1.0f;
24 m_pFont = TNULL;
25 m_fGap = 0.0f;
26 m_wszButtonText = TNULL;
27}
#define TNULL
Definition Typedefs.h:23
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25

◆ ~AGUI2Button()

AGUI2Button::~AGUI2Button ( )

Definition at line 29 of file AGUI2Button.cpp.

30{
31 m_oBackgroundRect.Unlink();
32}

Member Function Documentation

◆ Create()

void AGUI2Button::Create ( AGUI2Font * a_pFont,
TFLOAT a_fWidth,
const TWCHAR * a_wszText,
TFLOAT a_fGap )

Definition at line 34 of file AGUI2Button.cpp.

35{
36 TVALIDPTR( a_pFont );
37 TVALIDPTR( a_wszText );
38
39 m_fGap = a_fGap;
40 m_pFont = a_pFont;
41
42 m_oText.Create( a_pFont, a_fWidth );
43 SetButtonColour( m_uiEnabledColour );
44
45 if ( m_bScaleOnFocus )
46 m_oTransform.SetScale( m_fScale, m_fScale );
47
48 m_oText.SetText( a_wszText );
49 AddChildTail( m_oText );
50
52 m_oText.SetTextAlign( AGUI2Font::TextAlign_Center );
53}
#define TVALIDPTR(PTR)
Definition Defines.h:139
@ AGUI2ATTACHMENT_MIDDLECENTER
void AddChildTail(AGUI2Element &a_rElement)
AGUI2Transform m_oTransform
TBOOL Create(AGUI2FontDef *a_pFontDef)
Definition AGUI2Font.cpp:13
@ TextAlign_Center
Definition AGUI2Font.h:40

◆ GetBackground()

AGUI2Rectangle & AGUI2Button::GetBackground ( )
inline

Definition at line 35 of file AGUI2Button.h.

35{ return m_oBackgroundRect; }

◆ GetDimensions()

void AGUI2Button::GetDimensions ( TFLOAT & a_rWidth,
TFLOAT & a_rHeight )
overridevirtual

Reimplemented from AGUI2Element.

Definition at line 70 of file AGUI2Button.cpp.

71{
72 m_oText.GetDimensions( a_rWidth, a_rHeight );
73}

◆ GetFlowOffset()

TFLOAT AGUI2Button::GetFlowOffset ( )
overridevirtual

Reimplemented from AGUI2MenuItem.

Definition at line 149 of file AGUI2Button.cpp.

150{
151 TVALIDPTR( m_pFont );
152 return m_pFont->GetLinesMargin() * 0.5f + m_fGap;
153}

◆ GetFlowVisualOffset()

TFLOAT AGUI2Button::GetFlowVisualOffset ( )
overridevirtual

Reimplemented from AGUI2MenuItem.

Definition at line 143 of file AGUI2Button.cpp.

144{
145 TVALIDPTR( m_pFont );
146 return m_pFont->GetLinesMargin() * 0.5f + m_fGap;
147}

◆ GetId()

TINT AGUI2Button::GetId ( ) const
inline

Definition at line 18 of file AGUI2Button.h.

18{ return m_iButtonID; }

◆ GetTextBox()

AGUI2TextBox & AGUI2Button::GetTextBox ( )
inline

Definition at line 36 of file AGUI2Button.h.

36{ return m_oText; }

◆ OnFocus()

void AGUI2Button::OnFocus ( )
overridevirtual

Reimplemented from AGUI2MenuItem.

Definition at line 101 of file AGUI2Button.cpp.

102{
103 m_bFocused = TTRUE;
104
105 if ( m_bScaleOnFocus )
106 m_oTransform.SetScale( m_fFocusedScale, m_fFocusedScale );
107
108 SetButtonColour( m_uiFocusedColour );
109
110 if ( m_bUseRectangle1 )
111 {
112 TFLOAT fWidth, fHeight;
113 GetDimensions( fWidth, fHeight );
114
115 m_Rectangle1.SetDimensions( fWidth + m_fRectangle1Width, fHeight + m_fRectangle1Height );
116 LinkChildBefore( m_Rectangle1, m_oText );
117 }
118}
float TFLOAT
Definition Typedefs.h:4
virtual void GetDimensions(TFLOAT &a_rWidth, TFLOAT &a_rHeight) override
void LinkChildBefore(AGUI2Element &a_rNewChildren, AGUI2Element &a_rInsertAfter)

◆ OnFocusLost()

void AGUI2Button::OnFocusLost ( )
overridevirtual

Reimplemented from AGUI2MenuItem.

Definition at line 120 of file AGUI2Button.cpp.

121{
122 m_bFocused = TFALSE;
123
124 if ( m_bScaleOnFocus )
125 m_oTransform.SetScale( m_fScale, m_fScale );
126
127 SetButtonColour( IsEnabled() ? m_uiEnabledColour : m_uiDisabledColour );
128
129 if ( m_bUseRectangle1 )
130 m_Rectangle1.RemoveSelf();
131}
TBOOL IsEnabled() const
Definition AGUI2Menu.h:105

◆ SetAlpha()

void AGUI2Button::SetAlpha ( TFLOAT a_fAlpha)
overridevirtual

Reimplemented from AGUI2MenuItem.

Definition at line 75 of file AGUI2Button.cpp.

76{
77 m_oText.SetAlpha( a_fAlpha );
78 m_Rectangle1.SetAlpha( a_fAlpha );
79 m_oBackgroundRect.SetAlpha( a_fAlpha );
80
81 for ( auto it = m_oText.ChildRBegin(); it != TNULL; it = m_oText.GetPrevChild( it ) )
82 {
83 it->SetAlpha( a_fAlpha );
84 }
85
86 AGUI2MenuItem::SetAlpha( a_fAlpha );
87}
virtual void SetAlpha(TFLOAT a_fAlpha) override

◆ SetDisabledColour()

void AGUI2Button::SetDisabledColour ( TUINT a_uiColour)
inline

Definition at line 24 of file AGUI2Button.h.

24{ m_uiDisabledColour = a_uiColour; }

◆ SetEnabled()

void AGUI2Button::SetEnabled ( TBOOL a_bEnabled)
overridevirtual

Reimplemented from AGUI2MenuItem.

Definition at line 133 of file AGUI2Button.cpp.

134{
135 if ( IsEnabled() != a_bEnabled )
136 {
137 AGUI2MenuItem::SetEnabled( a_bEnabled );
138
139 SetButtonColour( IsEnabled() ? m_uiEnabledColour : m_uiDisabledColour );
140 }
141}
virtual void SetEnabled(TBOOL a_bEnabled)

◆ SetEnabledColour()

void AGUI2Button::SetEnabledColour ( TUINT a_uiColour)
inline

Definition at line 23 of file AGUI2Button.h.

23{ m_uiEnabledColour = a_uiColour; }

◆ SetFocusedColour()

void AGUI2Button::SetFocusedColour ( TUINT a_uiColour)
inline

Definition at line 22 of file AGUI2Button.h.

22{ m_uiFocusedColour = a_uiColour; }

◆ SetFocusedScale()

void AGUI2Button::SetFocusedScale ( TFLOAT a_fScale)
inline

Definition at line 21 of file AGUI2Button.h.

21{ m_fFocusedScale = a_fScale; }

◆ SetId()

void AGUI2Button::SetId ( TINT a_iID)
inline

Definition at line 17 of file AGUI2Button.h.

17{ m_iButtonID = a_iID; }

◆ SetImage()

void AGUI2Button::SetImage ( const TCHAR * a_szTexSec,
TFLOAT a_fScaleX,
TFLOAT a_fScaleY )

Definition at line 55 of file AGUI2Button.cpp.

56{
57 TVALIDPTR( a_szTexSec );
58
59 AGUI2TextureSection* pTexSec = AGUI2TextureSectionManager::GetTextureSection( a_szTexSec );
60 TVALIDPTR( pTexSec );
61
62 TFLOAT fHeight = m_oText.GetHeight() * a_fScaleY;
63 TFLOAT fWidth = m_oText.GetWidth() * a_fScaleX;
64 m_oBackgroundRect.SetDimensions( fWidth, fHeight );
65 m_oBackgroundRect.SetTextureSection( pTexSec );
66 m_oBackgroundRect.SetAttachment( AGUI2ATTACHMENT_MIDDLECENTER, AGUI2ATTACHMENT_MIDDLECENTER );
67 LinkChildBefore( m_oBackgroundRect, m_oText );
68}
static AGUI2TextureSection * GetTextureSection(const TCHAR *a_szSectionName)

◆ SetScaleOnFocus()

void AGUI2Button::SetScaleOnFocus ( TBOOL a_bScaleOnFocus)
inline

Definition at line 20 of file AGUI2Button.h.

20{ m_bScaleOnFocus = a_bScaleOnFocus; }

◆ SetShadowAlpha()

void AGUI2Button::SetShadowAlpha ( TFLOAT a_fAlpha)
overridevirtual

Reimplemented from AGUI2Element.

Definition at line 89 of file AGUI2Button.cpp.

90{
91 m_oText.SetShadowAlpha( a_fAlpha );
92
93 for ( auto it = m_oText.ChildRBegin(); it != TNULL; it = m_oText.GetPrevChild( it ) )
94 {
95 it->SetShadowAlpha( a_fAlpha );
96 }
97
99}
virtual void SetShadowAlpha(TFLOAT a_fAlpha)

◆ SetTextShadow()

void AGUI2Button::SetTextShadow ( TBOOL a_bEnabled,
TUINT32 a_uiColour,
TFLOAT a_fAlpha )
inline

Definition at line 26 of file AGUI2Button.h.

27 {
28 m_oText.SetShadow( a_bEnabled, a_uiColour );
29 m_oText.SetShadowAlpha( a_fAlpha );
30 }

◆ SetTextShadowOffset() [1/2]

void AGUI2Button::SetTextShadowOffset ( TFLOAT a_fOffset)
inline

Definition at line 32 of file AGUI2Button.h.

32{ m_oText.SetShadowOffset( a_fOffset, a_fOffset ); }

◆ SetTextShadowOffset() [2/2]

void AGUI2Button::SetTextShadowOffset ( TFLOAT a_fOffsetX,
TFLOAT a_fOffsetY )
inline

Definition at line 33 of file AGUI2Button.h.

33{ m_oText.SetShadowOffset( a_fOffsetX, a_fOffsetY ); }

The documentation for this class was generated from the following files: