CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
UIStackView.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 "UIView.hpp"
11
12namespace CeresEngine {
13
18 class UIStackView : public UIView {
19 using super = UIView;
20
21 public:
22 enum class Orientation {
28
34 };
35
36 enum class Alignment {
40 Leading,
41
43 Center,
44
49 };
50
52 enum class Distribution {
54 Fill,
55
57 Fitting,
58
60 Equal,
61 };
62
63 private:
69
72
74
81
89 double mSpacing = 8.0;
90
91 private:
93
94 public:
95 using UIView::UIView;
96
99
101 ~UIStackView() override;
102
103 public:
106
108 void setOrientation(Orientation orientation);
109
112
114 void setAlignment(Alignment alignment);
115
118
121
124
127
129 [[nodiscard]] double getSpacing() const noexcept { return mSpacing; }
130
132 void setSpacing(double spacing);
133
134 protected: // UIView
136 void didAddSubview(UIView& view) override;
137
139 void didRemoveSubview(UIView& view) override;
140
141 void updateConstraints() override;
142 };
143
144 std::ostream& operator<<(std::ostream& os, UIStackView::Orientation value);
145 std::ostream& operator<<(std::ostream& os, UIStackView::Alignment value);
146 std::ostream& operator<<(std::ostream& os, UIStackView::Distribution value);
147
148} // namespace CeresEngine
A view that arranges an array of views horizontally or vertically and updates their placement and siz...
Definition UIStackView.hpp:18
void setEdgeInsets(const UIEdgeInsets &edgeInsets)
The geometric padding, in points, inside the stack view, surrounding its views.
UIEdgeInsets mEdgeInsets
The geometric padding, in points, inside the stack view, surrounding its views.
Definition UIStackView.hpp:80
Orientation
Definition UIStackView.hpp:22
@ Vertical
The vertical orientation.
@ Horizontal
The horizontal orientation.
Vector< UILayoutConstraint > mStackViewConstraints
Definition UIStackView.hpp:92
UIView()
Initializes new UIView object with an empty frame rectangle.
Alignment mAlignment
The view alignment within the stack view.
Definition UIStackView.hpp:71
double getSpacing() const noexcept
The minimum spacing, in points, between adjacent views in the stack view.
Definition UIStackView.hpp:129
Distribution
Determines how subviews are distributed in the stack view.
Definition UIStackView.hpp:52
@ Fill
The subviews will fill the available space the stack views.
@ Equal
All views will have an equal size.
@ Fitting
The subviews will use their fitting size.
Distribution getDistribution() const noexcept
Definition UIStackView.hpp:117
void didAddSubview(UIView &view) override
Overridden by subclasses to perform additional actions when subviews are added to the view.
void setOrientation(Orientation orientation)
The horizontal or vertical layout direction of the stack view.
const UIEdgeInsets & getEdgeInsets() const noexcept
The geometric padding, in points, inside the stack view, surrounding its views.
Definition UIStackView.hpp:123
void setSpacing(double spacing)
The minimum spacing, in points, between adjacent views in the stack view.
Orientation getOrientation() const noexcept
The horizontal or vertical layout direction of the stack view.
Definition UIStackView.hpp:105
Alignment getAlignment() const noexcept
The view alignment within the stack view.
Definition UIStackView.hpp:111
Orientation mOrientation
The horizontal or vertical layout direction of the stack view.
Definition UIStackView.hpp:68
void didRemoveSubview(UIView &view) override
Overridden by subclasses to perform additional actions when subviews are removed to the view.
Distribution mDistribution
Definition UIStackView.hpp:73
UIStackView()
Creates a new UIStackView with default settings.
void setDistribution(Distribution distribution)
~UIStackView() override
Destroys the UIStackView and releases it's subviews.
Alignment
Definition UIStackView.hpp:36
@ Leading
Aligns subviews to the leading edge of the stack view.
@ Center
Aligns subviews to the center of the stack view.
@ Trailing
Aligns subviews to the trailing edge of the stack view.
void setAlignment(Alignment alignment)
The view alignment within the stack view.
double mSpacing
The minimum spacing, in points, between adjacent views in the stack view.
Definition UIStackView.hpp:89
void updateConstraints() override
Updates constraints for the view.
The infrastructure for drawing and handling events in a UI.
Definition UIView.hpp:153
UIView()
Initializes new UIView object with an empty frame rectangle.
Definition Application.hpp:19
Rect2Edge UIEdgeInsets
The inset distances for views.
Definition UIUtility.hpp:42
constexpr Byte operator<<(const Byte arg, const _IntType shift) noexcept
Definition DataTypes.hpp:44
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25