mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 22:30:03 -04:00
Improve default font height based on https://github.com/emilk/egui/pull/5809
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
use crate::{Frame, Id, Image, Response, Sense, Style, TextStyle, Ui, Widget, WidgetText};
|
use crate::{
|
||||||
|
FontSelection, Frame, Id, Image, Response, Sense, Style, TextStyle, Ui, Widget, WidgetText,
|
||||||
|
};
|
||||||
use ahash::HashMap;
|
use ahash::HashMap;
|
||||||
use emath::{Align2, NumExt, Rect, Vec2};
|
use emath::{Align2, NumExt, Rect, Vec2};
|
||||||
use epaint::{Color32, Fonts, Galley};
|
use epaint::{Color32, Fonts, Galley};
|
||||||
@@ -112,6 +114,12 @@ impl<'a> WidgetLayout<'a> {
|
|||||||
preferred_width += gap_space;
|
preferred_width += gap_space;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let default_font_height = || {
|
||||||
|
let font_selection = FontSelection::default();
|
||||||
|
let font_id = font_selection.resolve(ui.style());
|
||||||
|
ui.fonts(|f| f.row_height(&font_id))
|
||||||
|
};
|
||||||
|
|
||||||
let max_font_size = ui
|
let max_font_size = ui
|
||||||
.fonts(|fonts| {
|
.fonts(|fonts| {
|
||||||
atomics
|
atomics
|
||||||
@@ -120,7 +128,7 @@ impl<'a> WidgetLayout<'a> {
|
|||||||
.filter_map(|a| a.get_min_height_for_image(fonts, ui.style()))
|
.filter_map(|a| a.get_min_height_for_image(fonts, ui.style()))
|
||||||
.max_by(|a, b| a.partial_cmp(b).unwrap_or(std::cmp::Ordering::Equal))
|
.max_by(|a, b| a.partial_cmp(b).unwrap_or(std::cmp::Ordering::Equal))
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| ui.text_style_height(&TextStyle::Body));
|
.unwrap_or_else(default_font_height);
|
||||||
|
|
||||||
for ((idx, item)) in atomics.0.into_iter().enumerate() {
|
for ((idx, item)) in atomics.0.into_iter().enumerate() {
|
||||||
if item.shrink {
|
if item.shrink {
|
||||||
|
|||||||
Reference in New Issue
Block a user