BsGUIContent.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. namespace BansheeEngine
  6. {
  7. /** @addtogroup GUI
  8. * @{
  9. */
  10. /** Type of GUI element states. */
  11. enum class GUIElementState
  12. {
  13. Normal = 0x01, /**< Normal state when button is not being iteracted with. */
  14. Hover = 0x02, /**< State when pointer is hovering over the button. */
  15. Active = 0x04, /**< State when button is being clicked. */
  16. Focused = 0x08, /**< State when button has been selected. */
  17. NormalOn = 0x11, /**< Normal state when button is not being iteracted with and is in "on" state. */
  18. HoverOn = 0x12, /**< State when pointer is hovering over the button and is in "on" state. */
  19. ActiveOn = 0x14, /**< State when button is being clicked and is in "on" state. */
  20. FocusedOn = 0x18 /**< State when button has been selected and is in "on" state. */
  21. };
  22. /** Contains separate GUI content images for every possible GUI element state. */
  23. struct BS_EXPORT GUIContentImages
  24. {
  25. GUIContentImages() {}
  26. GUIContentImages(const HSpriteTexture& image);
  27. HSpriteTexture normal;
  28. HSpriteTexture hover;
  29. HSpriteTexture active;
  30. HSpriteTexture focused;
  31. HSpriteTexture normalOn;
  32. HSpriteTexture hoverOn;
  33. HSpriteTexture activeOn;
  34. HSpriteTexture focusedOn;
  35. };
  36. /**
  37. * Holds data used for displaying content in a GUIElement. Content can consist of a string, image, a tooltip or none
  38. * of those.
  39. */
  40. class BS_EXPORT GUIContent
  41. {
  42. public:
  43. /** Constructs an empty content. */
  44. GUIContent();
  45. /** Constructs content with just a string. */
  46. GUIContent(const HString& text);
  47. /** Constructs content with a string and a tooltip. */
  48. GUIContent(const HString& text, const HString& tooltip);
  49. /** Constructs content with just an image. */
  50. GUIContent(const GUIContentImages& image);
  51. /** Constructs content with an image and a tooltip. */
  52. GUIContent(const HSpriteTexture& image, const HString& tooltip);
  53. /** Constructs content with a string and an image. */
  54. GUIContent(const HString& text, const GUIContentImages& image);
  55. /** Constructs content with a string, an image and a tooltip. */
  56. GUIContent(const HString& text, const GUIContentImages& image, const HString& tooltip);
  57. /** Returns string content (if any). */
  58. const HString& getText() const { return mText; }
  59. /** Returns image content (if any). */
  60. const HSpriteTexture& getImage(GUIElementState state = GUIElementState::Normal) const;
  61. /** Returns tooltip content (if any). */
  62. const HString& getTooltip() const { return mTooltipText; }
  63. /** Determines the spacing between text and image content in pixels. */
  64. static const UINT32 IMAGE_TEXT_SPACING;
  65. private:
  66. HString mText;
  67. GUIContentImages mImages;
  68. HString mTooltipText;
  69. };
  70. /** @} */
  71. }