BsEditorWindowBase.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 "Utility/BsEvent.h"
  6. namespace bs
  7. {
  8. /** @addtogroup Implementation
  9. * @{
  10. */
  11. /**
  12. * A base class for all editor window. Each editor window is backed by a render window (for example the OS "window"),
  13. * and also provides a GUI widget for child elements to use. On top of that it also provides basic GUI like window
  14. * background and frame, as well as setting up the OS-specific areas for resize/move operations.
  15. */
  16. class BS_ED_EXPORT EditorWindowBase
  17. {
  18. public:
  19. virtual ~EditorWindowBase();
  20. /** Moves the window on the desktop. Coordinates are in screen space. */
  21. virtual void setPosition(INT32 x, INT32 y);
  22. /** Resizes the window. */
  23. virtual void setSize(UINT32 width, UINT32 height);
  24. /** Returns the X position of the window in screen coordinates. */
  25. INT32 getLeft() const;
  26. /** Returns the X position of the window in screen coordinates. */
  27. INT32 getTop() const;
  28. /** Returns the width of the window in pixels. */
  29. UINT32 getWidth() const;
  30. /** Returns the height of the window in pixels. */
  31. UINT32 getHeight() const;
  32. /** Closes and destroys the window. */
  33. virtual void close();
  34. /** Hides the window without closing it. */
  35. void hide();
  36. /** Return true if this is the main editor window. */
  37. virtual bool isMain() const { return false; }
  38. /** Called once every frame. Internal method. */
  39. virtual void update() { }
  40. /** Returns the render window that this editor window is being rendered to. */
  41. SPtr<RenderWindow> getRenderWindow() const { return mRenderWindow; }
  42. /** Returns the GUI widget used for displaying all GUI contents in the window. */
  43. HGUIWidget getGUIWidget() const { return mGUI; }
  44. /** Returns the camera used for rendering the window GUI contents. */
  45. HCamera getGUICamera() const { return mCamera; }
  46. /** Checks whether the window currently has keyboard focus. */
  47. bool hasFocus() const;
  48. protected:
  49. EditorWindowBase(bool isModal = false, UINT32 width = 200, UINT32 height = 200);
  50. EditorWindowBase(const SPtr<RenderWindow>& renderWindow);
  51. /** Common code for constructing the object to be called from all constructors. */
  52. void construct(const SPtr<RenderWindow>& renderWindow);
  53. /** Initializes elements that cannot be initialized in the constructor. Must be called right after construction. */
  54. virtual void initialize();
  55. /** Callback that triggers whenever the underlying render window changes size. */
  56. virtual void resized() { }
  57. SPtr<RenderWindow> mRenderWindow;
  58. HSceneObject mSceneObject;
  59. HGUIWidget mGUI;
  60. HCamera mCamera;
  61. GameObjectHandle<WindowFrameWidget> mWindowFrame;
  62. bool mOwnsRenderWindow;
  63. bool mIsModal;
  64. private:
  65. HEvent mResizedConn;
  66. };
  67. /** @} */
  68. }