mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-01 10:47:56 +01:00
Merge production main, shell area: port side for the minimal-port plumbing, production's fixes kept
- Cargo.toml, deckcraft-web and ui-egui Cargo.toml: the port's craft-libs and egui pins and the craft facade; production's craft-host/keymap/theme/window and craft-web-api/web-host lines dropped. - desktop main.rs: the port's runtime install and hooks; production's macOS refusal fix (refusal_dialog and its test) kept. - web.rs, app.rs, app/input.rs, app/keys.rs, canvas.rs, canvas/context_menu.rs, eyedropper.rs, lib.rs, menus.rs, opening.rs, settings.rs, show/ui.rs, sorter.rs, status.rs: the port's code; production's framework.rs and document_focus modules are no longer declared (the framework canvas, window intents and QAT claims cover them). - model chart.rs: production's comment for the ? placeholders. - show/frames.rs: an audio icon with Hide During Show stays hidden while it plays (#1659), through MediaClip::hidden_during_show. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3b6ce8298c
commit
0274166b8f
20 files changed
+1
-2057
No files matched your search
-56
@@ -12,7 +12,6 @@ repository = "https://github.com/storytold/deckcraft"
|
||||
|
||||
[workspace.dependencies]
|
||||
# OPC part-name primitives and package reader/writer.
|
||||
<<<<<<< HEAD
|
||||
craft-opc = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "0.1.0" }
|
||||
# Compound File Binary directory reads (password-protected deck detection).
|
||||
craft-cfb = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "0.1.0" }
|
||||
@@ -26,19 +25,6 @@ craft-pptx = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c
|
||||
craft = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "0.1.0" }
|
||||
# Shared MCP stdio framing and protocol constants (craft-libs#778).
|
||||
craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "0.1.0" }
|
||||
=======
|
||||
craft-opc = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" }
|
||||
# Compound File Binary directory reads (password-protected deck detection).
|
||||
craft-cfb = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" }
|
||||
# Bounded XML reader and writer primitives.
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" }
|
||||
# DrawingML colours, themes, charts, tables and text (craft-libs#778, #792).
|
||||
craft-drawingml = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" }
|
||||
# PresentationML PPTX/POTX/PPSX reader and writer (craft-libs#778).
|
||||
craft-pptx = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" }
|
||||
# Shared MCP stdio framing and protocol constants (craft-libs#778).
|
||||
craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" }
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
# internal
|
||||
deckcraft-geom = { path = "crates/geom" }
|
||||
deckcraft-color = { path = "crates/color" }
|
||||
@@ -78,7 +64,6 @@ vello_cpu = "0.2"
|
||||
vello_common = { version = "0.2", default-features = false }
|
||||
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "webp", "gif", "tiff", "bmp"] }
|
||||
# Base64 for command payloads (engine); base64_compat keeps the legacy lenient decoder. Same rev as craft-deckcraft-format.
|
||||
<<<<<<< HEAD
|
||||
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
# craft-media, craft-audio and craft-video share types and stay on one rev.
|
||||
# The .deckcraft package layer (identity, manifest, member names, bounded reads); crates/format maps the presentation onto it.
|
||||
@@ -94,29 +79,6 @@ craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c8
|
||||
# craft-update: app-specific pretend versions apply to startup and manual checks.
|
||||
craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", features = ["ui"] }
|
||||
craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
=======
|
||||
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" }
|
||||
# craft-media, craft-audio and craft-video share types and stay on one rev.
|
||||
# The .deckcraft package layer (identity, manifest, member names, bounded reads); crates/format maps the presentation onto it.
|
||||
craft-deckcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" }
|
||||
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" }
|
||||
craft-media = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0", default-features = false }
|
||||
craft-audio = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0", default-features = false, features = ["opus-decode"] }
|
||||
# H.264, HEVC, VP9 and AV1 decoders.
|
||||
craft-video = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0", default-features = false, features = ["h264-decode", "hevc-decode", "vp9-decode", "av1-decode", "threads"] }
|
||||
# WMF, EMF and EMF+ reader.
|
||||
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0", default-features = false, features = ["write", "write-simple-text"] }
|
||||
# craft-update: app-specific pretend versions apply to startup and manual checks.
|
||||
craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", features = ["ui"] }
|
||||
craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" }
|
||||
# The framework runtime's host: the app's identity, its window services, its key overrides and the theme mode
|
||||
# the framework's components draw in.
|
||||
craft-host = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" }
|
||||
craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" }
|
||||
craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" }
|
||||
craft-window = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.1.0" }
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
i_overlay = "9"
|
||||
quick-xml = "0.41"
|
||||
zip = { version = "3", default-features = false, features = ["deflate"] }
|
||||
@@ -161,7 +123,6 @@ codegen-units = 16
|
||||
debug = 0
|
||||
|
||||
[patch.crates-io]
|
||||
<<<<<<< HEAD
|
||||
# BEGIN port-kit framework overrides
|
||||
krilla = { path = "../craft-libs/vendor/krilla" }
|
||||
hayro = { path = "../craft-libs/vendor/hayro" }
|
||||
@@ -187,23 +148,6 @@ egui_system_font_provider = { path = "../egui/crates/egui_system_font_provider"
|
||||
eframe = { path = "../egui/crates/eframe" }
|
||||
egui_demo_lib = { path = "../egui/crates/egui_demo_lib" }
|
||||
egui_inspection = { path = "../egui/crates/egui_inspection" }
|
||||
=======
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "=0.8.2" }
|
||||
ecolor = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
emath = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
epaint = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui-winit = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui_glow = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui_extras = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
eframe = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" }
|
||||
# END port-kit framework overrides
|
||||
# port-kit overridden: krilla = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.8.2" }
|
||||
|
||||
@@ -17,13 +17,6 @@ path = "src/main.rs"
|
||||
craft = { workspace = true, features = ["ui", "automation", "window", "settings", "font-catalog"] }
|
||||
deckcraft-engine = { workspace = true }
|
||||
deckcraft-ui-egui = { workspace = true }
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
# The page command API (storytold/craft-libs#413): window.deckcraft over the control channel.
|
||||
craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" }
|
||||
# The host messages (storytold/craft-libs): one contract and one bridge for the web builds.
|
||||
craft-web-host = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" }
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
egui = { workspace = true }
|
||||
log = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
@@ -58,7 +58,6 @@ pub fn start() {
|
||||
if let Some(rs) = &cc.wgpu_render_state {
|
||||
log::info!("deckcraft-web {}: wgpu backend {:?}", env!("CARGO_PKG_VERSION"), rs.adapter.get_info().backend);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
let shell_info = ShellInfo::default();
|
||||
let repaint = cc.egui_ctx.clone();
|
||||
let install = InstallSpec::new(shell_info, Arc::new(SystemWindows))
|
||||
@@ -86,18 +85,6 @@ pub fn start() {
|
||||
frame: Frame::Native,
|
||||
at_exit: None,
|
||||
};
|
||||
=======
|
||||
deckcraft_ui_egui::install_ime_pass_hooks(&cc.egui_ctx);
|
||||
// The presenter popup draws DeckCraft's presenter view only, with no framework component, so
|
||||
// it runs without the framework runtime.
|
||||
if let Some(token) = crate::presenter::token() {
|
||||
let presenter = crate::presenter::Popup::new(token, cc.egui_ctx.clone()).map_err(std::io::Error::other)?;
|
||||
return Ok(Box::new(presenter) as Box<dyn eframe::App>);
|
||||
}
|
||||
deckcraft_ui_egui::framework::install_headless(&cc.egui_ctx);
|
||||
let inbox: Inbox = Inbox::default();
|
||||
let mut services = services(inbox.clone(), cc.egui_ctx.clone());
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
if let Some(bridge) = &app_bridge {
|
||||
bridge.listen(cc.egui_ctx.clone());
|
||||
}
|
||||
@@ -187,7 +174,6 @@ impl eframe::App for WebShell {
|
||||
bridge.open_files(&mut self.app);
|
||||
}
|
||||
self.app.logic(ctx);
|
||||
self.app.close_path(ctx);
|
||||
if let Some(bridge) = &self.bridge {
|
||||
bridge.report_dirty(&self.app);
|
||||
}
|
||||
@@ -222,7 +208,6 @@ impl eframe::App for WebShell {
|
||||
});
|
||||
}
|
||||
self.app.raw_input_hook(ctx, raw);
|
||||
self.app.before_input(ctx);
|
||||
}
|
||||
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
|
||||
@@ -62,19 +62,11 @@ struct App {
|
||||
|
||||
impl eframe::App for App {
|
||||
fn logic(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
<<<<<<< HEAD
|
||||
self.app.logic(ctx);
|
||||
=======
|
||||
#[cfg(target_os = "macos")]
|
||||
apple_events::poll(&self.1, &mut self.0, ctx);
|
||||
self.0.logic(ctx);
|
||||
self.0.close_path(ctx);
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
}
|
||||
/// Forward native raw input to the wrapped application once per frame, then hand the framework
|
||||
/// runtime this frame's root values.
|
||||
fn raw_input_hook(&mut self, ctx: &egui::Context, raw: &mut egui::RawInput) {
|
||||
<<<<<<< HEAD
|
||||
// egui-winit's WindowEvent::Focused arm emits WindowFocused. Only this pass's events
|
||||
// trigger a refresh; a second pass with no input cannot repeat the activation.
|
||||
if raw.events.iter().any(|event| matches!(event, egui::Event::WindowFocused(true))) {
|
||||
@@ -87,14 +79,6 @@ impl eframe::App for App {
|
||||
embed::before_ui(ui.ctx(), frame);
|
||||
self.app.ui(ui);
|
||||
self.panels.pump(Some(frame));
|
||||
=======
|
||||
self.0.raw_input_hook(ctx, raw);
|
||||
self.0.before_input(ctx);
|
||||
}
|
||||
fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame) {
|
||||
deckcraft_ui_egui::framework::before_ui(ui.ctx(), &*frame);
|
||||
self.0.ui(ui);
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
}
|
||||
fn on_exit(&mut self) {
|
||||
self.app.leave();
|
||||
@@ -351,14 +335,6 @@ fn main() -> eframe::Result {
|
||||
Backend::from_env()
|
||||
}
|
||||
};
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// `Default` lets winit choose, and winit takes Wayland whenever `WAYLAND_DISPLAY` is set.
|
||||
#[cfg(not(all(unix, not(target_os = "macos"))))]
|
||||
let x11 = false;
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
let native_wayland = !x11 && std::env::var_os("WAYLAND_DISPLAY").is_some_and(|w| !w.is_empty());
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
#[cfg(not(all(unix, not(target_os = "macos"))))]
|
||||
let backend = Backend::from_env();
|
||||
let decision = decide_for(PREFIX, backend, if cfg!(target_os = "macos") { TitleBarPref::Integrated } else { TitleBarPref::System });
|
||||
@@ -410,7 +386,6 @@ fn main() -> eframe::Result {
|
||||
deckcraft_ui_egui::os_window::name_for(deckcraft_ui_egui::os_window::identity()),
|
||||
options,
|
||||
Box::new(move |cc| {
|
||||
<<<<<<< HEAD
|
||||
let ctx = &cc.egui_ctx;
|
||||
let _ = context.set(ctx.clone());
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd", target_os = "dragonfly"))]
|
||||
@@ -451,15 +426,6 @@ fn main() -> eframe::Result {
|
||||
}
|
||||
Err(error) => log::error!("control server: {error}"),
|
||||
}
|
||||
=======
|
||||
deckcraft_ui_egui::framework::install(&cc.egui_ctx, x11)?;
|
||||
deckcraft_ui_egui::install_ime_pass_hooks(&cc.egui_ctx);
|
||||
let mut app = SlideApp::new(Session::new(), services);
|
||||
// Presenter View asks winit how many displays there are when a show starts.
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
if let Some(window) = cc.winit_window().cloned() {
|
||||
app.services.displays = Some(Box::new(move || display_count(&window)));
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
}
|
||||
let mut app = SlideApp::new(ctx, platform)?;
|
||||
if !nightly {
|
||||
|
||||
@@ -1181,11 +1181,7 @@ mod tests {
|
||||
c.y_format = Some(r#"_-* #\ ##0\ "₽"_-;\-* #\ ##0\ "₽"_-;_-* "-"??\ "₽"_-;_-@_-"#.into());
|
||||
c.lang = Some("ru-RU".into());
|
||||
assert_eq!(c.axis_label(false, 800_000.0), "800\u{a0}000 ₽");
|
||||
<<<<<<< HEAD
|
||||
// The zero section `"-"??\ "₽"`: each `?` shows an insignificant zero as a digit-wide space (ECMA-376 §18.8.31).
|
||||
=======
|
||||
// Excel shows each `?` of the zero section as a space.
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
assert_eq!(c.axis_label(false, 0.0), "- ₽");
|
||||
// No format: General.
|
||||
assert_eq!(c.axis_label(true, 2.5), "2,5");
|
||||
|
||||
@@ -21,16 +21,7 @@ deckcraft-anim = { workspace = true }
|
||||
deckcraft-engine = { workspace = true }
|
||||
deckcraft-media = { workspace = true }
|
||||
egui = { workspace = true, features = ["default_fonts", "monochrome_emoji_fonts"] }
|
||||
<<<<<<< HEAD
|
||||
ttf-parser = "0.25"
|
||||
=======
|
||||
egui_extras = { workspace = true }
|
||||
craft-ui = { workspace = true }
|
||||
craft-host = { workspace = true }
|
||||
craft-keymap = { workspace = true }
|
||||
craft-theme = { workspace = true }
|
||||
craft-window = { workspace = true }
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
log = { workspace = true }
|
||||
|
||||
@@ -19,21 +19,14 @@ use craft::ui::shell::{AppShell, PageKind, Slot, SlotSize, embed};
|
||||
mod clipboard;
|
||||
mod commands;
|
||||
mod control;
|
||||
mod document_focus;
|
||||
pub(crate) mod files;
|
||||
mod frame;
|
||||
mod input;
|
||||
mod keys;
|
||||
mod playback;
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub(crate) use commands::GRID_SPACING_RANGE;
|
||||
pub(crate) use files::FileOperation;
|
||||
=======
|
||||
#[cfg(test)]
|
||||
pub(crate) use clipboard::{OBJECTS_MARKER, system_clipboard_text};
|
||||
pub(crate) use document_focus::DocumentFocus;
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
#[cfg(test)]
|
||||
pub(crate) use files::web_image_files;
|
||||
pub(crate) use keys::QAT_CLAIMS;
|
||||
@@ -193,51 +186,17 @@ impl SlideApp {
|
||||
status: None,
|
||||
opening: None,
|
||||
fonts_noted: Default::default(),
|
||||
<<<<<<< HEAD
|
||||
perf: Perf { frame_ms: 0.0, render_ms: 0.0 },
|
||||
=======
|
||||
perf: Perf { frame_ms: 0.0, render_ms: 0.0, fps: 0.0 },
|
||||
synthetic: vec![],
|
||||
synthetic_pending: false,
|
||||
synthetic_next: vec![],
|
||||
synthetic_next_target: None,
|
||||
synthetic_injected: vec![],
|
||||
synthetic_injected_at: None,
|
||||
synthetic_generation: 0,
|
||||
synthetic_target: None,
|
||||
synthetic_focus: None,
|
||||
document_focus: DocumentFocus::default(),
|
||||
synthetic_injected_time: None,
|
||||
ribbon_scroll: HashMap::new(),
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
show_instance: 0,
|
||||
eyedropper: None,
|
||||
integrated_titlebar: !matches!(frame, craft::window::policy::Frame::Native),
|
||||
backstage: None,
|
||||
pending_urls: Vec::new(),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
<<<<<<< HEAD
|
||||
print_previews: Default::default(),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
updates_rt: Default::default(),
|
||||
selpane: Default::default(),
|
||||
=======
|
||||
updates_rt: updates_ui::Runtime::default(),
|
||||
framework_dialogs: craft_ui::dialog::DialogHost::new(),
|
||||
framework_host: crate::framework::host(),
|
||||
pending_copy: None,
|
||||
capture: capture::Capture::default(),
|
||||
styled: false,
|
||||
restyle: true,
|
||||
fonts_ready: false,
|
||||
last_time: 0.0,
|
||||
last_recovery: 0.0,
|
||||
quit_confirmed: false,
|
||||
notes_buf: (0, usize::MAX, notes::Draft::default()),
|
||||
ui_fonts: uifonts::UiFonts::default(),
|
||||
thumb_drag: None,
|
||||
selpane: selpane::State::default(),
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
align_to: None,
|
||||
doc_window: None,
|
||||
sorter: Default::default(),
|
||||
@@ -422,24 +381,7 @@ impl SlideApp {
|
||||
self.poll_opening();
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
updates_ui::tick(self, ctx);
|
||||
<<<<<<< HEAD
|
||||
self.take_file_answers();
|
||||
=======
|
||||
// Inbox results are host file bytes and do not need fonts or a painted frame. A
|
||||
// window that starts hidden must still apply a file picked before its first UI pass.
|
||||
self.drain_inbox();
|
||||
}
|
||||
self.drain_screenshots();
|
||||
// `raw_input_hook` ran before this logic pass. This is normally a no-op now that
|
||||
// target-changing work is deferred for a live batch; it still covers a target change
|
||||
// made by other logic, and keeps a logic-only batch pending for the next hook.
|
||||
self.retract_synthetic_after_logic(ctx);
|
||||
// Queued/settling screenshots force the bounded hidden paints they need; issued ones
|
||||
// rely on the screenshot command and the completion callback, with only a deadline wake.
|
||||
self.capture.request_paint_if_needed(ctx, web_time::Instant::now());
|
||||
if !self.synthetic.is_empty() || !self.synthetic_next.is_empty() || self.synthetic_pending {
|
||||
ctx.request_repaint();
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
}
|
||||
self.autosave_if_due(ctx);
|
||||
self.tick_media_clock(ctx);
|
||||
@@ -459,35 +401,7 @@ impl SlideApp {
|
||||
if !Self::root_viewport_admitted(&ctx) {
|
||||
return;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
let started = craft::platform::clock::monotonic_ms();
|
||||
=======
|
||||
self.ui_inner(ui);
|
||||
// The last writer (all panels, dialogs, the custom producer and deferred child windows)
|
||||
// has run. Observe the actual custom descriptor for this pass, then reconcile the reset
|
||||
// lifetime against the actual committed output. This also runs for discarded passes.
|
||||
self.ime_frame_viewport = Some(ctx.viewport_id());
|
||||
let custom = self.observe_ime(&ctx);
|
||||
self.finalize_ime_reset(&ctx, custom);
|
||||
}
|
||||
|
||||
/// Run the admitted root UI pass, including setup gating, panels, canvas, dialogs, overlays, and
|
||||
/// show mode.
|
||||
fn ui_inner(&mut self, ui: &mut egui::Ui) {
|
||||
let ctx = ui.ctx().clone();
|
||||
self.ime_frame_viewport = Some(ctx.viewport_id());
|
||||
self.ime_pending = None;
|
||||
let document_before = self.document_focus.drawn.take();
|
||||
if !self.ui_setup(&ctx) {
|
||||
// This pass is discarded for the new fonts. The input events were already consumed
|
||||
// by egui, so keep them queued for the next frame instead of silently losing them.
|
||||
self.requeue_injected_synthetic();
|
||||
return;
|
||||
}
|
||||
let t0 = now_ms();
|
||||
let t = theme::Tokens::get(&ctx);
|
||||
self.note_ui_text(&ctx);
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
self.media.sync_video_textures(&ctx);
|
||||
self.sync_backstage();
|
||||
self.keyboard(&ctx);
|
||||
@@ -516,7 +430,6 @@ impl SlideApp {
|
||||
} else {
|
||||
backstage::page(app, ui, cx);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
app.shell_body_end(ui);
|
||||
})
|
||||
.page_kind(page_kind)
|
||||
@@ -576,18 +489,6 @@ impl SlideApp {
|
||||
self.set_status(format!("Could not save settings: {error}"));
|
||||
}
|
||||
self.notices.clone().show(ui);
|
||||
=======
|
||||
}
|
||||
});
|
||||
self.finish_document(&ctx, document_before);
|
||||
toast::note_missing_fonts(self);
|
||||
toast::show(self, &ctx);
|
||||
dialogs::show(self, &ctx);
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
updates_ui::show(self, &ctx);
|
||||
self.framework_dialogs.run(ui);
|
||||
menus::palette(self, &ctx);
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
for url in std::mem::take(&mut self.pending_urls) {
|
||||
ctx.open_url(egui::OpenUrl::new_tab(url));
|
||||
}
|
||||
|
||||
@@ -47,222 +47,5 @@ impl SlideApp {
|
||||
host.withdraw_injected(host.current());
|
||||
self.injected_target = None;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
self.synthetic.push(event);
|
||||
}
|
||||
|
||||
/// Events admitted by the control channel but not yet injected (including a batch waiting
|
||||
/// behind the one currently in flight).
|
||||
pub(crate) fn synthetic_queued_len(&self) -> usize {
|
||||
self.synthetic.len() + self.synthetic_next.len()
|
||||
}
|
||||
|
||||
/// Forget the injected or queued synthetic batch and everything recorded about it. Events
|
||||
/// waiting in `synthetic_next` are a separate, newer batch and are promoted by the caller.
|
||||
fn clear_synthetic_batch(&mut self) {
|
||||
self.synthetic.clear();
|
||||
self.synthetic_pending = false;
|
||||
self.synthetic_injected.clear();
|
||||
self.synthetic_injected_at = None;
|
||||
self.synthetic_injected_time = None;
|
||||
self.synthetic_target = None;
|
||||
self.synthetic_focus = None;
|
||||
}
|
||||
|
||||
/// Start the batch that was queued behind an older one once the older batch is gone.
|
||||
pub(super) fn promote_next_synthetic(&mut self) {
|
||||
if self.synthetic_pending || !self.synthetic.is_empty() || self.synthetic_next.is_empty() {
|
||||
return;
|
||||
}
|
||||
self.synthetic = std::mem::take(&mut self.synthetic_next);
|
||||
self.synthetic_target = self.synthetic_next_target.take();
|
||||
self.synthetic_focus = None;
|
||||
}
|
||||
|
||||
/// A font/layout pass will be discarded: egui already consumed the injected events but the
|
||||
/// app deliberately lays nothing out, so put them back at the head of the queue. The next
|
||||
/// frame injects them again after the new fonts are installed; otherwise a control click that
|
||||
/// happened to arrive on the very first frame would be acknowledged without ever reaching the
|
||||
/// UI.
|
||||
pub(super) fn requeue_injected_synthetic(&mut self) {
|
||||
if !self.synthetic_pending {
|
||||
return;
|
||||
}
|
||||
let mut combined = std::mem::take(&mut self.synthetic_injected);
|
||||
combined.append(&mut self.synthetic);
|
||||
self.synthetic = combined;
|
||||
self.synthetic_pending = false;
|
||||
self.synthetic_injected_at = None;
|
||||
self.synthetic_injected_time = None;
|
||||
self.synthetic_focus = None;
|
||||
if self.synthetic.is_empty() {
|
||||
self.synthetic_target = None;
|
||||
self.promote_next_synthetic();
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove exactly the recorded synthetic events from `events`. The recorded index is tried
|
||||
/// first so an identical host event earlier in the batch is never removed; the last exact
|
||||
/// match is only a fallback for a raw input that was rewritten around the events.
|
||||
fn drain_synthetic_from(&self, events: &mut Vec<egui::Event>) -> bool {
|
||||
let injected = &self.synthetic_injected;
|
||||
let n = injected.len();
|
||||
if n == 0 {
|
||||
return false;
|
||||
}
|
||||
let exact = self.synthetic_injected_at.filter(|start| events.get(*start..*start + n).is_some_and(|w| w == injected.as_slice()));
|
||||
let at = exact.or_else(|| events.windows(n).rposition(|w| w == injected.as_slice()));
|
||||
if let Some(at) = at {
|
||||
events.drain(at..at + n);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// Drop an injected batch whose document, canvas, focus or modal owner changed during
|
||||
/// `logic`. eframe calls `raw_input_hook` before `App::logic`, so a control request drained
|
||||
/// there can still retarget the same `RawInput`.
|
||||
///
|
||||
/// This must not infer the pass phase from `ViewportInfo::visible()`: a visible root can run
|
||||
/// logic-only (an overdue redraw), and a hidden root can run a full pass for a screenshot or
|
||||
/// `RequestPaintWhileHidden`. A logic-only callback leaves `InputState` from the *previous*
|
||||
/// pass; remove the batch only when the live input carries exactly what this pass injected
|
||||
/// (same `RawInput::time` and the exact recorded event window). Otherwise keep the pending
|
||||
/// bookkeeping so the next `raw_input_hook` can retract the events from the carried
|
||||
/// `RawInput` before eframe delivers them in a full pass.
|
||||
pub(super) fn retract_synthetic_after_logic(&mut self, ctx: &egui::Context) {
|
||||
if !self.synthetic_pending {
|
||||
return;
|
||||
}
|
||||
let current = self.input_target();
|
||||
let focus = crate::framework::focused_widget(ctx);
|
||||
if self.synthetic_target == Some(current) && focus == self.synthetic_focus {
|
||||
return;
|
||||
}
|
||||
let injected_time = self.synthetic_injected_time;
|
||||
let mut removed = false;
|
||||
ctx.input_mut(|i| {
|
||||
// A logic-only call keeps the previous pass's `InputState`; its `raw.time` is not the
|
||||
// time of the RawInput this batch was injected into. Never drain an older batch that
|
||||
// happens to look similar.
|
||||
if i.raw.time != injected_time {
|
||||
return;
|
||||
}
|
||||
let mut events = std::mem::take(&mut i.events);
|
||||
let ok = self.drain_synthetic_from(&mut events);
|
||||
i.events = events;
|
||||
if ok {
|
||||
// Keep `InputState::raw` consistent with what UI code reads as `events`.
|
||||
let mut raw_events = std::mem::take(&mut i.raw.events);
|
||||
let _ = self.drain_synthetic_from(&mut raw_events);
|
||||
i.raw.events = raw_events;
|
||||
removed = true;
|
||||
}
|
||||
});
|
||||
if removed {
|
||||
self.clear_synthetic_batch();
|
||||
self.promote_next_synthetic();
|
||||
} else {
|
||||
// Logic-only (or a pass whose input does not contain the batch): the events are in
|
||||
// eframe's carried RawInput. Keep `synthetic_pending`, `synthetic_injected` and the
|
||||
// stale target so the next hook retracts them there. Events queued after the batch
|
||||
// belong to the same stale target as well.
|
||||
self.synthetic.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// True when the pending synthetic batch is in this pass's live `InputState`, i.e. this is
|
||||
/// the full pass the batch was admitted for and egui has already derived pointer/key state
|
||||
/// from it. A logic-only callback leaves the previous pass's `InputState` (with another
|
||||
/// `raw.time`) and must not be mistaken for the live pass, so control/background work is
|
||||
/// still drained there and the next `raw_input_hook` retracts a batch that went stale.
|
||||
pub(super) fn synthetic_batch_is_live(&self, ctx: &egui::Context) -> bool {
|
||||
if !self.synthetic_pending || self.synthetic_injected.is_empty() {
|
||||
return false;
|
||||
}
|
||||
let Some(injected_time) = self.synthetic_injected_time else { return false };
|
||||
let injected = &self.synthetic_injected;
|
||||
ctx.input(|i| i.raw.time == Some(injected_time) && i.events.windows(injected.len()).any(|w| w == injected.as_slice()))
|
||||
}
|
||||
|
||||
/// Input that belongs to the pass about to run: native dropped files and one synthetic
|
||||
/// control-channel batch. The synthetic batch is injected at most once; while it is
|
||||
/// unacknowledged, later passes cannot replay it. A document, canvas, focus or modal change
|
||||
/// drops the whole queued batch rather than typing into the wrong place.
|
||||
///
|
||||
/// The hook always injects into the `RawInput`; it does not try to guess whether eframe will
|
||||
/// run this as a full or a logic-only pass. `run_logic` does not consume events but eframe
|
||||
/// carries the whole `RawInput` into the next full pass, so an already-injected batch is
|
||||
/// retracted at the next hook if a control request changed the target, and otherwise is
|
||||
/// delivered exactly once in the next real UI pass. `ViewportInfo::visible()` is not a phase
|
||||
/// signal: a hidden root still gets a full pass for a screenshot or `RequestPaintWhileHidden`.
|
||||
pub fn raw_input_hook(&mut self, ctx: &egui::Context, raw: &mut egui::RawInput) {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
for f in std::mem::take(&mut raw.dropped_files) {
|
||||
let name = f.path().file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_else(|| "dropped file".into());
|
||||
match f.bytes() {
|
||||
Ok(bytes) => self.open_or_insert_bytes(&name, &bytes),
|
||||
Err(e) => self.set_status(e),
|
||||
}
|
||||
}
|
||||
let focus = crate::framework::focused_widget(ctx);
|
||||
if self.synthetic_pending {
|
||||
let current = self.input_target();
|
||||
if self.synthetic_target != Some(current) || focus != self.synthetic_focus {
|
||||
// eframe keeps the whole RawInput from a logic-only pass in `pending_raw_input`
|
||||
// and appends the next host input to it. The events are already in `raw.events`;
|
||||
// clearing only the unsent queue would still deliver the stale click or key into
|
||||
// the new document on the next full pass. Retract exactly the batch we appended.
|
||||
let _ = self.drain_synthetic_from(&mut raw.events);
|
||||
self.clear_synthetic_batch();
|
||||
// New control input queued for the current target while the stale batch was in
|
||||
// flight is a separate batch; keep it instead of clearing it with the old one.
|
||||
self.promote_next_synthetic();
|
||||
} else {
|
||||
// This RawInput is the carrier for the next pass, and eframe refreshes its time
|
||||
// on every call. Record the current time so `retract_synthetic_after_logic` can
|
||||
// tell this full pass's live `InputState` from a logic-only callback's stale one.
|
||||
self.synthetic_injected_time = raw.time;
|
||||
}
|
||||
}
|
||||
if self.synthetic_pending || self.synthetic.is_empty() {
|
||||
return;
|
||||
}
|
||||
let current = self.input_target();
|
||||
if self.synthetic_target != Some(current) {
|
||||
// The batch was queued for a document/slide/canvas that has since changed.
|
||||
self.synthetic.clear();
|
||||
self.synthetic_target = None;
|
||||
self.promote_next_synthetic();
|
||||
if self.synthetic.is_empty() {
|
||||
return;
|
||||
}
|
||||
if self.synthetic_target != Some(current) {
|
||||
// The newer batch is stale too: drop it rather than delivering it to this target.
|
||||
self.synthetic.clear();
|
||||
self.synthetic_target = None;
|
||||
self.synthetic_next.clear();
|
||||
self.synthetic_next_target = None;
|
||||
return;
|
||||
}
|
||||
}
|
||||
self.synthetic_generation = self.synthetic_generation.wrapping_add(1).max(1);
|
||||
log::debug!("injecting synthetic input batch {}", self.synthetic_generation);
|
||||
let n = match self.synthetic.first() {
|
||||
Some(egui::Event::PointerMoved(_) | egui::Event::PointerButton { .. }) => 1,
|
||||
_ => self.synthetic.iter().position(|e| matches!(e, egui::Event::Key { pressed: false, .. })).map_or(self.synthetic.len(), |i| i + 1),
|
||||
};
|
||||
let n = n.min(self.synthetic.len());
|
||||
let batch: Vec<egui::Event> = self.synthetic.drain(..n).collect();
|
||||
let at = raw.events.len();
|
||||
raw.events.extend(batch.iter().cloned());
|
||||
self.synthetic_injected = batch;
|
||||
self.synthetic_injected_at = Some(at);
|
||||
self.synthetic_injected_time = raw.time;
|
||||
self.synthetic_pending = true;
|
||||
self.synthetic_focus = focus;
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
use super::SlideApp;
|
||||
use craft::keymap::{Chord, Key, Mods as KeyMods};
|
||||
use craft::ui::runtime::focus;
|
||||
@@ -31,74 +30,6 @@ impl SlideApp {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
=======
|
||||
use super::clipboard::OBJECTS_MARKER;
|
||||
use super::{Mods, SlideApp, Value, backstage, json, menus};
|
||||
use crate::framework::widget_has_keyboard;
|
||||
|
||||
impl SlideApp {
|
||||
/// The app shortcuts that still make sense on the empty File/start screen: create, open,
|
||||
/// the command palette, preferences and the File tab itself. Document commands (save, find,
|
||||
/// hyperlink, show, zoom) stay out; none of them can act on a presentation that is not open.
|
||||
fn start_screen_shortcut(key: egui::Key, m: Mods) -> bool {
|
||||
use egui::Key::*;
|
||||
matches!(
|
||||
(key, m.cmd, m.shift, m.alt),
|
||||
(O, true, false, false) | (P, true, true, false) | (Comma, true, false, false) | (F, false, false, true)
|
||||
)
|
||||
}
|
||||
|
||||
/// File-tab navigation and document-free shortcuts, also used on the start screen.
|
||||
fn route_backstage_keys(&mut self, events: Vec<egui::Event>) {
|
||||
if self.backstage.is_none() {
|
||||
return;
|
||||
}
|
||||
// The File tab: its own keys (Esc goes back, arrows walk the side menu) and app
|
||||
// shortcuts (New, Open, Command Palette…); typing, pasting or deleting would edit the
|
||||
// hidden presentation.
|
||||
let start_screen = self.session.active().is_none();
|
||||
for e in events {
|
||||
if let egui::Event::Key { key, pressed: true, modifiers, .. } = e {
|
||||
let mods = Mods { shift: modifiers.shift, alt: modifiers.alt, cmd: modifiers.command || modifiers.ctrl };
|
||||
let handled = backstage::key(self, key, mods)
|
||||
// With no presentation the File home only owns the shortcuts that create or
|
||||
// open one. Borrowing the whole document shortcut table here would also arm
|
||||
// Save/Save As, hyperlink, find/replace, show and zoom against the empty
|
||||
// start screen, which is a scope expansion no editing route needs.
|
||||
|| (mods.cmd || mods.alt)
|
||||
&& (!start_screen || Self::start_screen_shortcut(key, mods))
|
||||
&& menus::ui_shortcut(self, key, mods);
|
||||
if handled {
|
||||
continue;
|
||||
}
|
||||
// Engine shortcuts that don't touch the hidden slide (Ctrl+N).
|
||||
if mods.cmd
|
||||
&& matches!(key, egui::Key::N)
|
||||
&& let Err(e) = self.session.key(key_name(key), mods)
|
||||
{
|
||||
self.set_status(e.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Keyboard and clipboard for the slide (with nothing or the document window focused).
|
||||
pub(super) fn keyboard(&mut self, ctx: &egui::Context) {
|
||||
let mut events = ctx.input(|i| i.events.clone());
|
||||
if crate::framework::window_escape(ctx) {
|
||||
events.push(crate::framework::ESCAPE_PRESS);
|
||||
}
|
||||
// Ctrl+V with only an image on the clipboard: egui-winit sends no Paste event and swallows the
|
||||
// key press, so the release of a V press never seen is the paste. Tracked even while a text
|
||||
// field has focus, so that a V typed there is not taken for one.
|
||||
let mut image_paste = false;
|
||||
let mut pasted_image_event = false;
|
||||
for e in &events {
|
||||
match e {
|
||||
egui::Event::PasteImage(_) => {
|
||||
pasted_image_event = true;
|
||||
self.v_seen = true;
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -118,63 +49,10 @@ impl SlideApp {
|
||||
// every key after it would go there instead of the slide (#78).
|
||||
ctx.memory_mut(|m| m.move_focus(egui::FocusDirection::None));
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
// egui 0.37 carries a clipboard image as its own event; it inserts once.
|
||||
egui::Event::PasteImage(image) if !focus::has_any(ctx) => {
|
||||
if let Err(error) = self.paste_picture(&image) {
|
||||
self.set_status(error);
|
||||
=======
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let viewport = self.ime_viewport_or(ctx);
|
||||
if self.session.active().is_none() {
|
||||
// No document: keep slide-editing input suspended, while the start screen's
|
||||
// File-tab navigation and document-free shortcuts remain available.
|
||||
self.suspend_ime_reset(viewport);
|
||||
self.route_ime_controls_only(ctx, &events);
|
||||
if self.palette.is_none() && self.dialog.as_ref().is_none_or(|d| !d.modal()) && !widget_has_keyboard(ctx) {
|
||||
self.route_backstage_keys(events);
|
||||
}
|
||||
self.drain_requests();
|
||||
return;
|
||||
}
|
||||
let modal = self.dialog.as_ref().is_some_and(|d| d.modal()) || self.palette.is_some();
|
||||
self.edited_text_takes_focus(ctx);
|
||||
if widget_has_keyboard(ctx) || modal {
|
||||
// A stock field/modal/palette owns input now. Retire the custom fence, then visit
|
||||
// controls in raw order; stock text/key events are left for the stock widgets.
|
||||
self.suspend_ime_reset(viewport);
|
||||
self.route_ime_controls_only(ctx, &events);
|
||||
return;
|
||||
}
|
||||
if self.backstage.is_some() {
|
||||
self.suspend_ime_reset(viewport);
|
||||
self.route_ime_controls_only(ctx, &events);
|
||||
self.route_backstage_keys(events);
|
||||
self.drain_requests();
|
||||
return;
|
||||
}
|
||||
let img = if image_paste { self.services.clipboard_image.as_mut().and_then(|f| f()) } else { None };
|
||||
if let Some(png) = img {
|
||||
let data = deckcraft_engine::cmd::base64_encode(&png);
|
||||
if let Err(e) = self.session.execute("insert.picture", &json!({"name": "Pasted image.png", "data": data})) {
|
||||
self.set_status(e.to_string());
|
||||
}
|
||||
}
|
||||
for e in events {
|
||||
// An earlier command in this raw batch may have settled the composition. Request the
|
||||
// replacement at this ordered boundary, before the current event is considered.
|
||||
self.note_settled_composition(ctx);
|
||||
match e {
|
||||
egui::Event::ImeResetCompleted { request_id } => self.ime_reset_completed(request_id, ctx),
|
||||
egui::Event::PasteImage(image) => match color_image_png(&image) {
|
||||
Ok(png) => {
|
||||
let params = json!({"name": "Pasted image.png", "data": deckcraft_engine::cmd::base64_encode(&png)});
|
||||
if let Err(e) = self.session.execute("insert.picture", ¶ms) {
|
||||
self.set_status(e.to_string());
|
||||
}
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
}
|
||||
}
|
||||
egui::Event::Text(text) if !focus::has_any(ctx) => {
|
||||
@@ -184,7 +62,6 @@ impl SlideApp {
|
||||
self.set_status(error.to_string());
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
// The canvas composes for a selected shape (`text_host::show_selection_ime`): the first preedit starts
|
||||
// editing it, and the framework editor takes the composition from there. A commit or deletion with
|
||||
// nothing edited is a stale one and must not replace the shape's text.
|
||||
@@ -193,59 +70,6 @@ impl SlideApp {
|
||||
&& let Err(error) = self.session.compose_text(&text, active_range_chars.map(|range| (range.start, range.end)))
|
||||
{
|
||||
self.set_status(error.to_string());
|
||||
=======
|
||||
egui::Event::Ime(ime) => self.ime_event(ctx, &ime),
|
||||
egui::Event::Copy => self.publish_clipboard(ctx, false),
|
||||
egui::Event::Cut => self.publish_clipboard(ctx, true),
|
||||
egui::Event::Paste(text) => {
|
||||
// Our own marker for objects without text: paste what the session copied.
|
||||
let text = if text == OBJECTS_MARKER { String::new() } else { text };
|
||||
// A picture (TIFF from Keynote, a screenshot) lands when the paste has no text.
|
||||
// Text keeps its HTML (bold, italic, underline) when the host can read it.
|
||||
let html = self.services.clipboard_html.as_mut().and_then(|f| f()).filter(|h| !h.is_empty());
|
||||
// egui 0.37 sends `PasteImage` directly; the services fallback stays for
|
||||
// integrations that still send an empty `Paste`, and for a browser's Copy
|
||||
// Image, whose text is only the picture's link. Never insert twice.
|
||||
let wants_picture = text.is_empty() || super::clipboard::names_a_picture(&text, html.as_deref());
|
||||
let img = if wants_picture && !pasted_image_event { self.services.clipboard_image.as_mut().and_then(|f| f()) } else { None };
|
||||
let revision = self.session.active().map(|d| d.revision);
|
||||
let r = match img {
|
||||
Some(png) => self
|
||||
.session
|
||||
.execute("insert.picture", &json!({"name": "Pasted image.png", "data": deckcraft_engine::cmd::base64_encode(&png)})),
|
||||
None => {
|
||||
let mut params = json!({"text": text});
|
||||
if let Some(h) = html {
|
||||
params["html"] = Value::String(h);
|
||||
}
|
||||
self.session.execute("edit.paste", ¶ms)
|
||||
}
|
||||
};
|
||||
if let Err(e) = r {
|
||||
self.set_status(e.to_string());
|
||||
}
|
||||
if self.session.active().map(|d| d.revision) != revision {
|
||||
self.note_application_edit(ctx);
|
||||
}
|
||||
}
|
||||
egui::Event::Key { key, pressed: true, modifiers, .. } => {
|
||||
if key == egui::Key::Escape && self.anim_preview.is_some() && !modifiers.command && !modifiers.ctrl && !modifiers.alt {
|
||||
self.anim_preview = None;
|
||||
continue;
|
||||
}
|
||||
let mods = Mods { shift: modifiers.shift, alt: modifiers.alt, cmd: modifiers.command || modifiers.ctrl };
|
||||
if !self.session.tool.drawing_freeform() && menus::ui_shortcut(self, key, mods) {
|
||||
continue;
|
||||
}
|
||||
let name = key_name(key);
|
||||
let revision = self.session.active().map(|d| d.revision);
|
||||
match self.session.key(name, mods) {
|
||||
Ok(_) => {}
|
||||
Err(e) => self.set_status(e.to_string()),
|
||||
}
|
||||
if self.session.active().map(|d| d.revision) != revision {
|
||||
self.note_application_edit(ctx);
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
||||
@@ -37,7 +37,6 @@ fn navigation() -> NavigationOptions {
|
||||
navigation
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
/// Shows the slide picture, its controls and the engine's canvas tool in paint order.
|
||||
pub(crate) fn show(app: &mut SlideApp, ui: &mut Ui) {
|
||||
let Some(st) = app.session.active() else { return };
|
||||
@@ -50,202 +49,6 @@ pub(crate) fn show(app: &mut SlideApp, ui: &mut Ui) {
|
||||
ui.set_clip_rect(ui.clip_rect().intersect(room));
|
||||
let env = Env::of(ui);
|
||||
let scheme = env.get::<ZoomScheme>();
|
||||
=======
|
||||
impl Xf {
|
||||
pub fn to_screen(&self, p: Point) -> Pos2 {
|
||||
pos2(self.origin.x + p.x as f32 * self.scale, self.origin.y + p.y as f32 * self.scale)
|
||||
}
|
||||
pub fn to_slide(&self, p: Pos2) -> Point {
|
||||
Point::new(((p.x - self.origin.x) / self.scale) as f64, ((p.y - self.origin.y) / self.scale) as f64)
|
||||
}
|
||||
}
|
||||
|
||||
fn mods(ui: &Ui) -> Mods {
|
||||
ui.input(|i| Mods { shift: i.modifiers.shift, alt: i.modifiers.alt, cmd: i.modifiers.command || i.modifiers.ctrl })
|
||||
}
|
||||
|
||||
/// The slide's rect on screen for the current zoom.
|
||||
pub fn layout(app: &SlideApp, avail: Rect) -> (Rect, f32) {
|
||||
let Some(d) = app.session.active() else { return (avail, 1.0) };
|
||||
let page = deckcraft_engine::page_size(d);
|
||||
// Loaded sizes are repaired; a zero or non-finite side would still make the fit infinite.
|
||||
let side = |v: f64| if v.is_finite() { (v as f32).max(1.0) } else { 1.0 };
|
||||
let (sw, sh) = (side(page.width), side(page.height));
|
||||
let margin = 28.0;
|
||||
let fit = ((avail.width() - margin * 2.0) / sw).min((avail.height() - margin * 2.0) / sh).max(0.05);
|
||||
// A zoom from outside the editor's own controls (settings, the control protocol) is kept in range.
|
||||
let scale = app.ui.zoom.filter(|z| z.is_finite() && *z > 0.0).map_or(fit, |z| z.clamp(*crate::ZOOM_RANGE.start(), *crate::ZOOM_RANGE.end()));
|
||||
let size = vec2(sw * scale, sh * scale);
|
||||
let mut r = Rect::from_center_size(avail.center(), size);
|
||||
if size.x > avail.width() {
|
||||
r = Rect::from_min_size(pos2(avail.min.x + margin, r.min.y), size);
|
||||
}
|
||||
if size.y > avail.height() {
|
||||
r = Rect::from_min_size(pos2(r.min.x, avail.min.y + margin), size);
|
||||
}
|
||||
(r, scale)
|
||||
}
|
||||
|
||||
/// The mouse wheel or a trackpad flick turns slides when the canvas has nothing to scroll.
|
||||
fn wheel_navigation(app: &mut SlideApp, ui: &mut Ui, carry_id: egui::Id, doc_uid: u64) {
|
||||
if app.anim_preview_active() || app.session.tool.marquee.is_some() || app.session.tool.dragging() {
|
||||
return;
|
||||
}
|
||||
let (_, mut carry): (u64, f32) = ui.data_mut(|d| d.get_temp(carry_id).unwrap_or_default());
|
||||
let wheel_step = app.session.active().and_then(|d| {
|
||||
let current = d.selection.slide;
|
||||
ui.input(|i| wheel_slide_target(&i.events, current, d.doc.slides.len(), &mut carry)).map(|target| (current, target))
|
||||
});
|
||||
ui.data_mut(|d| d.insert_temp(carry_id, (doc_uid, carry)));
|
||||
if let Some((current, index)) = wheel_step {
|
||||
if index != current {
|
||||
let _ = app.run("slide.go", json!({"index": index}));
|
||||
}
|
||||
} else if let Some(next) = page_flick(ui.input(|i| trackpad_scroll(&i.events))) {
|
||||
// Point-based trackpad gestures keep their cooldown. Raw input avoids reading
|
||||
// the smoothed tail of a discrete mouse notch as another page turn.
|
||||
let gate = ui.scope_id().with("wheel_gate");
|
||||
let last: f64 = ui.data_mut(|d| d.get_temp(gate).unwrap_or(f64::NEG_INFINITY));
|
||||
let now = ui.input(|i| i.time);
|
||||
if now - last > 0.35 {
|
||||
ui.data_mut(|d| d.insert_temp(gate, now));
|
||||
let _ = app.run(if next { "slide.next" } else { "slide.previous" }, json!({}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn empty_deck_prompt(app: &mut SlideApp, ui: &mut Ui, avail: Rect, t: &Tokens) {
|
||||
ui.advance_cursor_after_rect(avail);
|
||||
let resp = app.document_widget(ui, avail, Sense::click());
|
||||
ui.painter().text(avail.center(), Align2::CENTER_CENTER, "Click to add first slide", theme::font(22.0), t.text_dim);
|
||||
// Enter on the focused document is the session's New Slide, not a click of the prompt.
|
||||
if resp.clicked_by(egui::PointerButton::Primary) || ui.input(|i| i.has_accesskit_action_request(resp.id, egui::accesskit::Action::Click)) {
|
||||
let _ = app.run("slide.new", json!({"layout": "title"}));
|
||||
}
|
||||
}
|
||||
|
||||
fn reset_wheel_carry(ui: &Ui, carry_id: egui::Id, doc_uid: u64) {
|
||||
ui.data_mut(|d| {
|
||||
if d.get_temp::<(u64, f32)>(carry_id).is_none_or(|(uid, _)| uid != doc_uid) {
|
||||
d.insert_temp(carry_id, (doc_uid, 0.0_f32));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// The scroll offset that keeps the slide point under `pointer` (or the canvas middle) fixed
|
||||
/// when the scale changed since the last frame.
|
||||
fn anchored_offset(last: Option<(Rect, f32)>, content_rect: Rect, scale: f32, pointer: Option<Pos2>, avail: Rect) -> Option<egui::Vec2> {
|
||||
let (last_rect, last_scale) = last?;
|
||||
if (scale - last_scale).abs() <= 1e-6 {
|
||||
return None;
|
||||
}
|
||||
let anchor = pointer.unwrap_or(avail.center());
|
||||
let at = (anchor - last_rect.min) / last_scale;
|
||||
Some(content_rect.min + at * scale - anchor)
|
||||
}
|
||||
|
||||
fn slide_gifs(app: &mut SlideApp, now: f64) -> Vec<crate::media::Gif> {
|
||||
match app.session.active() {
|
||||
Some(d) if d.selection.target == Target::Slides => app.media.gifs(d.uid, &d.doc, d.selection.slide, now, &app.session.gif_paused),
|
||||
_ => vec![],
|
||||
}
|
||||
}
|
||||
|
||||
/// Paint the editing canvas, including rulers, selection handles, overlays, and current
|
||||
/// zoom/scroll state.
|
||||
pub fn show(app: &mut SlideApp, ui: &mut Ui) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let avail = ui.available_rect_before_wrap();
|
||||
app.canvas_rect = Some(avail);
|
||||
// The notes pane and the panes beside the canvas are editor chrome over it: nothing the
|
||||
// canvas paints or hit-tests (the media bar hangs 6 pt below its clip, handles stick out of a
|
||||
// shape, scroll bars) may reach into them. The parent's clip still covers the whole central
|
||||
// area, so clip this `Ui` to the rect the canvas was given (#1922).
|
||||
ui.set_clip_rect(avail.intersect(ui.clip_rect()));
|
||||
let Some(st) = app.session.active() else { return };
|
||||
// The leftover fraction of a wheel line belongs to one presentation. Drop it whenever another
|
||||
// one is drawn here, hovered or not, so switching away and back starts from zero.
|
||||
let carry_id = ui.scope_id().with("wheel_carry");
|
||||
let doc_uid = st.uid;
|
||||
reset_wheel_carry(ui, carry_id, doc_uid);
|
||||
if st.doc.slides.is_empty() && st.selection.target == Target::Slides {
|
||||
empty_deck_prompt(app, ui, avail, &t);
|
||||
return;
|
||||
}
|
||||
// Scroll when zoomed beyond the window.
|
||||
let scroll_id = ui.scope_id().with("canvas_scroll");
|
||||
let last_id = scroll_id.with("last");
|
||||
let mut offset: egui::Vec2 = ui.data_mut(|d| d.get_temp(scroll_id).unwrap_or_default());
|
||||
let last: Option<(Rect, f32)> = ui.data_mut(|d| d.get_temp(last_id));
|
||||
ui.advance_cursor_after_rect(avail);
|
||||
let resp = app.document_widget(ui, avail, Sense::click_and_drag());
|
||||
let (wheel, zoom_delta, hover) = ui.input(|i| (i.smooth_scroll_delta, i.zoom_delta(), i.pointer.hover_pos()));
|
||||
let zooming = resp.hovered() && (zoom_delta - 1.0).abs() > 1e-3;
|
||||
if zooming {
|
||||
let cur = app.ui.zoom.unwrap_or_else(|| layout(app, avail).1);
|
||||
app.ui.zoom = Some((cur * zoom_delta).clamp(0.1, 4.0));
|
||||
}
|
||||
let (content_rect, scale) = layout(app, avail);
|
||||
// A new zoom keeps the slide point under the pointer (wheel, pinch) or under the middle of the
|
||||
// canvas (Zoom In/Out, the slider) where it was, instead of growing from the corner (#106).
|
||||
if let Some(o) = anchored_offset(last, content_rect, scale, zooming.then_some(hover).flatten(), avail) {
|
||||
offset = o;
|
||||
}
|
||||
let overflow = vec2((content_rect.width() + 56.0 - avail.width()).max(0.0), (content_rect.height() + 56.0 - avail.height()).max(0.0));
|
||||
// Scroll bars on the axes that overflow (#1157). They sit over the canvas edge and take their
|
||||
// presses before the slide does; the rulers keep their strips.
|
||||
let inset = if app.ui.ruler { 16.0 } else { 0.0 };
|
||||
let mut on_bar = false;
|
||||
let mut bar_active = [false; 2];
|
||||
for axis in 0..2 {
|
||||
let Some((track, thumb, travel)) = scroll_bar(avail, inset, overflow, offset, axis) else { continue };
|
||||
let bar_id = scroll_id.with(("bar", axis));
|
||||
let bar = ui.interact(track, bar_id, Sense::click_and_drag());
|
||||
on_bar |= bar.hovered();
|
||||
bar_active[axis] = bar.hovered() || bar.dragged();
|
||||
// Where the button went down and the offset then: egui calls a press a click until it
|
||||
// moves 6 pt, so the release point can't tell the thumb from the track, and drag_delta
|
||||
// misses those first points.
|
||||
let grab_id = bar_id.with("grab");
|
||||
if bar.is_pointer_button_down_on()
|
||||
&& let Some(origin) = ui.input(|i| i.pointer.primary_pressed().then(|| i.pointer.press_origin()).flatten())
|
||||
{
|
||||
ui.data_mut(|d| d.insert_temp(grab_id, (origin, offset[axis])));
|
||||
}
|
||||
let grab: Option<(Pos2, f32)> = ui.data_mut(|d| d.get_temp(grab_id));
|
||||
if let Some((origin, start)) = grab {
|
||||
if bar.dragged_by(egui::PointerButton::Primary)
|
||||
&& travel > 0.0
|
||||
&& let Some(p) = bar.interact_pointer_pos()
|
||||
{
|
||||
if last.is_some_and(|(_, s)| (scale - s).abs() > 1e-6) {
|
||||
// A zoom during the drag moved the slide about its anchor: carry on from there.
|
||||
ui.data_mut(|d| d.insert_temp(grab_id, (p, offset[axis])));
|
||||
} else {
|
||||
offset[axis] = start + (p[axis] - origin[axis]) * overflow[axis] / travel;
|
||||
}
|
||||
} else if bar.clicked() && !thumb.contains(origin) {
|
||||
// A click on the track beside the thumb moves one window's length toward it.
|
||||
let page = avail.size()[axis] * 0.9;
|
||||
offset[axis] += if origin[axis] < thumb.min[axis] { -page } else { page };
|
||||
}
|
||||
if bar.drag_stopped() || bar.clicked() {
|
||||
ui.data_mut(|d| d.remove_temp::<(Pos2, f32)>(grab_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resp.hovered() || on_bar) && !zooming {
|
||||
if overflow != egui::Vec2::ZERO {
|
||||
offset -= wheel;
|
||||
} else {
|
||||
wheel_navigation(app, ui, carry_id, doc_uid);
|
||||
}
|
||||
}
|
||||
offset.x = offset.x.clamp(0.0, overflow.x);
|
||||
offset.y = offset.y.clamp(0.0, overflow.y);
|
||||
// On the physical pixel grid, so the slide texture is one texel per device pixel (#184). The
|
||||
// zoom anchor keeps the unsnapped rect, so snapping never accumulates into drift.
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
let ppp = ui.ctx().pixels_per_point();
|
||||
let mut view = app.canvas_view;
|
||||
let mut jumped = false;
|
||||
|
||||
@@ -25,7 +25,6 @@ pub(crate) fn show(app: &mut SlideApp, ui: &mut Ui, canvas: &Response, ask: Opti
|
||||
let view = app.canvas_view;
|
||||
app.squiggles.menu_word = app.session.active().and_then(|st| app.squiggles.word_at(st, view.to_doc(at), 4.0 / view.zoom));
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
let Some(menu) = &app.canvas_menu else { return };
|
||||
let at = menu.at;
|
||||
let mut open = true;
|
||||
@@ -33,14 +32,6 @@ pub(crate) fn show(app: &mut SlideApp, ui: &mut Ui, canvas: &Response, ask: Opti
|
||||
let editing = app.session.active().and_then(|st| app.session.tool.editing_points(st).and_then(|id| st.shape(id).cloned()));
|
||||
if let Some(shape) = editing {
|
||||
edit_points_menu(app, ui, &shape);
|
||||
=======
|
||||
// Real clicks only: with the canvas focused, egui's own context menu would close on Enter and Space.
|
||||
let open = if resp.secondary_clicked() { Some(true) } else { resp.clicked_by(egui::PointerButton::Primary).then_some(false) };
|
||||
egui::Popup::context_menu(resp).open_memory(open.map(egui::SetOpenCommand::Bool)).show(|ui| {
|
||||
let editing = app.session.active().and_then(|d| app.session.tool.editing_points(d).and_then(|id| d.shape(id).cloned()));
|
||||
if let Some(sh) = editing {
|
||||
edit_points_menu(app, ui, &sh);
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
return;
|
||||
}
|
||||
if let Some(word) = app.squiggles.menu_word.clone() {
|
||||
|
||||
@@ -39,42 +39,11 @@ pub fn arm(app: &mut SlideApp, target: Target) {
|
||||
return;
|
||||
}
|
||||
let slide = d.selection.slide;
|
||||
<<<<<<< HEAD
|
||||
let image = Arc::new(deckcraft_render::render_slide(&d.doc, slide, &deckcraft_render::RenderOpts { scale: SCALE, ..Default::default() }));
|
||||
let tool = DropperTool::new(move |[x, y]| {
|
||||
let (x, y) = (x * SCALE, y * SCALE);
|
||||
if !(0.0..f64::from(image.width)).contains(&x) || !(0.0..f64::from(image.height)).contains(&y) {
|
||||
return None;
|
||||
=======
|
||||
let image = deckcraft_render::render_slide(&d.doc, slide, &deckcraft_render::RenderOpts { scale: SCALE, ..Default::default() });
|
||||
app.eyedropper = Some(State { pick, slide, image });
|
||||
app.set_status(match pick {
|
||||
Pick::Menu(_) => "Eyedropper: click the slide (Esc cancels)",
|
||||
Pick::TransparentColor => "Set Transparent Color: click the colour in the picture (Esc cancels)",
|
||||
});
|
||||
}
|
||||
|
||||
fn hex(c: [u8; 4]) -> String {
|
||||
format!("{:02X}{:02X}{:02X}", c[0], c[1], c[2])
|
||||
}
|
||||
|
||||
/// The slide canvas while the Eyedropper waits: the pointer is a crosshair with the colour under it
|
||||
/// beside it, a real click takes it (Enter and Space are egui's fake clicks of the focused canvas). Returns true when it
|
||||
/// used the pointer (the tools get none).
|
||||
pub fn canvas(app: &mut SlideApp, ui: &Ui, resp: &egui::Response, xf: Xf) -> bool {
|
||||
let Some(state) = app.eyedropper.as_ref() else { return false };
|
||||
let escape = crate::framework::escape_pressed(ui.ctx());
|
||||
if escape || resp.secondary_clicked() {
|
||||
app.eyedropper = None;
|
||||
return true;
|
||||
}
|
||||
let Some(pos) = resp.hover_pos() else { return true };
|
||||
let on_slide = app.slide_rect.is_some_and(|r| r.contains(pos));
|
||||
if !on_slide {
|
||||
ui.ctx().set_cursor_icon(CursorIcon::NotAllowed);
|
||||
if resp.clicked_by(egui::PointerButton::Primary) {
|
||||
app.eyedropper = None;
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
}
|
||||
let [r, g, b, a] = image.straight_at(x as u32, y as u32)?.map(|channel| f32::from(channel) / 255.0);
|
||||
Some(Srgba::new(r, g, b, a))
|
||||
@@ -103,38 +72,12 @@ pub fn after_pass(app: &mut SlideApp, ctx: &Context, mut tool: DropperTool<'stat
|
||||
ctx.request_repaint();
|
||||
return;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
if let Some(([x, y], color)) = tool.take_at() {
|
||||
match armed.target {
|
||||
Target::Menu(key) => app.host_answers.push(HostAnswer::Eyedropper { key, color: color.with_alpha(1.0) }),
|
||||
Target::TransparentColor => {
|
||||
if let Err(error) = app.session.execute("picture.transparentColor", &serde_json::json!({"at": [x, y]})) {
|
||||
app.set_status(error.to_string());
|
||||
=======
|
||||
ui.ctx().set_cursor_icon(CursorIcon::Crosshair);
|
||||
let p = xf.to_slide(pos);
|
||||
let under = state.image.straight_at((p.x * SCALE).max(0.0) as u32, (p.y * SCALE).max(0.0) as u32);
|
||||
if let Some(c) = under {
|
||||
loupe(ui, pos, c);
|
||||
}
|
||||
if resp.clicked_by(egui::PointerButton::Primary) {
|
||||
let (pick, slide) = (state.pick, state.slide);
|
||||
app.eyedropper = None;
|
||||
match pick {
|
||||
Pick::Menu(menu) => {
|
||||
match app.session.execute("slide.colorAt", &serde_json::json!({"slide": slide, "x": p.x, "y": p.y, "scale": SCALE})) {
|
||||
Ok(v) => {
|
||||
if let Some(color) = v["color"].as_str() {
|
||||
store_result(ui.ctx(), menu, color);
|
||||
}
|
||||
}
|
||||
Err(e) => app.set_status(e.to_string()),
|
||||
}
|
||||
}
|
||||
Pick::TransparentColor => {
|
||||
if let Err(e) = app.session.execute("picture.transparentColor", &serde_json::json!({"at": [p.x, p.y]})) {
|
||||
app.set_status(e.to_string());
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ pub mod dialogs;
|
||||
pub mod doc_window;
|
||||
pub mod eyedropper;
|
||||
pub mod flavor;
|
||||
pub mod framework;
|
||||
pub mod icons;
|
||||
pub mod media;
|
||||
pub mod menus;
|
||||
@@ -212,41 +211,6 @@ pub struct SlideApp {
|
||||
fonts_noted: std::collections::HashSet<u64>,
|
||||
/// Frame and picture rendering measurements.
|
||||
pub perf: Perf,
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
/// Synthetic input events (control channel `ui.click` etc.), injected one per frame.
|
||||
pub(crate) synthetic: Vec<egui::Event>,
|
||||
/// A synthetic batch has been injected but the UI pass has not acknowledged it. While this
|
||||
/// is set no second batch is injected, so a hidden/discarded frame cannot replay an event.
|
||||
synthetic_pending: bool,
|
||||
/// Events queued while an older batch is still pending. They belong to the target at the time
|
||||
/// they were queued, so a later document change cannot make them fall in behind the old batch
|
||||
/// and get cleared with it.
|
||||
synthetic_next: Vec<egui::Event>,
|
||||
synthetic_next_target: Option<InputTarget>,
|
||||
/// The exact events appended to the pending `RawInput`; retracted on a target change.
|
||||
synthetic_injected: Vec<egui::Event>,
|
||||
/// Where `synthetic_injected` was appended in `RawInput::events`. Retraction uses this
|
||||
/// index so an identical host event earlier in the batch is never removed instead.
|
||||
synthetic_injected_at: Option<usize>,
|
||||
/// Identity of the last injected synthetic batch (for diagnostics).
|
||||
synthetic_generation: u64,
|
||||
/// Document/slide/canvas identity the queued/injected batch belongs to.
|
||||
synthetic_target: Option<InputTarget>,
|
||||
/// Focus identity the pending batch was injected with (the document window counts as none); a focus change
|
||||
/// retracts it.
|
||||
synthetic_focus: Option<egui::Id>,
|
||||
/// The document window as a Tab stop, and when it takes the keyboard focus.
|
||||
document_focus: app::DocumentFocus,
|
||||
/// `RawInput::time` of the pass the batch was injected into. A logic-only callback leaves
|
||||
/// `InputState` from the previous pass; comparing this value keeps retraction from draining
|
||||
/// an unrelated batch out of that stale input.
|
||||
synthetic_injected_time: Option<f64>,
|
||||
/// Horizontal scroll offset (as `f32` bits) of each ribbon tab, recorded for
|
||||
/// [`InputTarget`]. Scroll state is per tab in egui, so the identity is too.
|
||||
ribbon_scroll: HashMap<String, u32>,
|
||||
/// Monotonic identity for a new slide show instance (`start_show`).
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
show_instance: u64,
|
||||
/// An eyedropper waiting for a sample from the slide.
|
||||
pub eyedropper: Option<eyedropper::Armed>,
|
||||
@@ -259,33 +223,7 @@ pub struct SlideApp {
|
||||
print_previews: craft::platform::temp::TempFiles,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
updates_rt: updates_ui::Runtime,
|
||||
<<<<<<< HEAD
|
||||
/// Selection pane: folded groups and the Shift-run anchor.
|
||||
=======
|
||||
/// The framework dialogs (the update prompt and check result), run once per pass after the
|
||||
/// app's own UI.
|
||||
pub framework_dialogs: craft_ui::dialog::DialogHost,
|
||||
/// Who DeckCraft is to the framework's dialogs.
|
||||
framework_host: std::sync::Arc<craft_host::Host>,
|
||||
/// Text for the system clipboard from a Copy or Cut command, handed over on the next frame.
|
||||
pending_copy: Option<String>,
|
||||
/// Bounded screenshot completion slots for the control channel (egui 0.37 callbacks).
|
||||
capture: capture::Capture,
|
||||
styled: bool,
|
||||
restyle: bool,
|
||||
fonts_ready: bool,
|
||||
last_time: f64,
|
||||
/// When AutoRecover data was last written (monotonic seconds, not wall time).
|
||||
pub last_recovery: f64,
|
||||
/// Quit was confirmed (changes saved or discarded): let the window close.
|
||||
pub quit_confirmed: bool,
|
||||
pub(crate) notes_buf: (u64, usize, notes::Draft),
|
||||
/// Faces borrowed from the font database for text the interface fonts can't draw (#101).
|
||||
pub ui_fonts: uifonts::UiFonts,
|
||||
/// Slide drag in the thumbnail pane or the Slide Sorter: the dragged slides and the drop gap.
|
||||
pub(crate) thumb_drag: Option<thumbs::SlideDrag>,
|
||||
/// Selection pane: folded groups, renaming, drag and drop.
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
pub selpane: selpane::State,
|
||||
pub(crate) align_to: Option<(Vec<deckcraft_model::ShapeId>, bool)>,
|
||||
/// The second document window, while open.
|
||||
@@ -310,12 +248,8 @@ mod collection_scroll_tests;
|
||||
#[cfg(test)]
|
||||
mod compare_tests;
|
||||
#[cfg(test)]
|
||||
<<<<<<< HEAD
|
||||
#[path = "datetime_tests.rs"]
|
||||
mod datetime_tests;
|
||||
=======
|
||||
mod document_focus_tests;
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
#[cfg(test)]
|
||||
mod eyedropper_tests;
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -11,215 +11,10 @@ pub(crate) fn palette_entries(session: &crate::Session) -> Vec<HelpEntry> {
|
||||
session
|
||||
.commands()
|
||||
.into_iter()
|
||||
<<<<<<< HEAD
|
||||
.filter(|row| row.enabled && !needs_arguments(row.params) && !UI_COMMANDS.iter().any(|ui| ui.label == row.label))
|
||||
.map(|row| HelpEntry::new(CommandRef::new(row.id), row.label).with_path(row.menu))
|
||||
.chain(UI_COMMANDS.iter().filter(|row| !needs_arguments(row.params)).map(|row| HelpEntry::new(CommandRef::new(row.id), row.label)))
|
||||
.collect()
|
||||
=======
|
||||
// Commands that need a path or other value fail when the palette runs them with `{}`.
|
||||
.filter(|c| c.enabled && !crate::UI_COMMANDS.iter().any(|u| u.1 == c.label) && !deckcraft_engine::cmd::needs_arguments(c.params))
|
||||
.map(|c| (c.id.to_string(), c.label.to_string(), c.shortcut))
|
||||
.chain(crate::UI_COMMANDS.iter().filter(|c| !deckcraft_engine::cmd::needs_arguments(c.3)).map(|c| (c.0.to_string(), c.1.to_string(), c.2)))
|
||||
.filter(|(id, label, _)| q.is_empty() || label.to_lowercase().contains(q) || id.to_lowercase().contains(q))
|
||||
.collect();
|
||||
items.sort_by_key(|(_, l, _)| !l.to_lowercase().starts_with(q));
|
||||
items.truncate(60);
|
||||
items
|
||||
}
|
||||
|
||||
/// ⇧⌘P: search every command by name and run it.
|
||||
pub fn palette(app: &mut SlideApp, ctx: &egui::Context) {
|
||||
let Some((mut query, mut sel)) = app.palette.take() else { return };
|
||||
let t = Tokens::get(ctx);
|
||||
let mut close = false;
|
||||
let mut run: Option<String> = None;
|
||||
egui::Window::new("command_palette")
|
||||
.title_bar(false)
|
||||
.anchor(egui::Align2::CENTER_TOP, egui::vec2(0.0, 90.0))
|
||||
.fixed_size(egui::vec2(520.0, 380.0))
|
||||
.show(ctx, |ui| {
|
||||
let r = ui.add(egui::TextEdit::singleline(&mut query).hint_text("Search commands…").desired_width(f32::INFINITY).font(theme::font(15.0)));
|
||||
r.request_focus();
|
||||
let q = query.to_lowercase();
|
||||
let items = palette_items(&app.session, &q);
|
||||
let (down, up, enter) =
|
||||
ui.input(|i| (i.key_pressed(egui::Key::ArrowDown), i.key_pressed(egui::Key::ArrowUp), i.key_pressed(egui::Key::Enter)));
|
||||
let esc = crate::framework::escape_pressed(ui.ctx());
|
||||
if down {
|
||||
sel = (sel + 1).min(items.len().saturating_sub(1));
|
||||
}
|
||||
if up {
|
||||
sel = sel.saturating_sub(1);
|
||||
}
|
||||
if esc {
|
||||
close = true;
|
||||
}
|
||||
if enter && let Some((id, ..)) = items.get(sel) {
|
||||
run = Some(id.clone());
|
||||
}
|
||||
egui::ScrollArea::vertical().max_height(320.0).show(ui, |ui| {
|
||||
for (k, (id, label, sc)) in items.iter().enumerate() {
|
||||
let r = ui.horizontal(|ui| {
|
||||
let resp = ui.selectable_label(k == sel, label);
|
||||
if let Some(s) = sc {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
ui.label(egui::RichText::new(crate::ribbon::pretty_shortcut(s)).color(t.text_faint));
|
||||
});
|
||||
}
|
||||
resp
|
||||
});
|
||||
if r.inner.clicked() {
|
||||
run = Some(id.clone());
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
if let Some(id) = run {
|
||||
let _ = app.run(&id, json!({}));
|
||||
close = true;
|
||||
}
|
||||
if !close {
|
||||
app.palette = Some((query, sel));
|
||||
}
|
||||
}
|
||||
|
||||
/// The application menu tree: (menu, [(label, command id, shortcut)]), "-" = separator. Used by the
|
||||
/// native macOS menu bar and as the parity catalogue's live side.
|
||||
pub fn menu_tree() -> Vec<(&'static str, Vec<(&'static str, &'static str)>)> {
|
||||
vec![
|
||||
(
|
||||
"File",
|
||||
vec![
|
||||
("New Presentation", "file.new"),
|
||||
("Open…", "app.openDialog"),
|
||||
("-", ""),
|
||||
("Close", "app.closePresentation"),
|
||||
("Save", "file.save"),
|
||||
("Save As…", "app.saveAsDialog"),
|
||||
("Export…", "app.exportDialog"),
|
||||
("Print…", "app.print"),
|
||||
("-", ""),
|
||||
("Properties", "file.properties"),
|
||||
],
|
||||
),
|
||||
(
|
||||
"Edit",
|
||||
vec![
|
||||
("Undo", "edit.undo"),
|
||||
("Redo", "edit.redo"),
|
||||
("-", ""),
|
||||
("Cut", "edit.cut"),
|
||||
("Copy", "edit.copy"),
|
||||
("Paste", "edit.paste"),
|
||||
("Paste and Match Formatting", "edit.pasteText"),
|
||||
("Paste Special…", "app.pasteSpecial"),
|
||||
("-", ""),
|
||||
("Select All", "edit.selectAll"),
|
||||
("Duplicate", "edit.duplicate"),
|
||||
("Delete Slide", "slide.delete"),
|
||||
("-", ""),
|
||||
("Find…", "app.find"),
|
||||
("Replace…", "app.replace"),
|
||||
],
|
||||
),
|
||||
(
|
||||
"View",
|
||||
vec![
|
||||
("Normal", "view.normal"),
|
||||
("Slide Sorter", "view.sorter"),
|
||||
("Notes Page", "view.notesPage"),
|
||||
("Outline View", "view.outline"),
|
||||
("Reading View", "view.reading"),
|
||||
("Slide Show", "show.start"),
|
||||
("-", ""),
|
||||
("Slide Master", "view.slideMaster"),
|
||||
("Handout Master", "view.handoutMaster"),
|
||||
("Notes Master", "view.notesMaster"),
|
||||
("-", ""),
|
||||
("Ruler", "view.ruler"),
|
||||
("Gridlines", "view.gridlines"),
|
||||
("Guides", "view.guides"),
|
||||
("Grid Options…", "view.gridOptions"),
|
||||
("-", ""),
|
||||
("Zoom…", "view.zoomDialog"),
|
||||
("Zoom In", "view.zoomIn"),
|
||||
("Zoom Out", "view.zoomOut"),
|
||||
("Fit to Window", "view.fit"),
|
||||
("-", ""),
|
||||
("New Window", "view.newWindow"),
|
||||
],
|
||||
),
|
||||
(
|
||||
"Insert",
|
||||
vec![
|
||||
("New Slide", "slide.new"),
|
||||
("Duplicate Slide", "slide.duplicate"),
|
||||
("-", ""),
|
||||
("Section", "section.add"),
|
||||
("Text Box", "insert.textBox"),
|
||||
("Decorative Text", "insert.wordArt"),
|
||||
("Date and Time", "insert.dateTime"),
|
||||
("Slide Number", "insert.slideNumber"),
|
||||
("-", ""),
|
||||
("Table…", "insert.table"),
|
||||
("Chart", "insert.chart"),
|
||||
("Picture from File…", "app.insertPictureDialog"),
|
||||
("Photo Album…", "insert.photoAlbum"),
|
||||
("Edit Photo Album…", "insert.photoAlbumEdit"),
|
||||
("Audio from File…", "app.insertAudioDialog"),
|
||||
("Video from File…", "app.insertVideoDialog"),
|
||||
],
|
||||
),
|
||||
(
|
||||
"Format",
|
||||
vec![
|
||||
("Font…", "format.fontDialog"),
|
||||
("Paragraph…", "format.paragraphDialog"),
|
||||
("Bold", "format.bold"),
|
||||
("Italic", "format.italic"),
|
||||
("Underline", "format.underline"),
|
||||
("-", ""),
|
||||
("Align Left", "format.alignLeft"),
|
||||
("Center", "format.alignCenter"),
|
||||
("Align Right", "format.alignRight"),
|
||||
("Justify", "format.justify"),
|
||||
("-", ""),
|
||||
("Size and Position…", "shape.sizePosition"),
|
||||
("Right-to-Left Text Direction", "format.rtl"),
|
||||
],
|
||||
),
|
||||
(
|
||||
"Arrange",
|
||||
vec![
|
||||
("Bring to Front", "arrange.bringToFront"),
|
||||
("Send to Back", "arrange.sendToBack"),
|
||||
("Bring Forward", "arrange.bringForward"),
|
||||
("Send Backward", "arrange.sendBackward"),
|
||||
("-", ""),
|
||||
("Group", "arrange.group"),
|
||||
("Ungroup", "arrange.ungroup"),
|
||||
("Regroup", "arrange.regroup"),
|
||||
("-", ""),
|
||||
("Rotate Left 90°", "arrange.rotateLeft"),
|
||||
("Rotate Right 90°", "arrange.rotateRight"),
|
||||
("Flip Horizontal", "arrange.flipHorizontal"),
|
||||
("Flip Vertical", "arrange.flipVertical"),
|
||||
],
|
||||
),
|
||||
(
|
||||
"Slide Show",
|
||||
vec![
|
||||
("Play from Start", "show.fromStart"),
|
||||
("Play from Current Slide", "show.fromCurrent"),
|
||||
("-", ""),
|
||||
("Hide Slide", "slide.hide"),
|
||||
("Set Up Show…", "show.setup"),
|
||||
],
|
||||
),
|
||||
("Help", vec![("About DeckCraft", "app.about"), ("Check for Updates…", "app.checkUpdates"), ("Command Palette", "app.palette")]),
|
||||
]
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -100,19 +100,8 @@ impl SlideApp {
|
||||
.show(ui, |ui, _| {
|
||||
Text::new(format!("Reading the file: {secs:.0} s")).shade(Shade::Muted).show(ui);
|
||||
});
|
||||
<<<<<<< HEAD
|
||||
// BlockingOverlay::cancel emits Requested for its button and Escape for the key.
|
||||
if shown.output.closed.is_some() {
|
||||
=======
|
||||
ui.add_space(6.0);
|
||||
ui.weak(format!("Reading the file: {secs:.0} s"));
|
||||
ui.add_space(6.0);
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
cancel = ui.button("Cancel").clicked();
|
||||
});
|
||||
});
|
||||
if cancel || ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape)) || crate::framework::take_window_cancel(ctx) {
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
self.cancel_opening();
|
||||
}
|
||||
ui.ctx().request_repaint_after(std::time::Duration::from_secs(1));
|
||||
@@ -263,40 +252,8 @@ mod tests {
|
||||
}));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
/// Encoded host bytes of a deck; the file extension selects its format.
|
||||
fn saved_as(file: &str, slides: usize) -> (String, Vec<u8>) {
|
||||
=======
|
||||
/// Opening a path displays progress; cancelling closes the progress window without opening the
|
||||
/// deck.
|
||||
#[test]
|
||||
fn the_progress_window_shows_and_cancel_closes_it() {
|
||||
use egui_kittest::kittest::Queryable;
|
||||
let mut app = SlideApp::new(Session::with_new(), crate::Services::default());
|
||||
// A read that never answers: the window stays until Cancel.
|
||||
let (_tx, rx) = std::sync::mpsc::channel();
|
||||
app.opening = Some(Opening { path: "/decks/Big deck.pptx".into(), started_ms: crate::now_ms(), generation: 1, rx });
|
||||
let mut harness = egui_kittest::Harness::builder()
|
||||
.with_context_setup(crate::framework::install_headless)
|
||||
.with_size(egui::vec2(1000.0, 700.0))
|
||||
.build_ui_state(
|
||||
|ui, app: &mut SlideApp| {
|
||||
app.logic(ui.ctx());
|
||||
app.ui(ui);
|
||||
},
|
||||
app,
|
||||
);
|
||||
harness.run_steps(3);
|
||||
harness.get_by_label("Opening Big deck.pptx…");
|
||||
harness.get_by_label("Cancel").click();
|
||||
harness.run_steps(2);
|
||||
assert!(harness.state().opening.is_none());
|
||||
assert_eq!(harness.state().session.documents().len(), 1);
|
||||
}
|
||||
|
||||
/// A deck of `slides` slides saved as `file` (its extension picks the format).
|
||||
fn saved_as(file: &str, slides: usize) -> String {
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
let mut s = Session::with_new();
|
||||
for _ in 1..slides {
|
||||
s.execute("slide.new", &serde_json::json!({})).unwrap();
|
||||
@@ -359,24 +316,9 @@ mod tests {
|
||||
fn leaving_the_ppsx_show_keeps_the_deck_open() {
|
||||
let (path, bytes) = saved_as("leave.ppsx", 2);
|
||||
for leave in [egui::Key::Escape, egui::Key::ArrowRight] {
|
||||
<<<<<<< HEAD
|
||||
let files = Arc::new(ScriptedFiles::new().with_file(&path, bytes.clone()));
|
||||
let mut harness = scripted(Session::new(), files);
|
||||
assert!(harness.state_mut().open_from_system(std::slice::from_ref(&path)).is_empty());
|
||||
=======
|
||||
let mut app = SlideApp::new(Session::new(), crate::Services::default());
|
||||
assert!(app.open_from_system(std::slice::from_ref(&path)).is_empty());
|
||||
let mut harness = egui_kittest::Harness::builder()
|
||||
.with_context_setup(crate::framework::install_headless)
|
||||
.with_size(egui::vec2(1000.0, 700.0))
|
||||
.build_ui_state(
|
||||
|ui, app: &mut SlideApp| {
|
||||
app.logic(ui.ctx());
|
||||
app.ui(ui);
|
||||
},
|
||||
app,
|
||||
);
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
harness.run_steps(3);
|
||||
assert!(harness.state().show.is_some(), "the show is running");
|
||||
if leave == egui::Key::ArrowRight {
|
||||
|
||||
@@ -161,7 +161,6 @@ mod tests {
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
<<<<<<< HEAD
|
||||
let stray = DeckSettings { ui: UiState { zoom: Some(1.0e4), ..Default::default() }, ..Default::default() };
|
||||
for (name, settings) in [("hostile", hostile), ("stray", stray)] {
|
||||
let path = dir(name)?;
|
||||
@@ -176,22 +175,6 @@ mod tests {
|
||||
egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)),
|
||||
|platform| platform.settings = Location::Dir(path.clone()),
|
||||
);
|
||||
=======
|
||||
for ui in [hostile.clone().sanitized(), UiState { zoom: Some(1.0e4), ..Default::default() }] {
|
||||
let mut app = crate::SlideApp::new(deckcraft_engine::Session::with_new(), crate::Services::default());
|
||||
// The second case is not sanitized: the canvas keeps a stray zoom in range itself.
|
||||
app.ui = ui;
|
||||
let mut h = egui_kittest::Harness::builder()
|
||||
.with_context_setup(crate::framework::install_headless)
|
||||
.with_size(egui::vec2(1200.0, 800.0))
|
||||
.build_ui_state(
|
||||
|ui, app: &mut crate::SlideApp| {
|
||||
app.logic(ui.ctx());
|
||||
app.ui(ui);
|
||||
},
|
||||
app,
|
||||
);
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
h.run_steps(4);
|
||||
assert_eq!(h.state().ui.zoom, expected.ui.zoom);
|
||||
let scale = h.state().canvas_scale();
|
||||
|
||||
@@ -398,9 +398,7 @@ pub(crate) fn prepare(
|
||||
let clips = crate::media::slide_media(doc, slide);
|
||||
let hidden: Vec<_> = clips
|
||||
.iter()
|
||||
.filter(|(id, _, clip)| {
|
||||
clip.hide_while_not_playing && !media.status(*id).is_some_and(|status| status.state != deckcraft_media::PlayState::Ended)
|
||||
})
|
||||
.filter(|(id, _, clip)| clip.hidden_during_show(media.status(*id).is_some_and(|status| status.state != deckcraft_media::PlayState::Ended)))
|
||||
.map(|clip| clip.0)
|
||||
.collect();
|
||||
let animating = show.state.playing || show.state.trigger_playing();
|
||||
|
||||
@@ -362,503 +362,7 @@ fn advance(app: &mut SlideApp, show: &mut Show, doc_uid: u64, doc: &Presentation
|
||||
run_media_cues(app, show, doc_uid, doc);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
fn finish(app: &mut SlideApp, mut show: Show, now: f64, keep: bool) {
|
||||
=======
|
||||
fn begin_slide(app: &mut SlideApp, show: &Show, f: &Fr, size: (u32, u32)) -> Sl {
|
||||
let Fr { ctx, doc, doc_uid, now, .. } = *f;
|
||||
let idx = show.state.slide;
|
||||
let step = show.state.step;
|
||||
// A main step or a triggered animation is running: the picture changes every frame.
|
||||
let animating = show.state.playing || show.state.trigger_playing();
|
||||
let t = if show.state.playing { now - show.step_start } else { 0.0 };
|
||||
let plays = show.state.trigger_plays();
|
||||
let stamps = show.state.trigger_stamps();
|
||||
let media = crate::media::slide_media(doc, idx);
|
||||
let hidden: Vec<ShapeId> = media
|
||||
.iter()
|
||||
.filter(|(id, _, clip)| clip.hidden_during_show(app.media.status(*id).is_some_and(|s| s.state != deckcraft_media::PlayState::Ended)))
|
||||
.map(|m| m.0)
|
||||
.collect();
|
||||
let gifs = app.media.gifs(doc_uid, doc, idx, now, &app.session.gif_paused);
|
||||
let times: Vec<_> = gifs.iter().map(|g| (g.id, g.t)).collect();
|
||||
crate::media::gif_repaint(ctx, &gifs);
|
||||
let gif = crate::media::gif_key(&gifs);
|
||||
let done: Vec<(ShapeId, usize)> = plays.iter().map(|p| (p.trigger, p.step)).collect();
|
||||
let key = Key { slide: idx, step, size, doc: std::sync::Arc::as_ptr(doc) as usize, hidden: hidden.clone(), plays: done, gif };
|
||||
let back_key = BackKey { slide: idx, size, doc: key.doc };
|
||||
Sl { idx, step, animating, t, plays, stamps, media, hidden, times, gifs, key, back_key, size }
|
||||
}
|
||||
|
||||
fn frame_texture(show: &mut Show, f: &Fr, sl: &Sl) -> Option<TextureHandle> {
|
||||
let Fr { ctx, doc, .. } = *f;
|
||||
let Sl { idx, step, animating, size, .. } = *sl;
|
||||
if !animating && show.tex.as_ref().is_some_and(|(k, _)| *k == sl.key) {
|
||||
show.tex.as_ref().map(|(_, t)| t.clone())
|
||||
} else {
|
||||
// The frame rendered ahead of time, when it is this one (waiting for it beats starting over).
|
||||
let ready = match show.prefetch.take() {
|
||||
Some(p) if p.key == sl.key && !animating => p.rx.recv().ok(),
|
||||
_ => None,
|
||||
};
|
||||
let ci = match ready {
|
||||
Some(ci) => ci,
|
||||
None => {
|
||||
let tl = show.timeline(doc).clone();
|
||||
// Animating: the backdrop doesn't change, only the shapes over it are drawn.
|
||||
let back = animating.then(|| show.backdrop(doc, sl.back_key));
|
||||
render_frame(doc, idx, tl, step, sl.t, size, sl.hidden.clone(), &sl.times, render_threads(), &sl.plays, &sl.stamps, back.as_deref())
|
||||
}
|
||||
};
|
||||
if show.remote_opened && show.presenter {
|
||||
show.remote_preview = crate::presenter::Preview::from_image(&ci);
|
||||
}
|
||||
let tex = match show.tex.take() {
|
||||
Some((_, mut h)) => {
|
||||
crate::textures::replace(ctx, &mut h, ci);
|
||||
h
|
||||
}
|
||||
None => crate::textures::upload(ctx, "show", ci),
|
||||
};
|
||||
show.tex = Some((sl.key.clone(), tex.clone()));
|
||||
Some(tex)
|
||||
}
|
||||
}
|
||||
|
||||
fn prefetch_next(app: &mut SlideApp, show: &mut Show, f: &Fr, sl: &Sl) {
|
||||
let Fr { doc, doc_uid, now, .. } = *f;
|
||||
let Sl { animating, size, .. } = *sl;
|
||||
// While this slide rests, render the next one's first frame (not one with GIFs, whose
|
||||
// frame depends on when it is entered).
|
||||
// A slide with animations gets its backdrop ready while it rests, so they start smoothly.
|
||||
if !animating && !show.timeline(doc).is_empty() {
|
||||
show.prefetch_backdrop(doc, sl.back_key);
|
||||
}
|
||||
if !animating && show.trans.is_none() && !show.preview_only {
|
||||
let next = show.state.peek_next(doc);
|
||||
let wanted = next.filter(|n| app.media.gifs(doc_uid, doc, *n, now, &app.session.gif_paused).is_empty());
|
||||
if let Some(n) = wanted
|
||||
&& show.prefetch.as_ref().is_none_or(|p| p.key.slide != n || p.key.size != size || p.key.doc != std::sync::Arc::as_ptr(doc) as usize)
|
||||
{
|
||||
show.prefetch = start_prefetch(doc, n, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_transition(show: &mut Show, f: &Fr, sl: &Sl, painter: &egui::Painter, tex: &Option<TextureHandle>) -> bool {
|
||||
let Fr { ctx, doc, now, srect, .. } = *f;
|
||||
let Sl { idx, size, .. } = *sl;
|
||||
let mut drew = false;
|
||||
let morphing = show.trans.as_ref().is_some_and(|tr| tr.kind == "morph" && tr.from.is_some() && now - tr.start < tr.dur);
|
||||
let tl = if morphing { Some(show.timeline(doc).clone()) } else { None };
|
||||
let morph = match (&show.trans, tl) {
|
||||
(Some(tr), Some(tl)) => {
|
||||
let p = ((now - tr.start) / tr.dur.max(0.01)).clamp(0.0, 1.0);
|
||||
let hidden_b = |id: ShapeId| {
|
||||
let st = state_for(&tl, id, 0, 0.0, &[], &[]);
|
||||
!st.visible || st.opacity <= 0.0 || sl.hidden.contains(&id)
|
||||
};
|
||||
tr.from
|
||||
.and_then(|i| doc.slides.get(i).map(|a| (i, a)))
|
||||
.zip(doc.slides.get(idx))
|
||||
.map(|((i, a), b)| (i, deckcraft_anim::morph_frame(doc, a, b, p, &hidden_b)))
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
if let (Some((from, m)), Some(tr)) = (morph, show.trans.as_mut()) {
|
||||
let f = |id: ShapeId| ShapeState { opacity: m.opacity_of(id), ..Default::default() };
|
||||
let threads = if cfg!(target_arch = "wasm32") { 0 } else { std::thread::available_parallelism().map(|n| n.get().min(8) as u16).unwrap_or(0) };
|
||||
let opts =
|
||||
RenderOpts { scale: size.0 as f64 / doc.slide_size.width.max(1.0), size: Some(size), state: Some(&f), threads, ..Default::default() };
|
||||
let text: Vec<deckcraft_render::TextMorph> =
|
||||
m.text.iter().map(|x| deckcraft_render::TextMorph { old: x.old, new: x.new, from: x.from, to: x.to, chars: x.chars, t: m.mix }).collect();
|
||||
let paths: Vec<deckcraft_render::PathMorph> = m
|
||||
.paths
|
||||
.iter()
|
||||
.map(|x| deckcraft_render::PathMorph { id: x.id, from: x.from.clone(), from_box: x.from_box, to_box: x.to_box, t: m.mix })
|
||||
.collect();
|
||||
let img = deckcraft_render::render_blend(doc, (from, idx), m.mix, &m.shapes, &text, &paths, &opts);
|
||||
let ci = crate::textures::to_color_image(&img, false);
|
||||
let frame = match tr.morph.take() {
|
||||
Some(mut h) => {
|
||||
crate::textures::replace(ctx, &mut h, ci);
|
||||
h
|
||||
}
|
||||
None => crate::textures::upload(ctx, "morph", ci),
|
||||
};
|
||||
painter.image(frame.id(), srect, Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), Color32::WHITE);
|
||||
tr.morph = Some(frame);
|
||||
drew = true;
|
||||
ctx.request_repaint();
|
||||
} else if let (Some(tr), Some(new)) = (show.trans.as_mut(), &tex) {
|
||||
let p = ((now - tr.start) / tr.dur.max(0.01)).clamp(0.0, 1.0);
|
||||
if p < 1.0 {
|
||||
// Slides split into background and content are rendered once per transition;
|
||||
// every frame only composites cached textures.
|
||||
if tr.parts.is_none() && deckcraft_anim::uses_slide_parts(&tr.kind, &tr.option) {
|
||||
tr.parts = Some(part_textures(ctx, doc, tr.from, idx, size));
|
||||
}
|
||||
if tr.old.is_none()
|
||||
&& let Some(prev) = tr.from
|
||||
&& !deckcraft_anim::uses_slide_parts(&tr.kind, &tr.option)
|
||||
{
|
||||
let threads =
|
||||
if cfg!(target_arch = "wasm32") { 0 } else { std::thread::available_parallelism().map(|n| n.get().min(8) as u16).unwrap_or(0) };
|
||||
let timeline = ShowState::timeline(doc, prev);
|
||||
let step = timeline.steps();
|
||||
let ci = render_frame(doc, prev, timeline, step, 0.0, size, vec![], &[], threads, &[], &[], None);
|
||||
tr.old = Some(crate::textures::upload(ctx, "trans-old", ci));
|
||||
}
|
||||
let aspect = doc.slide_size.width / doc.slide_size.height.max(1.0);
|
||||
let part = |k: usize| tr.parts.as_ref().and_then(|p| p.get(k).cloned().flatten());
|
||||
let parts = [part(0), part(1), part(2), part(3)];
|
||||
for l in transition_layers(&tr.kind, &tr.option, tr.reverse, p, aspect) {
|
||||
let old_or_black = |t: Option<&TextureHandle>| match t {
|
||||
Some(o) => quad_mesh(Some(o.id()), srect, &l, Color32::WHITE),
|
||||
None => quad_mesh(None, srect, &l, Color32::BLACK),
|
||||
};
|
||||
let mesh = match l.source {
|
||||
Source::Old => old_or_black(tr.old.as_ref()),
|
||||
Source::New => quad_mesh(Some(new.id()), srect, &l, Color32::WHITE),
|
||||
Source::Black => quad_mesh(None, srect, &l, Color32::BLACK),
|
||||
Source::White => quad_mesh(None, srect, &l, Color32::WHITE),
|
||||
Source::OldBack => old_or_black(parts[0].as_ref().or(tr.old.as_ref())),
|
||||
Source::NewBack => quad_mesh(Some(parts[2].as_ref().unwrap_or(new).id()), srect, &l, Color32::WHITE),
|
||||
Source::OldContent => match &parts[1] {
|
||||
Some(t) => quad_mesh(Some(t.id()), srect, &l, Color32::WHITE),
|
||||
None => continue,
|
||||
},
|
||||
Source::NewContent => match &parts[3] {
|
||||
Some(t) => quad_mesh(Some(t.id()), srect, &l, Color32::WHITE),
|
||||
None => continue,
|
||||
},
|
||||
};
|
||||
painter.add(egui::Shape::mesh(mesh));
|
||||
}
|
||||
drew = true;
|
||||
ctx.request_repaint();
|
||||
}
|
||||
}
|
||||
drew
|
||||
}
|
||||
|
||||
/// The layers of a transition at progress `p`. A reversed transition (going back, #1531) runs
|
||||
/// from its end to its start, so the slide being left plays the part of the new slide and the
|
||||
/// slide coming back the part of the old one.
|
||||
pub(super) fn transition_layers(kind: &str, option: &str, reverse: bool, p: f64, aspect: f64) -> Vec<Layer> {
|
||||
if !reverse {
|
||||
return deckcraft_anim::transition_frame(kind, option, p, aspect);
|
||||
}
|
||||
let mut layers = deckcraft_anim::transition_frame(kind, option, 1.0 - p, aspect);
|
||||
for l in &mut layers {
|
||||
l.source = swap_old_new(l.source);
|
||||
}
|
||||
layers
|
||||
}
|
||||
|
||||
fn swap_old_new(s: Source) -> Source {
|
||||
match s {
|
||||
Source::Old => Source::New,
|
||||
Source::New => Source::Old,
|
||||
Source::OldBack => Source::NewBack,
|
||||
Source::NewBack => Source::OldBack,
|
||||
Source::OldContent => Source::NewContent,
|
||||
Source::NewContent => Source::OldContent,
|
||||
Source::Black | Source::White => s,
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_videos(app: &mut SlideApp, show: &mut Show, f: &Fr, sl: &Sl, painter: &egui::Painter, tex: &Option<TextureHandle>) -> (Vec<ShapeId>, bool) {
|
||||
let Fr { doc, full, srect, .. } = *f;
|
||||
if let Some(tex) = &tex {
|
||||
painter.image(tex.id(), srect, show.zoom_uv(), Color32::WHITE);
|
||||
}
|
||||
// Playing video: the current frame in its box, or full screen.
|
||||
let (sw, sh) = (doc.slide_size.width as f32, doc.slide_size.height as f32);
|
||||
let uv = show.zoom_uv();
|
||||
let mut framed: Vec<ShapeId> = vec![];
|
||||
let mut full_screen = false;
|
||||
for (id, x, clip) in &sl.media {
|
||||
if !clip.video || sl.hidden.contains(id) {
|
||||
continue;
|
||||
}
|
||||
let r = if clip.full_screen && app.media.is_playing(*id) {
|
||||
full_screen = true;
|
||||
full
|
||||
} else {
|
||||
slide_box(srect, uv, (sw, sh), (x.x as f32, x.y as f32, x.w as f32, x.h as f32))
|
||||
};
|
||||
if crate::media::paint_frame(painter, &app.media, *id, r, clip.crop) {
|
||||
framed.push(*id);
|
||||
}
|
||||
}
|
||||
(framed, full_screen)
|
||||
}
|
||||
|
||||
fn draw_overlay(show: &mut Show, f: &Fr, sl: &Sl, painter: &egui::Painter, framed: &[ShapeId], full_screen: bool) {
|
||||
let Fr { ctx, doc, srect, .. } = *f;
|
||||
let Sl { idx, step, animating, size, .. } = *sl;
|
||||
let uv = show.zoom_uv();
|
||||
// Shapes stacked above a playing video show over it, as in PowerPoint (#1005); a video
|
||||
// playing full screen covers the whole slide.
|
||||
let skip = if full_screen { vec![] } else { below_playing_video(doc, idx, framed) };
|
||||
if skip.is_empty() {
|
||||
show.overlay = None;
|
||||
} else {
|
||||
let fresh = !animating && show.overlay.as_ref().is_some_and(|(k, s, _)| *k == sl.key && *s == skip);
|
||||
if !fresh {
|
||||
let tl = show.timeline(doc).clone();
|
||||
let ci = render_overlay(doc, idx, tl, step, sl.t, size, sl.hidden.clone(), &skip, &sl.times, render_threads(), &sl.plays, &sl.stamps);
|
||||
let handle = match show.overlay.take() {
|
||||
Some((_, _, mut h)) => {
|
||||
crate::textures::replace(ctx, &mut h, ci);
|
||||
h
|
||||
}
|
||||
None => crate::textures::upload(ctx, "show-overlay", ci),
|
||||
};
|
||||
show.overlay = Some((sl.key.clone(), skip, handle));
|
||||
}
|
||||
if let Some((_, _, h)) = &show.overlay {
|
||||
painter.image(h.id(), srect, uv, Color32::WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_media_controls(app: &mut SlideApp, ui: &mut Ui, show: &mut Show, f: &Fr, sl: &Sl, painter: &egui::Painter) {
|
||||
let Fr { ctx, doc, doc_uid, now, srect, .. } = *f;
|
||||
let sw = doc.slide_size.width as f32;
|
||||
// Play/pause on the animated GIF under the pointer, and the audio/video bar.
|
||||
// Slide Show ▸ Show Media Controls hides both (the click still sl.plays a clip).
|
||||
// Not while zoomed: the controls sit where the whole slide would be.
|
||||
if doc.show.show_media_controls && !show.zoom_arm && show.zoom.is_none() {
|
||||
let k = srect.width() / sw.max(1.0);
|
||||
if let Some(p) = ctx.input(|i| i.pointer.hover_pos()).filter(|_| !show.pen && !show.laser && show.pointer_awake(now)) {
|
||||
for g in &sl.gifs {
|
||||
let r = on_screen(srect, k, &g.rect);
|
||||
if r.contains(p) {
|
||||
let b = crate::media::gif_button_rect(r);
|
||||
crate::media::paint_gif_button(painter, b, g.paused, b.contains(p));
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some((id, clip, bar)) = media_bar_target(ctx, doc, show, srect).filter(|_| show.pointer_awake(now)) {
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(500));
|
||||
let action = {
|
||||
let status = app.media.status(id);
|
||||
crate::media::control_bar(ui, bar, status.as_ref(), &clip)
|
||||
};
|
||||
let pos = app.media.status(id).map(|s| s.position).unwrap_or(0.0);
|
||||
match action {
|
||||
Some(crate::media::BarAction::Toggle) => app.media.toggle(doc_uid, doc, id, &clip, crate::media::Owner::Show),
|
||||
Some(crate::media::BarAction::Seek(t)) => app.media.seek(doc_uid, doc, id, &clip, t, crate::media::Owner::Show),
|
||||
Some(crate::media::BarAction::Nudge(dt)) => app.media.seek(doc_uid, doc, id, &clip, (pos + dt).max(0.0), crate::media::Owner::Show),
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_slide(app: &mut SlideApp, ui: &mut Ui, show: &mut Show, f: &Fr, painter: &egui::Painter) {
|
||||
let Fr { ctx, full, srect, .. } = *f;
|
||||
let ppp = ctx.pixels_per_point();
|
||||
// A huge screen or DPI mustn't ask for a picture the GPU can't hold: render at most its limit
|
||||
// (drawn stretched to the screen).
|
||||
let size = crate::textures::fit_size(
|
||||
((srect.width() * ppp).round().clamp(1.0, u32::MAX as f32) as u32, (srect.height() * ppp).round().clamp(1.0, u32::MAX as f32) as u32),
|
||||
crate::textures::max_side(ctx),
|
||||
);
|
||||
if show.ended {
|
||||
painter.text(
|
||||
pos2(full.center().x, full.min.y + 40.0),
|
||||
Align2::CENTER_CENTER,
|
||||
"End of slide show, click to exit.",
|
||||
theme::font(18.0),
|
||||
Color32::from_gray(200),
|
||||
);
|
||||
} else {
|
||||
let sl = begin_slide(app, show, f, size);
|
||||
let tex = frame_texture(show, f, &sl);
|
||||
prefetch_next(app, show, f, &sl);
|
||||
if !draw_transition(show, f, &sl, painter, &tex) {
|
||||
show.trans = None;
|
||||
let (framed, full_screen) = draw_videos(app, show, f, &sl, painter, &tex);
|
||||
draw_overlay(show, f, &sl, painter, &framed, full_screen);
|
||||
draw_media_controls(app, ui, show, f, &sl, painter);
|
||||
}
|
||||
if sl.animating {
|
||||
ctx.request_repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_pen_and_hints(ui: &mut Ui, show: &mut Show, f: &Fr, painter: &egui::Painter, pointing: bool) {
|
||||
let Fr { ctx, doc, now, full, srect, .. } = *f;
|
||||
if let Some(c) = show.blank {
|
||||
painter.rect_filled(full, CornerRadius::ZERO, c);
|
||||
}
|
||||
if !show.goto.is_empty() {
|
||||
let label = format!("Go to slide {}", show.goto);
|
||||
let w = (28.0 + label.len() as f32 * 10.0).clamp(160.0, full.width() - 32.0);
|
||||
let r = Rect::from_min_size(pos2(full.min.x + 16.0, full.max.y - 96.0), vec2(w, 36.0));
|
||||
painter.rect_filled(r, CornerRadius::same(6), Color32::from_black_alpha(190));
|
||||
painter.text(r.center(), Align2::CENTER_CENTER, label, theme::font(18.0), Color32::WHITE);
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(200));
|
||||
}
|
||||
// Pen.
|
||||
let resp = ui.interact(full, ui.scope_id().with("show_pen"), if show.pen { Sense::drag() } else { Sense::hover() });
|
||||
if show.pen {
|
||||
resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, "Pen"));
|
||||
}
|
||||
if show.pen {
|
||||
if resp.drag_started() {
|
||||
show.strokes.push(vec![]);
|
||||
}
|
||||
let uv = show.zoom_uv();
|
||||
if resp.dragged()
|
||||
&& let Some(p) = resp.interact_pointer_pos()
|
||||
&& let Some((nx, ny)) = norm_on_slide(srect, uv, p)
|
||||
&& let Some(s) = show.strokes.last_mut()
|
||||
{
|
||||
s.push(pos2(nx, ny));
|
||||
}
|
||||
ctx.set_cursor_icon(egui::CursorIcon::Crosshair);
|
||||
} else if show.laser {
|
||||
ctx.set_cursor_icon(egui::CursorIcon::None);
|
||||
} else if show.zoom_arm || show.grid {
|
||||
ctx.set_cursor_icon(egui::CursorIcon::Crosshair);
|
||||
} else if show.hides_idle_cursor(now) {
|
||||
// Idle first: a still pointer hides also over a clickable shape, such as a playing clip.
|
||||
ctx.set_cursor_icon(egui::CursorIcon::None);
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(500));
|
||||
} else if pointing {
|
||||
ctx.set_cursor_icon(egui::CursorIcon::PointingHand);
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(500));
|
||||
}
|
||||
let pen_col = theme::to_color32(doc.show.pen_color);
|
||||
let uv = show.zoom_uv();
|
||||
for s in &show.strokes {
|
||||
let pts: Vec<Pos2> = s.iter().map(|q| slide_to_screen(srect, uv, q.x, q.y)).collect();
|
||||
painter.add(egui::Shape::line(pts, Stroke::new(3.0, pen_col)));
|
||||
}
|
||||
if show.laser
|
||||
&& !show.ended
|
||||
&& let Some(p) = ctx.input(|i| i.pointer.hover_pos())
|
||||
{
|
||||
let c = theme::to_color32(doc.show.laser_color);
|
||||
painter.circle_filled(p, 16.0, Color32::from_rgba_unmultiplied(c.r(), c.g(), c.b(), 70));
|
||||
painter.circle_filled(p, 5.5, c);
|
||||
}
|
||||
if show.zoom_arm && !show.grid {
|
||||
painter.text(
|
||||
pos2(full.center().x, full.min.y + 36.0),
|
||||
Align2::CENTER_CENTER,
|
||||
"Click the slide to zoom in. Esc cancels.",
|
||||
theme::font(16.0),
|
||||
Color32::WHITE,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_bars(ui: &mut Ui, show: &mut Show, f: &Fr, painter: &egui::Painter, out: &mut Out) {
|
||||
let Fr { ctx, doc, now, full, .. } = *f;
|
||||
// Reading view bar / on-screen controls.
|
||||
if show.reading {
|
||||
let bar = Rect::from_min_max(pos2(full.min.x, full.max.y - 34.0), full.max);
|
||||
painter.rect_filled(bar, CornerRadius::ZERO, Color32::from_gray(32));
|
||||
painter.text(
|
||||
pos2(bar.min.x + 14.0, bar.center().y),
|
||||
Align2::LEFT_CENTER,
|
||||
format!("Slide {} of {}", show.state.slide + 1, doc.slides.len()),
|
||||
theme::font(12.0),
|
||||
Color32::from_gray(200),
|
||||
);
|
||||
let mut child = ui.new_child(
|
||||
egui::UiBuilder::new()
|
||||
.max_rect(Rect::from_min_max(pos2(bar.max.x - 260.0, bar.min.y), bar.max))
|
||||
.layout(egui::Layout::right_to_left(egui::Align::Center)),
|
||||
);
|
||||
if child.button("Close").clicked() {
|
||||
out.keep = false;
|
||||
}
|
||||
if child.button("▶").clicked() {
|
||||
let a = show.state.next(doc);
|
||||
if !show.apply(a, doc, now) {
|
||||
out.keep = false;
|
||||
}
|
||||
}
|
||||
if child.button("◀").clicked() {
|
||||
let a = show.state.prev(doc);
|
||||
show.apply(a, doc, now);
|
||||
}
|
||||
} else if !show.grid && (show.pointer_awake(now) || show.zoom_arm) {
|
||||
let bar = tool_bar_rect(full);
|
||||
painter.rect_filled(bar, CornerRadius::same(17), Color32::from_black_alpha(140));
|
||||
let mut child =
|
||||
ui.new_child(egui::UiBuilder::new().max_rect(bar.shrink2(vec2(10.0, 4.0))).layout(egui::Layout::left_to_right(egui::Align::Center)));
|
||||
let b = |ui: &mut Ui, s: &str| ui.add(egui::Button::new(egui::RichText::new(s).color(Color32::WHITE).size(15.0)).frame(false));
|
||||
if b(&mut child, "◀").clicked() {
|
||||
let a = show.state.prev(doc);
|
||||
show.apply(a, doc, now);
|
||||
}
|
||||
if b(&mut child, "▶").clicked() {
|
||||
let a = show.state.next(doc);
|
||||
if !show.apply(a, doc, now) {
|
||||
out.keep = false;
|
||||
}
|
||||
}
|
||||
if b(&mut child, if show.pen { "✏ on" } else { "✏" }).clicked() {
|
||||
show.set_pen(!show.pen);
|
||||
}
|
||||
if b(&mut child, if show.laser { "◉ on" } else { "◉" }).clicked() {
|
||||
show.set_laser(!show.laser);
|
||||
}
|
||||
if b(&mut child, "Black").clicked() {
|
||||
toggle_blank(show, Color32::BLACK);
|
||||
}
|
||||
if b(&mut child, "White").clicked() {
|
||||
toggle_blank(show, Color32::WHITE);
|
||||
}
|
||||
if b(&mut child, "All").clicked() {
|
||||
show.grid = !show.grid;
|
||||
}
|
||||
if b(&mut child, show.zoom_label()).clicked() {
|
||||
show.zoom_key();
|
||||
}
|
||||
if b(&mut child, "End").clicked() {
|
||||
out.keep = false;
|
||||
}
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(300));
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_extras(show: &mut Show, f: &Fr, painter: &egui::Painter, out: &mut Out) {
|
||||
let Fr { ctx, doc, now, full, .. } = *f;
|
||||
if show.grid && !show.ended {
|
||||
paint_grid(painter, ctx, show, doc, full);
|
||||
}
|
||||
if show.rehearse {
|
||||
let t = now - show.slide_start;
|
||||
let total = now - show.show_start;
|
||||
let r = Rect::from_min_size(pos2(full.min.x + 12.0, full.min.y + 12.0), vec2(220.0, 30.0));
|
||||
painter.rect_filled(r, CornerRadius::same(6), Color32::from_black_alpha(160));
|
||||
painter.text(
|
||||
r.center(),
|
||||
Align2::CENTER_CENTER,
|
||||
format!("Slide {:02}:{:04.1} Total {:02}:{:02}", (t / 60.0) as u32, t % 60.0, (total / 60.0) as u32, (total % 60.0) as u32),
|
||||
theme::font(13.0),
|
||||
Color32::WHITE,
|
||||
);
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(100));
|
||||
}
|
||||
// Presenter view in a second window.
|
||||
if out.keep && show.presenter && !show.reading && !show.remote_opened {
|
||||
presenter_window(ctx, show, doc, now, &mut out.keep);
|
||||
}
|
||||
}
|
||||
|
||||
fn finish(app: &mut SlideApp, mut show: Show, f: &Fr, keep: bool) {
|
||||
let Fr { ctx, now, .. } = *f;
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
if keep {
|
||||
app.show = Some(show);
|
||||
} else {
|
||||
|
||||
@@ -88,208 +88,7 @@ fn groups(doc: &Presentation) -> Vec<(Option<usize>, Vec<usize>)> {
|
||||
out
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
/// Grid of slides with collapsible, editable and movable sections.
|
||||
=======
|
||||
struct Header<'a> {
|
||||
uid: u64,
|
||||
index: usize,
|
||||
name: &'a str,
|
||||
count: usize,
|
||||
first: Option<u32>,
|
||||
}
|
||||
|
||||
/// Render one slide-sorter section header, handle its collapse/drag interactions, and return the
|
||||
/// occupied rectangle.
|
||||
fn section_header(app: &mut SlideApp, ui: &mut Ui, h: &Header<'_>) -> Rect {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let width = ui.available_width();
|
||||
let (r, _) = ui.allocate_exact_size(vec2(width, 32.0), Sense::hover());
|
||||
let resp = ui.interact(r, ui.scope_id().with(("sorter-section", h.uid, h.index)), Sense::click_and_drag());
|
||||
resp.widget_info(|| WidgetInfo::labeled(Role::Button, true, h.name));
|
||||
let open = h.first.is_none_or(|id| !app.sorter.collapsed.contains(&(h.uid, id)));
|
||||
let dragging = app.sorter.drag.is_some_and(|(from, _)| from == h.index);
|
||||
let bg = if dragging {
|
||||
t.selected
|
||||
} else if resp.hovered() {
|
||||
t.hover
|
||||
} else {
|
||||
t.card
|
||||
};
|
||||
let painter = ui.painter_at(r);
|
||||
painter.rect_filled(r, CornerRadius::same(4), bg);
|
||||
let chev = Rect::from_center_size(pos2(r.min.x + 20.0, r.center().y), vec2(24.0, 24.0));
|
||||
let cresp = ui.interact(chev, ui.scope_id().with(("sorter-fold", h.uid, h.index)), Sense::click());
|
||||
let fold = format!("{} {}", if open { "Collapse" } else { "Expand" }, h.name);
|
||||
cresp.widget_info(|| WidgetInfo::labeled(Role::Button, true, &fold));
|
||||
icons::paint(&painter, chev.shrink(4.0), if open { Icon::ChevronDown } else { Icon::ChevronRight }, t.text_dim, h.first.is_none());
|
||||
let renaming = app.sorter.renaming.clone().filter(|(uid, index, _)| *uid == h.uid && *index == h.index).map(|(_, _, text)| text);
|
||||
let name_rect = Rect::from_min_max(pos2(r.min.x + 40.0, r.min.y + 4.0), pos2(r.max.x - 56.0, r.max.y - 4.0));
|
||||
if let Some(mut buf) = renaming {
|
||||
let edit_id = ui.scope_id().with(("sorter-rename", h.uid, h.index));
|
||||
let out =
|
||||
ui.put(name_rect, egui::TextEdit::singleline(&mut buf).id(edit_id).hint_text("Name").font(theme::bold(13.0)).margin(vec2(4.0, 2.0)));
|
||||
let already = app.sorter.rename_started;
|
||||
if !already {
|
||||
out.request_focus();
|
||||
if let Some(mut state) = egui::TextEdit::load_state(ui.ctx(), edit_id) {
|
||||
let all = egui::text::CCursorRange::two(egui::text::CCursor::new(0), egui::text::CCursor::new(buf.chars().count()));
|
||||
state.cursor.set_char_range(Some(all));
|
||||
state.store(ui.ctx(), edit_id);
|
||||
}
|
||||
app.sorter.rename_started = true;
|
||||
}
|
||||
let (enter, esc) = (ui.input(|i| i.key_pressed(egui::Key::Enter)), crate::framework::escape_pressed(ui.ctx()));
|
||||
// The frame that asks for focus has not had it yet; committing then would cancel the rename.
|
||||
if already && (out.lost_focus() || enter || esc) {
|
||||
app.sorter.renaming = None;
|
||||
app.sorter.rename_started = false;
|
||||
let trimmed = buf.trim();
|
||||
if !esc && !trimmed.is_empty() && trimmed != h.name {
|
||||
let _ = app.run("section.rename", json!({"index": h.index, "name": trimmed}));
|
||||
}
|
||||
} else if let Some((_, _, text)) = app.sorter.renaming.as_mut() {
|
||||
*text = buf;
|
||||
}
|
||||
} else {
|
||||
painter.text(pos2(name_rect.min.x, r.center().y), Align2::LEFT_CENTER, h.name, theme::bold(13.0), t.text);
|
||||
}
|
||||
painter.text(pos2(r.max.x - 16.0, r.center().y), Align2::RIGHT_CENTER, format!("({})", h.count), theme::font(12.0), t.text_dim);
|
||||
if cresp.clicked()
|
||||
&& let Some(id) = h.first
|
||||
{
|
||||
let key = (h.uid, id);
|
||||
if open {
|
||||
app.sorter.collapsed.insert(key);
|
||||
} else {
|
||||
app.sorter.collapsed.remove(&key);
|
||||
}
|
||||
} else if resp.double_clicked() && app.sorter.renaming.is_none() {
|
||||
app.sorter.renaming = Some((h.uid, h.index, h.name.to_string()));
|
||||
app.sorter.rename_started = false;
|
||||
}
|
||||
let on_chevron = resp.interact_pointer_pos().is_some_and(|p| chev.contains(p));
|
||||
if resp.drag_started() && !on_chevron && app.sorter.renaming.is_none() {
|
||||
app.sorter.drag = Some((h.index, h.index));
|
||||
app.thumb_drag = None;
|
||||
}
|
||||
let index = h.index;
|
||||
let name = h.name.to_string();
|
||||
resp.context_menu(|ui| {
|
||||
if ui.button("Rename Section…").clicked() {
|
||||
let mut d = crate::dialogs::Dialog::new("renameSection");
|
||||
d.params = json!({"index": index, "name": name});
|
||||
app.dialog = Some(d);
|
||||
ui.close();
|
||||
}
|
||||
if ui.button("Add Section").clicked() {
|
||||
if let Some(at) = app.session.active().map(|st| st.selection.slide) {
|
||||
let _ = app.run("section.add", json!({"at": at}));
|
||||
}
|
||||
ui.close();
|
||||
}
|
||||
if ui.button("Remove Section").clicked() {
|
||||
let _ = app.run("section.remove", json!({"index": index}));
|
||||
ui.close();
|
||||
}
|
||||
if ui.button("Remove Section & Slides").clicked() {
|
||||
let _ = app.run("section.remove", json!({"index": index, "slides": true}));
|
||||
ui.close();
|
||||
}
|
||||
if ui.button("Move Section Up").clicked() {
|
||||
let _ = app.run("section.move", json!({"index": index, "to": index.saturating_sub(1)}));
|
||||
ui.close();
|
||||
}
|
||||
if ui.button("Move Section Down").clicked() {
|
||||
let _ = app.run("section.move", json!({"index": index, "to": index + 1}));
|
||||
ui.close();
|
||||
}
|
||||
});
|
||||
r
|
||||
}
|
||||
|
||||
struct Grid<'a> {
|
||||
doc: &'a Presentation,
|
||||
indices: &'a [usize],
|
||||
cur: usize,
|
||||
multi: &'a [SlideId],
|
||||
tw: f32,
|
||||
th: f32,
|
||||
}
|
||||
|
||||
/// One section's thumbnails. Returns whether a thumbnail is still being drawn.
|
||||
fn place_slides(app: &mut SlideApp, ui: &mut Ui, g: &Grid<'_>, budget: &mut u32, rects: &mut Vec<(usize, Rect)>) -> bool {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let ppp = ui.ctx().pixels_per_point();
|
||||
let cols = ((ui.available_width() - 32.0) / (g.tw + 36.0)).floor().max(1.0) as usize;
|
||||
let mut need_more = false;
|
||||
let rows = g.indices.len().div_ceil(cols);
|
||||
for row in 0..rows {
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(24.0);
|
||||
for c in 0..cols {
|
||||
let Some(&i) = g.indices.get(row * cols + c) else { break };
|
||||
let (cell, resp) = ui.allocate_exact_size(vec2(g.tw + 36.0, g.th + 36.0), Sense::click_and_drag());
|
||||
let label = format!("Slide {}", i + 1);
|
||||
resp.widget_info(|| WidgetInfo::labeled(Role::Button, true, &label));
|
||||
let img = crate::textures::device_pixel_rect(Rect::from_min_size(cell.min + vec2(18.0, 8.0), vec2(g.tw, g.th)), ppp);
|
||||
rects.push((i, cell));
|
||||
let p = ui.painter();
|
||||
// Only cells in view (plus a little margin) ask for a thumbnail, so a deck bigger
|
||||
// than the thumbnail cache does not evict its own thumbnails forever (#969).
|
||||
let near = ui.clip_rect().expand2(vec2(0.0, 2.0 * cell.height())).intersects(cell);
|
||||
let tex =
|
||||
if near { app.textures.thumb(ui.ctx(), g.doc, i, (img.width() * ppp).round() as u32, app.ui.grayscale, budget) } else { None };
|
||||
match tex {
|
||||
Some(tex) => {
|
||||
p.image(tex.id(), img, Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), Color32::WHITE);
|
||||
}
|
||||
None => {
|
||||
p.rect_filled(img, CornerRadius::ZERO, Color32::WHITE);
|
||||
need_more |= near;
|
||||
}
|
||||
}
|
||||
let id = g.doc.slides.get(i).map(|s| s.id);
|
||||
let selected = i == g.cur || id.is_some_and(|id| g.multi.contains(&id));
|
||||
p.rect_stroke(
|
||||
img.expand(if selected { 2.0 } else { 0.0 }),
|
||||
CornerRadius::same(3),
|
||||
Stroke::new(if selected { 3.0 } else { 1.0 }, if selected { t.accent } else { t.border }),
|
||||
egui::StrokeKind::Outside,
|
||||
);
|
||||
p.text(pos2(img.min.x, img.max.y + 12.0), Align2::LEFT_CENTER, format!("{}", i + 1), theme::font(12.0), t.text_dim);
|
||||
if let Some(tr) = g.doc.slides.get(i).and_then(|s| s.transition.as_ref()).filter(|tr| tr.kind != "none") {
|
||||
p.text(pos2(img.max.x, img.max.y + 12.0), Align2::RIGHT_CENTER, format!("★ {}", tr.kind), theme::font(10.5), t.text_faint);
|
||||
}
|
||||
if resp.clicked() {
|
||||
let (shift, add) = ui.input(|inp| (inp.modifiers.shift, inp.modifiers.command));
|
||||
if shift {
|
||||
let _ = app.run("slide.selectRange", json!({"to": i, "add": add}));
|
||||
} else if add {
|
||||
if let Some(id) = id {
|
||||
let _ = app.run("slide.selectSlides", json!({"ids": [id.0], "add": true}));
|
||||
}
|
||||
} else {
|
||||
let _ = app.run("slide.go", json!({"index": i}));
|
||||
}
|
||||
}
|
||||
if resp.double_clicked() {
|
||||
let _ = app.run("slide.go", json!({"index": i}));
|
||||
app.ui.view = crate::ViewMode::Normal;
|
||||
}
|
||||
if resp.drag_started() && app.sorter.drag.is_none() {
|
||||
crate::thumbs::start_slide_drag(app, i);
|
||||
}
|
||||
resp.context_menu(|ui| crate::thumbs::slide_menu(app, ui, i));
|
||||
}
|
||||
});
|
||||
}
|
||||
need_more
|
||||
}
|
||||
|
||||
/// Grid of slides; click selects, double-click opens in Normal view, drag reorders.
|
||||
/// With sections, each one is a bar: add, rename, collapse, and drag the whole section.
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
pub fn show(app: &mut SlideApp, ui: &mut Ui) {
|
||||
let Some(st) = app.session.active() else { return };
|
||||
let (uid, doc, cur) = (st.uid, st.doc.clone(), st.selection.slide);
|
||||
@@ -308,7 +107,6 @@ pub fn show(app: &mut SlideApp, ui: &mut Ui) {
|
||||
}
|
||||
keys.extend(slides.iter().map(|&index| Key::Slide(doc.slides[index].id)));
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
let source = keyed(&keys, |key: &Key| *key);
|
||||
let thumbs = thumb_source::thumbnails(ui.ctx());
|
||||
let pictures = DeckThumbs::new(doc.clone(), app.ui.grayscale);
|
||||
@@ -324,21 +122,6 @@ pub fn show(app: &mut SlideApp, ui: &mut Ui) {
|
||||
let _ = app.run("edit.selectAll", json!({"scope": "slides"}));
|
||||
} else {
|
||||
let _ = app.run(&fired.command.id, fired.command.params);
|
||||
=======
|
||||
let doc = st.doc.clone();
|
||||
let cur = st.selection.slide;
|
||||
let multi = st.selection.slides.clone();
|
||||
let zoom = app.ui.sorter_zoom.clamp(0.5, 3.0);
|
||||
let grouped = groups(&doc);
|
||||
// Behind the thumbnails, which take the presses: the document's Tab stop and key target.
|
||||
app.document_behind(ui, ui.available_rect_before_wrap());
|
||||
egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| {
|
||||
ui.add_space(12.0);
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(24.0);
|
||||
if ui.add(egui::Button::new("Add Section").stroke(Stroke::new(1.0, t.border))).clicked() {
|
||||
let _ = app.run("section.add", json!({"at": cur}));
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
}
|
||||
}
|
||||
if Button::new(words.add_section.clone()).show(ui).clicked() {
|
||||
@@ -459,7 +242,6 @@ pub fn show(app: &mut SlideApp, ui: &mut Ui) {
|
||||
});
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
fn select_slides(app: &mut SlideApp, doc: &Presentation, selection: &Selection<Key>) {
|
||||
let selected: HashSet<_> = selection.items.iter().copied().collect();
|
||||
let mut ids: Vec<_> = doc.slides.iter().filter(|slide| selected.contains(&Key::Slide(slide.id))).map(|slide| slide.id.0).collect();
|
||||
@@ -477,16 +259,6 @@ fn select_slides(app: &mut SlideApp, doc: &Presentation, selection: &Selection<K
|
||||
}
|
||||
|
||||
fn section_menu(app: &mut SlideApp, ui: &mut Ui, index: usize, opener: &egui::Response, words: &SorterWords) {
|
||||
=======
|
||||
/// Notes Page: the slide on top and its notes underneath, on a page.
|
||||
pub fn notes_page(app: &mut SlideApp, ui: &mut Ui) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let avail = ui.available_rect_before_wrap();
|
||||
ui.painter().rect_filled(avail, CornerRadius::ZERO, t.canvas);
|
||||
if app.session.active().is_some() {
|
||||
app.document_widget(ui, avail, Sense::click());
|
||||
}
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
let Some(st) = app.session.active() else { return };
|
||||
let Some(section) = st.doc.sections.get(index) else { return };
|
||||
let (name, current, count) = (section.name.clone(), st.selection.slide, st.doc.sections.len());
|
||||
|
||||
@@ -56,7 +56,6 @@ pub fn status_bar(app: &mut SlideApp, ui: &mut Ui) {
|
||||
} else {
|
||||
words.slide_master.clone()
|
||||
};
|
||||
<<<<<<< HEAD
|
||||
let document = Size::new(st.doc.slide_size.width, st.doc.slide_size.height);
|
||||
let (lang, no_proof) = crate::dialogs::selected_language(app);
|
||||
let language = crate::squiggles::display_lang_name(ui.ctx(), &lang);
|
||||
@@ -85,109 +84,6 @@ pub fn status_bar(app: &mut SlideApp, ui: &mut Ui) {
|
||||
});
|
||||
if open_language {
|
||||
app.open_dialog("language", json!({}));
|
||||
=======
|
||||
use serde_json::json;
|
||||
|
||||
use crate::{Services, SlideApp, ViewMode};
|
||||
|
||||
/// A long proofing language in a narrow window must not take clicks meant for the controls on
|
||||
/// the right: Notes toggles the notes pane and the Language dialog stays closed.
|
||||
#[test]
|
||||
fn a_long_language_name_leaves_the_notes_button_clickable() {
|
||||
let mut app = SlideApp::new(Session::with_new(), Services::default());
|
||||
app.session.execute("shape.insert", &json!({"preset": "rect", "rect": [80, 120, 400, 100], "text": "hello"})).unwrap();
|
||||
app.session.execute("format.language", &json!({"lang": "en-US-x-a-very-long-private-use-tag"})).unwrap();
|
||||
app.ui.notes = false;
|
||||
let size = egui::vec2(700.0, 800.0);
|
||||
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(size).build_ui_state(
|
||||
|ui, app: &mut SlideApp| {
|
||||
app.logic(ui.ctx());
|
||||
app.ui(ui);
|
||||
},
|
||||
app,
|
||||
);
|
||||
h.run_steps(3);
|
||||
assert!(!h.state().ui.notes);
|
||||
{
|
||||
let mut notes = h.query_all_by_role_and_label(Role::Button, "Notes");
|
||||
let button = notes.next().expect("the Notes button is there");
|
||||
assert!(notes.next().is_none(), "exactly one Notes button, not a duplicated label target");
|
||||
assert_eq!(button.accesskit_node().toggled(), Some(Toggled::False), "the Notes button reports its off state to screen readers");
|
||||
}
|
||||
// The controls on the right start 560 points from the bar's right edge, which is 8 points
|
||||
// inside the window (x 132); the Notes button is the leftmost of them. Its position depends
|
||||
// on the interface font's widths, so the clicks use the position it was laid out at.
|
||||
let right_x = size.x - 8.0 - 560.0;
|
||||
let notes = h.get_by_label("Notes").rect();
|
||||
assert!(notes.left() > right_x + 2.0, "the Notes button ({notes:?}) starts after x {right_x}");
|
||||
let click = |h: &mut Harness<'_, SlideApp>, at: egui::Pos2| {
|
||||
h.hover_at(at);
|
||||
h.run_steps(1);
|
||||
for pressed in [true, false] {
|
||||
h.event(Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE });
|
||||
}
|
||||
h.run_steps(3);
|
||||
};
|
||||
// The gap before the controls is outside the language name's clickable area.
|
||||
click(&mut h, egui::pos2((right_x + notes.left()) / 2.0, notes.center().y));
|
||||
assert!(h.state().dialog.is_none(), "the Language dialog stayed closed");
|
||||
assert!(!h.state().ui.notes, "the click in the gap did not reach the Notes button");
|
||||
click(&mut h, notes.center());
|
||||
assert!(h.state().ui.notes, "the click reached the Notes button");
|
||||
assert_eq!(
|
||||
h.get_by_role_and_label(egui::Role::Button, "Notes").accesskit_node().toggled(),
|
||||
Some(Toggled::True),
|
||||
"the open notes pane is exposed as a pressed Notes button"
|
||||
);
|
||||
assert!(h.state().dialog.is_none(), "the Language dialog stayed closed");
|
||||
}
|
||||
|
||||
/// Screen readers find each status-bar control by name, hear the language and zoom it shows,
|
||||
/// hear which view button is on, and read the slide counter and the status message.
|
||||
#[test]
|
||||
fn status_bar_controls_have_names() {
|
||||
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1200.0, 800.0)).build_ui_state(
|
||||
|ui, app: &mut SlideApp| {
|
||||
app.logic(ui.ctx());
|
||||
app.ui(ui);
|
||||
},
|
||||
SlideApp::new(Session::with_new(), Services::default()),
|
||||
);
|
||||
h.run_steps(3);
|
||||
let status_y = h.get_by_role_and_label(Role::Button, "Fit slide to current window").rect().center().y;
|
||||
for name in ["Fit slide to current window", "Zoom In", "Zoom Out", "Slide Show", "Reading View"] {
|
||||
// The ribbon also has a "Slide Show" control. Require exactly one named button
|
||||
// in the Fit button's laid-out status row, allowing the app's UI zoom.
|
||||
let buttons = h.get_all_by_role_and_label(Role::Button, name).filter(|n| n.rect().y_range().contains(status_y)).count();
|
||||
assert_eq!(buttons, 1, "one {name} button in the status bar");
|
||||
}
|
||||
let pct = format!("{}%", (h.state().canvas_scale * 100.0).round());
|
||||
assert_eq!(h.get_by_role_and_label(Role::Button, "Zoom level").value().as_deref(), Some(pct.as_str()));
|
||||
let zoom = h.get_by_role_and_label(Role::Slider, "Zoom");
|
||||
assert_eq!(zoom.value().as_deref(), Some(pct.as_str()));
|
||||
// Its number and range are in percent, as the value text is.
|
||||
let node = zoom.accesskit_node();
|
||||
assert_eq!(node.numeric_value().map(f64::round), Some((h.state().canvas_scale * 100.0).round().into()));
|
||||
assert_eq!((node.min_numeric_value(), node.max_numeric_value()), (Some(10.0), Some(400.0)));
|
||||
assert_eq!(h.get_by_role_and_label(Role::Button, "Language").value().as_deref(), Some("English (United States)"));
|
||||
let toggled = |h: &Harness<'_, SlideApp>, name: &str| h.get_by_role_and_label(Role::Button, name).accesskit_node().toggled();
|
||||
assert_eq!(toggled(&h, "Normal"), Some(Toggled::True));
|
||||
assert_eq!(toggled(&h, "Slide Sorter"), Some(Toggled::False));
|
||||
h.get_by_role_and_label(Role::Button, "Slide Sorter").click();
|
||||
h.run_steps(3);
|
||||
assert_eq!(h.state().ui.view, ViewMode::Sorter, "the click by name reached the Slide Sorter button");
|
||||
assert_eq!(toggled(&h, "Slide Sorter"), Some(Toggled::True));
|
||||
assert_eq!(toggled(&h, "Normal"), Some(Toggled::False));
|
||||
assert_eq!(toggled(&h, "Reading View"), Some(Toggled::False));
|
||||
h.state_mut().ui.view = ViewMode::Reading;
|
||||
h.run_steps(3);
|
||||
assert_eq!(toggled(&h, "Reading View"), Some(Toggled::True));
|
||||
assert_eq!(toggled(&h, "Slide Sorter"), Some(Toggled::False));
|
||||
assert_eq!(h.get_by_value("Slide 1 of 1").accesskit_node().role(), Role::Label);
|
||||
h.state_mut().set_status("Saved a copy");
|
||||
h.run_steps(3);
|
||||
assert_eq!(h.get_by_value("Saved a copy").accesskit_node().role(), Role::Label);
|
||||
>>>>>>> b6dd921b46498082f4f451673ff694ee83413c08
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user