1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
3 | #pragma once |
4 | #include "BsPrerequisites.h" |
5 | |
6 | namespace bs |
7 | { |
8 | /** @addtogroup GUI |
9 | * @{ |
10 | */ |
11 | |
12 | /** Type of GUI element states. */ |
13 | enum class BS_SCRIPT_EXPORT(pl:true,m:GUI) GUIElementState |
14 | { |
15 | Normal = 0x01, /**< Normal state when element is not being iteracted with. */ |
16 | Hover = 0x02, /**< State when pointer is hovering over the element. */ |
17 | Active = 0x04, /**< State when element is being clicked. */ |
18 | Focused = 0x08, /**< State when the element has input focus and pointer is not hovering over the element. */ |
19 | FocusedHover = 0x10, /**< State when the element has input focus and pointer is hovering over the element. */ |
20 | NormalOn = 0x101, /**< Same as Normal, if the element is also in the "on" state. */ |
21 | HoverOn = 0x102, /**< Same as Hover, if the element is also in the "on" state. */ |
22 | ActiveOn = 0x104, /**< Same as Active, if the element is also in the "on" state. */ |
23 | FocusedOn = 0x108, /**< Same as Focused, if the element is also in the "on" state. */ |
24 | FocusedHoverOn = 0x110, /**< Same as FocusedHover, if the element is also in the "on" state. */ |
25 | |
26 | // Helpers |
27 | TypeMask BS_SCRIPT_EXPORT(ex:true) = 0xFF, /**< Mask for determining the state type (ignoring the on state). */ |
28 | OnFlag BS_SCRIPT_EXPORT(ex:true) = 0x100 /**< Flag that differentiates between on and off states. */ |
29 | }; |
30 | |
31 | /** Contains separate GUI content images for every possible GUI element state. */ |
32 | struct BS_EXPORT BS_SCRIPT_EXPORT(pl:true,m:GUI) GUIContentImages |
33 | { |
34 | GUIContentImages() = default; |
35 | |
36 | GUIContentImages(const HSpriteTexture& image) |
37 | :normal(image), hover(image), active(image), focused(image), |
38 | normalOn(image), hoverOn(image), activeOn(image), focusedOn(image) |
39 | { } |
40 | |
41 | BS_NORREF HSpriteTexture normal; |
42 | BS_NORREF HSpriteTexture hover; |
43 | BS_NORREF HSpriteTexture active; |
44 | BS_NORREF HSpriteTexture focused; |
45 | BS_NORREF HSpriteTexture normalOn; |
46 | BS_NORREF HSpriteTexture hoverOn; |
47 | BS_NORREF HSpriteTexture activeOn; |
48 | BS_NORREF HSpriteTexture focusedOn; |
49 | }; |
50 | |
51 | /** |
52 | * Holds data used for displaying content in a GUIElement. Content can consist of a string, image, a tooltip or none |
53 | * of those. |
54 | */ |
55 | class BS_EXPORT BS_SCRIPT_EXPORT(pl:true,m:GUI) GUIContent |
56 | { |
57 | public: |
58 | /** Constructs an empty content. */ |
59 | GUIContent() = default; |
60 | |
61 | /** Constructs content with just a string. */ |
62 | GUIContent(const HString& text) |
63 | : text(text) |
64 | { } |
65 | |
66 | /** Constructs content with a string and a tooltip. */ |
67 | GUIContent(const HString& text, const HString& tooltip) |
68 | : text(text), tooltip(tooltip) |
69 | { } |
70 | |
71 | /** Constructs content with just an image. */ |
72 | GUIContent(const GUIContentImages& image) |
73 | : images(image) |
74 | { } |
75 | |
76 | /** Constructs content with an image and a tooltip. */ |
77 | GUIContent(const GUIContentImages& image, const HString& tooltip) |
78 | : images(image), tooltip(tooltip) |
79 | { } |
80 | |
81 | /** Constructs content with a string and an image. */ |
82 | GUIContent(const HString& text, const GUIContentImages& image) |
83 | : text(text), images(image) |
84 | { } |
85 | |
86 | /** Constructs content with a string, an image and a tooltip. */ |
87 | GUIContent(const HString& text, const GUIContentImages& image, const HString& tooltip) |
88 | : text(text), images(image), tooltip(tooltip) |
89 | { } |
90 | |
91 | /** Returns image content (if any). */ |
92 | const HSpriteTexture& getImage(GUIElementState state = GUIElementState::Normal) const; |
93 | |
94 | /** Determines the spacing between text and image content in pixels. */ |
95 | static const UINT32 IMAGE_TEXT_SPACING; |
96 | |
97 | HString text; |
98 | GUIContentImages images; |
99 | HString tooltip; |
100 | }; |
101 | |
102 | /** @} */ |
103 | } |