mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Mobile fixes
This commit is contained in:
@@ -29,8 +29,8 @@ pub struct Fonts {
|
||||
impl Fonts {
|
||||
pub fn new() -> Fonts {
|
||||
let mut sizes = FontSizes::new();
|
||||
sizes.insert(TextStyle::Body, 20.0);
|
||||
sizes.insert(TextStyle::Button, 20.0);
|
||||
sizes.insert(TextStyle::Body, 18.0);
|
||||
sizes.insert(TextStyle::Button, 22.0);
|
||||
sizes.insert(TextStyle::Heading, 30.0);
|
||||
Fonts::from_sizes(sizes)
|
||||
}
|
||||
|
||||
@@ -299,6 +299,10 @@ impl Region {
|
||||
&self.options
|
||||
}
|
||||
|
||||
pub fn data(&self) -> &Arc<Data> {
|
||||
&self.data
|
||||
}
|
||||
|
||||
pub fn input(&self) -> &GuiInput {
|
||||
self.data.input()
|
||||
}
|
||||
@@ -329,7 +333,7 @@ impl Region {
|
||||
);
|
||||
let text: String = text.into();
|
||||
let id = self.make_child_id(&text);
|
||||
let text_style = TextStyle::Heading;
|
||||
let text_style = TextStyle::Button;
|
||||
let font = &self.fonts()[text_style];
|
||||
let (text, text_size) = font.layout_multiline(&text, self.width());
|
||||
let text_cursor = self.cursor + self.options().button_padding;
|
||||
|
||||
@@ -154,4 +154,14 @@ pub fn remap_clamp(from: f32, from_min: f32, from_max: f32, to_min: f32, to_max:
|
||||
lerp(to_min, to_max, t)
|
||||
}
|
||||
|
||||
pub fn clamp(x: f32, min: f32, max: f32) -> f32 {
|
||||
if x <= min {
|
||||
min
|
||||
} else if x >= max {
|
||||
max
|
||||
} else {
|
||||
x
|
||||
}
|
||||
}
|
||||
|
||||
pub const TAU: f32 = 2.0 * std::f32::consts::PI;
|
||||
|
||||
Reference in New Issue
Block a user