Merge pull request #937 from nanox333/codex/fix-828-gpu-info-dialog

Keep GPU Information dialog layout steady

# Conflicts:
#	crates/ui-egui/src/panels/dialogs.rs
#	crates/ui-egui/tests/ui_settings_info.rs
This commit is contained in:
Brandon Thomas
2026-10-12 04:21:06 -04:00
3 changed files with 32 additions and 2 deletions
+10 -1
View File
@@ -158,6 +158,14 @@ fn modal_space(ctx: &egui::Context) -> egui::Vec2 {
}
pub(crate) fn modal(ctx: &egui::Context, title: &str, size: egui::Vec2, t: &Tokens, body: impl FnOnce(&mut egui::Ui)) {
modal_with_scroll(ctx, title, size, t, false, body);
}
pub(crate) fn modal_vertical(ctx: &egui::Context, title: &str, size: egui::Vec2, t: &Tokens, body: impl FnOnce(&mut egui::Ui)) {
modal_with_scroll(ctx, title, size, t, true, body);
}
fn modal_with_scroll(ctx: &egui::Context, title: &str, size: egui::Vec2, t: &Tokens, vertical_only: bool, body: impl FnOnce(&mut egui::Ui)) {
let max_height = (modal_space(ctx).y - 84.0).max(40.0);
modal_fit(ctx, title, size, t, |ui, _| {
egui::ScrollArea::both().max_height(max_height).auto_shrink([false, true]).show(ui, body);
@@ -178,7 +186,8 @@ pub(crate) fn modal_fit(ctx: &egui::Context, title: &str, size: egui::Vec2, t: &
// The id stays keyed on the untranslated source, so switching language cannot move it.
ui.label(egui::RichText::new(tr(title)).font(Tokens::semibold(15.0)).color(t.tab_text_active));
ui.add_space(10.0);
let title_h = ui.cursor().top() - ui.min_rect().top();
let scroll = if vertical_only { egui::ScrollArea::vertical() } else { let title_h = ui.cursor() };
scroll.top() - ui.min_rect().top();
body(ui, (size.y - 36.0 - title_h).max(40.0));
});
}
+2 -1
View File
@@ -904,7 +904,8 @@ pub(crate) fn close_info(app: &mut EffectcraftApp) {
pub fn show_info(app: &mut EffectcraftApp, ctx: &egui::Context, t: &Tokens) {
let (title, body) = app.dialog_state.info.clone();
let mut close = false;
super::dialogs::modal(ctx, &title, vec2(440.0, 160.0), t, |ui| {
// The text wraps within this small dialog; avoid a horizontal scrollbar changing its height.
super::dialogs::modal_vertical(ctx, &title, vec2(440.0, 160.0), t, |ui| {
ui.label(tr(&body));
ui.add_space(16.0);
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {