BsGUITabButton.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 "BsGUIToggle.h"
  6. #include "BsGUIToggleGroup.h"
  7. #include "BsImageSprite.h"
  8. #include "BsEvent.h"
  9. namespace BansheeEngine
  10. {
  11. /** @cond INTERNAL */
  12. /** @addtogroup GUI-Editor
  13. * @{
  14. */
  15. /**
  16. * Specialization of a GUIToggle element used for displaying tabs in a GUITabbedTitleBar. Aside from being toggleable
  17. * these buttons also track drag and drop operations.
  18. */
  19. class GUITabButton : public GUIToggle
  20. {
  21. public:
  22. /** Returns type name of the GUI element used for finding GUI element styles. */
  23. static const String& getGUITypeName();
  24. /**
  25. * Creates a new GUI tab button element.
  26. *
  27. * @param[in] toggleGroup A toggle group that forms a link between related tab buttons.
  28. * @param[in] index Unique index that can be used for identifying a tab.
  29. * @param[in] text Label to display in the button.
  30. * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
  31. * GUIWidget the element is used on. If not specified default style is used.
  32. */
  33. static GUITabButton* create(const GUIToggleGroupPtr& toggleGroup, UINT32 index, const HString& text,
  34. const String& styleName = StringUtil::BLANK);
  35. /**
  36. * Creates a new GUI tab button element.
  37. *
  38. * @param[in] toggleGroup A toggle group that forms a link between related tab buttons.
  39. * @param[in] index Unique index that can be used for identifying a tab.
  40. * @param[in] text Label to display in the button.
  41. * @param[in] options Options that allow you to control how is the element positioned and sized.
  42. * This will override any similar options set by style.
  43. * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
  44. * GUIWidget the element is used on. If not specified default style is used.
  45. */
  46. static GUITabButton* create(const GUIToggleGroupPtr& toggleGroup, UINT32 index, const HString& text,
  47. const GUIOptions& options, const String& styleName = StringUtil::BLANK);
  48. /**
  49. * Creates a new GUI tab button element.
  50. *
  51. * @param[in] toggleGroup A toggle group that forms a link between related tab buttons.
  52. * @param[in] index Unique index that can be used for identifying a tab.
  53. * @param[in] content Content to display in the button.
  54. * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
  55. * GUIWidget the element is used on. If not specified default style is used.
  56. */
  57. static GUITabButton* create(const GUIToggleGroupPtr& toggleGroup, UINT32 index, const GUIContent& content,
  58. const String& styleName = StringUtil::BLANK);
  59. /**
  60. * Creates a new GUI tab button element.
  61. *
  62. * @param[in] toggleGroup A toggle group that forms a link between related tab buttons.
  63. * @param[in] index Unique index that can be used for identifying a tab.
  64. * @param[in] content Content to display in the button.
  65. * @param[in] options Options that allow you to control how is the element positioned and sized.
  66. * This will override any similar options set by style.
  67. * @param[in] styleName Optional style to use for the element. Style will be retrieved from GUISkin of the
  68. * GUIWidget the element is used on. If not specified default style is used.
  69. */
  70. static GUITabButton* create(const GUIToggleGroupPtr& toggleGroup, UINT32 index, const GUIContent& content,
  71. const GUIOptions& options, const String& styleName = StringUtil::BLANK);
  72. /** Returns the unique index for this tab button. */
  73. UINT32 getIndex() const { return mIndex; }
  74. /** @copydoc GUIToggle::toggleOn */
  75. void toggleOn() override;
  76. /** @copydoc GUIToggle::toggleOff */
  77. void toggleOff() override;
  78. /** Changes the button state to dragged or not dragged, resulting primarily in a visual change. */
  79. void _setDraggedState(bool active);
  80. /**
  81. * Triggered when the user starts dragging the tab button. Reported parameters are the unique index of the tab and
  82. * pointer position relative to parent GUIWidget.
  83. */
  84. Event<void(UINT32, const Vector2I&)> onDragged;
  85. /**
  86. * Triggered when the user ends dragging the tab button. Reported parameters are the unique index of the tab and
  87. * pointer position relative to parent GUIWidget.
  88. */
  89. Event<void(UINT32, const Vector2I&)> onDragEnd;
  90. protected:
  91. GUITabButton(const String& styleName, const GUIToggleGroupPtr& toggleGroup, UINT32 index, const GUIContent& content, const GUIDimensions& dimensions);
  92. /** @copydoc GUIElement::_mouseEvent */
  93. virtual bool _mouseEvent(const GUIMouseEvent& ev) override;
  94. UINT32 mIndex;
  95. Vector2I mDragStartPosition;
  96. bool mDraggedState;
  97. GUIElementState mInactiveState;
  98. static const UINT32 DRAG_MIN_DISTANCE;
  99. };
  100. /** @} */
  101. /** @endcond */
  102. }