OROCHI
 
Loading...
Searching...
No Matches
GxGuiButton.h
Go to the documentation of this file.
1//===========================================================================
10//===========================================================================
11#pragma once
12
13#if GX_DEVELOP
14
15GX_CORE_NAMESPACE_BEGIN()
16
17//===========================================================================
19//===========================================================================
20class GxGuiButton : public GxGuiBase
21{
22 //-----------------------------------------------------------
24 //-----------------------------------------------------------
26public:
27 GX_RTTI_CLASS(GxGuiButton, GxGuiBase)
28 // GxGuiButton継承クラス用禁止宣言
30
31
32 //-----------------------------------------------------------
34 //-----------------------------------------------------------
36public:
38 GxGuiButton(void);
39
41 GxGuiButton( const GxProperty& clickEvent, GxTypedObject* pOwner = nullptr );
42
44 GxGuiButton( const GxProperty& toggleOnEvent, const GxProperty& toggleOffEvent );
45
47 b32 initialize( void ) override;
48
50 //-----------------------------------------------------------
52 //-----------------------------------------------------------
54public:
56 void update( void ) override;
57
59 void executeClickEvent( void );
60
62 void executeOnEvent( void );
63
65 void executeOffEvent( void );
66
68 void onMouseDown(const GxPoint2& position, u32 button) override;
69
71 void onMouseUp(const GxPoint2& position, u32 button) override;
72
74 void onDraw(void) override;
75
77 GxSize getUseRegionSize(void) const override;
78
81 void onMouseHover(const GxPoint2& position) override;
82
84 //-----------------------------------------------------------
86 //-----------------------------------------------------------
88public:
90 void setClickEvent( const GxProperty& clickEvent );
91
93 void setToggleEvent( const GxProperty& toggleOnEvent, const GxProperty& toggleOffEvent );
94
97 GX_FORCE_INLINE void setLabel( const GxString& label ){ _label = label; _labelSize = GxGuiGraphics::calculateStringSize( _label.getString() ); }
98
101 constexpr GX_CSTR getLabel( void ) const { return _label.getString(); }
102
105 GX_FORCE_INLINE void setIconHandle( GX_HANDLE iconHandle ){ setIconHandle( iconHandle, iconHandle ); setDrawFrame(true); }
106
110 GX_FORCE_INLINE void setIconHandle( GX_HANDLE onIconHandle, GX_HANDLE offIconHandle ){ _onIconHandle = onIconHandle; _offIconHandle = offIconHandle; setDrawFrame(false); }
111
114 void setOn( b32 on );
115
118 GX_FORCE_INLINE b32 isOn( void ) const { return _on; }
119
122 GX_FORCE_INLINE void setCanControl( b32 can ){ _canControl = can; }
123
125 void setColor( const GxColor& colorOn, const GxColor& colorOff, b32 useOnOffColor = true );
126
128 GX_FORCE_INLINE void setColor( const GxColor& color, b32 useOnOffColor = true ){ setColor( color,color,useOnOffColor ); }
129
131 GX_FORCE_INLINE const GxColor& getOnColor( void ) const { return _onColor; }
132
134 GX_FORCE_INLINE const GxColor& getOffColor( void ) const { return _offColor; }
135
137 GX_FORCE_INLINE void setColorDefault( void ){ setColor( GxColor::getLerp( getKeyWord1Color(), GxColor::BLACK, 0.5f) ); }
138
140 //@param b32 [in] 枠を描画するか指定
141 GX_FORCE_INLINE void setDrawFrame( b32 draw ){ _isDrawFrame = draw; }
142
144 GX_FORCE_INLINE void setHoverMessage( GX_CSTR message ){ GX_ASSERT( message, "pMessage is nullptr"); _hoverMessage = message; }
145
147 //-----------------------------------------------------------
149 //-----------------------------------------------------------
151protected:
152 GxTypedObject* _pOwner;
153
154 GxProperty _clickEvent;
155 GxProperty _toggleOnEvent;
156 GxProperty _toggleOffEvent;
157
158 GX_HANDLE _onIconHandle;
159 GX_HANDLE _offIconHandle;
160
161 GxString _label;
162 GxSize _labelSize;
163
164 b32 _on;
165 b32 _mouseDown;
166 b32 _canControl;
167 b32 _useToggle;
168
169 b32 _isDrawFrame;
170
171 GxColor _onColor;
172 GxColor _offColor;
173 GxColor _drawOnColor[4];
174 GxColor _drawOffColor[4];
175
176 GxString _hoverMessage;
177
179};
180
181GX_CORE_NAMESPACE_END()
182
183#endif // GX_DEVELOP
#define GX_PROHIBIT_CLASS_BASE_REFERENCE(__CLASS__)
GxClassBaseReference継承の禁止宣言(new以外の生成禁止 + コピー禁止)
Definition GxBase.h:244
void GxTypedObject
その他
Definition GxDefine.h:213
u32 GX_HANDLE
ハンドル
Definition GxDefine.h:214
プロパティクラス
Definition GxProperty.h:48
Definition GxColor.h:21
static const GxColor BLACK
Definition GxColor.h:29
static GX_FORCE_INLINE GxColor getLerp(const GxColor color0, const GxColor color1, f32 t)
補間値を取得(互換用)
Definition GxColor.inl:468
座標
Definition GxStruct.h:867
サイズ
Definition GxStruct.h:730
文字列型クラス
Definition GxString.h:18
32bitブーリアン
Definition GxDefine.h:173