OROCHI
 
Loading...
Searching...
No Matches
GxGuiBase.h
Go to the documentation of this file.
1//===========================================================================
10//===========================================================================
11#pragma once
12
13#if GX_DEVELOP
14
15GX_CORE_NAMESPACE_BEGIN()
16class GxGuiWindow;
17
18//===========================================================================
20//===========================================================================
21class GxGuiBase : public GxClassBaseReference
22{
23 //-----------------------------------------------------------
25 //-----------------------------------------------------------
27public:
28 GX_RTTI_CLASS(GxGuiBase, GxClassBaseReference)
29 // GxClassBaseReference継承クラス用禁止宣言
31 // new, delete定義
32 GX_OPERATOR_NEW_DELETE(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP)
33
34
35 enum ATTRIBUTE
36 {
37 //---- 属性
38 ATTRIBUTE_SHOW = (1 << 0),
39 ATTRIBUTE_DISABLE = (1 << 1),
40
41 ATTRIBUTE_CLIP_PARENT_CLIANT = (1 << 3),
42 ATTRIBUTE_CLIP_PARENT_WINDOW = (1 << 4),
43 ATTRIBUTE_FOLLOW_PARENT = (1 << 5),
44 ATTRIBUTE_SELECTED_FOREGROUND = (1 << 6),
45
46 //---- 状態
47 ATTRIBUTE_ACTIVE = (1 << 12),
48 ATTRIBUTE_CAPTURED = (1 << 13),
49 ATTRIBUTE_CURSOR_IN = (1 << 14),
50 ATTRIBUTE_READONLY = (1 << 15),
51 ATTRIBUTE_READONLY_INIT = (1 << 16),
52 };
53
54private:
56 static constexpr s32 HOVER_EVENT_DELAY = 30;
57
59 enum class STATUS
60 {
61 CREATE,
62 EXIST,
63 DELETE_,
64 INVALID
65 };
66
68 //----------------------------------------
70 //----------------------------------------
72public:
74 GxGuiBase(void);
76 GxGuiBase( const GxRect& rect );
78 s32 release( void ) override;
79
81 //----------------------------------------
83 //----------------------------------------
85public:
87 virtual b32 initialize( void );
89 static GxGuiBase* createGui(GxProperty& property, GxTypedObject* pOwner, const GxRtti& rtti, u32 index = 0);
91 virtual void setRegion(const GxRect& rect, b32 force = false );
93 GX_FORCE_INLINE void updateRegion( void ){ setRegion(_region, true); }
95 void setPosition(const GxPoint2& position);
97 void setSize(const GxSize& size);
99 void setFocus( b32 focus = true );
101 void add(GxGuiBase* pGui );
103 void remove(void);
105 void removeChild( GxGuiBase* pChild );
107 virtual b32 close(void);
109 GX_FORCE_INLINE virtual void closeChild( void ){ closeChildFromRelease(); }
111 void closeChildFromRelease( void );
112
114 void messageUpdate( void );
115
116 // 子Gui更新
117 void updateGuiChild( void );
118
120 void updateMouse( void );
121
123 void updateKey( void );
124
125protected:
127 GX_FORCE_INLINE virtual void update( void ){}
128
130 GX_FORCE_INLINE virtual void postUpdate( void ){}
131
133 void updateWindowRect( void );
134
135public:
137 void messageDraw( const GxRect& clipRect );
138
140 void drawGrid( void );
141
143 void drawCursor( void );
144
146 void messageScreenRender( void );
147
148protected:
150 virtual void onDraw( void );
151
153 GX_FORCE_INLINE virtual void onNoClientDraw( void ){}
154
156 void onDrawChild( void );
157
159 GX_FORCE_INLINE virtual void preDraw( void ){}
160
162 GX_FORCE_INLINE virtual void postDraw( void ){}
163
165 GX_FORCE_INLINE virtual void screenRender( void ){};
166
167public:
170 GX_FORCE_INLINE virtual GxPoint2 getScrollOffset( void ) const { return GxPoint2::ZERO; }
171
174 GX_FORCE_INLINE virtual void onFocus( b32 focus ){}
175
177 virtual void onDropFile( GX_CSTR pFilePath );
178
180 virtual void onDropUnit( GxUnitBase* pUnit );
181
183 GX_FORCE_INLINE virtual void onDragMouseUp(u32 /*button*/) {};
184
186 GX_FORCE_INLINE virtual GxGuiGraphics::MOUSE_CURSOR getMouseCursor( void ){ return GxGuiGraphics::MOUSE_CURSOR::ARROW; }
187
188protected:
191 GX_FORCE_INLINE virtual void onActive( b32 /*active*/ ){}
192
194 GX_FORCE_INLINE virtual void onCreate( void ){}
195
197 GX_FORCE_INLINE virtual void onDestroy( void ){}
198
200 virtual void onAttach( void );
201
203 GX_FORCE_INLINE virtual void onDetach( void ){}
204
207 GX_FORCE_INLINE virtual void onAddGui( GxGuiBase* /*pGui*/ ){}
208
211 GX_FORCE_INLINE virtual void onRemoveGui( GxGuiBase* /*pGui*/ ){};
212
215 GX_FORCE_INLINE virtual void onSize( const GxSize& /*size*/ ){}
216
220 GX_FORCE_INLINE virtual GxRect calculateClientRect( const GxRect& clientRect ) const { return clientRect; }
221
224 GX_FORCE_INLINE virtual void onKeyDown( GxKeyboard::KEY key ){ onKeyDownParent(key); }
225
228 GX_FORCE_INLINE virtual void onKeyPress( GxKeyboard::KEY key ){ onKeyPressParent(key); }
229
232 GX_FORCE_INLINE virtual void onKeyUp( GxKeyboard::KEY key ){ onKeyUpParent(key); }
233
237 GX_FORCE_INLINE virtual void onClick( const GxPoint2& /*position*/, u32 /*button*/ ){ onClickParent(); }
238
242 GX_FORCE_INLINE virtual void onNoClientClick( const GxPoint2& /*position*/,u32 /*button*/ ){ onClickParent(); }
243
247 GX_FORCE_INLINE virtual void onDoubleClick( const GxPoint2& /*position*/,u32 /*button*/ ){ onDoubleClickParent(); }
248
252 GX_FORCE_INLINE virtual void onNoClientDoubleClick( const GxPoint2& /*position*/,u32 /*button*/ ){ onDoubleClickParent(); }
253
256 GX_FORCE_INLINE virtual void onMouseMove( const GxPoint2& /*position*/ ){ onMouseMoveParent(); }
257
260 GX_FORCE_INLINE virtual void onNoClientMouseMove( const GxPoint2& /*position*/ ){ onMouseMoveParent(); }
261
264 GX_FORCE_INLINE virtual void onMouseHover(const GxPoint2& /*position*/ ){ onMouseHoverParent(); }
265
268 GX_FORCE_INLINE virtual void onNoClientMouseHover(const GxPoint2& /*position*/ ){ onMouseHoverParent(); }
269
273 GX_FORCE_INLINE virtual void onMouseWheel( const GxPoint2& /*position*/,s32 /*rotate*/ ){ onMouseWheelParent(); }
274
278 GX_FORCE_INLINE virtual void onNoClientMouseWheel( const GxPoint2& /*position*/,s32 /*rotate*/ ){ onMouseWheelParent(); }
279
283 GX_FORCE_INLINE virtual void onMouseDown( const GxPoint2& /*position*/,u32 /*button*/ ){ onMouseDownParent(); }
284
288 GX_FORCE_INLINE virtual void onNoClientMouseDown( const GxPoint2& /*position*/,u32 /*button*/ ){ onMouseDownParent(); }
289
291 virtual void onMouseUp(const GxPoint2& position, u32 button);
292
296 GX_FORCE_INLINE virtual void onNoClientMouseUp( const GxPoint2& /*position*/,u32 /*button*/ ){ onMouseUpParent(); }
297
299 GX_FORCE_INLINE virtual void onMouseEnter( void ){}
300
302 GX_FORCE_INLINE virtual void onMouseLeave( void ){}
303
305 void onKeyDownParent( GxKeyboard::KEY key );
306
308 void onKeyPressParent( GxKeyboard::KEY key );
309
311 void onKeyUpParent( GxKeyboard::KEY key );
312
314 void onClickParent( void );
315
317 void onDoubleClickParent( void );
318
320 void onMouseMoveParent( void );
321
323 void onMouseHoverParent( void );
324
326 void onMouseWheelParent( void );
327
329 void onMouseDownParent( void );
330
332 void onMouseUpParent( void );
333
335 b32 isInWindow(const GxPoint2& screenPosition) const;
336
340 GX_FORCE_INLINE b32 isInClient( const GxPoint2& screenPosition ) const { return ( (_clientRegion + _windowRect.getLeftTop()) & _drawRect ).isIncluding(screenPosition); }
341
345 GX_FORCE_INLINE GxPoint2 clientToScreen( const GxPoint2& point ) const { return noClientToScreen( point ) + _clientRegion.getLeftTop(); }
346
350 GX_FORCE_INLINE GxPoint2 screenToClient(const GxPoint2& point ) const { return screenToNoClient( point ) - _clientRegion.getLeftTop(); }
351
355 GX_FORCE_INLINE GxPoint2 noClientToScreen(const GxPoint2& point ) const { return _windowRect.getLeftTop() + point; }
356
360 GX_FORCE_INLINE GxPoint2 screenToNoClient(const GxPoint2& point ) const { return point - _windowRect.getLeftTop(); }
361
365 GX_FORCE_INLINE GxPoint2 noClientToClient( const GxPoint2& point ) const { return point - _clientRegion.getLeftTop(); }
366
370 GX_FORCE_INLINE GxPoint2 clientToNoClient( const GxPoint2& point ) const { return point + _clientRegion.getLeftTop(); }
371
373 GxColor getBackColor( void ) const;
375 GxColor getKeyWord1Color( void ) const;
377 GxColor getKeyWord2Color( void ) const;
378
380 GxGuiBase* getPreviousFocus( void );
381
383 GxGuiBase* getNextFocus( void );
384
385public:
388 GX_FORCE_INLINE virtual GxGuiBase* getBypassPreviousFocus( GxGuiBase* /*pFocus*/ ) { return nullptr; }
389
391 GX_FORCE_INLINE virtual GxGuiBase* getBypassNextFocus( GxGuiBase* /*pFocus*/ ) { return nullptr; }
392
394 GX_FORCE_INLINE virtual void setPropertyValueFromChild( void ) {}
395
397 //----------------------------------------
399 //----------------------------------------
401public:
404 constexpr GxGuiBase* getNext(void) { return _pNext; }
405
408 constexpr GxGuiBase* getNext(void) const { return _pNext; }
409
412 GxGuiBase* getTop(void);
413
416 const GxGuiBase* getTop(void) const;
417
420 GxGuiBase* getTail(void);
421
424 const GxGuiBase* getTail(void) const;
425
428 GX_FORCE_INLINE GxGuiBase* getPrevious(void) { return _pPrevious; }
429
432 constexpr GxGuiBase* getPrevious(void) const { return _pPrevious; }
433
436 GX_FORCE_INLINE GxGuiBase* getParent(void) { return _pParent; }
437
440 constexpr GxGuiBase* getParent(void) const { return _pParent; }
441
443 GxGuiWindow* getParentWindow(b32 isTopWindow = false) const;
444
447 GX_FORCE_INLINE GxGuiBase* getChild(void) { return _pChild; }
448
451 constexpr GxGuiBase* getChild(void) const { return _pChild; }
452
454 b32 isRoot(const GxGuiBase* pGui) const;
455
457 b32 hasChild(const GxGuiBase* pGui) const;
458
460 u32 getChildNum(void) const;
461
464 GX_FORCE_INLINE b32 isEnable(void) const { return ((_status == STATUS::CREATE) || (_status == STATUS::EXIST)); }
465
468 GX_FORCE_INLINE b32 isReadOnly(void)const { return isAttribute(ATTRIBUTE_READONLY); }
469
471 constexpr void setInvalid(void) { _status = STATUS::INVALID; }
472
475 GX_FORCE_INLINE const GxRect& getWindowRect(void) const { return _windowRect; }
476
479 GX_FORCE_INLINE const GxRect& getClientRegion(void) const { return _clientRegion; }
480
483 GX_FORCE_INLINE void setClientRegion(const GxRect& rect) { _clientRegion = rect; }
484
487 GX_FORCE_INLINE const GxRect& getDrawRect(void) const { return _drawRect; }
488
490 void setAttribute(ATTRIBUTE attribute, b32 on);
491
495 GX_FORCE_INLINE b32 isAttribute(ATTRIBUTE attribute) const { return (_attribute & attribute) != 0; }
496
499 GX_FORCE_INLINE const GxRect& getRegion(void) const { return _region; }
500
503 void setActive(b32 active = true);
504
506 void setForeground(void);
507
509 GX_FORCE_INLINE virtual void updateAnimation(void) {}
510
513 GX_FORCE_INLINE b32 isFocused(void) const { return getGxGuiSystem()->getFocus() == this; }
514
517 GX_FORCE_INLINE b32 isActive(void) const { return isAttribute(ATTRIBUTE_ACTIVE); }
518
522 GX_FORCE_INLINE virtual GxSize getClampedRegionSize(const GxSize& size) const { return size; }
523
526 GX_FORCE_INLINE virtual GxSize getUseRegionSize(void) const { return GxSize::ZERO; }
527
529 virtual GxGuiBase* getGui(const GxPoint2& position, const GxRect& clipRect);
530
532 void setModalMode(b32 on);
533
535 //----------------------------------------
537 //----------------------------------------
539private:
540 GxGuiBase* _pNext;
541 GxGuiBase* _pPrevious;
542 GxGuiBase* _pParent;
543 GxGuiBase* _pChild;
544
545 STATUS _status;
546
547 u32 _attribute;
548
549 u32 _clickButton;
550
551 s32 _hoverDelayTimer;
552
553 GxRect _windowRect;
554 GxRect _region;
555 GxRect _clientRegion;
556 GxRect _drawRect;
557
559};
560
562#define GX_UPDATE_GUI_POINTER(__POINTER__) if( (__POINTER__) && (!(__POINTER__)->isEnable()) ) { (__POINTER__) = nullptr; }
563
564GX_CORE_NAMESPACE_END()
565
566#endif // GX_DEVELOP
#define GX_PROHIBIT_CLASS_BASE_REFERENCE(__CLASS__)
GxClassBaseReference継承の禁止宣言(new以外の生成禁止 + コピー禁止)
Definition GxBase.h:244
void GxTypedObject
その他
Definition GxDefine.h:213
@ INVALID
無効なビュー
参照オブジェクト基底クラス
Definition GxBase.h:122
プロパティクラス
Definition GxProperty.h:48
実行時型情報クラス
Definition GxRtti.h:154
ユニット基礎クラス
Definition GxUnitBase.h:45
Definition GxColor.h:21
座標
Definition GxStruct.h:867
static const GxPoint2 ZERO
原点座標
Definition GxStruct.h:876
矩形
Definition GxStruct.h:951
サイズ
Definition GxStruct.h:730
static const GxSize ZERO
0
Definition GxStruct.h:743
32bitブーリアン
Definition GxDefine.h:173