egui_alignments
Simple alignment tools for egui
Example Usage
Align a single widget
use ;
use Alignable;
new
.top;
if new
.center
.clicked
new
.bottom;
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.
use ;
use center_horizontal;
let mut clicked_button = None;
center_vertical
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.
use Align;
use ;
center_horizontal;
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.
use Align;
use ;
column;
If you want to have stretches with different sizes, you may use stretch_with_weight.
use Align;
use ;
column