OROCHI
 
Loading...
Searching...
No Matches
GxGuiProperty.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//===========================================================================
20//===========================================================================
21class GxGuiProperty : public GxGuiBase
22{
23 //-----------------------------------------------------------
25 //-----------------------------------------------------------
27public:
28 GX_RTTI_ABSTRACT_CLASS(GxGuiProperty, GxGuiBase)
29 // ClassBaseReference継承クラス用禁止宣言
31
32
33 enum class NAME_TYPE
34 {
35 NONE = 0,
36 LEFT,
37 RIGHT
38 };
39
41 enum GUI_PROPERTY_ATTRIBUTE
42 {
43 GUI_PROPERTY_ATTRIBUTE_NONE = 0,
44 GUI_PROPERTY_ATTRIBUTE_ARRAY_COUNT_OFF = (1UL << 1),
45 };
46
48 static const u32 FLAME_MARGIN_WIDTH;
50 static const u32 FLAME_MARGIN_HEIGHT;
52 static const u32 REGION_HEIGHT;
53
55 //-----------------------------------------------------------
57 //-----------------------------------------------------------
59public:
61 GxGuiProperty(void);
63 GxGuiProperty(const GxProperty& propertyData, GxTypedObject* pOwner, const GxRtti& rtti, u32 index = 0, NAME_TYPE nameType = NAME_TYPE::NONE);
64
66 b32 initialize( void ) override;
67
69 s32 release( void ) override;
70
72 //-----------------------------------------------------------
74 //-----------------------------------------------------------
76
78 void update( void ) override;
79
81 void updateName(void);
82
83public:
85 GxSize getUseRegionSize(void) const override;
86
87protected:
89 void onSize(const GxSize& size) override;
90
92 void onNoClientDraw(void) override;
93
95 void onNoClientMouseDown(const GxPoint2& position, u32 button) override;
96
98 void onNoClientMouseUp(const GxPoint2& position, u32 button) override;
99
101 GxRect calculateClientRect(const GxRect& clientRect) const override;
102
104 void onKeyDown(GxKeyboard::KEY key) override;
105
107 //-----------------------------------------------------------
109 //-----------------------------------------------------------
111public:
114 constexpr void setNameType( NAME_TYPE nameType ){ _nameType = nameType; }
115
118 constexpr NAME_TYPE getNameType( void ) const { return _nameType; }
119
122 GX_FORCE_INLINE const GxProperty& getProperty(void) const { return _property; }
123
126 GX_FORCE_INLINE GxProperty& getProperty(void){ return _property; }
127
129 GX_FORCE_INLINE void setProperty( GxProperty* pProperty ) { _property = *pProperty; }
130
133 constexpr GxTypedObject* getOwner( void ) const { return _pOwner; }
134
137 GX_FORCE_INLINE const GxRtti* getOwnerRtti(void) const { return _pOwnerRtti; }
138
141 constexpr u32 getIndex( void ) const { return _index; }
142
145 template<typename T> void getPropertyValue( T& value ) const
146 {
147 _property.getValue( _pOwner,value,_index );
148 }
149
152 template<typename T> void setPropertyValue( const T& value )
153 {
154 // 初めてHistoryリストに自身を載せる場合、undoで値を戻せるように変更前の値を登録
155 if( !isAttribute ( GxGuiBase::ATTRIBUTE_DISABLE )
156 && !isAttribute ( GxGuiBase::ATTRIBUTE_READONLY )
157 && !getGxGuiSystem()->isExistHistoryParam(this) )
158 {
159 getGxGuiSystem()->addHistoryParam(this);
160 }
161
162 _property.setValue( _pOwner, value, _index );
163 // 値の変更を親のプロパティに伝搬
164 auto* parent = getParent();
165 if(parent)
166 {
167 parent->setPropertyValueFromChild();
168 }
169
170 // Historyリストに現在の値を登録
171 if( !isAttribute ( GxGuiBase::ATTRIBUTE_DISABLE )
172 && !isAttribute ( GxGuiBase::ATTRIBUTE_READONLY ) )
173 {
174 getGxGuiSystem()->addHistoryParam(this);
175 }
176 getGxGuiSystem()->onSetPropertyValue(this);
177 }
178
181 GX_FORCE_INLINE const GxRect& getNameRect( void ) const { return _nameRect; }
182
185 void setNameRect( const GxRect& nameRect );
186
189 constexpr void setNameWidth( s32 width ){ _nameWidth = width; _nameWidthRate = 0; }
190
193 constexpr void setNameWidthRate( f32 rate ){ _nameWidthRate = rate; _nameWidth = 0; }
194
196 b32 isPropertyAttribute( GUI_PROPERTY_ATTRIBUTE attribute ) const;
197
199 void setPropertyAttribute( GUI_PROPERTY_ATTRIBUTE attribute, b32 on );
200
203 GX_FORCE_INLINE b32 isMouseDownOnName(void) const { return _mouseDownOnName; }
204
206 GX_FORCE_INLINE void setDefaultValueIcon( b32 flag ) { _defaultValueIconFlag = flag; }
207
208protected:
210 GX_FORCE_INLINE virtual b32 isDefaultValue(void) { return true; }
211
213 template<typename T> b32 isDefaultValueSub(void)
214 {
215 const auto* pDefaultObject = const_cast<GxRtti*>(getOwnerRtti())->getDefaultObject(_pOwner);
216 if (pDefaultObject)
217 {
218 T value;
219 getPropertyValue(value);
220 T defaultValue;
221 getProperty().getValue(pDefaultObject, defaultValue, getIndex());
222 return value == defaultValue;
223 }
224 return true;
225 }
226
228 template<> b32 isDefaultValueSub<GX_CSTR>(void)
229 {
230 const auto* pDefaultObject = const_cast<GxRtti*>(getOwnerRtti())->getDefaultObject(_pOwner);
231 if (pDefaultObject)
232 {
233 GX_CSTR value;
234 getPropertyValue(value);
235 GX_CSTR defaultValue;
236 getProperty().getValue(pDefaultObject, defaultValue, getIndex());
237 return GX_STRCMP(value, defaultValue) == 0;
238 }
239 return true;
240 }
241
243 template<> b32 isDefaultValueSub<GxString*>(void)
244 {
245 const auto* pDefaultObject = const_cast<GxRtti*>(getOwnerRtti())->getDefaultObject(_pOwner);
246 if (pDefaultObject)
247 {
248 GxString* pValue;
249 getProperty().getValue(getOwner(), pValue, getIndex());
250 GxString* pDefaultValue;
251 getProperty().getValue(pDefaultObject, pDefaultValue, getIndex());
252 return *pValue == *pDefaultValue;
253 }
254 return true;
255 }
256
258 virtual void setDefaultValue( void ){}
259
261 template<typename T> void setDefaultValueSub( void )
262 {
263 const auto* pDefaultObject = const_cast<GxRtti*>(getOwnerRtti())->getDefaultObject(_pOwner);
264 if( pDefaultObject )
265 {
266 T defaultValue;
267 getProperty().getValue( pDefaultObject, defaultValue, getIndex() );
268 setPropertyValue( defaultValue );
269 }
270 }
271
273 //-----------------------------------------------------------
275 //-----------------------------------------------------------
277private:
278 GxProperty _property;
279 GxTypedObject* _pOwner;
280 const GxRtti* _pOwnerRtti;
281 u32 _index;
282
283 b32 _mouseDownOnName;
284 u32 _guiPropertyAttribute;
285
286 NAME_TYPE _nameType;
287 GxRect _nameRect;
288
289 GxString _displayName;
290 GxString _clipDisplayName;
291 GxSize _clipDisplayNameSize;
292
293 s32 _nameWidth;
294 f32 _nameWidthRate;
295
296 GxRect _defaultValueIconRect;
297 f32 _defaultValueIconFlag;
298
300};
301
302GX_CORE_NAMESPACE_END()
303
304#endif // GX_DEVELOP
#define GX_PROHIBIT_CLASS_BASE_REFERENCE(__CLASS__)
GxClassBaseReference継承の禁止宣言(new以外の生成禁止 + コピー禁止)
Definition GxBase.h:244
void GxTypedObject
その他
Definition GxDefine.h:213
@ NONE
何もしない
#define GX_STRCMP(__STRING0__, __STRING1__)
文字列比較
Definition GxString.h:616
プロパティクラス
Definition GxProperty.h:48
実行時型情報クラス
Definition GxRtti.h:154
座標
Definition GxStruct.h:867
矩形
Definition GxStruct.h:951
サイズ
Definition GxStruct.h:730
文字列型クラス
Definition GxString.h:18
32bitブーリアン
Definition GxDefine.h:173