OROCHI
 
Loading...
Searching...
No Matches
GxGuiWindow.h
Go to the documentation of this file.
1//===========================================================================
10//===========================================================================
11#pragma once
12
13#if GX_DEVELOP
14
15GX_CORE_NAMESPACE_BEGIN()
16class GxGuiMenu;
17class GxGuiHover;
18
19//===========================================================================
25//===========================================================================
26#if defined(_WINDOWS)
27class GxGuiWindow : public GxGuiBase, public GxRenderNotifier
28#else //_WINDOWS
29class GxGuiWindow : public GxGuiBase
30#endif // !_WINDOWS
31{
32 //-----------------------------------------------------------
34 //-----------------------------------------------------------
36public:
37 GX_RTTI_CLASS_ICON(GxGuiWindow, GxGuiBase, GxRtti::ICON_TYPE::OROCHI)
38 // GxClassBaseReference継承クラス用禁止宣言
40
41
42 enum class FAIRING_MODE
43 {
44 NORMAL = 0,
45 MIN,
46 MAX,
47 };
48
50 enum class DOCKING_MODE
51 {
52 OFF = -1,
53 LEFT = 0,
54 RIGHT,
55 TOP,
56 BOTTOM,
57 CENTER,
58 MAX,
59 };
60
61protected:
63 enum class CONTROL_MODE
64 {
65 OFF = 0,
66 SIZE_LEFT,
67 SIZE_TOP,
68 SIZE_RIGHT,
69 SIZE_BOTTOM,
70 SIZE_LEFTTOP,
71 SIZE_RIGHTTOP,
72 SIZE_LEFTBOTTOM,
73 SIZE_RIGHTBOTTOM,
74 TRANSLATE,
75
76 CLOSE,
77 SIZEMIN,
78 SIZEMAX,
79 MAX
80 };
81
82 class GxWindowButton;
83 class GxMenuBar;
84 class GxViewBar;
85
86private:
88 static constexpr u32 CAPTION_SIZE_Y = 16;
90 static constexpr u32 WINDOW_FRAME = 4;
92 static constexpr u32 CAPTION_MARGIN_TOP = 0;
94 static constexpr u32 CAPTION_MARGIN_SIDE = 4;
96 static constexpr u32 CAPTION_MARGIN_BOTTOM = 2;
98 static constexpr u32 BUTTON_SIZE = CAPTION_SIZE_Y - CAPTION_MARGIN_TOP - CAPTION_MARGIN_BOTTOM;
100 static constexpr u32 BUTTON_MARGIN_SIDE = 2;
101
103 enum class HIT
104 {
105 NONE = 0,
106
107 CLIENT,
108
109 // GxGuiWindowが使用
110 CAPTION,
111 LEFT,
112 TOP,
113 RIGHT,
114 BOTTOM,
115 LEFTTOP,
116 RIGHTTOP,
117 LEFTBOTTOM,
118 RIGHTBOTTOM,
119 CLOSE,
120 SIZEMAX,
121 SIZEMIN,
122
123 MAX
124 };
125
127 enum class BAR_TYPE
128 {
129 MENU,
130 VIEW,
131 MAX
132 };
133
135 //-----------------------------------------------------------
137 //-----------------------------------------------------------
139public:
141 GxGuiWindow(void);
143 GxGuiWindow( b32 useCloseWindowButton, b32 useMinWindowButton, b32 useMaxWindowButton, b32 useCaption = true, b32 isOutsideWindow = false);
144
145private:
146#if GX_EDITOR
148 void resetWindow(void);
149#endif //GX_EDITOR
150
152 //-----------------------------------------------------------
154 //-----------------------------------------------------------
156public:
158 b32 initialize( void ) override;
159
161 void update( void ) override;
162
163 // 解放
164 void cleanup( void ) override;
165
167 void closeChild( void ) override;
168
170 void onNoClientDraw( void ) override;
171
172#if GX_EDITOR
174 void setRegion(const GxRect& rect, b32 force = false ) override;
176 b32 onResetDevice(void) override;
178 void preDraw( void ) override;
180 void postDraw( void ) override;
181#endif //GX_EDITOR
182
184 void screenRender( void ) override;
185
187 void setCaptionName( GX_CSTR pName );
190 GX_FORCE_INLINE void setCaptionName( const GxString& name ){ setCaptionName( name.getString() ); }
191
194 GX_FORCE_INLINE const GxString& getCaptionName( void ) const { return _captionName; }
195
197 b32 createMenuBar( const GxPropertyTable& propertyTable );
198
200 void clearMenuBar(void);
201
203 b32 createViewBar( const GxPropertyTable& propertyTable, GxResTexture* pResIconTexture, const GxVector2& iconTextureSize, const GxVector2& iconTextureStartUV );
204
206 void clearViewBar(void);
207
209 void setPopupMenu(GxGuiMenu* pGuiMenu);
210
212 void setPopupHover(const GxPoint2& position, GX_CSTR message, const GxGuiBase* pOwner, b32 useAdjust = true);
213private:
215 void closeHover(void);
216public:
218 void setFairingMode( FAIRING_MODE mode );
219
221 void maximize( void );
222
224 void minimize( void );
225
227 void normalize( void );
228
230 GX_FORCE_INLINE virtual GxSize getDefaultWindowSize(void) const { return GxSize(400, 300); }
231
233 GxSize getClampedRegionSize( const GxSize& requestSize ) const override;
234
236 void onSize(const GxSize& size) override;
237
239 GX_FORCE_INLINE virtual void closeAll(void) { eventClose(); }
241 void eventClose(void);
242
244 GxRect calculateClientRect( const GxRect& clientRect ) const override;
245
247 void setPositionInScreen(const GxSize& screenSize);
248private:
250 void controlWindowOnMouseDown(const GxPoint2& position, u32 button);
251
253 GxRect calcFairingRect(FAIRING_MODE mode) const;
254
256 HIT getMouseHitTest(const GxPoint2& point);
257
259 void updateCaption(void);
260
261#if GX_EDITOR
263 static LRESULT CALLBACK wndProc(HWND windowHandle, UINT uMessage, WPARAM wParam, LPARAM lParam);
264#endif //GX_EDITOR
265
266protected:
268 virtual void controlWindow(void);
269
271 void eventMin(void);
272
274 void eventMax(void);
275
277 GxGuiGraphics::MOUSE_CURSOR getMouseCursor(void) override;
278
280 GX_FORCE_INLINE void onMouseDown(const GxPoint2& /*position*/, u32 /*button*/) override {};
281
283 void onNoClientMouseDown(const GxPoint2& position, u32 button) override;
284
286 void onMouseUp(const GxPoint2& position, u32 button) override;
287
289 void onNoClientDoubleClick(const GxPoint2& position, u32 button) override;
290
292 void onActive(b32 active) override;
293
295 void onMouseLeave(void) override;
296
298 static GxRect calcDockingRect(const GxRect& windowRect, DOCKING_MODE mode);
301 GX_FORCE_INLINE virtual DOCKING_MODE getDockingModeFromGuide(void) const { return DOCKING_MODE::OFF; }
302
303#if GX_EDITOR
305 void createOutsideWindow(void);
307 void releaseOutsideWindow(void);
308#endif //GX_EDITOR
309
311 //-----------------------------------------------------------
313 //-----------------------------------------------------------
315public:
318 constexpr void setIconHandle( GX_HANDLE handle ){ _iconHandle = handle; }
319
322 GX_FORCE_INLINE b32 isSendClientRectToChildGuiFormRegion( void ) const { return _isSendClientRectToChildGuiFormRegion; }
323
326 GX_FORCE_INLINE void setSendClientRectToChildGuiFormRegion( b32 isSendClientRectToChildGuiFormRegion ){ _isSendClientRectToChildGuiFormRegion = isSendClientRectToChildGuiFormRegion; }
327
329 GX_FORCE_INLINE b32 isFairingMode(FAIRING_MODE mode) const { return _fairingMode == mode; }
330
332 GX_FORCE_INLINE virtual b32 isNormalWindow( void ) const { return isFairingMode(FAIRING_MODE::NORMAL); }
333
335 GX_FORCE_INLINE const GxRect& getNormalRect( void ) const { return _normalRect; }
336
338 GX_FORCE_INLINE void setNormalRect( const GxRect& normalRect ) { _normalRect = normalRect; }
339
341 GX_FORCE_INLINE b32 isMovable(void) const { return _isMovable; }
343 GX_FORCE_INLINE void setMovable(b32 enable) { _isMovable = enable; }
345 GX_FORCE_INLINE b32 isClosable(void) const { return _isClosable; }
347 GX_FORCE_INLINE void setClosable(b32 enable) { _isClosable = enable; }
349 void setVisible(b32 enable);
350
352 b32 isDocking(void) const;
354 b32 isDockingEnable(void) const;
355
356#if GX_EDITOR
358 constexpr HWND getWindowHandle(void) const { return _hwnd; }
360 GX_FORCE_INLINE b32 isActiveWindow(void) const { return GetActiveWindow() == _hwnd; }
362 b32 isOnMouseWindowHandle(HWND hwnd) const;
364#if GX_USE_DX11
365 GX_FORCE_INLINE GxRenderTexture* getRenderTexture(void) const { return _pRenderTexture; }
366#elif GX_USE_DX12
367 GX_FORCE_INLINE GxRenderTexture* getRenderTexture(void) const { return _pRenderTexture[getGxRenderDevice()->getWriteBuffer()]; }
368#endif //GX_USE_DX12
369#endif //GX_EDITOR
370
372 GX_FORCE_INLINE b32 isControlMode(CONTROL_MODE mode) const { return _controlMode == mode; }
373
374#if GX_EDITOR
376 GX_FORCE_INLINE b32 isOutsideWindow(void) const { return _isOutsideWindow; }
377#endif //GX_EDITOR
379 constexpr GxGuiButton* getCloseButton(void) const { return _pCloseButton; }
381 GX_FORCE_INLINE b32 isEnableClose(void) const { return _useCloseWindowButton; }
383 GX_FORCE_INLINE b32 isEnableMin(void) const { return _useMinWindowButton; }
385 GX_FORCE_INLINE b32 isEnableMax(void) const { return _useMaxWindowButton; }
386private:
388 constexpr u32 getCaptionSizeY(void) const { return _useCaption ? CAPTION_SIZE_Y : 0; }
390 GX_FORCE_INLINE u32 getWindowFrameSize(void) const { return isDocking() ? 0 : WINDOW_FRAME; }
391
393 //-----------------------------------------------------------
395 //-----------------------------------------------------------
397protected:
398 GxGuiButton* _pMinButton;
399 GxGuiButton* _pMaxButton;
400 GxGuiButton* _pCloseButton;
401 GxMenuBar* _pBar[static_cast<int>(BAR_TYPE::MAX)];
402
403 b32 _isSendClientRectToChildGuiFormRegion;
404
405 b32 _isMovable;
406 b32 _isClosable;
407 b32 _useCloseWindowButton;
408 b32 _useMinWindowButton;
409 b32 _useMaxWindowButton;
410 b32 _useCaption;
411
412 FAIRING_MODE _fairingMode;
413
414 GxString _captionName;
415 GxString _clipCaptionName;
416
417 GxRect _normalRect;
418
419 CONTROL_MODE _controlMode;
420 GxPoint2 _clickOffset;
421
422 GxRect _nameRect;
423
424 GX_HANDLE _iconHandle;
425
426 s32 _minIndex;
427
428#if GX_EDITOR
429 b32 _isOutsideWindow;
430 HWND _hwnd;
431 b32 _resetWindowFlag;
432#if GX_USE_DX11
433 GxRenderTexture* _pRenderTexture;
434 IDXGISwapChain* _pDXGISwapChain;
435#elif GX_USE_DX12
436 GxRenderTexture* _pRenderTexture[3];
437 IDXGISwapChain3* _pDXGISwapChain;
438#endif GX_USE_DX12
439#endif //GX_EDITOR
440
442};
443
444//===========================================================================
446//===========================================================================
447class GxGuiWindow::GxMenuBar : public GxClassBaseReference
448{
449 //-----------------------------------------------------------
451 //-----------------------------------------------------------
453public:
454 GX_RTTI_CLASS(GxMenuBar, GxClassBaseReference)
455 // GxClassBaseReference継承クラス用禁止宣言
457 // new, delete定義
458 GX_OPERATOR_NEW_DELETE(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP)
459
460 struct GxItem;
461
463 static const s32 MENU_MARGIN_SIZE_LEFT;
465 static const s32 MENU_MARGIN_SIZE_RIGHT;
467 static const s32 MENU_MARGIN_SIZE_TOP;
469 static const s32 MENU_MARGIN_SIZE_BOTTOM;
471 static const s32 MENU_MARGIN_SIZE_WIDTH;
473 static const s32 MENU_MARGIN_SIZE_HEIGHT;
474
476 //-----------------------------------------------------------
478 //-----------------------------------------------------------
480public:
482 GxMenuBar(void);
483
485 GxMenuBar(GxGuiWindow* pOwner);
486
488 void cleanup( void ) override;
489
491 //-----------------------------------------------------------
493 //-----------------------------------------------------------
495public:
497 void setPropertyTable( const GxPropertyTable& propertyTable );
498
500 GxSize getUseSize( void );
501
503 constexpr u32 getItemNum( void ) const { return _itemNum; }
504
506 const GxItem* getItem( u32 index ) const;
507
509 virtual void updateItemTable( const GxRect& menuRect );
510
511private:
513 virtual GxSize getItemSize( GxProperty& property );
514
515public:
517 void onMouseMove(const GxPoint2& posotion, u32 button);
518
520 void onMouseDown(const GxPoint2& position, u32 button);
521
523 //-----------------------------------------------------------
525 //-----------------------------------------------------------
527public:
529 b32 isOpen( void ) const;
531 void openSubMenu( s32 index );
533 void closeSubMenu( void );
534private:
536 s32 getItemIndex(const GxPoint2& position);
537
539 //-----------------------------------------------------------
541 //-----------------------------------------------------------
543public:
544 GxGuiWindow* _pOwner;
545
546 s32 _selectedIndex;
547 GxPropertyTable _propertyTable;
548
549 u32 _itemNum;
550 GxItem* _pItemTable;
551 GxGuiMenu* _pGuiMenu;
552
554};
555
556//-----------------------------------------------------------
558//-----------------------------------------------------------
559struct GxGuiWindow::GxMenuBar::GxItem : public GxStructBase
560{
561 //-----------------------------------------------------------
563 //-----------------------------------------------------------
565public:
566 GX_RTTI_STRUCT(GxItem)
567
568 // new, delete定義
569 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP)
570
571
572 //-----------------------------------------------------------
574 //-----------------------------------------------------------
576public:
577 GxRect _selectRegion;
578 u32 _depth;
579
581};
582
583//===========================================================================
585//===========================================================================
586class GxGuiWindow::GxViewBar : public GxGuiWindow::GxMenuBar
587{
588 //-----------------------------------------------------------
590 //-----------------------------------------------------------
592public:
593 GX_RTTI_CLASS(GxGuiWindow::GxViewBar, GxGuiWindow::GxMenuBar)
594 // GxClassBaseReference継承クラス用禁止宣言
596 // new, delete定義
597 GX_OPERATOR_NEW_DELETE(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP)
598
599
600 static const s32 VIEW_ICON_WIDTH;
602 static const s32 VIEW_ICON_HEIGHT;
603
605 //-----------------------------------------------------------
607 //-----------------------------------------------------------
609public:
611 GxViewBar(void);
613 GxViewBar(GxGuiWindow* pOwner);
615 void cleanup( void ) override;
616
618 //-----------------------------------------------------------
620 //-----------------------------------------------------------
622private:
624 GxSize getItemSize( GxProperty& property ) override;
625
626public:
628 GX_FORCE_INLINE void setIconTexture( GxResTexture* pResIconTexture, const GxVector2& iconTextureSize, const GxVector2& iconTextureStartUV ){ GX_SET_CLASS_BASE_REFERENCE( _pResIconTexture , pResIconTexture ); _iconTextureSize = iconTextureSize; _iconTextureStartUV = iconTextureStartUV; }
630 constexpr GxResTexture* getIconTexture( void ) const { return _pResIconTexture; }
632 GX_FORCE_INLINE GxVector2 getIconTextureSize( void ) const { return _iconTextureSize; }
634 GX_FORCE_INLINE GxVector2 getIconTextureStartUV( void ) const { return _iconTextureStartUV; }
635
637 //-----------------------------------------------------------
639 //-----------------------------------------------------------
641private:
642 GxResTexture* _pResIconTexture;
643 GxVector2 _iconTextureSize;
644 GxVector2 _iconTextureStartUV;
645
647};
648
649GX_CORE_NAMESPACE_END()
650
651#endif // GX_DEVELOP
#define GX_PROHIBIT_CLASS_BASE_REFERENCE(__CLASS__)
GxClassBaseReference継承の禁止宣言(new以外の生成禁止 + コピー禁止)
Definition GxBase.h:244
#define GX_SET_CLASS_BASE_REFERENCE(__DST__, __SRC__)
オブジェクト設定(参照カウンタを使用する場合)
Definition GxBase.h:318
@ MAX
定義数
u32 GX_HANDLE
ハンドル
Definition GxDefine.h:214
@ NONE
何もしない
@ NORMAL
法線(VS入力,VS→PS)
@ MIN
最小値(min(src,dst))
参照オブジェクト基底クラス
Definition GxBase.h:122
virtual void cleanup(void)
delete直前に呼び出される関数
Definition GxBase.cpp:248
プロパティクラス
Definition GxProperty.h:48
プロパティテーブルクラス
Definition GxProperty.h:1641
constexpr u32 getWriteBuffer(void) const
書き込むバッファIndexの取得
Definition GxRenderDevice.h:1032
描画関連のイベントを通知します
Definition GxRenderNotifier.h:22
virtual GX_FORCE_INLINE b32 onResetDevice(void)
デバイスのリセット後に通知
Definition GxRenderNotifier.h:54
テクスチャクラス
Definition GxRenderTexture.h:19
テクスチャリソース
Definition GxResTexture.h:23
座標
Definition GxStruct.h:867
矩形
Definition GxStruct.h:951
サイズ
Definition GxStruct.h:730
文字列型クラス
Definition GxString.h:18
GX_FORCE_INLINE GX_STR getString(void)
文字列取得
Definition GxString.h:165
Definition GxBase.h:24
2次元ベクトル
Definition GxVector.h:34
32bitブーリアン
Definition GxDefine.h:173