mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-14 19:27:05 -04:00
Merge pull request #1018 from pravdomil/claude/gpu-dialog-enter-ok-209420
This commit is contained in:
commit
59bf40a5da
2 files changed
+33
-1
No files matched your search
@@ -905,7 +905,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;
|
||||
// Enter presses OK, the default (and only) button.
|
||||
let mut close = !ctx.egui_wants_keyboard_input() && ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Enter));
|
||||
// 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));
|
||||
|
||||
@@ -154,3 +154,34 @@ fn gpu_information_dialog_stays_in_place() {
|
||||
assert!((current.min - start.min).length() < 1.0, "GPU Information dialog moved");
|
||||
}
|
||||
}
|
||||
|
||||
/// Enter presses OK, the dialog's default button: back to Settings when it was opened from
|
||||
/// there, closed otherwise.
|
||||
#[test]
|
||||
fn gpu_information_enter_presses_ok() {
|
||||
let mut session = Session::default();
|
||||
session.execute("comp.new", json!({"width":32,"height":32,"duration":2})).unwrap();
|
||||
let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_eframe(|_| EffectcraftApp::new(session));
|
||||
h.run_steps(4);
|
||||
let enter = |h: &mut Harness<'_, EffectcraftApp>| {
|
||||
for pressed in [true, false] {
|
||||
h.event(Event::Key { key: Key::Enter, physical_key: Some(Key::Enter), pressed, repeat: false, modifiers: Modifiers::NONE });
|
||||
h.step();
|
||||
}
|
||||
h.run_steps(3);
|
||||
};
|
||||
let ctx = h.ctx.clone();
|
||||
menus::invoke(h.state_mut(), &ctx, "app.gpuInfo", json!({})).unwrap();
|
||||
h.run_steps(3);
|
||||
assert_eq!(h.state().dialog, Some(Dialog::Info));
|
||||
enter(&mut h);
|
||||
assert!(h.state().dialog.is_none(), "Enter closed GPU Information");
|
||||
|
||||
menus::invoke(h.state_mut(), &ctx, "app.settings", json!({"page":"previews"})).unwrap();
|
||||
h.run_steps(3);
|
||||
let at = rect(&h, "settings.button.GPU Information").center();
|
||||
click(&mut h, at);
|
||||
assert_eq!(h.state().dialog, Some(Dialog::Info));
|
||||
enter(&mut h);
|
||||
assert_eq!(h.state().dialog, Some(Dialog::Settings), "Enter returned to the pending Settings transaction");
|
||||
}
|
||||
Reference in new issue
Block a user