1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//! # egui_alignments
//!
//! Simple alignment tools for egui
//!
//! ## Example Usage
//!
//! ### Align a single widget
//!
//! ```rust
//! use egui::{Button, Label};
//! use egui_alignments::Alignable;
//!
//! # egui::__run_test_ui(|ui| {
//! Label::new("This label will be shown at the top")
//! .top(ui);
//!
//! if Button::new("This label will be shown at the center")
//! .center(ui)
//! .clicked()
//! {
//! println!("Center button clicked!");
//! }
//!
//! Label::new("This label will be shown at the bottom")
//! .bottom(ui);
//! # });
//! ```
//!
//! ### Align multiple widgets
//!
//! The following buttons will be shown at the center of the screen horizontally
//! with the tip text above and click results below.
//!
//! ```rust
//! use egui::{Button, Widget};
//! use egui_alignments::{center_horizontal, center_vertical};
//!
//! # egui::__run_test_ui(|ui| {
//! let mut clicked_button = None;
//!
//! center_vertical(ui, |ui| {
//! ui.label("Click a button");
//!
//! ui.add_space(20.0);
//!
//! center_horizontal(ui, |ui| {
//! for i in 1..=10 {
//! if Button::new(format!("Button {}", i))
//! .ui(ui)
//! .clicked()
//! {
//! clicked_button = Some(i);
//! }
//! }
//! });
//!
//! ui.add_space(20.0);
//!
//! if let Some(i) = clicked_button {
//! ui.label(format!("You clicked button {}", i));
//! };
//! });
//! # });
//! ```
//!
//! ### Use containers
//!
//! Sometimes nested calls to alignment functions like `center_horizontal`, `top_vertical`, ...
//! may cause layout confusion due to interaction between inner and outer layouts.
//!
//! To prevent inner layouts from disrupting the outer ones, you may use containers for inner layouts
//!
//! Containers only cares about its inner alignments and act like a simple widget in the outer layout
//!
//! The following is an example usage of containers
//!
//! ```rust
//! use egui::Align;
//! use egui_alignments::{center_horizontal, column, row};
//!
//! # egui::__run_test_ui(|ui| {
//! center_horizontal(ui, |ui| {
//! ui.image("path/to/left/image");
//! column(ui, Align::Center, |ui| {
//! ui.label("top of right text");
//! row(ui, Align::Center, |ui| {
//! ui.label("left");
//! ui.label("middle");
//! ui.label("right");
//! });
//! ui.label("bottom of right text");
//! });
//! });
//! # });
//! ```
//!
//! This will show an image on the left, and a column of text on the right which contains a row of three labels in the middle.
//!
//! ### Use stretches
//!
//! Sometimes you may want to make a widget stretch to fill the remaining space
//! between widgets instead of besides them in a container.
//!
//! Use `stretch` to achieve this.
//!
//! ```rust
//! use egui::Align;
//! use egui_alignments::{column, stretch};
//!
//! # egui::__run_test_ui(|ui| {
//! column(ui, Align::Center, |ui| {
//! ui.label("Top");
//! stretch(ui);
//! ui.label("Bottom");
//! });
//! # });
//! ```
//!
//! If you want to have stretches with different sizes, you may use `stretch_with_weight`.
//!
//! ```rust
//! use egui::Align;
//! use egui_alignments::{column, stretch_with_weight};
//!
//! # egui::__run_test_ui(|ui| {
//! column(ui, Align::Center, |ui| {
//! ui.label("100% height");
//! stretch_with_weight(ui, 1.0);
//! ui.label("75% height");
//! stretch_with_weight(ui, 3.0);
//! ui.label("0% height");
//! });
//! # });
//! ```
pub use *;
pub use *;
pub use *;
use ;
// resize layout rect without moving the inner content.
// this is useful for layouts that contain growable widgets like `ScrollArea`.
pub