1.10
layout.h
1/*
2 * Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_DETAIL_LAYOUT_H
7#define EGT_DETAIL_LAYOUT_H
8
9#include <egt/detail/meta.h>
10#include <egt/geometry.h>
11#include <egt/widgetflags.h>
12#include <string>
13#include <vector>
14
15namespace egt
16{
17inline namespace v1
18{
19class Frame;
20
21namespace detail
22{
23
27struct EGT_API LayoutRect
28{
37 LayoutRect(uint32_t b,
38 const Rect& r,
39 uint32_t lm = 0,
40 uint32_t tm = 0,
41 uint32_t rm = 0,
42 uint32_t bm = 0) noexcept
43 : rect(r),
44 behave(b),
45 lmargin(lm),
46 tmargin(tm),
47 rmargin(rm),
48 bmargin(bm)
49 {}
50
60 LayoutRect(uint32_t b,
61 const Rect& r,
62 std::string s,
63 uint32_t lm = 0,
64 uint32_t tm = 0,
65 uint32_t rm = 0,
66 uint32_t bm = 0) noexcept
67 : str(std::move(s)),
68 rect(r),
69 behave(b),
70 lmargin(lm),
71 tmargin(tm),
72 rmargin(rm),
73 bmargin(bm)
74 {}
75
77 std::string str;
81 uint32_t behave{0};
83 uint32_t lmargin{0};
85 uint32_t tmargin{0};
87 uint32_t rmargin{0};
89 uint32_t bmargin{0};
90};
91
95EGT_API void flex_layout(const Rect& parent,
96 std::vector<LayoutRect>& children,
98 Orientation orient);
99
104EGT_API void flex_layout(const Rect& parent,
105 std::vector<LayoutRect>& children,
107 Orientation orient,
108 const AlignFlags& align);
109
114
118EGT_API uint32_t align_to_behave(const AlignFlags& align);
119}
120}
121}
122
123#endif
Alignment flags.
Definition widgetflags.h:379
EGT_API void flex_layout(const Rect &parent, std::vector< LayoutRect > &children, Justification justify, Orientation orient)
Perform a manual flex layout given a parent rect and children rects.
EGT_API uint32_t align_to_behave(const AlignFlags &align)
Compute lib lay behave from @align flags.
EGT_API uint32_t justify_to_contains(Justification justify, Orientation orient)
Compute lib lay contains from @justify and @orient parameters.
Justification
Generic justification of children flags.
Definition widgetflags.h:667
T & align(T &widget, const AlignFlags &a)
Helper to set alignment of a widget.
Definition widgetflags.h:624
Orientation
Generic orientation flags.
Definition widgetflags.h:652
EGT framework namespace.
Definition animation.h:24
Wrapper around properties for managing a rect by flex_layout().
Definition layout.h:28
LayoutRect(uint32_t b, const Rect &r, std::string s, uint32_t lm=0, uint32_t tm=0, uint32_t rm=0, uint32_t bm=0) noexcept
Definition layout.h:60
Rect rect
Rectangle if the object.
Definition layout.h:79
std::string str
String content of the object.
Definition layout.h:77
LayoutRect(uint32_t b, const Rect &r, uint32_t lm=0, uint32_t tm=0, uint32_t rm=0, uint32_t bm=0) noexcept
Definition layout.h:37