Merge branch 'port/deckcraft/red/app-r3-3' into port/deckcraft/area/app

# Conflicts:
#	crates/ui-egui/src/canvas/text_host.rs
This commit is contained in:
Dylan M. Taylor
2026-11-27 18:36:27 +00:00
6 changed files with 21 additions and 25 deletions
-1
View File
@@ -146,7 +146,6 @@ impl SlideApp {
catalog_generation,
injected_target: None,
twist_frame: None,
text_focus_asked: None,
clock: Default::default(),
root: RootEnv::new(),
#[cfg(not(target_arch = "wasm32"))]
-5
View File
@@ -156,11 +156,6 @@ fn empty_bullet_preview_follows_click_type_enter_and_toggle() {
h.run_steps(3);
let second = caret(&h);
assert!((first.x - second.x).abs() < 0.01, "empty lines retain the bullet indent");
eprintln!(
"DIAG empty_bullet_preview_follows_click_type_enter_and_toggle: first {first:?} second {second:?} caret {:?} para count {:?}",
h.state().session.active().unwrap().selection.text.as_ref().map(|t| t.caret),
h.state().session.active().unwrap().shapes().iter().find(|s| s.id == id).map(|s| format!("{:?}", s.kind).len())
);
assert!(second.y > first.y);
let st = h.state().session.active().unwrap();
let ts = st.selection.text.as_ref().unwrap();
+21 -16
View File
@@ -7,8 +7,10 @@ use craft::text::ui::editor::{
};
use craft::ui::canvas::CanvasSpace;
use craft::ui::contract::{Bind, Props as _, Show as _};
use craft::ui::runtime::focus::FocusRequest;
use craft::ui::runtime::{env::with_env, focus};
use craft::ui::runtime::{
env::with_env,
focus::{self, FocusRequest},
};
use deckcraft_engine::{Session, TextReplaceKind, TextSel, cmd::text};
use deckcraft_geom::Affine;
use deckcraft_model::text::TextBody;
@@ -309,34 +311,37 @@ 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.
/// 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> {
if crate::dialogs::modal_open(ui.ctx()) || app.palette_open || app.backstage_open() {
return None;
}
let state = app.session.active()?;
let Some(target) = state.selection.text.as_ref().filter(|target| !target.notes).cloned() else {
app.text_focus_asked = None;
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 target = app.session.active().and_then(|state| {
let target = state.selection.text.as_ref().filter(|target| !target.notes)?;
Some((state.uid, target.clone()))
});
let (Some((uid, target)), false) = (target, blocked) else {
ui.data_mut(|data| data.remove_temp::<egui::Id>(shown));
return None;
};
let id = ui.make_persistent_id(("slide-text-editor", state.uid, target.shape, target.cell));
let id = ui.make_persistent_id(("slide-text-editor", uid, target.shape, target.cell));
if focus::focused_rec(ui.ctx())
.is_some_and(|record| record.stop.id != id && record.stop.text && !record.stop.keys.is_document_editor())
{
return None;
}
let fresh = app.text_focus_asked != Some(id);
app.text_focus_asked = Some(id);
if let Err(error) = app.session.begin_text_edit_session() {
app.set_status(error.to_string());
return None;
}
let mut host = EngineTextHost::new(&mut app.session, target);
let Some(bounds) = host.bounds(space) else {
return None;
};
let bounds = host.bounds(space)?;
let mut selection = host.offsets.selection(&host.target);
let editor = TextEditor::new("Text", &mut host, Bind::bound(&mut selection)).id(id).click_runs(ClickRuns::Paragraphs);
let editor = if fresh { editor.request_focus(FocusRequest::Take) } else { editor };
let mut editor = TextEditor::new("Text", &mut host, Bind::bound(&mut selection)).id(id).click_runs(ClickRuns::Paragraphs);
if hosted != Some(id) {
editor = editor.request_focus(FocusRequest::Take);
}
ui.data_mut(|data| data.insert_temp(shown, id));
let output = if app.caret_blink == Some(false) {
with_env(ui, |env| env.motion = Some(MotionMode::Off), |ui| editor.show_at(ui, bounds))
} else {
@@ -310,7 +310,6 @@ fn append_picture(dialog: &mut HostedParamDialog, name: &str, bytes: &[u8], tota
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() {
eprintln!("DIAG create_inserts_the_album_in_one_step: action {action} pick={:?} can_pick={}", app.dialogs.album_pick, files.can_pick());
if action == "addPictures" && app.dialogs.album_pick.is_none() {
if files.can_pick() {
app.dialogs.album_pick = Some(files.pick(PickRequest::open_many("picture")));
@@ -414,7 +414,6 @@ 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()) {
-1
View File
@@ -145,7 +145,6 @@ pub struct SlideApp {
twist_frame: Option<u64>,
/// The slide text editor that already asked for the keyboard; it asks once per edit session, so a
/// later click on a ribbon control keeps its focus.
text_focus_asked: Option<egui::Id>,
clock: craft::platform::clock::Clock,
/// The token-size configuration keeps one identity across frames.
root: craft::ui::runtime::env::RootEnv,