2
0

BsModalWindow.h 2.3 KB

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