mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-01 18:23:52 -06:00
Merge branch 'port/deckcraft/look/app-3' into port/deckcraft/area/app
This commit is contained in:
@@ -188,7 +188,7 @@ fn matching_dialog(host: &DialogHost, key: &str) -> Option<DialogId> {
|
||||
"customShow" => typed_id::<HostedListManager>(host),
|
||||
"spelling" => typed_id::<craft::text::ui::spelling::CheckSpellingDialog>(host),
|
||||
"find" => typed_id::<craft::text::ui::find::FindReplaceDialog>(host),
|
||||
"quit" => typed_id::<UnsavedChangesDialog>(host),
|
||||
"quit" | "close" => typed_id::<UnsavedChangesDialog>(host),
|
||||
"about" => typed_id::<HostedAbout>(host),
|
||||
_ => host.open_dialogs().into_iter().find(|dialog| dialog.key.as_deref() == Some(key)).map(|dialog| dialog.id),
|
||||
}
|
||||
@@ -229,7 +229,8 @@ pub(crate) fn open_now(app: &mut SlideApp, ctx: &Context, host: &mut DialogHost,
|
||||
"spelling" => spelling::open(app, ctx, host, params),
|
||||
"accessibility" => accessibility::open(app, ctx, host, params),
|
||||
"find" => find::open(app, ctx, host, params),
|
||||
"quit" => closing::open(app, ctx, host, params),
|
||||
"quit" => closing::open(app, ctx, host, craft::quit::CloseScope::Quit),
|
||||
"close" => closing::open(app, ctx, host, craft::quit::CloseScope::Close),
|
||||
"about" => about::open(app, ctx, host, params),
|
||||
"preferences" => preferences::open(app, ctx, host, params),
|
||||
"autocorrect" => preferences::open_autocorrect(app, ctx, host, params),
|
||||
|
||||
@@ -9,10 +9,14 @@ use serde_json::{Value, json};
|
||||
use crate::SlideApp;
|
||||
use crate::app::files::SaveOutcome;
|
||||
|
||||
/// Opens the quit guard's current document question, if one is needed.
|
||||
pub(crate) fn open(app: &mut SlideApp, ctx: &Context, host: &mut DialogHost, _params: &Value) -> Result<Option<DialogId>, String> {
|
||||
let uids = app.session.documents().iter().filter(|doc| doc.is_dirty()).map(|doc| doc.uid).collect();
|
||||
app.start_closing(CloseScope::Quit, uids);
|
||||
/// Opens the guard's current document question, if one is needed: Quit asks about every unsaved presentation, Close
|
||||
/// about the active one.
|
||||
pub(crate) fn open(app: &mut SlideApp, ctx: &Context, host: &mut DialogHost, scope: CloseScope) -> Result<Option<DialogId>, String> {
|
||||
let uids = match scope {
|
||||
CloseScope::Close => app.session.active().filter(|doc| doc.is_dirty()).map(|doc| doc.uid).into_iter().collect(),
|
||||
_ => app.session.documents().iter().filter(|doc| doc.is_dirty()).map(|doc| doc.uid).collect(),
|
||||
};
|
||||
app.start_closing(scope, uids);
|
||||
pump(app, ctx, host);
|
||||
Ok(host.get::<UnsavedChangesDialog>().map(StackDialog::id))
|
||||
}
|
||||
@@ -258,4 +262,31 @@ mod tests {
|
||||
assert!(crate::dialogs::top_dialog(&h.ctx).is_none());
|
||||
assert_eq!(h.state_mut().close_decision(), CloseDecision::Close);
|
||||
}
|
||||
|
||||
/// The `close` dialog key asks about the active presentation alone, and only when it has unsaved changes.
|
||||
#[test]
|
||||
fn the_close_key_asks_about_the_active_unsaved_presentation() {
|
||||
let mut session = Session::new();
|
||||
for title in ["First", "Second"] {
|
||||
session.execute("file.new", &json!({})).unwrap();
|
||||
session.execute("file.properties", &json!({"title": title})).unwrap();
|
||||
}
|
||||
let mut h = harness(session, Services::default());
|
||||
h.run_steps(2);
|
||||
let ctx = h.ctx.clone();
|
||||
crate::dialogs::control(h.state_mut(), &ctx, "ui.dialog.open", &json!({"id": "close"})).expect("a dialog method").unwrap();
|
||||
h.run_steps(4);
|
||||
assert!(crate::dialogs::top_dialog(&h.ctx).is_some(), "an unsaved presentation is asked about");
|
||||
answer(&h, Some(CloseAnswer::DontSave));
|
||||
h.run_steps(4);
|
||||
assert_eq!(h.state().session.documents().len(), 1, "Don't Save closes the active presentation and keeps the other");
|
||||
assert!(!h.state().quit_allowed(), "the other presentation still has its changes");
|
||||
|
||||
let mut h = harness(Session::with_new(), Services::default());
|
||||
h.run_steps(2);
|
||||
let ctx = h.ctx.clone();
|
||||
crate::dialogs::control(h.state_mut(), &ctx, "ui.dialog.open", &json!({"id": "close"})).expect("a dialog method").unwrap();
|
||||
h.run_steps(4);
|
||||
assert!(crate::dialogs::top_dialog(&h.ctx).is_none(), "a presentation without changes needs no question");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,6 +276,8 @@ mod replacefonts_tests;
|
||||
#[cfg(test)]
|
||||
mod reuse_picker_tests;
|
||||
#[cfg(test)]
|
||||
mod ribbon_names_tests;
|
||||
#[cfg(test)]
|
||||
mod slide_size_tests;
|
||||
#[cfg(test)]
|
||||
mod split_button_tests;
|
||||
|
||||
@@ -66,7 +66,7 @@ pub(crate) fn insert(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
});
|
||||
});
|
||||
row.group(RibbonGroup::new("pictures", "Images", Icon::Picture.id().into()), |ui| {
|
||||
Button::command("app.insertPictureDialog").icon(Icon::Picture.id()).arrangement(Arrangement::Stacked).show(ui);
|
||||
Button::command("app.insertPictureDialog").label("Pictures").icon(Icon::Picture.id()).arrangement(Arrangement::Stacked).show(ui);
|
||||
photo_album_button(app, ui);
|
||||
Button::new("Screenshot")
|
||||
.icon(Icon::Screenshot.id())
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
use crate::{Services, Session};
|
||||
use egui::accesskit::Role;
|
||||
use egui_kittest::kittest::Queryable as _;
|
||||
use serde_json::json;
|
||||
|
||||
/// The ribbon's controls answer to the names a screen reader user or an agent reaches them by: a split button's arrow
|
||||
/// part is "<label> options", a stacked two-line label reads as one line, and the Insert tab's picture button is
|
||||
/// "Pictures". Each name is one button on its tab, so a lookup by name finds exactly that control.
|
||||
#[test]
|
||||
fn ribbon_controls_answer_to_their_spoken_names() {
|
||||
for (tab, names) in [
|
||||
("Home", &["Paste options", "Font Color options", "Bullets options"][..]),
|
||||
("Insert", &["Pictures"][..]),
|
||||
("Design", &["Background Styles"][..]),
|
||||
("Transitions", &["Effect Options"][..]),
|
||||
("Animations", &["Effect Options", "Add Animation"][..]),
|
||||
] {
|
||||
let mut session = Session::new();
|
||||
deckcraft_engine::sample::open_sample(&mut session).unwrap();
|
||||
let mut h = crate::test_harness::harness_with(
|
||||
session,
|
||||
Services::default(),
|
||||
egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)),
|
||||
|_| {},
|
||||
);
|
||||
h.state_mut().run("shape.insert", json!({"preset": "rect", "rect": [100, 100, 200, 100]})).unwrap();
|
||||
h.state_mut().ui.tab = tab.into();
|
||||
h.run_steps(4);
|
||||
for name in names {
|
||||
let found = h.query_all_by_role_and_label(Role::Button, name).count();
|
||||
assert_eq!(found, 1, "{tab}: one button named {name:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1388,10 +1388,7 @@ fn synthetic_click_is_consumed_on_its_old_target_before_logic_changes_the_docume
|
||||
/// Every target-changing app state withdraws a click captured for the earlier state.
|
||||
#[test]
|
||||
fn input_target_changes_retract_a_queued_click() {
|
||||
// The ribbon row's own arrow, not the canvas scroll bars' of the same name.
|
||||
let ribbon_arrow = |h: &egui_kittest::Harness<'_, SlideApp>| {
|
||||
h.get_by_role_and_label(egui::accesskit::Role::Group, "Ribbon").get_by_label("Scroll right").rect().center()
|
||||
};
|
||||
let ribbon_arrow = |h: &egui_kittest::Harness<'_, SlideApp>| h.get_by_label("Scroll ribbon right").rect().center();
|
||||
for case in [
|
||||
"show",
|
||||
"show step",
|
||||
|
||||
Reference in New Issue
Block a user