BsGUIComponentFoldout.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsGUIElementContainer.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief GUI element that serves as a title for a Component object. The foldout
  8. * displays a certain label (e.g. component name) and can be expanded or collapsed.
  9. *
  10. * @note It's up to the caller to actually hook up what expanding or collapsing the foldout means,
  11. * internally it just toggles a button.
  12. */
  13. class BS_ED_EXPORT GUIComponentFoldout : public GUIElementContainer
  14. {
  15. struct PrivatelyConstruct {};
  16. public:
  17. /**
  18. * Returns type name of the GUI element used for finding GUI element styles.
  19. */
  20. static const String& getGUITypeName();
  21. /**
  22. * Returns the style type name of the internal toggle button.
  23. */
  24. static const String& getFoldoutButtonStyleType();
  25. /**
  26. * @brief Creates a new GUI component foldout element.
  27. *
  28. * @param label Label to display in the foldout title.
  29. * @param options Options that allow you to control how is the element positioned and sized.
  30. * This will override any similar options set by style.
  31. * @param styleName Optional style to use for the element. Style will be retrieved
  32. * from GUISkin of the GUIWidget the element is used on. If not specified
  33. * default style is used.
  34. */
  35. static GUIComponentFoldout* create(const HString& label, const GUIOptions& options, const String& style = StringUtil::BLANK);
  36. /**
  37. * @brief Creates a new GUI component foldout element.
  38. *
  39. * @param label Label to display in the foldout title.
  40. * @param styleName Optional style to use for the element. Style will be retrieved
  41. * from GUISkin of the GUIWidget the element is used on. If not specified
  42. * default style is used.
  43. */
  44. static GUIComponentFoldout* create(const HString& label, const String& style = StringUtil::BLANK);
  45. GUIComponentFoldout(const PrivatelyConstruct& dummy, const HString& label, const String& style, const GUIDimensions& dimensions);
  46. /**
  47. * @brief Returns whether the foldout is currently expanded or collapsed.
  48. */
  49. bool isExpanded() const { return mIsExpanded; }
  50. /**
  51. * @brief Expands or collapses the foldout.
  52. */
  53. void setExpanded(bool expanded);
  54. /**
  55. * Changes the label displayed on the foldout.
  56. */
  57. void setContent(const GUIContent& content);
  58. /**
  59. * @copydoc GUIElement::setTint
  60. */
  61. virtual void setTint(const Color& color) override;
  62. /**
  63. * @copydoc GUIElement::_updateLayoutInternal
  64. */
  65. void _updateLayoutInternal(const GUILayoutData& data) override;
  66. /**
  67. * @copydoc GUIElement::_getOptimalSize
  68. */
  69. Vector2I _getOptimalSize() const override;
  70. Event<void(bool)> onStateChanged;
  71. protected:
  72. virtual ~GUIComponentFoldout();
  73. /**
  74. * @brief Triggered when the foldout is expanded or collapsed.
  75. * True means expanded, false collapsed.
  76. */
  77. void toggleTriggered(bool value);
  78. /**
  79. * @copydoc GUIElement::styleUpdated
  80. */
  81. void styleUpdated() override;
  82. GUIToggle* mToggle;
  83. bool mIsExpanded;
  84. };
  85. }