mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 22:00:03 -04:00
Add align2 option
This commit is contained in:
@@ -35,6 +35,7 @@ pub struct WidgetLayout<'a> {
|
|||||||
fallback_text_color: Option<Color32>,
|
fallback_text_color: Option<Color32>,
|
||||||
min_size: Vec2,
|
min_size: Vec2,
|
||||||
wrap_mode: Option<TextWrapMode>,
|
wrap_mode: Option<TextWrapMode>,
|
||||||
|
align2: Option<Align2>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> WidgetLayout<'a> {
|
impl<'a> WidgetLayout<'a> {
|
||||||
@@ -48,6 +49,7 @@ impl<'a> WidgetLayout<'a> {
|
|||||||
fallback_text_color: None,
|
fallback_text_color: None,
|
||||||
min_size: Vec2::ZERO,
|
min_size: Vec2::ZERO,
|
||||||
wrap_mode: None,
|
wrap_mode: None,
|
||||||
|
align2: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,6 +94,11 @@ impl<'a> WidgetLayout<'a> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn align2(mut self, align2: Align2) -> Self {
|
||||||
|
self.align2 = Some(align2);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn show(self, ui: &mut Ui) -> AtomicLayoutResponse {
|
pub fn show(self, ui: &mut Ui) -> AtomicLayoutResponse {
|
||||||
let Self {
|
let Self {
|
||||||
id,
|
id,
|
||||||
@@ -102,6 +109,7 @@ impl<'a> WidgetLayout<'a> {
|
|||||||
fallback_text_color,
|
fallback_text_color,
|
||||||
min_size,
|
min_size,
|
||||||
wrap_mode,
|
wrap_mode,
|
||||||
|
align2,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
let id = id.unwrap_or_else(|| ui.next_auto_id());
|
let id = id.unwrap_or_else(|| ui.next_auto_id());
|
||||||
@@ -126,7 +134,9 @@ impl<'a> WidgetLayout<'a> {
|
|||||||
|
|
||||||
let mut shrink_item = None;
|
let mut shrink_item = None;
|
||||||
|
|
||||||
let align2 = Align2([ui.layout().horizontal_align(), ui.layout().vertical_align()]);
|
let align2 = align2.unwrap_or_else(|| {
|
||||||
|
Align2([ui.layout().horizontal_align(), ui.layout().vertical_align()])
|
||||||
|
});
|
||||||
|
|
||||||
if atomics.0.len() > 1 {
|
if atomics.0.len() > 1 {
|
||||||
let gap_space = gap * (atomics.0.len() as f32 - 1.0);
|
let gap_space = gap * (atomics.0.len() as f32 - 1.0);
|
||||||
|
|||||||
Reference in New Issue
Block a user