Fission FSN
Loading...
Searching...
No Matches
fsCButtonComponent.h
Go to the documentation of this file.
1/********************************************************************
2*
3* Created: 17/3/2014 11:05
4*
5* File: fsCButtonComponent.h
6*
7* Author: Mick Waites
8*
9* Purpose: Control component for a GUI button entity.
10*
11*********************************************************************/
12
13#ifndef fsCButtonComponenthdr
14#define fsCButtonComponenthdr
15
16#include <fsCore/fsSColour.h>
18
20
21struct fsPoint;
22class fsCResourceName;
23class fsIFont;
24class fsCBrush;
25
27{
28 friend class fsCComponentFactory;
30
31public:
32
38
39 void brushesReplace(const fsCResourceName& pImageFileName, const fsCResourceName& pDownImageFileName,
40 const fsPoint& pSize);
41
42 void actionSet(const fsCUniqueId& pActionId, const fsStr& pParamStr);
43
44 // A disabled button stays in place, drawn faded, and ignores the pointer, so a layout keeps
45 // its balance where hiding the button would leave a hole.
46 void enabledSet(fsBool pEnabled);
47 fsBool enabledGet() const;
48
49 // Performs the button's action as a tap would, unless it is disabled. Like a tap, the action
50 // may destroy the button (and its gui), so callers must not touch either afterwards.
51 void press();
52
53 fsCEntity* buttonGuiEntityCreate(const fsStr& pEntityName, const fsCResourceName& pImageFileName,
54 const fsCResourceName& pDownImageFileName);
55 fsCEntity* textButtonGuiEntityCreate(const fsStr& pEntityName, const fsCResourceName& pImageFileName,
56 const fsCResourceName& pDownImageFileName, const fsStr& pText, fsIFont* pFont);
57
58 static const fsCUniqueId mTypeId;
59
60protected:
61
62 void defaultSpriteSet();
63
64 fsBool acceptingInputGet() const override;
65 fsBool highlightSetDo() override;
66
67 void onTap(const fsPoint& pTapPos) override;
68
69 static fsIComponent* create(fsCEntity* pParent);
70
71 void initialiseFromVariableTableDo(const fsCVariableTable& pVars) override;
72
74 ~fsCButtonComponent() override;
75
77 std::shared_ptr<fsCBrush> mBrush;
78 std::shared_ptr<fsCBrush> mOverBrush;
79
82
83private:
84
85 void enabledLookApply() const;
86
87 fsBool mEnabled;
88 fsSColour4B mTextColour;
89
90 static const fsCUniqueId mActionUnsetId;
91
92 void spriteInitialise(const fsCVariableTable& pVars);
93 void actionInitialise(const fsCVariableTable& pVars);
94 void textCreateIfWanted(const fsCVariableTable& pVars);
95
96 void actionPerform();
97};
98
99#endif
Definition fsCBrush.h:26
fsBool acceptingInputGet() const override
Definition fsCButtonComponent.cpp:209
sButtonEventMsgParam mActionParam
Definition fsCButtonComponent.h:81
friend class gfIAutoTestLevelUserInputComponent
Definition fsCButtonComponent.h:29
~fsCButtonComponent() override
Definition fsCButtonComponent.cpp:278
friend class fsCComponentFactory
Definition fsCButtonComponent.h:28
void brushesReplace(const fsCResourceName &pImageFileName, const fsCResourceName &pDownImageFileName, const fsPoint &pSize)
Definition fsCButtonComponent.cpp:24
std::shared_ptr< fsCBrush > mBrush
Definition fsCButtonComponent.h:77
fsCButtonComponent(fsCEntity *pParent)
Definition fsCButtonComponent.cpp:269
void initialiseFromVariableTableDo(const fsCVariableTable &pVars) override
Definition fsCButtonComponent.cpp:53
void actionSet(const fsCUniqueId &pActionId, const fsStr &pParamStr)
Definition fsCButtonComponent.cpp:133
static const fsCUniqueId mTypeId
Definition fsCButtonComponent.h:58
void press()
Definition fsCButtonComponent.cpp:231
fsBool enabledGet() const
Definition fsCButtonComponent.cpp:189
fsCEntity * buttonGuiEntityCreate(const fsStr &pEntityName, const fsCResourceName &pImageFileName, const fsCResourceName &pDownImageFileName)
Definition fsCButtonComponent.cpp:139
fsCUniqueId mActionId
Definition fsCButtonComponent.h:80
void onTap(const fsPoint &pTapPos) override
Definition fsCButtonComponent.cpp:239
static fsIComponent * create(fsCEntity *pParent)
Definition fsCButtonComponent.cpp:264
void enabledSet(fsBool pEnabled)
Definition fsCButtonComponent.cpp:173
std::shared_ptr< fsCBrush > mOverBrush
Definition fsCButtonComponent.h:78
fsPoint mSize
Definition fsCButtonComponent.h:76
void defaultSpriteSet()
Definition fsCButtonComponent.cpp:76
fsCEntity * textButtonGuiEntityCreate(const fsStr &pEntityName, const fsCResourceName &pImageFileName, const fsCResourceName &pDownImageFileName, const fsStr &pText, fsIFont *pFont)
Definition fsCButtonComponent.cpp:162
fsBool highlightSetDo() override
Definition fsCButtonComponent.cpp:214
Definition fsCEntity.h:39
Definition fsCResourceName.h:32
Definition fsCUniqueId.h:21
Definition fsCVariableTable.h:27
fsIComponent(fsCEntity *pParent)
Definition fsIComponent.cpp:86
Definition fsIFont.h:34
fsIGestureHandlingComponent(fsCEntity *pParent, fsBool pHandleTaps, fsBool pHandleDragEvent, fsBool pHandlePinchEvents)
Definition fsIGestureHandlingComponent.cpp:521
Definition fsStr.h:23
bool fsBool
Definition fsBaseTypes.h:26
Definition fsCButtonComponent.h:34
fsStr mStr
Definition fsCButtonComponent.h:35
fsCButtonComponent * mParent
Definition fsCButtonComponent.h:36
Definition fsIMessageDispatcher.h:32
Definition fsPoint.h:17
Definition fsSColour.h:54