wavelength 1.0.0
Loading...
Searching...
No Matches
uibutton.h
Go to the documentation of this file.
1#pragma once
2
4#include "os/prnstream.h"
5#include "rnd/rndmesh.h"
6#include "rnd/rndtext.h"
7#include "script/dataarray.h"
8#include "ui/uicomponent.h"
9#include "ui/uistyle.h"
10
24class UIButton : public UIComponent {
25public:
34 UIButton(DataArray *pData, const char *pszPanel);
35
42 ~UIButton() override;
43
55 static UIComponent *New(DataArray *pData, const char *pszPanel) {
56 return new UIButton(pData, pszPanel);
57 }
58
67 bool DispatchPriv(Message *pMsg) override;
68
76 void SetShowing(bool bShowing) override;
77
87 const char *Text() const override;
88
98 void SetText(const char *pszText) override;
99
109 void SetState(int nState, bool bForce) override;
110
117 void Unfocus() override;
118
126 void Poll(float fTime) override;
127
135 void Print(PrnStream &stream) override;
136
152 virtual void StartFlash(float fTime,
153 int nFlashes,
154 int nSelectedState,
155 int nNormalState,
156 float fSelectedMs,
157 float fNormalMs);
158
166 void SetStyle(UIStyle *pStyle);
167
177
179 UIStyle *GetStyle() const {
180 return mStyle;
181 }
182
183protected:
185
187
189
191
192 float mNormalMs;
193
194 float mFlashEnd;
195
197
199
201
203
205
207};
Reference-counted array of script data nodes.
Definition dataarray.h:20
Message the controller poll sends when a button is pressed or released.
Definition joypadinputmsg.h:23
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:40
Text output stream.
Definition prnstream.h:16
Triangle mesh with a material.
Definition rndmesh.h:31
Text drawn with a bitmap font as a mesh of one quad per character.
Definition rndtext.h:27
float mFlashStart
Definition uibutton.h:186
void SetShowing(bool bShowing) override
Show or hide the button, its text, and its mesh.
float mSelectedMs
Definition uibutton.h:190
RndMesh * mMesh
Definition uibutton.h:202
static UIComponent * New(DataArray *pData, const char *pszPanel)
Create a button from its script description.
Definition uibutton.h:55
void Print(PrnStream &stream) override
Write the name, the visibility, the state, and the flash.
UIButton(DataArray *pData, const char *pszPanel)
Construct a button from its script description.
UIStyle * GetStyle() const
Definition uibutton.h:179
void Poll(float fTime) override
Advance the flash to a time, and send the UIComponentSelectMsg once it ends.
void Unfocus() override
Stop a flash that runs and return to the state from before it.
float mFlashPeriod
Definition uibutton.h:188
bool HandleSelect(JoypadInputMsg *pMsg)
Start the flash when the cross button goes down.
void SetStyle(UIStyle *pStyle)
Replace the style and apply the current state again.
int mSelectedState
Definition uibutton.h:198
int mFlashDone
Definition uibutton.h:184
UIStyle * mStyle
Definition uibutton.h:206
const char * Text() const override
Report the text of the text object.
float mNormalMs
Definition uibutton.h:192
int mNormalState
Definition uibutton.h:196
virtual void StartFlash(float fTime, int nFlashes, int nSelectedState, int nNormalState, float fSelectedMs, float fNormalMs)
Start a flash between two states.
float mFlashEnd
Definition uibutton.h:194
void SetText(const char *pszText) override
Replace the text of the text object.
void SetState(int nState, bool bForce) override
Change the state and give the mesh and the text the material and the font the style lists for it.
~UIButton() override
Destroy the button.
int mRevertState
Definition uibutton.h:200
RndText * mText
Definition uibutton.h:204
bool DispatchPriv(Message *pMsg) override
Handle a controller button, or pass any other message to UIComponent.
UIComponent(DataArray *pData)
Construct a showing component in the normal state.
Definition uicomponent.h:37
Material and font a component draws with in each of its states.
Definition uistyle.h:15