2
0

BsModalWindow.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsEditorWindowBase.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Base implementation of a window that when open doesn't allow you
  8. * to interact with other windows. Modal windows are similar to editor
  9. * windows but cannot be docked, and are meant to be used for temporary
  10. * operations like dialog boxes and progress bars.
  11. */
  12. class BS_ED_EXPORT ModalWindow : public EditorWindowBase
  13. {
  14. public:
  15. virtual ~ModalWindow();
  16. /**
  17. * @copydoc EditorWindowBase::update
  18. */
  19. virtual void update() override;
  20. /**
  21. * @copydoc EditorWindowBase::close
  22. */
  23. virtual void close() override;
  24. /**
  25. * @brief Changes the text in the modal window title bar.
  26. */
  27. void setTitle(const HString& title);
  28. /**
  29. * Converts screen pointer coordinates into coordinates relative to the window content's GUI panel.
  30. */
  31. Vector2I screenToWindowPos(const Vector2I& screenPos) const;
  32. /**
  33. * Converts pointer coordinates relative to the window content's GUI panel into screen coordinates.
  34. */
  35. Vector2I windowToScreenPos(const Vector2I& windowPos) const;
  36. protected:
  37. friend class EditorWindowManager;
  38. ModalWindow(const HString& title, bool hasCloseButton = false);
  39. /**
  40. * @brief Returns the area in which the GUI contents are displayed (i.e. not including
  41. * title bar and other default elements). Area is relative to window.
  42. */
  43. Rect2I getContentArea() const;
  44. /**
  45. * @copydoc EditorWindowBase::resized
  46. */
  47. virtual void resized() override;
  48. private:
  49. /**
  50. * @brief Updates the placement of child GUI elements and their non-client
  51. * areas (used for OS move/resize operations). Should be called after
  52. * window size changes.
  53. */
  54. void updateSize();
  55. /**
  56. * @brief Returns the height in pixels taken up by the title bar.
  57. */
  58. UINT32 getTitleBarHeight() const;
  59. GUIPanel* mTitleBarPanel;
  60. GUIPanel* mTitleBarBgPanel;
  61. GUILabel* mTitle;
  62. GUIButton* mCloseButton;
  63. GUITexture* mTitleBarBg;
  64. protected:
  65. GUIPanel* mContents;
  66. };
  67. }