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
5#include "BsPrerequisites.h"
6
7namespace bs
8{
9 /** @addtogroup GUI
10 * @{
11 */
12
13 /**
14 * Controls GUI element layout options, possibly by overriding the default options specified in GUI element style.
15 * These options control GUI element placement and size in a GUI layout.
16 */
17 class BS_EXPORT GUIOption
18 {
19 /** Type of GUI element options. */
20 enum class Type
21 {
22 FixedWidth,
23 FlexibleWidth,
24 FixedHeight,
25 FlexibleHeight,
26 Position
27 };
28
29 public:
30 GUIOption() = default;
31
32 /**
33 * Constructs a GUI option notifying the GUI layout that this element should be positioned at this offset from the
34 * parent GUI panel. This option is ignored if element is part of a layout since it controls its placement.
35 */
36 static GUIOption position(INT32 x, INT32 y);
37
38 /**
39 * Constructs a GUI option notifying the GUI layout that this element has a fixed width. This will override the
40 * width property set in element style.
41 */
42 static GUIOption fixedWidth(UINT32 value);
43
44 /**
45 * Constructs a GUI option notifying the GUI layout that this element has a flexible width with optional min/max
46 * constraints (value of 0 means no constraint). This will override the width property set in element style.
47 */
48 static GUIOption flexibleWidth(UINT32 min = 0, UINT32 max = 0);
49
50 /**
51 * Constructs a GUI option notifying the GUI layout that this element has a fixed height. This will override the
52 * height property set in element style.
53 */
54 static GUIOption fixedHeight(UINT32 value);
55
56 /**
57 * Constructs a GUI option notifying the GUI layout that this element has a flexible height with optional min/max
58 * constraints (value of 0 means no constraint). This will override the height property set in element style.
59 */
60 static GUIOption flexibleHeight(UINT32 min = 0, UINT32 max = 0);
61
62 private:
63 friend struct GUIDimensions;
64
65 UINT32 min = 0;
66 UINT32 max = 0;
67 Type type = Type::FixedWidth;
68 };
69
70 /** Container for a list of options used for controlling GUI element properties. */
71 class BS_EXPORT GUIOptions
72 {
73 public:
74 GUIOptions() = default;
75
76 GUIOptions(const GUIOption& e0)
77 {
78 mOptions.push_back(e0);
79 }
80
81 GUIOptions(const GUIOption& e0, const GUIOption& e1)
82 {
83 mOptions.push_back(e0);
84 mOptions.push_back(e1);
85 }
86
87 GUIOptions(const GUIOption& e0, const GUIOption& e1, const GUIOption& e2)
88 {
89 mOptions.push_back(e0);
90 mOptions.push_back(e1);
91 mOptions.push_back(e2);
92 }
93
94 GUIOptions(const GUIOption& e0, const GUIOption& e1, const GUIOption& e2,
95 const GUIOption& e3)
96 {
97 mOptions.push_back(e0);
98 mOptions.push_back(e1);
99 mOptions.push_back(e2);
100 mOptions.push_back(e3);
101 }
102
103 GUIOptions(const GUIOption& e0, const GUIOption& e1, const GUIOption& e2,
104 const GUIOption& e3, const GUIOption& e4)
105 {
106 mOptions.push_back(e0);
107 mOptions.push_back(e1);
108 mOptions.push_back(e2);
109 mOptions.push_back(e3);
110 mOptions.push_back(e4);
111 }
112
113 /** Adds a new option to the options list. */
114 void addOption(const GUIOption& option)
115 {
116 mOptions.push_back(option);
117 }
118
119 private:
120 friend struct GUIDimensions;
121
122 Vector<GUIOption> mOptions;
123 };
124
125 /** @} */
126}
127