BsCGUIWidget.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsPrerequisites.h"
  5. #include "Scene/BsComponent.h"
  6. #include "Math/BsRect2I.h"
  7. #include "GUI/BsGUIWidget.h"
  8. namespace bs
  9. {
  10. /** @addtogroup GUI
  11. * @{
  12. */
  13. /** Component wrapper for GUIWidget. */
  14. class BS_EXPORT CGUIWidget : public Component
  15. {
  16. public:
  17. virtual ~CGUIWidget();
  18. /** @copydoc GUIWidget::setSkin */
  19. void setSkin(const HGUISkin& skin);
  20. /** @copydoc GUIWidget::getSkin */
  21. const GUISkin& getSkin() const;
  22. /** @copydoc GUIWidget::getSkinResource */
  23. const HGUISkin& getSkinResource() const;
  24. /** @copydoc GUIWidget::getPanel */
  25. GUIPanel* getPanel() const;
  26. /** @copydoc GUIWidget::getDepth */
  27. UINT8 getDepth() const;
  28. /** @copydoc GUIWidget::setDepth */
  29. void setDepth(UINT8 depth);
  30. /** @copydoc GUIWidget::inBounds */
  31. bool inBounds(const Vector2I& position) const;
  32. /** @copydoc GUIWidget::getBounds */
  33. const Rect2I& getBounds() const;
  34. /** @copydoc GUIWidget::isDirty */
  35. bool isDirty(bool cleanIfDirty);
  36. /** @copydoc GUIWidget::getTarget */
  37. Viewport* getTarget() const;
  38. /** @copydoc GUIWidget::getCamera */
  39. SPtr<Camera> getCamera() const;
  40. /** @copydoc GUIWidget::getElements */
  41. const Vector<GUIElement*>& getElements() const;
  42. public: // ***** INTERNAL ******
  43. /** @name Internal
  44. * @{
  45. */
  46. /** Returns the internal GUIWidget that is wrapped by this component. */
  47. GUIWidget* _getInternal() const { return mInternal.get(); };
  48. /** @} */
  49. protected:
  50. friend class SceneObject;
  51. friend class GUIElementBase;
  52. friend class GUIManager;
  53. /**
  54. * Constructs a new GUI widget attached to the specified parent scene object. Widget elements will be rendered on
  55. * the provided camera.
  56. */
  57. CGUIWidget(const HSceneObject& parent, const SPtr<Camera>& camera);
  58. /**
  59. * Constructs a new GUI widget attached to the specified parent scene object. Widget elements will be rendered on
  60. * the provided camera.
  61. */
  62. CGUIWidget(const HSceneObject& parent, const HCamera& camera);
  63. /** @copydoc Component::update */
  64. void update() override;
  65. /** @copydoc Component::onDestroyed */
  66. void onDestroyed() override;
  67. /** Called when the viewport size changes and widget elements need to be updated. */
  68. virtual void ownerTargetResized() { }
  69. /** Called when the parent window gained or lost focus. */
  70. virtual void ownerWindowFocusChanged() { }
  71. private:
  72. CGUIWidget(const CGUIWidget& other) { }
  73. SPtr<GUIWidget> mInternal;
  74. HEvent mOwnerTargetResizedConn;
  75. HEvent mOwnerWindowFocusChangedConn;
  76. SPtr<Camera> mCamera;
  77. UINT32 mParentHash;
  78. /************************************************************************/
  79. /* RTTI */
  80. /************************************************************************/
  81. public:
  82. friend class CGUIWidgetRTTI;
  83. static RTTITypeBase* getRTTIStatic();
  84. RTTITypeBase* getRTTI() const override;
  85. CGUIWidget(); // Serialization only
  86. };
  87. /** @} */
  88. }