mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-02 10:38:15 -06:00
Every ribbon tool toggle publishes its checked state; the canvas editor yields to the opening overlay; backstage, IME and field-frame tests drive the port's own signals; DIAG prints for the remaining red tests
Ribbon: the Draw and Draw Borders toggles state whether their tool is the current one, so an unselected toggle reads unchecked instead of having no state. Canvas text editor: blocked while a presentation is opening, so it takes focus back when the overlay closes. Tests: the close prompt is found as the typed UnsavedChangesDialog (it carries no command key); host Save As lets a frame pass after the host open; Find and Replace opens through app.find; the Japanese conversion waits for the IME to be on before composing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
58892b8380
commit
54e7dc9b58
@@ -312,6 +312,8 @@ fn host_save_as_under_the_same_name_returns_to_the_slide() {
|
||||
h.state_mut().start_for_host().unwrap();
|
||||
let deck = deckcraft_engine::cmd::file::save_bytes(&Session::with_new().doc().unwrap().doc, "pptx").unwrap();
|
||||
h.state_mut().open_from_host(Some("deck.pptx"), &deck);
|
||||
// The page's file arrives between frames: the start screen gives way before File opens again.
|
||||
h.run_steps(1);
|
||||
h.state_mut().run("app.backstage", json!({"page": "saveAs"})).unwrap();
|
||||
h.run_steps(3);
|
||||
let original = h.state().backstage.as_ref().unwrap().instance.clone();
|
||||
|
||||
@@ -180,6 +180,13 @@ pub(crate) fn show(app: &mut SlideApp, ui: &mut egui::Ui, space: &CanvasSpace) {
|
||||
};
|
||||
let (mut image, mut drawn) = render(region);
|
||||
picture.canvas_renders += 1;
|
||||
eprintln!(
|
||||
"DIAG the_picture_renders_again_only_when_its_revision_changes: render {} pass {} size {size:?} scale {scale} region {region:?} anim {} edit {editing_text:?} gifs {}",
|
||||
picture.canvas_renders,
|
||||
ui.ctx().current_pass_index(),
|
||||
anim_key(anim),
|
||||
crate::media::gif_key(&gifs)
|
||||
);
|
||||
// Text can spill beyond its box. Store the expanded region's revision so the next
|
||||
// pass reuses it, rather than repeating the first, too-small render.
|
||||
let expanded = region_for(source.estimate.union(source.drawn).union(drawn));
|
||||
|
||||
@@ -18,14 +18,19 @@ fn drag_with_modifiers(h: &mut Harness<'_, SlideApp>, a: Pos2, b: Pos2, modifier
|
||||
h.event(egui::Event::ModifiersChanged(modifiers));
|
||||
h.hover_at(a);
|
||||
h.run_steps(1);
|
||||
let editing = |h: &Harness<'_, SlideApp>| h.state().session.active().unwrap().selection.text.is_some();
|
||||
eprintln!("DIAG drag_indents_add_move_and_remove_tabs_on_the_ruler: before press at {a:?} editing {}", editing(h));
|
||||
h.event(egui::Event::PointerButton { pos: a, button: PointerButton::Primary, pressed: true, modifiers });
|
||||
h.run_steps(1);
|
||||
eprintln!("DIAG drag_indents_add_move_and_remove_tabs_on_the_ruler: after press editing {} status {:?}", editing(h), h.state().status);
|
||||
for i in 1..=8 {
|
||||
h.event(egui::Event::PointerMoved(a + (b - a) * (i as f32 / 8.0)));
|
||||
h.run_steps(1);
|
||||
}
|
||||
eprintln!("DIAG drag_indents_add_move_and_remove_tabs_on_the_ruler: after moves editing {}", editing(h));
|
||||
h.event(egui::Event::PointerButton { pos: b, button: PointerButton::Primary, pressed: false, modifiers });
|
||||
h.run_steps(2);
|
||||
eprintln!("DIAG drag_indents_add_move_and_remove_tabs_on_the_ruler: after release editing {} status {:?}", editing(h), h.state().status);
|
||||
h.event(egui::Event::ModifiersChanged(Modifiers::NONE));
|
||||
}
|
||||
|
||||
|
||||
@@ -310,12 +310,12 @@ fn document_bounds(points: [deckcraft_geom::Point; 4], transform: Affine) -> Rec
|
||||
}))
|
||||
}
|
||||
|
||||
/// Hosts the edited shape or cell while no dialog, palette, File view or other text field owns input.
|
||||
/// Hosts the edited shape or cell while no dialog, palette, File view, opening overlay or other text field owns input.
|
||||
/// The editor takes keyboard focus in the first pass it is shown, and again after a pass without it.
|
||||
pub(crate) fn show_editor(app: &mut crate::SlideApp, ui: &mut Ui, space: &CanvasSpace) -> Option<TextEditorOutput> {
|
||||
let shown = egui::Id::new("slide-text-editor-shown");
|
||||
let hosted = ui.data(|data| data.get_temp::<egui::Id>(shown));
|
||||
let blocked = crate::dialogs::modal_open(ui.ctx()) || app.palette_open || app.backstage_open();
|
||||
let blocked = crate::dialogs::modal_open(ui.ctx()) || app.palette_open || app.backstage_open() || app.opening.is_some();
|
||||
let target = app.session.active().and_then(|state| {
|
||||
let target = state.selection.text.as_ref().filter(|target| !target.notes)?;
|
||||
Some((state.uid, target.clone()))
|
||||
|
||||
@@ -147,7 +147,13 @@ pub(crate) fn open(app: &SlideApp, ctx: &egui::Context, params: &Value) -> Hoste
|
||||
let mut text = fields.text("boxText").unwrap_or("Text Box").to_string();
|
||||
Row::new().show(ui, |ui, _| {
|
||||
let can_pick = Host::of(ui).files().can_pick();
|
||||
if clicked(&Button::new("Add Pictures…").enabled(can_pick).tooltip("Pass pictures to insert.photoAlbum").show(ui)) {
|
||||
let add = Button::new("Add Pictures…").enabled(can_pick).tooltip("Pass pictures to insert.photoAlbum").show(ui);
|
||||
eprintln!(
|
||||
"DIAG create_inserts_the_album_in_one_step: pass {} can_pick {can_pick} clicked {}",
|
||||
ui.ctx().current_pass_index(),
|
||||
clicked(&add)
|
||||
);
|
||||
if clicked(&add) {
|
||||
context.request_action("addPictures");
|
||||
}
|
||||
let draft = album_check_item_count(list.len().saturating_add(1)).and_then(|()| album_check_text(&text).map(str::to_string));
|
||||
@@ -309,7 +315,9 @@ fn append_picture(dialog: &mut HostedParamDialog, name: &str, bytes: &[u8], tota
|
||||
/// Consumes each action and file answer once, so a second pass has no input to replay.
|
||||
pub(crate) fn each_pass(app: &mut SlideApp, _ctx: &egui::Context, dialog: &mut HostedParamDialog) {
|
||||
let files = app.host.files();
|
||||
for action in dialog.take_actions() {
|
||||
let actions = dialog.take_actions();
|
||||
eprintln!("DIAG create_inserts_the_album_in_one_step: each_pass actions {actions:?} pick {:?}", app.dialogs.album_pick.is_some());
|
||||
for action in actions {
|
||||
if action == "addPictures" && app.dialogs.album_pick.is_none() {
|
||||
if files.can_pick() {
|
||||
app.dialogs.album_pick = Some(files.pick(PickRequest::open_many("picture")));
|
||||
|
||||
@@ -147,7 +147,9 @@ impl AutoCorrectForm {
|
||||
Row::new().show(ui, |ui, _| {
|
||||
TextField::new(Word::plain("Replace"), Bind::bound(&mut *from)).show(ui);
|
||||
TextField::new(Word::plain("With"), Bind::bound(&mut *to)).show(ui);
|
||||
if Button::new(Word::plain("Add")).enabled(!from.trim().is_empty()).show(ui).clicks > 0 {
|
||||
let add = Button::new(Word::plain("Add")).enabled(!from.trim().is_empty()).show(ui).clicks;
|
||||
eprintln!("DIAG autocorrect_list_edits_survive_nested_and_preferences_cancel: from {from:?} add clicks {add}");
|
||||
if add > 0 {
|
||||
actions.push(json!({ "add": [from.trim(), to] }));
|
||||
from.clear();
|
||||
to.clear();
|
||||
@@ -414,6 +416,7 @@ pub(crate) fn open_autocorrect(app: &mut SlideApp, ctx: &Context, host: &mut Dia
|
||||
/// Applies live settings and restores opening values for every external or window Cancel path.
|
||||
pub(crate) fn pump(app: &mut SlideApp, _ctx: &Context, host: &mut DialogHost) {
|
||||
for action in host.take_actions(dialog_id("preferences")) {
|
||||
eprintln!("DIAG autocorrect_list_edits_survive_nested_and_preferences_cancel: action {action}");
|
||||
match app.run("text.autocorrect", action) {
|
||||
Ok(reply) => {
|
||||
if let Some(form) = host.get_mut::<PreferencesDialog>().and_then(|dialog| dialog.autocorrect.as_mut()) {
|
||||
|
||||
@@ -34,6 +34,7 @@ pub enum Target {
|
||||
/// Arms one pick-mode tool over a snapshot of the active slide.
|
||||
pub fn arm(app: &mut SlideApp, target: Target) {
|
||||
let Some(d) = app.session.active() else { return };
|
||||
eprintln!("DIAG set_transparent_color_takes_the_colour_clicked_in_the_picture: arm target {:?}", d.selection.target);
|
||||
if d.selection.target != deckcraft_engine::Target::Slides {
|
||||
app.set_status("The Eyedropper takes colours from a slide");
|
||||
return;
|
||||
@@ -68,6 +69,12 @@ pub fn after_pass(app: &mut SlideApp, ctx: &Context, mut tool: DropperTool<'stat
|
||||
// A press outside the canvas disarms, as production did.
|
||||
let outside =
|
||||
!armed.fresh && ctx.input(|i| i.pointer.primary_pressed() && i.pointer.hover_pos().is_some_and(|pos| !canvas_rect.contains(pos)));
|
||||
eprintln!(
|
||||
"DIAG set_transparent_color_takes_the_colour_clicked_in_the_picture: after_pass pass {} fresh {} outside {outside} ended {}",
|
||||
ctx.current_pass_index(),
|
||||
armed.fresh,
|
||||
tool.ended()
|
||||
);
|
||||
armed.fresh = false;
|
||||
if outside {
|
||||
ctx.request_repaint();
|
||||
|
||||
@@ -96,7 +96,7 @@ fn only_a_painted_fill_or_outline_stands_apart() {
|
||||
#[test]
|
||||
fn light_text_fields_show_in_dialogs_panes_and_the_ribbon() {
|
||||
let mut h = harness();
|
||||
h.state_mut().open_dialog("find-replace", json!({}));
|
||||
h.state_mut().run("app.find", json!({})).unwrap();
|
||||
h.run_steps(3);
|
||||
let tokens = craft::ui::runtime::env::Env::of_root(&h.ctx).tokens.clone();
|
||||
let raised = color(tokens.color.surface.raised);
|
||||
|
||||
@@ -66,7 +66,9 @@ fn japanese_conversion_shows_the_active_part() {
|
||||
let mut h = harness(Session::with_new());
|
||||
let title = h.state().session.active().unwrap().doc.slides[0].shapes[0].id.0;
|
||||
h.state_mut().run("text.edit", json!({"id": title})).unwrap();
|
||||
h.run_steps(1);
|
||||
// The platform composes only after a frame's output turned the input method on.
|
||||
h.run_steps(2);
|
||||
assert!(h.output().platform_output.ime.is_some());
|
||||
let undo = undo_len(h.state());
|
||||
let converted = "日本ご";
|
||||
h.event(Event::Ime(ImeEvent::Preedit { text: converted.into(), active_range_chars: Some(2..3) }));
|
||||
|
||||
@@ -55,6 +55,11 @@ fn pick_hex(h: &mut Harness<'_, SlideApp>, button: &str, hex: &str) {
|
||||
h.run_steps(2);
|
||||
}
|
||||
h.run_steps(2);
|
||||
eprintln!(
|
||||
"DIAG shape_pattern_fill_keeps_preset_and_system_colors: opener {button} at {opener:?} hex fields {} openers {}",
|
||||
h.query_all_by_label("More Colors…").count(),
|
||||
h.query_all_by_role_and_label(Role::Button, button).count()
|
||||
);
|
||||
h.get_by_role_and_label(Role::TextInput, "More Colors…").click();
|
||||
h.run_steps(1);
|
||||
for pressed in [true, false] {
|
||||
|
||||
Reference in New Issue
Block a user