mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
Change default text alignment to Center
This commit is contained in:
@@ -617,6 +617,14 @@ impl Ui {
|
|||||||
self.wrap_mode() == TextWrapMode::Wrap
|
self.wrap_mode() == TextWrapMode::Wrap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// How to vertically align text
|
||||||
|
#[inline]
|
||||||
|
pub fn text_valign(&self) -> Align {
|
||||||
|
#![allow(clippy::unused_self)]
|
||||||
|
// We currently always center-align, because that makes emojis and text nice and centered everywhere.
|
||||||
|
Align::Center
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a painter for a sub-region of this Ui.
|
/// Create a painter for a sub-region of this Ui.
|
||||||
///
|
///
|
||||||
/// The clip-rect of the returned [`Painter`] will be the intersection
|
/// The clip-rect of the returned [`Painter`] will be the intersection
|
||||||
|
|||||||
@@ -648,7 +648,7 @@ impl WidgetText {
|
|||||||
available_width: f32,
|
available_width: f32,
|
||||||
fallback_font: impl Into<FontSelection>,
|
fallback_font: impl Into<FontSelection>,
|
||||||
) -> Arc<Galley> {
|
) -> Arc<Galley> {
|
||||||
let valign = ui.layout().vertical_align();
|
let valign = ui.text_valign();
|
||||||
let style = ui.style();
|
let style = ui.style();
|
||||||
|
|
||||||
let wrap_mode = wrap_mode.unwrap_or_else(|| ui.wrap_mode());
|
let wrap_mode = wrap_mode.unwrap_or_else(|| ui.wrap_mode());
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ impl Label {
|
|||||||
return (pos, galley, response);
|
return (pos, galley, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
let valign = ui.layout().vertical_align();
|
let valign = ui.text_valign();
|
||||||
let mut layout_job = self
|
let mut layout_job = self
|
||||||
.text
|
.text
|
||||||
.into_layout_job(ui.style(), FontSelection::Default, valign);
|
.into_layout_job(ui.style(), FontSelection::Default, valign);
|
||||||
|
|||||||
@@ -279,6 +279,13 @@ pub struct TextFormat {
|
|||||||
|
|
||||||
/// If you use a small font and [`Align::TOP`] you
|
/// If you use a small font and [`Align::TOP`] you
|
||||||
/// can get the effect of raised text.
|
/// can get the effect of raised text.
|
||||||
|
///
|
||||||
|
/// If you use a small font and [`Align::BOTTOM`]
|
||||||
|
/// you get the effect of a subscript.
|
||||||
|
///
|
||||||
|
/// If you use [`Align::center`], you get text that is centered
|
||||||
|
/// around a common center-line, which is nice when mixining emojis
|
||||||
|
/// and normal text in e.g. a button.
|
||||||
pub valign: Align,
|
pub valign: Align,
|
||||||
// TODO(emilk): lowered
|
// TODO(emilk): lowered
|
||||||
}
|
}
|
||||||
@@ -295,7 +302,7 @@ impl Default for TextFormat {
|
|||||||
italics: false,
|
italics: false,
|
||||||
underline: Stroke::NONE,
|
underline: Stroke::NONE,
|
||||||
strikethrough: Stroke::NONE,
|
strikethrough: Stroke::NONE,
|
||||||
valign: Align::BOTTOM,
|
valign: Align::Center,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user