CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
UILayout.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "UIUtility.hpp"
11
15
17 class ConstraintSolver;
18}
19
20namespace CeresEngine {
21 class UIView;
22
39
40// /// A `UILayoutAnchor` variable that is linked to a view.
41// class UILayoutAttribute : public Constraint::AbstractVariable {
42// protected:
43// UIView& mView;
44//
45// public:
46// explicit UILayoutAttribute(UIView& view, const String& varName);
47//
48// public:
49// /// The view linked to this layout anchor variable.
50// UIView& getView() const { return mView; }
51//
52// public: // AbstractVariable
53// /// \copydoc AbstractVariable::isExternal
54// [[nodiscard]] bool isExternal() const final { return true; }
55//
56// /// \copydoc AbstractVariable::isPivotable
57// [[nodiscard]] bool isPivotable() const final { return false; }
58//
59// /// \copydoc AbstractVariable::isRestricted
60// [[nodiscard]] bool isRestricted() const final { return false; }
61//
62// /// \copydoc AbstractVariable::isFloat
63// [[nodiscard]] bool isFloat() const final { return true; }
64//
65// /// \copydoc AbstractVariable::getName
66// [[nodiscard]] String getName() const final;
67//
68// /// \copydoc AbstractVariable::toString
69// [[nodiscard]] String toString() const final { return getName(); }
70// };
71//
72// /// A `UILayoutAttribute` variable that is linked to a view.
73// class UILayoutAnchorVariable : public UILayoutAttribute {
74// private:
75// /// The anchor value. This is just an internal value used during layout
76// /// computation.
77// double mValue = 0.0;
78//
79// public:
80// using UILayoutAttribute::UILayoutAttribute;
81//
82// public: // AbstractVariable
83// /// \copydoc AbstractVariable::setValue
84// void setValue(double newValue) final { mValue = newValue; }
85//
86// /// \copydoc AbstractVariable::getValue
87// [[nodiscard]] double getValue() const final { return mValue; }
88// };
89//
90// // ---------------------------------------------------------------------------------------------
91//
92// /// A `UILayoutAttribute` variable that is linked to a view.
93// class UILayoutFrameAttribute : public UILayoutAttribute {
94// protected:
95// /// The `UIView` frame rectangle.
96// UIRect& mFrame;
97//
98// public:
99// /// Creates a new `UILayoutAttribute` for the frame rectangle.
100// /// \param view The view that owns the attribute.
101// /// \param varName The name of view variable being controlled.
102// /// \param frame A reference to the frame rectangle to be controlled.
103// explicit UILayoutFrameAttribute(UIView& view, const String& varName, UIRect& frame);
104//
105// protected:
106// virtual const double& getProperty(const UIRect& frame) const = 0;
107//
108// double& getProperty(UIRect& frame) const { return const_cast<double&>(getProperty(const_cast<const UIRect&>(frame))); }
109//
110// public: // AbstractVariable
111// /// \copydoc AbstractVariable::setValue
112// void setValue(double newValue) final;
113//
114// /// \copydoc AbstractVariable::getValue
115// [[nodiscard]] double getValue() const final;
116// };
117//
118// class UILayoutSizeWidthAttribute final : public UILayoutFrameAttribute {
119// public:
120// using UILayoutFrameAttribute::UILayoutFrameAttribute;
121//
122// protected: // UILayoutFrameAttribute
123// /// \copydoc UILayoutFrameAttribute::getProperty
124// const double& getProperty(const UIRect& rect) const final { return rect.size.width; }
125// };
126//
127// class UILayoutSizeHeightAttribute final : public UILayoutFrameAttribute {
128// public:
129// using UILayoutFrameAttribute::UILayoutFrameAttribute;
130//
131// protected: // UILayoutFrameAttribute
132// /// \copydoc UILayoutFrameAttribute::getProperty
133// const double& getProperty(const UIRect& rect) const final { return rect.size.height; }
134// };
135//
136// class UILayoutLocationXAttribute final : public UILayoutFrameAttribute {
137// public:
138// using UILayoutFrameAttribute::UILayoutFrameAttribute;
139//
140// protected: // UILayoutFrameAttribute
141// /// \copydoc UILayoutFrameAttribute::getProperty
142// const double& getProperty(const UIRect& rect) const final { return rect.origin.x; }
143// };
144//
145// class UILayoutLocationYAttribute final : public UILayoutFrameAttribute {
146// public:
147// using UILayoutFrameAttribute::UILayoutFrameAttribute;
148//
149// protected: // UILayoutFrameAttribute
150// /// \copydoc UILayoutFrameAttribute::getProperty
151// const double& getProperty(const UIRect& rect) const final { return rect.origin.y; }
152// };
153
154 // ---------------------------------------------------------------------------------------------
155
214
232
235 class UILayoutSolver;
236
237}
An equation or inequality involving one or more variables.
Definition Constraint.hpp:38
Every constraint has a strength that determines where it sits in the hierarchy; strong constraints ar...
Definition ConstraintStrength.hpp:91
A variable as used in an expression.
Definition ConstraintVariable.hpp:50
Definition UILayoutSolver.hpp:16
Definition Constraint.hpp:22
Definition Application.hpp:19