1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 12:50:04 -04:00

Add AtomLayoutStyle

This commit is contained in:
Lucas Meurer
2026-08-28 18:08:04 +02:00
parent 13dc9d528c
commit debd1e30c9
5 changed files with 143 additions and 71 deletions

View File

@@ -6,7 +6,9 @@
use eframe::egui::{
self, CentralPanel, Color32, Frame, Panel, TextStyle,
theme::StyleProvider,
widget_style::{ButtonStyle, HasClasses as _, StyleArgs, TextVisuals, WidgetState},
widget_style::{
AtomLayoutStyle, ButtonStyle, HasClasses as _, StyleArgs, TextVisuals, WidgetState,
},
};
/// Buttons with this class are styled as a destructive action.
@@ -60,15 +62,19 @@ impl StyleProvider<ButtonStyle> for MyTheme {
};
ButtonStyle {
min_size: egui::vec2(0.0, style.spacing.interact_size.y),
frame: Frame::new()
.fill(fill)
.corner_radius(self.corner_radius)
.inner_margin(8),
text_style: TextVisuals {
color: Color32::WHITE,
// Resolve the font from the style, so we follow the user's font sizes:
font_id: TextStyle::Button.resolve(style),
atom_layout: AtomLayoutStyle {
min_size: egui::vec2(0.0, style.spacing.interact_size.y),
gap: style.spacing.icon_spacing,
frame: Frame::new()
.fill(fill)
.corner_radius(self.corner_radius)
.inner_margin(8),
text_style: TextVisuals {
color: Color32::WHITE,
// Resolve the font from the style, so we follow the user's font sizes:
font_id: TextStyle::Button.resolve(style),
},
..Default::default()
},
}
}