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

This commit is contained in:
Dylan M. Taylor committed 2026-11-27 18:36:07 +00:00
commit 0cb3a2e2fd
7 files changed
+52 -36

No files matched your search

+1
View File
@@ -146,6 +146,7 @@ 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"))]
+1 -2
View File
@@ -355,12 +355,11 @@ impl SlideApp {
return;
}
let id = edit_command_of(&fired.command.id);
super::keys::diag(format_args!("fire {} source={:?} phase={:?} pasted={}", fired.command.id, fired.source, fired.phase, fired.pasted.is_some()));
if self.session.active().is_none() && !START_SCREEN.contains(&id) {
return;
}
// The File view covers the slide: its keys edit nothing behind it.
if fired.source == FireSource::Key && self.backstage_open() && id.starts_with("edit.") {
if fired.source == FireSource::Key && self.backstage_open() && (id.starts_with("edit.") || id.starts_with("text.")) {
return;
}
if fired.source == FireSource::Palette {
+1 -20
View File
@@ -1,4 +1,4 @@
use super::{Mods, SlideApp, qat};
use super::{Mods, SlideApp};
use craft::keymap::{Chord, Key, Mods as KeyMods};
use craft::ui::runtime::focus;
use craft::ui::runtime::keys::{Intent, with_window_intents};
@@ -40,21 +40,10 @@ impl SlideApp {
if crate::dialogs::modal_open(ctx) || self.palette_open || self.backstage_open() {
break;
}
diag(format_args!("keyboard event {event:?} focus={}", focus::has_any(ctx)));
match event {
egui::Event::Key { key, pressed: true, modifiers, .. } => {
let mods =
Mods { shift: modifiers.shift, alt: modifiers.alt, cmd: modifiers.command || (!self.session.mac_keys && modifiers.ctrl) };
if !self.session.mac_keys
&& !mods.cmd
&& !mods.shift
&& mods.alt
&& self.session.active().is_some_and(|d| d.selection.text.is_none())
&& let Some(index) = QAT_CLAIMS.iter().position(|chord| chord.to_egui_shortcut().logical_key == key)
{
qat::run_index(self, index);
continue;
}
if key == egui::Key::Tab && !focus::has_any(ctx) {
// The slide has the keyboard, so Tab is ours (indent, tab character, next
// shape). Left to egui it would also focus the first ribbon widget, and
@@ -88,14 +77,6 @@ impl SlideApp {
}
}
/// Temporary: prints `what` for the running test, in the form `diag-cut.py` reads.
pub(crate) fn diag(what: std::fmt::Arguments<'_>) {
let thread = std::thread::current();
if let Some(test) = thread.name().and_then(|name| name.strip_prefix("tests::")) {
eprintln!("DIAG {test}: {what}");
}
}
/// Engine key name for an egui key.
pub fn key_name(key: egui::Key) -> &'static str {
use egui::Key::*;
-7
View File
@@ -61,12 +61,6 @@ pub(crate) fn show(app: &mut SlideApp, ui: &mut Ui) {
} else {
&fit[..]
};
let claims = if !app.session.mac_keys && !app.backstage_open() && app.session.active().is_some_and(|st| st.selection.text.is_none()) {
// PLAN: assumed pub(crate) use keys::QAT_CLAIMS (shell-w11)
crate::app::QAT_CLAIMS
} else {
&[]
};
let strips = (app.ui.ruler && !app.anim_preview_active()).then(|| rulers::rulers(app)).flatten();
let canvas_id = ui.scope_id().with("slide_canvas");
let mut canvas = Canvas::new(Word::plain("Slide canvas"))
@@ -76,7 +70,6 @@ pub(crate) fn show(app: &mut SlideApp, ui: &mut Ui) {
.navigation(navigation())
.queued(queued)
.keys_to_body(true)
.key_claims(claims)
.with_rulers(strips)
.rulers(rulers::ruler_text(app.session.prefs.units), rulers::ruler_text(app.session.prefs.units));
if jumped {
+5 -4
View File
@@ -7,6 +7,7 @@ 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 deckcraft_engine::{Session, TextReplaceKind, TextSel, cmd::text};
use deckcraft_geom::Affine;
@@ -310,32 +311,32 @@ 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.
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() {
eprintln!("DIAG korean_composes_in_a_slide_text_box: blocked modal={} palette={} backstage={}", 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 {
eprintln!("DIAG korean_composes_in_a_slide_text_box: no text target");
app.text_focus_asked = None;
return None;
};
let id = ui.make_persistent_id(("slide-text-editor", state.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())
{
eprintln!("DIAG korean_composes_in_a_slide_text_box: another text stop owns focus");
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 {
eprintln!("DIAG korean_composes_in_a_slide_text_box: no bounds, frame={}", host.frame.is_some());
return None;
};
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 output = if app.caret_blink == Some(false) {
with_env(ui, |env| env.motion = Some(MotionMode::Off), |ui| editor.show_at(ui, bounds))
} else {
+41 -3
View File
@@ -37,6 +37,28 @@ const SLIDE_KEYS: &[Chord] = &[
Chord::new(KeyMods::NONE, Key::PageDown),
];
/// `base` followed by the quick access chords: Alt+digit runs a slot wherever the slide has the keys.
const fn with_quick_access<const N: usize>(base: &[Chord]) -> [Chord; N] {
let slots = crate::app::QAT_CLAIMS;
assert!(N == base.len() + slots.len());
let mut out = [slots[0]; N];
let mut at = 0;
while at < base.len() {
out[at] = base[at];
at += 1;
}
let mut slot = 0;
while slot < slots.len() {
out[base.len() + slot] = slots[slot];
slot += 1;
}
out
}
static FINISH_KEYS_QAT: [Chord; 11] = with_quick_access(FINISH_KEYS);
static SHAPE_KEYS_QAT: [Chord; 15] = with_quick_access(SHAPE_KEYS);
static SLIDE_KEYS_QAT: [Chord; 17] = with_quick_access(SLIDE_KEYS);
/// The engine pointer tool used by the editor canvas.
pub(crate) struct EngineTool<'a> {
app: &'a mut SlideApp,
@@ -133,16 +155,25 @@ impl<'a> EngineTool<'a> {
fn contextual_keys(&self) -> &'static [Chord] {
let Some(st) = self.app.session.active() else { return &[] };
// Alt+digit slots belong to the Windows-style keys; on a Mac the digits are the app's own chords.
let slots = !self.app.session.mac_keys;
if st.selection.text.is_some() || self.blocked() || self.app.anim_preview_active() {
&[]
} else if self.app.session.tool.drawing_freeform() || self.app.session.tool.editing_points(st).is_some() {
FINISH_KEYS
if slots { &FINISH_KEYS_QAT[..] } else { FINISH_KEYS }
} else if st.selection.shapes.is_empty() {
SLIDE_KEYS
if slots { &SLIDE_KEYS_QAT[..] } else { SLIDE_KEYS }
} else if slots {
&SHAPE_KEYS_QAT[..]
} else {
SHAPE_KEYS
}
}
fn deletes_shapes(&self) -> bool {
let keys = self.contextual_keys();
keys == SHAPE_KEYS || keys == &SHAPE_KEYS_QAT[..]
}
}
impl CanvasTool for EngineTool<'_> {
@@ -248,7 +279,7 @@ impl CanvasTool for EngineTool<'_> {
return ToolClaims::NONE;
}
let claims = ToolClaims::NONE.keys(keys).nudges();
if keys == SHAPE_KEYS { claims.deletes() } else { claims }
if self.deletes_shapes() { claims.deletes() } else { claims }
}
fn key(&mut self, key: &ToolKey, cx: &mut ToolContext<'_>) -> bool {
@@ -256,6 +287,13 @@ impl CanvasTool for EngineTool<'_> {
if claims.keys.is_empty() {
return false;
}
if let ToolKey::Kept(chord) = key
&& claims.keys.contains(chord)
&& let Some(slot) = crate::app::QAT_CLAIMS.iter().position(|claimed| claimed == chord)
{
self.end_twist();
return crate::qat::run_index(self.app, slot);
}
let (name, mods) = match key {
ToolKey::Submit => ("Enter", cx.mods),
ToolKey::Cancel if claims.keys.contains(&Chord::new(KeyMods::NONE, Key::Escape)) => ("Escape", cx.mods),
+3
View File
@@ -143,6 +143,9 @@ pub struct SlideApp {
/// The frame a trackpad twist last turned the selection in; a repeat pass of that frame carries no
/// twist and must not end the gesture.
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,