BsModalWindow.h 2.2 KB

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