Compare commits

..
Author SHA1 Message Date
dependabot[bot] 07f2495f28 ci(deps): bump the actions group across 1 directory with 3 updates
Bumps the actions group with 3 updates in the / directory: [step-security/harden-runner](https://github.com/step-security/harden-runner), [storytold/craft-common-actions/.github/workflows/nightly-release.yml](https://github.com/storytold/craft-common-actions) and [storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml](https://github.com/storytold/craft-common-actions).


Updates `step-security/harden-runner` from 2.22.4 to 2.23.0
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/v2.22.4...v2.23.0)

Updates `storytold/craft-common-actions/.github/workflows/nightly-release.yml` from be00e5ccd18b68e950c8a08532f2230e7c3d0cba to 4ec2a14646b538253fd5ebe109bf463a3d31b061
- [Commits](https://github.com/storytold/craft-common-actions/compare/be00e5ccd18b68e950c8a08532f2230e7c3d0cba...4ec2a14646b538253fd5ebe109bf463a3d31b061)

Updates `storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml` from be00e5ccd18b68e950c8a08532f2230e7c3d0cba to 4ec2a14646b538253fd5ebe109bf463a3d31b061
- [Commits](https://github.com/storytold/craft-common-actions/compare/be00e5ccd18b68e950c8a08532f2230e7c3d0cba...4ec2a14646b538253fd5ebe109bf463a3d31b061)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-version: 2.23.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: storytold/craft-common-actions/.github/workflows/nightly-release.yml
  dependency-version: 1754016e67ca9b74dfa4cf4678b2ac3548e9840f
  dependency-type: direct:production
  dependency-group: actions
- dependency-name: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml
  dependency-version: 1754016e67ca9b74dfa4cf4678b2ac3548e9840f
  dependency-type: direct:production
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-11-26 11:06:31 +00:00
skylar taylor-barrick ab3aaa198b Nightly: stop blocking a refused launch on macOS (#2374)
Nightly launch fix under Skylar's Exec 454: the Launcher's trailing `--` no longer reaches the file list where that applied, and a refused launch no longer blocks on macOS (the reason goes to stderr and the app exits 2).
2026-11-26 00:46:14 -06:00
aiongg 5b7b22dc51 Merge pull request #2346 from aiongg/minimal-port-next
DeckCraft: move to craft-libs next (minimal port)
2026-11-25 23:08:47 -05:00
skylar taylor-barrick a3386f3f7b Switch on supervised nightlies on the nightly-signer branch (#2371)
Supervised nightly switch-on, merged under Skylar's explicit Nightly 758 override after green CI, CodeRabbit on this head with no open threads, Sonar passing, and an independent adversarial review with no blockers.
2026-11-25 20:44:08 -06:00
skylar taylor-barrick 08ba5072a7 Use the shared nightly launcher template (#2367)
Renders the plain nightly tar's launcher from craft-common-actions' shared template.

Independent check: dylanmtaylor compared all 14 app launcher PRs byte for byte with the template rendered from the registry (https://github.com/storytold/craft-common-actions/pull/367#issuecomment-7172085284); this head was re-checked against craft-common-actions main 88148a5.
2026-11-25 16:16:45 -06:00
aiongg c57f634702 Repin craft-libs to storytold next 8fa4db64a9 and egui to b9770908e 2026-11-25 19:15:18 +00:00
aiongg 93567cf2e8 Lock: gpu-allocator uses windows 0.62.2, as wgpu-hal does (the Windows release build) 2026-11-25 18:23:50 +00:00
aiongg 24bdb62f96 Test: a press that takes no focus leaves the slide focused 2026-11-25 15:51:23 +00:00
aiongg 57a22b944f Repin craft-libs to storytold next aa401985d 2026-11-25 15:51:12 +00:00
aiongg 3791ce1189 Chart label test: Excel's ? placeholders are spaces 2026-11-25 14:19:40 +00:00
aiongg d532ff66a1 The slide takes the keyboard back when nothing has it and Tab has work 2026-11-25 14:14:09 +00:00
aiongg c74671d7c6 The slide keeps the keyboard after toolbar presses and dialogs; runtime windows carry the Nightly id 2026-11-25 14:12:47 +00:00
aiongg 44c80663b4 The canvas is one real Tab stop and takes the keyboard when pressed 2026-11-25 13:58:47 +00:00
aiongg 53e994b4e4 Allow egui::ComboBox: craft-libs next has no drop-in craft_ui::ComboBox 2026-11-25 13:57:02 +00:00
aiongg 96a244dcc5 Repin craft-libs to craft-libs#3505 head d1bdf8e5da (storytold next 980669cdce plus the host_canvas focus work) 2026-11-25 13:43:18 +00:00
aiongg b5a0f61c6b Repin craft-libs to storytold next 980669cdce and egui to storytold b15ffe9bfc 2026-11-25 13:42:42 +00:00
aiongg 32aac1d11c Merge main into minimal-port-next
Conflict: crates/ui-egui/src/lib.rs (kept both pub mod flavor and pub mod framework).
2026-11-25 13:40:58 +00:00
aiongg 9fb14fa6ec Repin craft-libs to 2f8d73e7cf (next-host-input on today's next) 2026-11-24 15:59:28 +00:00
aiongg 65df3159f8 Repin craft-libs to cd87dc61f7; pass the app icon to the host 2026-11-24 03:02:49 +00:00
aiongg 0d8d4b75d2 Claim Alt+1..9 for the Quick Access Toolbar on the document canvas; test that window keys reach the app 2026-11-24 01:32:58 +00:00
aiongg bfdca1cecd Test round 1: the offered-release test waits for the offer's install check 2026-11-24 01:22:03 +00:00
aiongg 1afbb0ecc3 Host the craft-ui runtime: embed hooks, update dialogs on a DialogHost, framework fonts, window Escape, document canvas; tests install the runtime 2026-11-24 01:07:19 +00:00
aiongg 49fb5cf76b Repin: Cargo.lock on the new pins (rustix 1.1.6) and the two new craft-pptx chart fields 2026-11-24 01:00:50 +00:00
aiongg 8a41a44b9f minimal-port rewrite: 31 edits (combo 31) 2026-11-24 00:55:21 +00:00
aiongg 205005691d minimal-port repin: 34 edits (revs 33, features 1) 2026-11-24 00:54:50 +00:00
117 changed files with 3597 additions and 1041 deletions
+5 -5
View File
@@ -2,13 +2,13 @@
"schema": "craft-nightly-release-policy/v3",
"repository": "storytold/deckcraft",
"repository_id": 1408294296,
"producer_workflow_id": null,
"producer_workflow_id": 429734568,
"producer_workflow_path": ".github/workflows/nightly.yml",
"producer_tooling_revision": "605d58766e8f536564da8fc81d3676ac86816dea",
"producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@605d58766e8f536564da8fc81d3676ac86816dea",
"producer_tooling_revision": "be00e5ccd18b68e950c8a08532f2230e7c3d0cba",
"producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba",
"signer_workflow_path": ".github/workflows/nightly-sign.yml",
"signer_tooling_revision": "605d58766e8f536564da8fc81d3676ac86816dea",
"release_branch": "release",
"signer_tooling_revision": "be00e5ccd18b68e950c8a08532f2230e7c3d0cba",
"release_branch": "nightly-signer",
"manual_actors": [
"bflatastic",
"dylanmtaylor",
+9 -9
View File
@@ -5,21 +5,21 @@ version: 'v0.0.3'
workflows:
'.github/workflows/ci.yml':
- 'actions/checkout@v7.0.1'
- 'step-security/harden-runner@v2.22.4'
- 'step-security/harden-runner@v2.23.0'
'.github/workflows/freebsd.yml': []
'.github/workflows/house-rules.yml': []
'.github/workflows/lockfile.yml':
- 'actions/checkout@v7.0.1'
- 'step-security/harden-runner@v2.22.4'
'.github/workflows/nightly-sign.yml': []
'.github/workflows/nightly.yml': []
- 'step-security/harden-runner@v2.23.0'
'.github/workflows/nightly-macos.yml':
- 'actions/checkout@v7.0.1'
- 'step-security/harden-runner@v2.22.4'
- 'step-security/harden-runner@v2.23.0'
'.github/workflows/nightly-sign.yml': []
'.github/workflows/nightly.yml': []
'.github/workflows/nix.yml': []
'.github/workflows/packaging-lint.yml':
- 'actions/checkout@v7.0.1'
- 'step-security/harden-runner@v2.22.4'
- 'step-security/harden-runner@v2.23.0'
'.github/workflows/release.yml': []
'.github/workflows/sonarcloud.yml': []
'.github/workflows/windows-arm64.yml': []
@@ -29,8 +29,8 @@ dependencies:
commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
owner_id: 44036562
repo_id: 197814629
'step-security/harden-runner@v2.22.4':
ref: 'v2.22.4'
commit: 'sha1-1d88384fd173af6ecb012dfd0264a306b711241a'
'step-security/harden-runner@v2.23.0':
ref: 'v2.23.0'
commit: 'sha1-aebdcf6156ab6691adf63218240e476564a1ed4c'
owner_id: 88700172
repo_id: 422287306
+1 -1
View File
@@ -27,7 +27,7 @@ jobs:
CRAFT_FONTS_REF: 37827adc41fd165f9a9234ac40f94dbad353aa69
steps:
- name: Harden runner
uses: step-security/harden-runner@v2.22.4
uses: step-security/harden-runner@v2.23.0
with:
egress-policy: audit
- name: Check out craft-fonts
+1 -1
View File
@@ -22,7 +22,7 @@ jobs:
timeout-minutes: 10
steps:
- name: Harden runner
uses: step-security/harden-runner@v2.22.4
uses: step-security/harden-runner@v2.23.0
with:
egress-policy: audit
- uses: actions/checkout@v7.0.1
+1 -1
View File
@@ -36,7 +36,7 @@ jobs:
RUST_BACKTRACE: 1
steps:
- name: Harden runner
uses: step-security/harden-runner@v2.22.4
uses: step-security/harden-runner@v2.23.0
with:
egress-policy: audit
- uses: actions/checkout@v7.0.1
+10 -7
View File
@@ -1,7 +1,8 @@
name: DeckCraft release-ref nightly signer
# Enabled for supervised manual dispatch on release. Main/release contents must match.
# A reusable callee does not change context; this must be a real top-level release dispatch.
# Enabled for supervised manual dispatch on the dedicated nightly-signer branch, which only ever
# fast-forwards to reviewed main commits (never the stable release branch).
# A reusable callee does not change context; this must be a real top-level signer-branch dispatch.
on:
workflow_dispatch:
inputs:
@@ -22,21 +23,23 @@ concurrency:
jobs:
release:
# Actual context guards: official repository, manual dispatch, real release branch.
# Actual context guards: official repository, manual dispatch, real nightly-signer branch.
if: >-
github.repository == 'storytold/deckcraft' &&
github.event_name == 'workflow_dispatch' &&
github.ref == 'refs/heads/release' && github.ref_type == 'branch'
github.ref == 'refs/heads/nightly-signer' && github.ref_type == 'branch'
permissions:
contents: write
actions: read
checks: read
attestations: write
id-token: write
uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@605d58766e8f536564da8fc81d3676ac86816dea
uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@4ec2a14646b538253fd5ebe109bf463a3d31b061
with:
tooling-revision: 605d58766e8f536564da8fc81d3676ac86816dea
tooling-revision: be00e5ccd18b68e950c8a08532f2230e7c3d0cba
app-name: deckcraft
producer_run_id: ${{ inputs.producer_run_id }}
producer_run_attempt: ${{ inputs.producer_run_attempt }}
# No secrets: inherit or raw platform values in this caller. Only the isolated native
# callee job may bind the existing release environment and export keys in its signing step.
# callee job may bind the release environment and export its keys; that environment must
# admit nightly-signer alongside release before the first dispatch.
+4 -4
View File
@@ -22,13 +22,13 @@ jobs:
actions: read
attestations: write
id-token: write
uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@605d58766e8f536564da8fc81d3676ac86816dea
uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@4ec2a14646b538253fd5ebe109bf463a3d31b061
with:
tooling-revision: 605d58766e8f536564da8fc81d3676ac86816dea
tooling-revision: be00e5ccd18b68e950c8a08532f2230e7c3d0cba
app-name: deckcraft
manual-actors: '["bflatastic","dylanmtaylor","echelon","FredApps","skylartaylor"]'
craft-fonts-ref: 37827adc41fd165f9a9234ac40f94dbad353aa69
# One producer run builds every listed platform for one all-or-nothing release. The pin is the
# craft-common-actions main commit that merged #339 (bounded lineage compares), on top of the
# Linux/macOS signer (#342).
# craft-common-actions main commit that merged the exact-analysis admission (#371, after #370,
# #369 and #364).
platforms: '["windows-x86_64","linux-x86_64","macos-aarch64"]'
+2 -2
View File
@@ -28,7 +28,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Harden runner
uses: step-security/harden-runner@v2.22.4
uses: step-security/harden-runner@v2.23.0
with:
egress-policy: audit
- uses: actions/checkout@v7.0.1
@@ -58,7 +58,7 @@ jobs:
contents: read
steps:
- name: Harden runner
uses: step-security/harden-runner@v2.22.4
uses: step-security/harden-runner@v2.23.0
with:
egress-policy: audit
- uses: actions/checkout@v7.0.1
Generated
+1420 -123
View File
File diff suppressed because it is too large Load Diff
+38 -32
View File
@@ -4,7 +4,7 @@ members = ["crates/*", "apps/*", "xtask"]
default-members = ["crates/*", "apps/deckcraft", "apps/deckcraft-cli"]
[workspace.package]
version = "0.19.1"
version = "0.19.0"
edition = "2024"
license = "MIT OR Apache-2.0"
rust-version = "1.95"
@@ -12,17 +12,17 @@ repository = "https://github.com/storytold/deckcraft"
[workspace.dependencies]
# OPC part-name primitives and package reader/writer.
craft-opc = { git = "https://github.com/storytold/craft-libs", rev = "8048f8ef92da80fb3ce5a056d59ca591ee66faf1", 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 = "8048f8ef92da80fb3ce5a056d59ca591ee66faf1", version = "0.1.0" }
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 = "8048f8ef92da80fb3ce5a056d59ca591ee66faf1", version = "0.1.0" }
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 = "8048f8ef92da80fb3ce5a056d59ca591ee66faf1", version = "0.1.0" }
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 = "8048f8ef92da80fb3ce5a056d59ca591ee66faf1", version = "0.1.0" }
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 = "bc186ca719958fcce3b6ee24794277eabed14609", version = "0.1.0" }
craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" }
# internal
deckcraft-geom = { path = "crates/geom" }
deckcraft-color = { path = "crates/color" }
@@ -62,21 +62,27 @@ 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.
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "254e9a409b410dc93c0e06ff66cd1e767893ac32", 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 = "254e9a409b410dc93c0e06ff66cd1e767893ac32", version = "=0.1.0" }
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "d0193d7e94b5ec180ecc2a152ea72047d39ac632", version = "=0.1.0" }
craft-media = { git = "https://github.com/storytold/craft-libs", rev = "010702ee9b030844c852939095b1da0d0656a890", version = "=0.1.0", default-features = false }
craft-audio = { git = "https://github.com/storytold/craft-libs", rev = "010702ee9b030844c852939095b1da0d0656a890", version = "=0.1.0", default-features = false, features = ["opus-decode"] }
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 = "010702ee9b030844c852939095b1da0d0656a890", version = "=0.1.0", default-features = false, features = ["h264-decode", "hevc-decode", "vp9-decode", "av1-decode", "threads"] }
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 = "f428c3d36e0faf3924b76956a01334c051543527", version = "=0.1.0" }
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "63196e66f3033a6623eb629af95a104d26986725", version = "=0.1.0", default-features = false, features = ["write", "write-simple-text"] }
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 = "63196e66f3033a6623eb629af95a104d26986725", features = ["egui"] }
craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "63196e66f3033a6623eb629af95a104d26986725", version = "=0.1.0" }
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" }
i_overlay = "9"
quick-xml = "0.41"
zip = { version = "3", default-features = false, features = ["deflate"] }
@@ -123,19 +129,19 @@ codegen-units = 16
debug = 0
[patch.crates-io]
krilla = { git = "https://github.com/storytold/craft-libs", rev = "63196e66f3033a6623eb629af95a104d26986725", version = "=0.8.2" }
ecolor = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
emath = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
epaint = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui-winit = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui_glow = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui_extras = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
eframe = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
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" }
winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" }
+7 -4
View File
@@ -183,10 +183,13 @@ dictionary or single window state. The Nightly app is started only by ArtCraft L
fenced against every stable data and install folder, so a Nightly window cannot fall back to
stable state. Nightly is managed by the Launcher and does not self-update.
On Linux, every Nightly format starts through the same launcher
(`packaging/linux/nightly-launch.sh`): the `.tar.gz` and AppImage, the deb/rpm package, the Flatpak
and the Arch handoff all pass `--launch-profile nightly-v1 --profile-root <dir> -- <files>` to the
GUI, so an unpacked or distro-installed copy is isolated without the Launcher.
On Linux, the plain nightly `.tar.gz` starts through the canonical shared launcher template
(`packaging/linux/nightly-launch.sh`, rendered from `craft-common-actions`'s
`scripts/nightly-launcher.sh.in`): `deckcraft` starts `deckcraft-bin` beside it on the nightly-v1
profile under the Nightly package identity. The distro formats keep their own launcher
(`packaging/linux/nightly-package-launch.sh`) and their own profile folder; the AppImage, the deb/rpm
package, the Flatpak and the Arch handoff all pass `--launch-profile nightly-v1 --profile-root <dir>
-- <files>` to the GUI, so an unpacked or distro-installed copy is isolated without the Launcher.
The channel's packaging lives in `packaging/nightly-common.sh`, `packaging/{linux,macos,windows}/nightly*`
and `.github/workflows/nightly*.yml`. The producer and signer workflows are registered and can be
+2 -2
View File
@@ -17,9 +17,9 @@ path = "src/main.rs"
deckcraft-engine = { workspace = true }
deckcraft-ui-egui = { workspace = true }
# 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 = "fd5e2feff6ea25bed371a99cc732b3968d621505", version = "0.1.0" }
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 = "fd5e2feff6ea25bed371a99cc732b3968d621505", version = "0.1.0" }
craft-web-host = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", version = "0.1.0" }
egui = { workspace = true }
log = { workspace = true }
serde_json = { workspace = true }
+5
View File
@@ -49,10 +49,13 @@ pub fn start() {
log::info!("deckcraft-web {}: wgpu backend {:?}", env!("CARGO_PKG_VERSION"), rs.adapter.get_info().backend);
}
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());
if let Some(bridge) = &app_bridge {
@@ -131,6 +134,7 @@ 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);
}
@@ -166,6 +170,7 @@ 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) {
+32 -3
View File
@@ -49,12 +49,16 @@ impl eframe::App for App {
#[cfg(target_os = "macos")]
apple_events::poll(&self.1, &mut self.0, ctx);
self.0.logic(ctx);
self.0.close_path(ctx);
}
/// Forward native raw input to the wrapped application once per pass.
/// 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) {
self.0.raw_input_hook(ctx, raw);
self.0.before_input(ctx);
}
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
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);
}
fn on_exit(&mut self) {
@@ -253,12 +257,20 @@ fn initialize_nightly_process_identity() -> Result<(), process_identity::Identit
)
}
/// Whether a refusal may also open a native message box. Standard error always carries the reason;
/// this only adds a box where one renders without the app's event loop. Never on macOS: rfd's alert
/// there needs the AppKit run loop this start has not reached, so a refused nightly launch hung in
/// an invisible modal instead of exiting (GridCraft Mac smoke, 2026-11-26).
fn refusal_dialog(flavor: build_flavor::BuildFlavor, desktop_session: bool, macos: bool) -> bool {
build_flavor::needs_native_error(flavor, desktop_session) && !macos
}
fn report_launch_profile_error(error: &str) {
eprintln!("DeckCraft launch profile: {error}");
let desktop_session = cfg!(windows)
|| cfg!(target_os = "macos")
|| (cfg!(target_os = "linux") && ["DISPLAY", "WAYLAND_DISPLAY"].into_iter().any(|key| std::env::var_os(key).is_some_and(|v| !v.is_empty())));
if build_flavor::needs_native_error(build_flavor::COMPILED, desktop_session) {
if refusal_dialog(build_flavor::COMPILED, desktop_session, cfg!(target_os = "macos")) {
if let Err(error) = initialize_nightly_process_identity() {
eprintln!("DeckCraft launch profile: {error}");
return;
@@ -361,6 +373,8 @@ fn main() -> eframe::Result {
}
};
// `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());
#[cfg(not(all(unix, not(target_os = "macos"))))]
@@ -391,6 +405,7 @@ fn main() -> eframe::Result {
deckcraft_ui_egui::os_window::name_for(deckcraft_ui_egui::os_window::identity()),
options,
Box::new(move |cc| {
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.
@@ -672,3 +687,17 @@ mod tests {
assert!(script.contains("has no embedded icon"), "package.ps1 does not reject an iconless exe");
}
}
#[cfg(test)]
mod refusal_dialog_tests {
use super::refusal_dialog;
use crate::build_flavor::BuildFlavor;
#[test]
fn a_refusal_never_blocks_on_a_modal_before_the_event_loop_on_macos() {
assert!(refusal_dialog(BuildFlavor::NightlyV1, true, false), "a desktop refusal still shows the box where one renders");
assert!(!refusal_dialog(BuildFlavor::NightlyV1, true, true), "macOS has no run loop yet: the modal would hang");
assert!(!refusal_dialog(BuildFlavor::NightlyV1, false, false), "a headless session has no box");
assert!(!refusal_dialog(BuildFlavor::Stable, true, false), "only a nightly refusal explains itself in a box");
}
}
-3
View File
@@ -2,7 +2,4 @@ allow-unwrap-in-tests = true
allow-expect-in-tests = true
allow-panic-in-tests = true
allow-indexing-slicing-in-tests = true
disallowed-types = [
{ path = "egui::ComboBox", reason = "use craft_ui::ComboBox: egui's combo box menu can't grow back while open (egui#5225)" },
]
cognitive-complexity-threshold = 30
+8
View File
@@ -293,6 +293,14 @@ impl Session {
Ok(true)
}
/// Whether Tab has something to do here: text is being edited (it indents, types a tab or goes to the next table
/// cell), or the slide has an object after the selected one. Past the last object it has nothing left to select.
pub fn tab_has_work(&self) -> bool {
let Some(st) = self.active() else { return false };
let last = st.shapes().iter().rev().find(|s| !s.hidden).map(|s| s.id);
st.selection.text.is_some() || (last.is_some() && st.selection.shapes.first().copied() != last)
}
fn cycle_selection(&mut self, forward: bool) -> Result<()> {
let st = self.doc()?;
let ids: Vec<_> = st.shapes().iter().filter(|s| !s.hidden).map(|s| s.id).collect();
+3 -2
View File
@@ -1181,7 +1181,8 @@ 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 ₽");
assert_eq!(c.axis_label(false, 0.0), "- ₽");
// Excel shows each `?` of the zero section as a space.
assert_eq!(c.axis_label(false, 0.0), "- ₽");
// No format: General.
assert_eq!(c.axis_label(true, 2.5), "2,5");
c.lang = None;
@@ -1190,7 +1191,7 @@ mod tests {
c.lang = Some("ru-RU".into());
c.series[0].number_format = Some(r#"#,##0\ "₽""#.into());
assert_eq!(c.data_label(&c.series[0], 516_600_000.0), "516\u{a0}600\u{a0}000 ₽");
assert_eq!(c.data_label(&c.series[1], 0.0), "- ₽");
assert_eq!(c.data_label(&c.series[1], 0.0), "- ₽");
}
#[test]
+3
View File
@@ -1298,6 +1298,9 @@ fn chart_to(c: &dm_chart::Chart) -> cd_chart::Chart {
gridlines: c.gridlines,
minor_gridlines: c.minor_gridlines,
axis_titles: c.axis_titles.clone(),
// DeckCraft's chart model keeps the raw category labels and the 1900 date system.
category_format: None,
date_1904: false,
style: c.style,
palette: c.palette.clone(),
plot_fill: c.plot_fill.as_ref().map(fill_to),
+4
View File
@@ -21,6 +21,10 @@ deckcraft-media = { workspace = true }
egui = { workspace = true, features = ["default_fonts", "monochrome_emoji_fonts"] }
egui_extras = { workspace = true }
craft-ui = { workspace = true }
craft-host = { workspace = true }
craft-keymap = { workspace = true }
craft-theme = { workspace = true }
craft-window = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
log = { workspace = true }
+11 -7
View File
@@ -21,13 +21,17 @@ fn harness() -> Harness<'static, SlideApp> {
}
let mut app = SlideApp::new(s, Services::default());
app.ui.pane = Some("animation".into());
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1400.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h
}
+8 -8
View File
@@ -13,6 +13,7 @@ use super::{
mod clipboard;
mod commands;
mod control;
mod document_focus;
pub(crate) mod files;
mod frame;
mod ime;
@@ -22,6 +23,7 @@ mod playback;
#[cfg(test)]
pub(crate) use clipboard::{OBJECTS_MARKER, system_clipboard_text};
pub(crate) use document_focus::DocumentFocus;
#[cfg(test)]
pub(crate) use files::web_image_files;
pub use keys::key_name;
@@ -69,6 +71,7 @@ impl SlideApp {
synthetic_generation: 0,
synthetic_target: None,
synthetic_focus: None,
document_focus: DocumentFocus::default(),
synthetic_injected_time: None,
ribbon_scroll: HashMap::new(),
show_instance: 0,
@@ -86,6 +89,8 @@ impl SlideApp {
print_previews: files::PrintPreviews::default(),
#[cfg(not(target_arch = "wasm32"))]
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,
@@ -247,14 +252,6 @@ impl SlideApp {
if !self.synthetic.is_empty() || !self.synthetic_next.is_empty() || self.synthetic_pending {
ctx.request_repaint();
}
// Closing the window with unsaved changes asks first.
if ctx.input(|i| i.viewport().close_requested()) && !self.quit_confirmed && self.session.documents().iter().any(|d| d.is_dirty()) {
ctx.send_viewport_cmd(egui::ViewportCommand::CancelClose);
self.show = None;
if self.dialog.as_ref().is_none_or(|d| d.id != "quit") {
self.dialog = Some(dialogs::Dialog::new("quit"));
}
}
self.autosave_if_due(ctx);
self.tick_media_clock(ctx);
self.note_settled_composition(ctx);
@@ -293,6 +290,7 @@ impl SlideApp {
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.
@@ -356,11 +354,13 @@ impl SlideApp {
}
}
});
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);
for url in std::mem::take(&mut self.pending_urls) {
ctx.open_url(egui::OpenUrl::new_tab(url));
+125
View File
@@ -0,0 +1,125 @@
//! The document window (the slide canvas, the slide sorter or the notes page) as the window's one document canvas: its
//! widget, its Tab stop and when it takes the keyboard focus.
use craft_ui::runtime::overlay::{self, OpenFilter};
use super::{SlideApp, ViewMode};
use crate::framework::{document_id, focus_document, focused_widget, host_canvas};
/// How many passes the document asks for the focus: egui names the widget of a closed palette, dialog or menu as
/// focused for one pass after it was last drawn.
const ASKING_PASSES: u8 = 2;
/// What the document window's focus depends on from pass to pass.
#[derive(Default)]
pub(crate) struct DocumentFocus {
/// The presentation (its uid) whose document window the pass drew; `None` on the start screen, the File tab and in
/// a slide show.
pub(super) drawn: Option<u64>,
/// The passes left in which a presentation that opened or became active asks for the focus.
opened: u8,
/// The passes left in which the document asks for the focus after a dialog, menu or popup closed.
uncovered: u8,
}
impl SlideApp {
/// Draws the document window's widget over `rect` and declares it as the window's canvas. A press in it gives it
/// the focus, unless a dialog is open. Real presses only: with the document focused, egui makes Enter and Space
/// clicks of it.
pub(crate) fn document_widget(&mut self, ui: &egui::Ui, rect: egui::Rect, sense: egui::Sense) -> egui::Response {
let resp = ui.interact(rect, document_id(), sense);
self.document_focus.drawn = self.session.active().map(|d| d.uid);
host_canvas(ui.ctx(), self.document_keeps_tab(ui.ctx()));
if resp.is_pointer_button_down_on() && ui.input(|i| i.pointer.any_pressed()) && !self.dialog_open(ui.ctx()) {
focus_document(ui.ctx());
}
resp
}
/// [`Self::document_widget`] behind widgets that take the presses (the slide sorter's thumbnails): a press on any of
/// them gives the document the focus, unless a text field has it.
pub(crate) fn document_behind(&mut self, ui: &egui::Ui, rect: egui::Rect) {
self.document_widget(ui, rect, egui::Sense::focusable_noninteractive());
let pressed = ui.input(|i| i.pointer.any_pressed()) && ui.rect_contains_pointer(rect);
if pressed && !ui.ctx().text_edit_focused() && !self.overlay_open(ui.ctx()) {
focus_document(ui.ctx());
}
}
/// Whether the document window is the slide being edited, where Tab can have work.
fn editing_slide(&self) -> bool {
self.backstage.is_none() && matches!(self.ui.view, ViewMode::Normal | ViewMode::Outline | ViewMode::Reading)
}
/// Whether the focused document keeps Tab: on the slide, while the session has something for it to do. A modal
/// dialog, a menu or a popup that is up gets it instead.
fn document_keeps_tab(&self, ctx: &egui::Context) -> bool {
self.editing_slide() && self.session.tab_has_work() && !self.overlay_open(ctx)
}
/// Whether a dialog, DeckCraft's or a modal one of the framework's, the palette or the opening overlay is up.
fn dialog_open(&self, ctx: &egui::Context) -> bool {
self.dialog.as_ref().is_some_and(|d| d.modal())
|| self.palette.is_some()
|| self.opening.is_some()
|| overlay::any_open(ctx, OpenFilter::Modal)
}
/// Whether a dialog ([`Self::dialog_open`]), or an egui menu or popup, is up.
fn overlay_open(&self, ctx: &egui::Context) -> bool {
self.dialog_open(ctx) || ctx.any_popup_open() || egui::Popup::is_any_open(ctx)
}
/// Whether the document may take the focus: no text field and no widget of another layer (the framework's update
/// notice) has it.
fn focus_is_free(ctx: &egui::Context) -> bool {
let layer = |id| ctx.read_response(id).map(|widget| widget.layer_id);
!ctx.text_edit_focused() && focused_widget(ctx).is_none_or(|id| layer(id) == layer(document_id()))
}
/// Ends the document window's pass, after the views; `before` is the presentation the last pass drew. The pass's
/// input has changed what Tab has to do, so the document is declared again. A presentation that opened or became
/// active asks for the focus. So does the document with nothing focused, when a dialog, menu or popup has closed, and
/// while Tab has work on the slide (a ribbon field committed with Enter leaves nothing focused). All wait for the
/// last dialog, menu or popup to close.
pub(super) fn finish_document(&mut self, ctx: &egui::Context, before: Option<u64>) {
let drawn = self.document_focus.drawn;
if drawn.is_none() {
self.document_focus.opened = 0;
self.document_focus.uncovered = 0;
return;
}
let keeps_tab = self.document_keeps_tab(ctx);
host_canvas(ctx, keeps_tab);
if drawn != before {
self.document_focus.opened = ASKING_PASSES;
}
if self.overlay_open(ctx) {
self.document_focus.uncovered = ASKING_PASSES;
return;
}
let unfocused = ctx.memory(|m| m.focused().is_none());
let DocumentFocus { opened, uncovered, .. } = &mut self.document_focus;
if *opened == 0 && *uncovered == 0 && !(unfocused && keeps_tab) {
return;
}
if unfocused || (*opened > 0 && Self::focus_is_free(ctx)) {
(*opened, *uncovered) = (0, 0);
focus_document(ctx);
} else {
(*opened, *uncovered) = (opened.saturating_sub(1), uncovered.saturating_sub(1));
ctx.request_repaint();
}
}
/// While slide text is being edited, the text owns the keyboard (#93). The focus on an ordinary widget (the ribbon
/// button whose Space inserted the text box) would swallow every later key and end text entry, and with nothing
/// focused (a ribbon field committed with Enter) Tab would leave the text. The document takes the focus; a text
/// field or an open menu keeps its keys.
pub(super) fn edited_text_takes_focus(&self, ctx: &egui::Context) {
let editing = self.editing_slide() && self.session.active().is_some_and(|d| d.selection.text.is_some());
if editing && !ctx.memory(|m| m.has_focus(document_id())) && !self.overlay_open(ctx) && Self::focus_is_free(ctx) {
focus_document(ctx);
}
}
}
+1 -1
View File
@@ -145,7 +145,7 @@ impl SlideApp {
&& ctx.input(|i| i.viewport().focused.unwrap_or(true))
&& ctx.input(|i| i.viewport().visible() != Some(false))
&& !ctx.input(|i| i.viewport().close_requested())
&& ctx.memory(|m| m.focused().is_none())
&& !crate::framework::widget_has_keyboard(ctx)
&& self.dialog.as_ref().is_none_or(|d| !d.modal())
&& self.palette.is_none()
&& self.backstage.is_none()
+2 -2
View File
@@ -140,7 +140,7 @@ impl SlideApp {
return;
}
let current = self.input_target();
let focus = ctx.memory(|m| m.focused());
let focus = crate::framework::focused_widget(ctx);
if self.synthetic_target == Some(current) && focus == self.synthetic_focus {
return;
}
@@ -210,7 +210,7 @@ impl SlideApp {
Err(e) => self.set_status(e),
}
}
let focus = ctx.memory(|m| m.focused());
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 {
+9 -22
View File
@@ -1,5 +1,6 @@
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,
@@ -47,9 +48,12 @@ impl SlideApp {
}
}
/// Keyboard and clipboard for the slide (when no text field has focus).
/// Keyboard and clipboard for the slide (with nothing or the document window focused).
pub(super) fn keyboard(&mut self, ctx: &egui::Context) {
let events = ctx.input(|i| i.events.clone());
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.
@@ -76,26 +80,15 @@ impl SlideApp {
// 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()) && ctx.memory(|m| m.focused().is_none()) {
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();
// While slide text is being edited, the text owns the keyboard (#93). Tab and the arrow
// keys move egui's keyboard focus onto ordinary widgets (the window's drag handle, ribbon
// buttons), and that stray focus would swallow every later key and end text entry. Let it
// go; a real text field or an open menu keeps its keys.
if !modal
&& self.session.active().is_some_and(|d| d.selection.text.is_some())
&& !ctx.text_edit_focused()
&& !ctx.any_popup_open()
&& let Some(id) = ctx.memory(|m| m.focused())
{
ctx.memory_mut(|m| m.surrender_focus(id));
}
if ctx.memory(|m| m.focused().is_some()) || modal {
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);
@@ -177,12 +170,6 @@ impl SlideApp {
}
}
egui::Event::Key { key, pressed: true, modifiers, .. } => {
if key == egui::Key::Tab {
// The slide has the keyboard, so Tab is ours (indent, tab character, next
// shape). Left to egui it would also focus the first ribbon widget, and
// every key after it would go there instead of the slide (#78).
ctx.memory_mut(|m| m.move_focus(egui::FocusDirection::None));
}
if key == egui::Key::Escape && self.anim_preview.is_some() && !modifiers.command && !modifiers.ctrl && !modifiers.alt {
self.anim_preview = None;
continue;
+2 -2
View File
@@ -156,7 +156,7 @@ pub(super) fn save_as(app: &mut SlideApp, ui: &mut Ui, bs: &mut Backstage, out:
ui.add_space(14.0);
let current = SAVE_TYPES.iter().find(|s| s.0 == bs.file_type).map_or(SAVE_TYPES[0].1, |s| s.1);
ui.horizontal(|ui| {
craft_ui::ComboBox::from_id_salt("backstage_save_type")
egui::ComboBox::from_id_salt("backstage_save_type")
.width(340.0)
// Every type in view: at the default height the last ones were behind a scroll.
.height(f32::INFINITY)
@@ -234,7 +234,7 @@ pub(super) fn about(app: &mut SlideApp, ui: &mut Ui) {
ui.set_width(340.0);
heading(ui, "Appearance");
let dark = app.ui.brightness == theme::Brightness::Dark;
craft_ui::ComboBox::from_id_salt("backstage_appearance")
egui::ComboBox::from_id_salt("backstage_appearance")
.width(260.0)
.selected_text(if dark { "Dark" } else { "Light" })
.show_ui(ui, |ui| {
+5 -5
View File
@@ -96,7 +96,7 @@ pub(super) fn print(app: &mut SlideApp, ui: &mut Ui, bs: &mut Backstage) {
PrintScope::Current => "Print Current Slide",
PrintScope::Custom => "Custom Range",
};
let combo = craft_ui::ComboBox::from_id_salt("backstage_print_scope").width(240.0).selected_text(scope).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt("backstage_print_scope").width(240.0).selected_text(scope).show_ui(ui, |ui| {
for (s, label) in
[(PrintScope::All, "Print All Slides"), (PrintScope::Current, "Print Current Slide"), (PrintScope::Custom, "Custom Range")]
{
@@ -119,7 +119,7 @@ pub(super) fn print(app: &mut SlideApp, ui: &mut Ui, bs: &mut Backstage) {
});
ui.add_space(4.0);
let layout = LAYOUTS.iter().find(|l| l.0 == bs.print_layout).map_or("Full Page Slides", |l| l.1);
let combo = craft_ui::ComboBox::from_id_salt("backstage_print_layout").width(240.0).selected_text(layout).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt("backstage_print_layout").width(240.0).selected_text(layout).show_ui(ui, |ui| {
for (id, label) in LAYOUTS {
if ui.selectable_label(bs.print_layout == id, label).clicked() {
bs.print_layout = id;
@@ -133,7 +133,7 @@ pub(super) fn print(app: &mut SlideApp, ui: &mut Ui, bs: &mut Backstage) {
// for notes pages and handouts.
ui.add_enabled_ui(bs.print_layout != "slides", |ui| {
let paper = deckcraft_engine::cmd::file::PAPERS.iter().find(|p| p.0 == bs.print_paper).map_or("Letter", |p| p.1);
craft_ui::ComboBox::from_id_salt("backstage_print_paper")
egui::ComboBox::from_id_salt("backstage_print_paper")
.width(240.0)
.selected_text(paper)
.show_ui(ui, |ui| {
@@ -147,7 +147,7 @@ pub(super) fn print(app: &mut SlideApp, ui: &mut Ui, bs: &mut Backstage) {
.widget_info(|| egui::WidgetInfo::labeled(egui::Role::ComboBox, true, "Paper size"));
ui.add_space(4.0);
let orient = if bs.print_landscape { "Landscape Orientation" } else { "Portrait Orientation" };
craft_ui::ComboBox::from_id_salt("backstage_print_orientation")
egui::ComboBox::from_id_salt("backstage_print_orientation")
.width(240.0)
.selected_text(orient)
.show_ui(ui, |ui| {
@@ -321,7 +321,7 @@ pub(super) fn export(app: &mut SlideApp, ui: &mut Ui, bs: &mut Backstage) {
ExportTask::Handouts => {
ui.label(RichText::new("Create Handouts").font(theme::font(16.0)).color(t.text));
bullets(ui, &["Several slides on each page of a PDF", "Three a page leaves lines for notes", "Print them for your audience"]);
let combo = craft_ui::ComboBox::from_id_salt("backstage_handouts")
let combo = egui::ComboBox::from_id_salt("backstage_handouts")
.width(240.0)
.selected_text(format!("{} slides per page", bs.handouts_per_page))
.show_ui(ui, |ui| {
+3 -3
View File
@@ -16,7 +16,7 @@ use crate::backstage::{Backstage, NAV_W, Nav, Page, PrintScope, entries, format_
use crate::{Services, SlideApp};
fn harness(app: SlideApp) -> Harness<'static, SlideApp> {
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
@@ -184,7 +184,7 @@ fn every_page_renders() {
/// In a window narrower than the page's maximum width the New tiles stay inside the right margin (#1421).
#[test]
fn new_tiles_keep_the_right_margin_in_a_narrow_window() {
let mut h = Harness::builder().with_size(egui::vec2(1000.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1000.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
@@ -847,7 +847,7 @@ fn about_has_product_links_and_credits_without_account_controls() {
/// At the 900-point minimum window width the About columns stack and Appearance stays on the page.
#[test]
fn about_appearance_stays_on_the_page_at_minimum_width() {
let mut h = Harness::builder().with_size(egui::vec2(900.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(900.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+11 -7
View File
@@ -33,13 +33,17 @@ fn browse_button_applies_the_picked_files_theme() {
s.execute("slide.new", &json!({"layout": "title", "title": "Hello"})).unwrap();
let mut app = SlideApp::new(s, services);
app.ui.tab = "Design".into();
let mut h = Harness::builder().with_size(egui::vec2(1600.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1600.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h.get_by_label("Browse for Themes…").click();
h.run_steps(3);
+6 -3
View File
@@ -112,9 +112,11 @@ fn wheel_navigation(app: &mut SlideApp, ui: &mut Ui, carry_id: egui::Id, doc_uid
}
fn empty_deck_prompt(app: &mut SlideApp, ui: &mut Ui, avail: Rect, t: &Tokens) {
let resp = ui.allocate_rect(avail, Sense::click());
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);
if resp.clicked() {
// 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"}));
}
}
@@ -172,7 +174,8 @@ pub fn show(app: &mut SlideApp, ui: &mut Ui) {
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));
let resp = ui.allocate_rect(avail, Sense::click_and_drag());
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 {
+3 -1
View File
@@ -7,7 +7,9 @@ pub(super) fn context_menu(app: &mut SlideApp, resp: &egui::Response) {
{
app.session.tool.edit_vertex = Some((path, index));
}
resp.context_menu(|ui| {
// 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);
+11 -7
View File
@@ -14,13 +14,17 @@ fn turn_guides_on_drag_one_and_drop_it_off_the_slide() {
let mut s = Session::with_new();
s.execute("slide.new", &json!({"layout": "blank"})).unwrap();
let app = SlideApp::new(s, Services::default());
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1400.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h.state_mut().run("view.guides", json!({"on": true})).unwrap();
h.run_steps(2);
+1 -1
View File
@@ -34,7 +34,7 @@ pub fn ime_area(app: &SlideApp, xf: Xf) -> Option<Rect> {
/// has settled.
pub(super) fn ime_output(app: &mut SlideApp, ui: &Ui, xf: Xf) {
let ctx = ui.ctx();
if ctx.memory(|m| m.focused().is_some()) || app.dialog.as_ref().is_some_and(|d| d.modal()) || app.palette.is_some() || app.backstage_open() {
if crate::framework::widget_has_keyboard(ctx) || app.dialog.as_ref().is_some_and(|d| d.modal()) || app.palette.is_some() || app.backstage_open() {
return;
}
let Some(r) = ime_area(app, xf) else { return };
+22 -14
View File
@@ -42,13 +42,17 @@ fn drag_indents_add_move_and_remove_tabs_on_the_ruler() {
s.execute("text.insert", &json!({"text": "Name\tRole\tTeam"})).unwrap();
let mut app = SlideApp::new(s, Services::default());
app.ui.ruler = true;
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1400.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
let (slide, k) = (h.state().slide_rect.unwrap(), h.state().canvas_scale);
let x0 = ruler(&mut h)["x"].as_f64().unwrap() as f32;
@@ -93,13 +97,17 @@ fn editing_harness() -> Harness<'static, SlideApp> {
s.execute("text.insert", &json!({"text": "Item\t9.50"})).unwrap();
let mut app = SlideApp::new(s, Services::default());
app.ui.ruler = true;
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1400.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h
}
+9 -8
View File
@@ -95,7 +95,7 @@ fn a_placeholder_that_inherits_its_box_has_a_resize_cursor() {
}
fn harness() -> Harness<'static, SlideApp> {
let mut h = Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state(
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);
@@ -315,13 +315,14 @@ fn app_with_table() -> (egui_kittest::Harness<'static, SlideApp>, deckcraft_mode
let r = s.execute("insert.table", &json!({"rows": 2, "cols": 2, "rect": [100.0, 100.0, 400.0, 80.0], "data": data})).unwrap();
let id = deckcraft_model::ShapeId(r["id"].as_u64().unwrap() as u32);
s.execute("edit.deselect", &json!({})).unwrap();
let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
SlideApp::new(s, Services::default()),
);
let mut harness =
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 SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
SlideApp::new(s, Services::default()),
);
// The app keeps requesting repaints, so step frames instead of run().
harness.run_steps(2);
(harness, id)
+11 -7
View File
@@ -22,13 +22,17 @@ fn harness() -> (Harness<'static, SlideApp>, usize) {
s.set_active(0);
s.execute("review.compare", &json!({"name": "Q3 review.deckcraft", "data": rev})).unwrap();
let app = SlideApp::new(s, Services::default());
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1400.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(4);
(h, n)
}
+1 -1
View File
@@ -12,7 +12,7 @@ use crate::{Services, SlideApp};
fn harness() -> Harness<'static, SlideApp> {
let mut app = SlideApp::new(Session::with_new(), Services::default());
app.ui.tab = "Insert".into();
let mut h = Harness::builder().with_size(egui::vec2(1800.0, 1100.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 1100.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+2 -2
View File
@@ -109,7 +109,7 @@ pub fn show(app: &mut SlideApp, ctx: &egui::Context) {
}
close = body(app, ui, &mut d);
});
let escape = ctx.input(|i| i.key_pressed(egui::Key::Escape));
let escape = crate::framework::escape_pressed(ctx);
if open && !close && !escape {
app.dialog = Some(d);
} else if !close && d.id == "preferences" {
@@ -262,7 +262,7 @@ fn color_label(v: &Value) -> String {
fn choice(ui: &mut Ui, d: &mut Dialog, salt: &str, name: &str, key: &str, choices: &[(&str, &str)]) {
let cur = d.get(key, "");
let label = choices.iter().find(|(v, _)| *v == cur).map(|(_, l)| *l).unwrap_or(cur.as_str());
let combo = craft_ui::ComboBox::from_id_salt(salt).selected_text(label).width(140.0).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt(salt).selected_text(label).width(140.0).show_ui(ui, |ui| {
for (v, l) in choices {
if ui.selectable_label(cur == *v, *l).clicked() {
d.fields.insert((*key).into(), (*v).into());
+11 -7
View File
@@ -85,13 +85,17 @@ mod about_credits_tests {
fn about_dialog_tabs_keep_responding() {
let mut app = SlideApp::new(deckcraft_engine::Session::with_new(), Services::default());
app.dialog = Some(Dialog::new("about"));
let mut h = Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1440.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(4);
assert_eq!(tab_of(&h), "about");
for label in ["Contributors", "Models", "About", "Models", "Contributors"] {
+7 -7
View File
@@ -101,7 +101,7 @@ fn dlg_slide_size(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bool {
}
let label = ui.label("Slides sized for:");
let preset = d.get("preset", "");
let combo = craft_ui::ComboBox::from_id_salt("sizes").selected_text(if preset.is_empty() { "Custom" } else { &preset }).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt("sizes").selected_text(if preset.is_empty() { "Custom" } else { &preset }).show_ui(ui, |ui| {
for (label, w, h) in deckcraft_model::defaults::SLIDE_SIZES {
if ui.selectable_label(preset == *label, *label).clicked() {
d.fields.insert("preset".into(), label.to_string());
@@ -149,7 +149,7 @@ fn dlg_header_footer(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bool {
ui.add_enabled_ui(date && automatic, |ui| {
ui.horizontal(|ui| {
ui.label(" Format:");
craft_ui::ComboBox::from_id_salt("hf-date-format").selected_text(label).width(200.0).show_ui(ui, |ui| {
egui::ComboBox::from_id_salt("hf-date-format").selected_text(label).width(200.0).show_ui(ui, |ui| {
for (kind, sample) in &rows {
if ui.selectable_label(fmt == *kind, sample).clicked() {
d.fields.insert("dateFormat".into(), (*kind).to_string());
@@ -264,7 +264,7 @@ fn dlg_setup_show(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bool {
let chosen = d.fields.entry("custom".into()).or_insert_with(|| sh.custom_show.clone().unwrap_or_default()).clone();
let field = ui.label("Slides");
let label = if chosen.is_empty() { "All slides".to_string() } else { chosen.clone() };
let combo = craft_ui::ComboBox::from_id_salt("setup_custom").selected_text(label).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt("setup_custom").selected_text(label).show_ui(ui, |ui| {
if ui.selectable_label(chosen.is_empty(), "All slides").clicked() {
d.fields.insert("custom".into(), String::new());
}
@@ -428,7 +428,7 @@ fn dlg_bullets(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bool {
let color = d.get("color", "");
ui.horizontal(|ui| {
let field = ui.add_sized(vec2(120.0, 20.0), egui::Label::new("Color:"));
let combo = craft_ui::ComboBox::from_id_salt("bullet-color")
let combo = egui::ComboBox::from_id_salt("bullet-color")
.selected_text(colors.iter().find(|c| c.0 == color).map_or("Automatic", |c| c.1))
.show_ui(ui, |ui| {
for (k, l) in colors {
@@ -535,7 +535,7 @@ fn dlg_action(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bool {
];
let shown = targets.iter().find(|t| t.0 == kind).map_or("Next Slide", |t| t.1);
ui.add_enabled_ui(hyperlink, |ui| {
let combo = craft_ui::ComboBox::from_id_salt("action-target").selected_text(shown).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt("action-target").selected_text(shown).show_ui(ui, |ui| {
for (k, l) in targets {
if ui.selectable_label(kind == k, l).clicked() {
d.fields.insert("kind".into(), k.into());
@@ -733,7 +733,7 @@ fn dlg_export(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bool {
ui.add_space(4.0);
ui.horizontal(|ui| {
let field = ui.label("Print layout:");
let combo = craft_ui::ComboBox::from_id_salt("pdf_layout")
let combo = egui::ComboBox::from_id_salt("pdf_layout")
.selected_text(match pdf_layout.as_str() {
"notes" => "Notes Pages",
"h1" => "Handouts (1 slide per page)",
@@ -818,7 +818,7 @@ fn dlg_replace_fonts(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bool {
let mut to = d.get("to", "");
egui::Grid::new("replace_fonts").num_columns(2).spacing(vec2(10.0, 8.0)).show(ui, |ui| {
let field = ui.label("Replace:");
let combo = craft_ui::ComboBox::from_id_salt("rf_from").width(240.0).selected_text(from.clone()).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt("rf_from").width(240.0).selected_text(from.clone()).show_ui(ui, |ui| {
for f in &used {
ui.selectable_value(&mut from, f.clone(), f);
}
@@ -31,13 +31,17 @@ fn two_boxes() -> Harness<'static, SlideApp> {
fn harness_of(s: Session) -> Harness<'static, SlideApp> {
let app = SlideApp::new(s, Services::default());
let mut h = Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1440.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(4);
h
}
+1 -1
View File
@@ -223,7 +223,7 @@ pub fn contributors_ui(ui: &mut egui::Ui) {
}
ui.separator();
let field = ui.label("Sort");
let combo = craft_ui::ComboBox::from_id_salt("credits_sort").selected_text(v.key.label().0).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt("credits_sort").selected_text(v.key.label().0).show_ui(ui, |ui| {
for k in SortKey::ALL {
if ui.selectable_label(v.key == k, k.label().0).clicked() {
v.key = k;
+1 -1
View File
@@ -49,7 +49,7 @@ pub(super) fn date_time_dialog(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog)
let lang_label = DATE_LANGS.iter().find(|(k, _)| *k == lang).map(|(_, l)| *l).unwrap_or("English (United States)");
ui.horizontal(|ui| {
ui.label("Language:");
let opened = craft_ui::ComboBox::from_id_salt("date-lang").selected_text(lang_label).width(240.0).show_ui(ui, |ui| {
let opened = egui::ComboBox::from_id_salt("date-lang").selected_text(lang_label).width(240.0).show_ui(ui, |ui| {
for (k, l) in DATE_LANGS {
if ui.selectable_label(lang == *k, *l).clicked() {
d.fields.insert("language".into(), (*k).to_string());
+1 -1
View File
@@ -16,7 +16,7 @@ pub(super) fn gif_options(app: &SlideApp, ui: &mut Ui, d: &mut Dialog) -> Result
ui.add_space(4.0);
ui.horizontal(|ui| {
let field = ui.add_sized(vec2(120.0, 20.0), egui::Label::new("Size:"));
let combo = craft_ui::ComboBox::from_id_salt("gif_size").selected_text(size_label(&size)).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt("gif_size").selected_text(size_label(&size)).show_ui(ui, |ui| {
for k in SIZE_PRESETS.iter().map(|(k, _)| *k).chain(["custom"]) {
if ui.selectable_label(size == k, size_label(k)).clicked() {
d.fields.insert("gifSize".into(), k.into());
+2 -2
View File
@@ -26,7 +26,7 @@ pub(super) fn font_dialog(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bo
}
ui.horizontal(|ui| {
let field = ui.add_sized(vec2(88.0, 20.0), egui::Label::new("Font"));
let combo = craft_ui::ComboBox::from_id_salt("font_dialog_family")
let combo = egui::ComboBox::from_id_salt("font_dialog_family")
.selected_text(if family.is_empty() { " " } else { family.as_str() })
.width(300.0)
.show_ui(ui, |ui| {
@@ -75,7 +75,7 @@ pub(super) fn font_dialog(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bo
let mut spacing = d.get("spacing", "0");
let edited = ui.add(egui::TextEdit::singleline(&mut spacing).desired_width(64.0).hint_text("pt"));
let mut picked = None;
let combo = craft_ui::ComboBox::from_id_salt("font_dialog_spacing")
let combo = egui::ComboBox::from_id_salt("font_dialog_spacing")
.selected_text(match spacing.as_str() {
"-3" => "Very tight",
"-1.5" => "Tight",
@@ -13,13 +13,17 @@ fn harness() -> Harness<'static, SlideApp> {
// A selected shape, not a caret: the dialog then formats the text that is already there.
let _ = s.execute("text.exit", &json!({}));
let app = SlideApp::new(s, Services::default());
let mut h = Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1440.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(4);
h
}
+12 -13
View File
@@ -103,20 +103,19 @@ pub(super) fn paragraph_dialog(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog)
let field = ui.add_sized(vec2(110.0, 20.0), egui::Label::new("Line spacing"));
let kind = d.get("lineKind", "multiple");
let value = d.get("lineValue", "1");
let combo =
craft_ui::ComboBox::from_id_salt("paragraph_line").selected_text(line_preset_label(&kind, &value)).width(140.0).show_ui(ui, |ui| {
for (label, k, v) in [
("Single", "multiple", Some("1")),
("1.5 lines", "multiple", Some("1.5")),
("Double", "multiple", Some("2")),
("Multiple", "multiple", None),
("Exactly", "exactly", None),
] {
if ui.selectable_label(line_preset_label(&kind, &value) == label, label).clicked() {
picked = Some((k, v));
}
let combo = egui::ComboBox::from_id_salt("paragraph_line").selected_text(line_preset_label(&kind, &value)).width(140.0).show_ui(ui, |ui| {
for (label, k, v) in [
("Single", "multiple", Some("1")),
("1.5 lines", "multiple", Some("1.5")),
("Double", "multiple", Some("2")),
("Multiple", "multiple", None),
("Exactly", "exactly", None),
] {
if ui.selectable_label(line_preset_label(&kind, &value) == label, label).clicked() {
picked = Some((k, v));
}
});
}
});
let _ = combo.response.labelled_by(field.id);
ui.add_space(8.0);
let _ = labeled_text(ui, d, "At", "lineValue", 64.0);
@@ -13,13 +13,17 @@ fn harness() -> Harness<'static, SlideApp> {
s.execute("shape.insert", &json!({"preset": "rect", "rect": [80.0, 80.0, 320.0, 80.0], "text": "Hello"})).unwrap();
let _ = s.execute("text.exit", &json!({}));
let app = SlideApp::new(s, Services::default());
let mut h = Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1440.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(4);
h
}
+1 -1
View File
@@ -69,7 +69,7 @@ fn pick_album_picture(app: &mut SlideApp) -> Option<Value> {
fn album_choice(ui: &mut Ui, d: &mut Dialog, id: &str, name: &str, key: &str, default: &str, choices: &[(&str, &str)]) {
let cur = d.get(key, default);
let label = choices.iter().find(|(k, _)| *k == cur).map(|(_, l)| *l).unwrap_or(default);
let opened = craft_ui::ComboBox::from_id_salt(id).selected_text(label).width(220.0).show_ui(ui, |ui| {
let opened = egui::ComboBox::from_id_salt(id).selected_text(label).width(220.0).show_ui(ui, |ui| {
for (k, l) in choices {
if ui.selectable_label(cur == *k, *l).clicked() {
d.fields.insert(key.into(), (*k).to_string());
@@ -18,13 +18,17 @@ fn png() -> Vec<u8> {
}
fn harness(app: SlideApp) -> Harness<'static, SlideApp> {
let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1600.0, 1200.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h
}
@@ -18,7 +18,7 @@ fn interface_size<'a>(h: &'a Harness<'_, SlideApp>) -> Node<'a> {
}
fn harness() -> Harness<'static, SlideApp> {
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
@@ -7,7 +7,7 @@ use serde_json::json;
use crate::{Services, SlideApp};
fn harness() -> Harness<'static, SlideApp> {
let mut h = Harness::builder().with_size(egui::vec2(1600.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1600.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+4 -4
View File
@@ -17,7 +17,7 @@ fn spelling_dialog_changes_and_ignores_words() {
let mut app = SlideApp::new(Session::with_new(), Services::default());
app.session.execute("shape.insert", &json!({"preset": "rect", "rect": [100, 100, 500, 120], "text": "Our plna for teh quarter"})).unwrap();
app.dialog = Some(crate::dialogs::Dialog::new("spelling"));
let mut h = Harness::builder().with_size(egui::vec2(1100.0, 700.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1100.0, 700.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
@@ -82,7 +82,7 @@ fn squiggles_mark_misspelt_words_in_the_background() {
let st = app.session.active().unwrap().clone();
let lines = app.squiggles.settle(&st);
assert_eq!(lines.len(), 3, "{lines:?}");
let mut h = Harness::builder().with_size(egui::vec2(1100.0, 700.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1100.0, 700.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
@@ -153,7 +153,7 @@ fn squiggles_in_table_cells_and_notes_and_on_the_ui_thread() {
// Each under its own cell: the first in the top-left one, the second in the bottom-right one.
assert!(lines[0].0.x < 380.0 && lines[0].0.y < 160.0 && lines[1].0.x > 380.0 && lines[1].0.y > 160.0, "{lines:?}");
assert_eq!(app.squiggles.settle_notes("Remmeber to show the totl", "xx-TB"), vec![(0, 8), (21, 25)]);
let mut h = Harness::builder().with_size(egui::vec2(1100.0, 760.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1100.0, 760.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
@@ -226,7 +226,7 @@ fn notes_menu_language_dialog_and_repeated_words() {
let st = app.session.active().unwrap().clone();
// "is is" is flagged as repeated, "wrok" as misspelt.
assert_eq!(app.squiggles.settle(&st).len(), 2);
let mut h = Harness::builder().with_size(egui::vec2(1100.0, 760.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1100.0, 760.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+24 -21
View File
@@ -48,13 +48,14 @@ fn header_footer_apply_keeps_an_existing_date_format() {
})
.collect()
};
let mut harness = egui_kittest::Harness::builder().with_size(vec2(1200.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
SlideApp::new(session, crate::Services::default()),
);
let mut harness =
egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(1200.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
SlideApp::new(session, crate::Services::default()),
);
harness.run_steps(2);
assert_eq!(date_fields(harness.state()), vec!["datetime4".to_string()]);
harness.state_mut().run("app.dialog", json!({"id": "headerFooter"})).unwrap();
@@ -89,13 +90,14 @@ fn export_dialog_writes_an_animated_gif() {
};
let mut session = deckcraft_engine::Session::with_new();
session.execute("slide.new", &json!({})).unwrap();
let mut harness = egui_kittest::Harness::builder().with_size(vec2(1200.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
SlideApp::new(session, services),
);
let mut harness =
egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(1200.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
SlideApp::new(session, services),
);
harness.run_steps(2);
harness.state_mut().run("app.exportDialog", json!({})).unwrap();
harness.run_steps(2);
@@ -140,13 +142,14 @@ fn export_dialog_writes_a_png_with_a_transparent_background() {
let path = dir.join("slide.png");
let picked = path.to_string_lossy().to_string();
let services = crate::Services { pick_save: Some(Box::new(move |_: &str| Some(picked.clone()))), ..Default::default() };
let mut harness = egui_kittest::Harness::builder().with_size(vec2(1200.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
SlideApp::new(deckcraft_engine::Session::with_new(), services),
);
let mut harness =
egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(1200.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
SlideApp::new(deckcraft_engine::Session::with_new(), services),
);
harness.run_steps(2);
harness.state_mut().run("app.exportDialog", json!({})).unwrap();
harness.run_steps(2);
@@ -10,7 +10,7 @@ use crate::{Services, SlideApp};
fn harness() -> Harness<'static, SlideApp> {
let mut app = SlideApp::new(Session::with_new(), Services::default());
app.ui.tab = "Design".into();
let mut h = Harness::builder().with_size(egui::vec2(1800.0, 1100.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 1100.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+1 -1
View File
@@ -30,7 +30,7 @@ fn theme_font_choices(app: &SlideApp, selected: &str) -> Vec<String> {
/// Draw an accessible font combo box and update the selected family; the caller supplies the
/// visible label.
fn font_combo(ui: &mut Ui, label: &str, choices: &[String], selected: &mut String) {
let resp = craft_ui::ComboBox::from_id_salt(label).selected_text(selected.as_str()).width(240.0).show_ui(ui, |ui| {
let resp = egui::ComboBox::from_id_salt(label).selected_text(selected.as_str()).width(240.0).show_ui(ui, |ui| {
for face in choices {
if ui.selectable_label(selected == face, face).clicked() {
*selected = face.clone();
@@ -9,7 +9,7 @@ use crate::{Services, SlideApp};
fn harness() -> Harness<'static, SlideApp> {
let mut app = SlideApp::new(Session::with_new(), Services::default());
app.ui.tab = "Design".into();
let mut h = Harness::builder().with_size(egui::vec2(1800.0, 1100.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 1100.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+63 -23
View File
@@ -1,8 +1,11 @@
//! One background check at start-up (and on demand from Help) for a newer release, and the modal
//! prompt that offers to update and restart. The flow itself is `craft_update::updater::Updater`.
//! One background check at start-up (and on demand from Help) for a newer release, the modal
//! prompt that offers to update and restart, and the result of a check, as craft-update's dialogs
//! on the app's [`DialogHost`](craft_ui::dialog::DialogHost). The flow itself is
//! `craft_update::updater::Updater`.
use craft_ui::dialog::DialogResult;
use craft_update::stack_dialogs::{CheckChoice, UpdateCheckDialog};
use craft_update::updater::{Action, Status, Updater};
use craft_update::{CheckResultDialog, CheckResultResponse};
use crate::SlideApp;
@@ -63,42 +66,62 @@ pub(crate) fn tick(app: &mut SlideApp, ctx: &egui::Context) {
return;
}
if std::mem::take(&mut rt.check_requested) {
rt.updater.check_now(ctx);
rt.updater.check_now();
} else if rt.enabled {
rt.updater.check_at_start(ctx);
rt.updater.check_at_start();
}
rt.updater.tick(ctx);
}
/// One pass of the update flow, before the dialog host runs (`SlideApp::ui`): answers the result
/// dialog closed in the last pass, drives the startup prompt, and keeps the result dialog open and
/// current while the updater has something to report.
pub(crate) fn show(app: &mut SlideApp, ctx: &egui::Context) {
if !app.updates_rt.stable_services {
return;
}
// An installation starts, and a ready update asks the app to close, only while nothing is unsaved.
let clean = !app.session.documents().iter().any(|d| d.is_dirty());
match app.updates_rt.updater.show_if(ctx, clean) {
// Answered before the dialog is kept open below, so a dismissed result does not open again.
if let Some(result) = app.framework_dialogs.take::<UpdateCheckDialog>() {
answer(&mut app.updates_rt, ctx, result, clean);
}
match app.updates_rt.updater.run(&mut app.framework_dialogs, clean) {
Action::OpenUrl(url) => ctx.open_url(egui::OpenUrl::new_tab(url)),
// The app's close path asks about unsaved work; `on_exit` starts the restart helper.
Action::Close => ctx.send_viewport_cmd(egui::ViewportCommand::Close),
Action::None => {}
_ => {}
}
// The result window reports a requested check, and at the first start after an update what
// The result dialog reports a requested check, and at the first start after an update what
// that update came to (installed, or why it failed).
let rt = &mut app.updates_rt;
if !matches!(rt.updater.status(), Status::Idle) {
let response = CheckResultDialog::new(&crate::UPDATE_APP, VERSION).show(ctx, rt.updater.status());
answer(rt, response);
let updater = &app.updates_rt.updater;
let reports = !matches!(updater.status(), Status::Idle);
let (status, installing, message) = (updater.status().clone(), updater.is_installing(), updater.status_message());
let open = app.framework_dialogs.is_open::<UpdateCheckDialog>();
if reports && !open {
app.framework_dialogs.open(UpdateCheckDialog::new(VERSION));
} else if !reports && open {
app.framework_dialogs.cancel::<UpdateCheckDialog>(ctx);
}
if let Some(dialog) = app.framework_dialogs.get_mut::<UpdateCheckDialog>() {
dialog.set_status(status);
dialog.set_installing(installing);
dialog.set_message(message);
}
}
/// Acts on the result window's answer.
fn answer(rt: &mut Runtime, response: CheckResultResponse) {
match response {
CheckResultResponse::Close => rt.updater.dismiss_status(),
CheckResultResponse::CheckAgain => rt.check_requested = true,
// The next frame's `show_if` asks the window to close once nothing is unsaved.
CheckResultResponse::RestartToUpdate => rt.updater.restart_to_update(),
CheckResultResponse::None => {}
/// Acts on the result dialog's answer.
fn answer(rt: &mut Runtime, ctx: &egui::Context, result: DialogResult<CheckChoice>, clean: bool) {
match result {
DialogResult::Ok(CheckChoice::CheckNow | CheckChoice::CheckAgain) => rt.check_requested = true,
// The next pass's `run` asks the window to close once nothing is unsaved.
DialogResult::Ok(CheckChoice::RestartToUpdate) => rt.updater.restart_to_update(),
DialogResult::Ok(CheckChoice::Update) => {
rt.updater.request_install(clean);
}
DialogResult::Ok(CheckChoice::Download) => ctx.open_url(egui::OpenUrl::new_tab(crate::UPDATE_APP.releases_url())),
// OK, Esc and the close box dismiss the outcome it showed.
_ => rt.updater.dismiss_status(),
}
}
@@ -110,9 +133,22 @@ mod tests {
fn an_offered_release_opens_the_prompt() {
let mut app = SlideApp::new(deckcraft_engine::Session::new(), crate::Services::default());
let ctx = egui::Context::default();
crate::framework::install_headless(&ctx);
assert!(!app.updates_rt.updater.prompt_open());
app.updates_rt.updater.offer(craft_update::Release { tag: "v99.0.0".into(), ..Default::default() });
ctx.run_ui(egui::RawInput::default(), |ui| show(&mut app, ui.ctx())).textures_delta.clear();
// The offer reads on a thread whether this copy can install the release itself; a later
// pass's tick opens the prompt.
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(5);
while !app.updates_rt.updater.prompt_open() && std::time::Instant::now() < deadline {
ctx.run_ui(egui::RawInput::default(), |ui| {
tick(&mut app, ui.ctx());
show(&mut app, ui.ctx());
app.framework_dialogs.run(ui);
})
.textures_delta
.clear();
std::thread::sleep(std::time::Duration::from_millis(2));
}
assert!(app.updates_rt.updater.prompt_open());
}
@@ -169,14 +205,16 @@ mod tests {
std::fs::write(root.join("data").join("self-update-done.txt"), VERSION).unwrap();
let mut app = app_with_records(&root);
let ctx = egui::Context::default();
crate::framework::install_headless(&ctx);
ctx.run_ui(egui::RawInput::default(), |ui| {
tick(&mut app, ui.ctx());
show(&mut app, ui.ctx());
app.framework_dialogs.run(ui);
})
.textures_delta
.clear();
assert!(matches!(app.updates_rt.updater.status(), Status::Updated(_)), "{:?}", app.updates_rt.updater.status());
answer(&mut app.updates_rt, CheckResultResponse::Close);
answer(&mut app.updates_rt, &ctx, DialogResult::Ok(CheckChoice::Close), true);
assert_eq!(app.updates_rt.updater.status(), &Status::Idle);
let _ = std::fs::remove_dir_all(&root);
}
@@ -189,14 +227,16 @@ mod tests {
std::fs::write(root.join("data").join("logs").join("self-update-error.txt"), "the disk is full").unwrap();
let mut app = app_with_records(&root);
let ctx = egui::Context::default();
crate::framework::install_headless(&ctx);
ctx.run_ui(egui::RawInput::default(), |ui| {
tick(&mut app, ui.ctx());
show(&mut app, ui.ctx());
app.framework_dialogs.run(ui);
})
.textures_delta
.clear();
assert_eq!(app.updates_rt.updater.status(), &Status::InstallFailed("the disk is full".into()));
answer(&mut app.updates_rt, CheckResultResponse::CheckAgain);
answer(&mut app.updates_rt, &ctx, DialogResult::Ok(CheckChoice::CheckAgain), true);
assert!(app.updates_rt.check_requested);
let _ = std::fs::remove_dir_all(&root);
}
+232
View File
@@ -0,0 +1,232 @@
//! The document window as the window's one canvas stop: Tab, real presses and its keys.
use deckcraft_engine::Session;
use egui::{Event, Id, Key, Modifiers, PointerButton, Role, vec2};
use egui_kittest::Harness;
use egui_kittest::kittest::Queryable as _;
use serde_json::json;
use crate::framework::document_id;
use crate::state::ViewMode;
use crate::{Services, SlideApp};
fn harness() -> Harness<'static, SlideApp> {
let mut session = Session::with_new();
session.prefs.autocorrect = false;
let mut app = SlideApp::new(session, Services::default());
app.ui.notes = false;
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(1200.0, 800.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(4);
h
}
fn focused(h: &Harness<'_, SlideApp>) -> Option<Id> {
h.ctx.memory(|m| m.focused())
}
fn press(h: &mut Harness<'_, SlideApp>, modifiers: Modifiers, key: Key) {
h.key_press_modifiers(modifiers, key);
h.run_steps(2);
}
fn tab(h: &mut Harness<'_, SlideApp>) {
press(h, Modifiers::NONE, Key::Tab);
}
fn selected(h: &Harness<'_, SlideApp>) -> Vec<deckcraft_model::ShapeId> {
h.state().session.active().unwrap().selection.shapes.clone()
}
#[test]
fn tab_selects_the_slides_objects_then_moves_on_and_shift_tab_walks_back() {
let mut h = harness();
assert_eq!(focused(&h), Some(document_id()), "an opened presentation has the keyboard");
let objects: Vec<_> = h.state().session.active().unwrap().shapes().iter().map(|s| s.id).collect();
assert!(objects.len() > 1);
for object in &objects {
tab(&mut h);
assert_eq!((selected(&h), focused(&h)), (vec![*object], Some(document_id())));
}
press(&mut h, Modifiers::SHIFT, Key::Tab);
let before = focused(&h);
assert!(before.is_some() && before != Some(document_id()), "with the last object selected, Shift+Tab leaves the slide");
tab(&mut h);
assert_eq!(focused(&h), Some(document_id()), "Tab from the stop before it stops at the slide");
tab(&mut h);
let after = focused(&h);
assert!(after.is_some() && after != Some(document_id()) && after != before, "past the last object, Tab moves on");
press(&mut h, Modifiers::SHIFT, Key::Tab);
assert_eq!(focused(&h), Some(document_id()), "Shift+Tab walks back to the slide");
assert_eq!(selected(&h), objects[objects.len() - 1..]);
}
#[test]
fn a_press_on_the_slide_takes_the_keyboard_from_a_focused_button() {
let mut h = harness();
h.get_by_role_and_label(Role::Button, "File").focus();
h.run_steps(2);
assert!(h.get_by_role_and_label(Role::Button, "File").is_focused());
let pos = h.state().canvas_rect.unwrap().right_bottom() - vec2(10.0, 10.0);
h.hover_at(pos);
h.run_steps(1);
for pressed in [true, false] {
h.event(Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE });
h.run_steps(1);
}
assert_eq!(focused(&h), Some(document_id()));
press(&mut h, Modifiers::NONE, Key::Enter);
assert!(!h.state().backstage_open(), "the File button isn't activated");
assert_eq!(h.state().session.active().unwrap().doc.slides.len(), 2, "Enter adds a slide");
}
#[test]
fn after_a_press_on_a_pane_tab_selects_the_next_object() {
let mut h = harness();
let pos = egui::pos2(h.state().ui.thumbs_width / 2.0, 300.0);
h.hover_at(pos);
h.run_steps(1);
for pressed in [true, false] {
h.event(Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE });
h.run_steps(2);
}
assert!(h.state().slides_focused, "the press is in the thumbnail pane");
let first = h.state().session.active().unwrap().shapes()[0].id;
tab(&mut h);
assert_eq!((selected(&h), focused(&h)), (vec![first], Some(document_id())));
}
#[test]
fn after_a_dialog_closes_tab_selects_the_next_object() {
let mut h = harness();
h.state_mut().dialog = Some(crate::dialogs::Dialog::new("find"));
h.run_steps(3);
assert!(h.ctx.text_edit_focused(), "the dialog's field has the focus");
h.state_mut().dialog = None;
h.run_steps(4);
let first = h.state().session.active().unwrap().shapes()[0].id;
tab(&mut h);
assert_eq!((selected(&h), focused(&h)), (vec![first], Some(document_id())));
}
#[test]
fn after_enter_in_a_ribbon_field_tab_selects_the_next_object() {
let mut h = harness();
h.state_mut().ui.tab = "Transitions".into();
tab(&mut h);
let objects: Vec<_> = h.state().session.active().unwrap().shapes().iter().map(|s| s.id).collect();
assert_eq!(selected(&h), objects[..1]);
h.get_by_role_and_label(Role::TextInput, "Duration value").focus();
h.run_steps(2);
assert!(h.ctx.text_edit_focused());
press(&mut h, Modifiers::NONE, Key::Enter);
assert!(!h.ctx.text_edit_focused(), "Enter commits the field");
assert!(h.state().session.active().unwrap().selection.text.is_none(), "and reaches nothing on the slide");
tab(&mut h);
assert_eq!((selected(&h), focused(&h)), (vec![objects[1]], Some(document_id())));
}
#[test]
fn a_press_in_the_sorter_takes_the_keyboard_from_a_focused_button() {
let mut h = harness();
h.state_mut().ui.view = ViewMode::Sorter;
h.run_steps(3);
h.get_by_role_and_label(Role::Button, "File").focus();
h.run_steps(2);
assert_ne!(focused(&h), Some(document_id()));
let pos = h.get_by_role_and_label(Role::Button, "Slide 1").rect().center();
h.hover_at(pos);
h.run_steps(1);
h.event(Event::PointerButton { pos, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE });
h.run_steps(2);
assert_eq!(focused(&h), Some(document_id()));
}
#[test]
fn edited_text_traps_no_focus_in_the_sorter_or_the_file_tab() {
let mut h = harness();
let title = h.state().session.active().unwrap().shapes()[0].id.0;
h.state_mut().session.execute("text.edit", &json!({"id": title})).unwrap();
h.run_steps(2);
h.state_mut().ui.view = ViewMode::Sorter;
h.run_steps(2);
tab(&mut h);
let stop = focused(&h);
assert!(stop.is_some_and(|id| id != document_id()), "Tab moves on from the sorter");
tab(&mut h);
assert!(focused(&h).is_some_and(|id| Some(id) != stop && id != document_id()), "and on again");
h.state_mut().open_backstage(crate::backstage::Page::Home);
h.run_steps(3);
tab(&mut h);
h.run_steps(2);
assert!(h.state().session.active().unwrap().selection.text.is_some());
assert!(focused(&h).is_some(), "Tab stays on a control of the File tab");
}
#[test]
fn a_presentation_opened_from_the_palette_gets_the_keyboard() {
let mut h = harness();
h.state_mut().run("app.palette", json!({})).unwrap();
h.run_steps(3);
assert!(h.ctx.text_edit_focused(), "the palette's field has the focus");
let app = h.state_mut();
app.palette = None;
app.run("file.new", json!({})).unwrap();
app.run("slide.new", json!({"layout": "blank"})).unwrap();
assert!(!app.session.tab_has_work(), "an empty slide, which asks for the focus only because it opened");
h.run_steps(4);
assert_eq!(focused(&h), Some(document_id()));
}
#[test]
fn the_focused_slide_takes_arrows_escape_typing_and_tab() {
let mut h = harness();
let left = |h: &Harness<'_, SlideApp>| {
let st = h.state().session.active().unwrap();
deckcraft_engine::cmd::xfrm_of(&st.doc, &st.selection, &st.shapes()[0]).x
};
tab(&mut h);
let x = left(&h);
press(&mut h, Modifiers::NONE, Key::ArrowRight);
assert!(left(&h) > x, "the arrow moves the object, not the focus");
press(&mut h, Modifiers::NONE, Key::Escape);
assert!(selected(&h).is_empty());
assert_eq!(focused(&h), Some(document_id()), "Escape leaves the focus on the slide");
tab(&mut h);
h.event(Event::Text("ab".into()));
h.run_steps(2);
tab(&mut h);
h.event(Event::Text("c".into()));
h.run_steps(2);
let st = h.state().session.active().unwrap();
assert_eq!(st.shapes()[0].text.as_ref().unwrap().text(), "ab\tc");
assert!(st.selection.text.is_some());
press(&mut h, Modifiers::NONE, Key::Escape);
assert!(h.state().session.active().unwrap().selection.text.is_none(), "Escape ends text editing");
assert_eq!(focused(&h), Some(document_id()));
}
#[test]
fn every_view_draws_the_document_and_the_file_tab_takes_its_focus() {
let mut h = harness();
for view in [ViewMode::Outline, ViewMode::Reading, ViewMode::NotesPage, ViewMode::Sorter] {
h.state_mut().ui.view = view;
h.run_steps(3);
assert_eq!(focused(&h), Some(document_id()), "the focus stays in the document window");
}
tab(&mut h);
assert!(focused(&h).is_some_and(|id| id != document_id()), "Tab has no work in the slide sorter");
h.state_mut().ui.view = ViewMode::Normal;
h.state_mut().open_backstage(crate::backstage::Page::Home);
h.run_steps(3);
assert!(h.state().backstage_open());
h.key_press(Key::Escape);
h.run_steps(3);
assert!(!h.state().backstage_open(), "Escape leaves the File tab");
assert_eq!(focused(&h), Some(document_id()), "and the slide has the keyboard again");
}
+5 -4
View File
@@ -123,10 +123,11 @@ fn hex(c: [u8; 4]) -> String {
}
/// The slide canvas while the Eyedropper waits: the pointer is a crosshair with the colour under it
/// beside it, a click takes it. Returns true when it used the pointer (the tools get none).
/// 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 = ui.input(|i| i.key_pressed(egui::Key::Escape));
let escape = crate::framework::escape_pressed(ui.ctx());
if escape || resp.secondary_clicked() {
app.eyedropper = None;
return true;
@@ -135,7 +136,7 @@ pub fn canvas(app: &mut SlideApp, ui: &Ui, resp: &egui::Response, xf: Xf) -> boo
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() {
if resp.clicked_by(egui::PointerButton::Primary) {
app.eyedropper = None;
}
return true;
@@ -146,7 +147,7 @@ pub fn canvas(app: &mut SlideApp, ui: &Ui, resp: &egui::Response, xf: Xf) -> boo
if let Some(c) = under {
loupe(ui, pos, c);
}
if resp.clicked() {
if resp.clicked_by(egui::PointerButton::Primary) {
let (pick, slide) = (state.pick, state.slide);
app.eyedropper = None;
match pick {
+15 -2
View File
@@ -15,7 +15,7 @@ fn harness() -> Harness<'static, SlideApp> {
session.execute("slide.new", &json!({"layout": "blank"})).unwrap();
session.execute("shape.insert", &json!({"preset": "rect", "rect": [100, 100, 200, 100]})).unwrap();
session.execute("shape.fill", &json!({"color": "#ff0000"})).unwrap();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
@@ -59,6 +59,19 @@ fn selection(h: &Harness<'static, SlideApp>) -> Vec<u32> {
h.state().session.doc().unwrap().selection.shapes.iter().map(|s| s.0).collect()
}
#[test]
fn space_on_the_focused_slide_picks_no_colour() {
let mut h = harness();
ask(&mut h);
let on_shape = at(&h, 150.0, 150.0);
h.input_mut().events.push(Event::PointerMoved(on_shape));
h.run_steps(3);
assert!(h.ctx.memory(|m| m.has_focus(crate::framework::document_id())));
h.key_press(egui::Key::Space);
h.run_steps(3);
assert!(h.state().eyedropper.is_some() && !result_waits_for(&h.ctx, menu()));
}
#[test]
fn a_click_on_the_slide_takes_the_colour_under_it_and_nothing_else_happens() {
let mut h = harness();
@@ -125,7 +138,7 @@ fn set_transparent_color_takes_the_colour_clicked_in_the_picture() {
session.execute("insert.picture", &json!({"data": data, "name": "a.png", "rect": [100, 100, 400, 200]})).unwrap();
let mut app = SlideApp::new(session, Services::default());
app.ui.tab = "Picture Format".into();
let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1600.0, 1200.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+11 -7
View File
@@ -13,13 +13,17 @@ use serde_json::json;
use crate::{Services, SlideApp, theme};
fn harness(app: SlideApp) -> Harness<'static, SlideApp> {
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1400.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
// The app keeps asking for frames, so step instead of run().
h.run_steps(3);
h
+11 -7
View File
@@ -14,13 +14,17 @@ fn ctrl_f_puts_the_caret_in_find_what() {
s.execute("text.exit", &json!({})).unwrap();
s.doc_mut().unwrap().selection.shapes.clear();
let app = SlideApp::new(s, Services::default());
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1400.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::F);
h.run_steps(3);
+182
View File
@@ -0,0 +1,182 @@
//! The craft-ui runtime, hosted from DeckCraft's own eframe `App` (craft-libs docs/craft-framework.md, section 2.2).
//! The desktop app calls [`install`] once, [`SlideApp::before_input`] in `raw_input_hook`, [`SlideApp::close_path`]
//! last in `logic`, and [`before_ui`] first in `ui`; the browser build and tests install with [`install_headless`].
//! `SlideApp::ui` runs the framework dialogs ([`SlideApp::framework_dialogs`]) after DeckCraft's own UI.
//!
//! The runtime takes Escape, Tab and the clipboard events for the whole window unless one of DeckCraft's own egui
//! widgets has the keyboard. The window's Escape is read with [`escape_pressed`] or [`take_window_cancel`]; the
//! document window is declared to the runtime with [`host_canvas`] each pass that draws it, which keeps the edit chords
//! and the clipboard events, and Tab while it has the focus and Tab has work, in egui's input for DeckCraft's own key
//! routing (`SlideApp::keyboard`). That routing has the keyboard unless [`widget_has_keyboard`].
use std::sync::Arc;
use craft_host::target::ShellInfo;
use craft_host::{AppInfo, Host};
use craft_keymap::{Chord, Key, Mods};
use craft_ui::fonts::{I18nScripts, SystemFonts, UiFonts};
use craft_ui::runtime::env::{RootEnv, Scale};
use craft_ui::runtime::focus::{self, EditSet, FocusTarget, KeepKeys, KeyUse};
use craft_ui::runtime::frame::{FrameInput, FrameOutput};
use craft_ui::runtime::keys::{Intent, with_window_intents};
use craft_ui::shell::embed::{self, CloseDecision};
use craft_window::system::WindowSystem;
use crate::SlideApp;
/// Each pass of the root window, first in `App::ui`: hands the runtime the native window it answers the hit test of
/// (Windows) and fits the window to its monitor once.
#[cfg(not(target_arch = "wasm32"))]
pub use craft_ui::shell::embed::before_ui;
/// The scripts of the interface languages, for the font stack.
static SCRIPTS: I18nScripts = I18nScripts;
/// The runtime's first font stack: egui's bundled faces and no installed system fonts. DeckCraft's own definitions
/// (`theme::install_fonts_with`, in the first UI pass) replace it before anything is drawn.
fn ui_fonts() -> UiFonts<'static> {
UiFonts::new(&SCRIPTS).system_fonts(SystemFonts::Off)
}
fn install_with(ctx: &egui::Context, shell: ShellInfo, windows: Arc<dyn WindowSystem>) -> Result<(), String> {
let spec = craft_ui::InstallSpec::new(shell, windows).app_id(crate::os_window::app_id());
embed::install(ctx, spec, &ui_fonts()).map(drop).map_err(|error| format!("the UI runtime could not be installed: {error}"))
}
/// Installs the runtime on the desktop window's context, once, before the first pass. `forced_x11` when the app
/// opens its window through XWayland. DeckCraft draws its own title bar row (`ribbon::title_bar`) and gives the
/// runtime no frame decision, so the runtime takes no part of the window's move area or hit test.
#[cfg(not(target_arch = "wasm32"))]
pub fn install(ctx: &egui::Context, forced_x11: bool) -> Result<(), String> {
use craft_host::target::Backend;
let backend = if forced_x11 { Backend::X11 } else { Backend::from_env() };
install_with(ctx, ShellInfo::default().backend(backend), Arc::new(craft_window::system::SystemWindows))
}
/// Installs the runtime on a context with no native window of its own: the browser build's canvas and test windows.
pub fn install_headless(ctx: &egui::Context) {
if let Err(error) = install_with(ctx, ShellInfo::default(), Arc::new(craft_window::system::NoWindows)) {
log::warn!("{error}");
}
}
/// Who DeckCraft is to the framework's dialogs (the update dialogs show its name and icon).
pub(crate) fn host() -> Arc<Host> {
Arc::new(
Host::builder(AppInfo { id: "deckcraft", name: "DeckCraft", version: env!("CARGO_PKG_VERSION") })
.icon_png(include_bytes!("../../../assets/app-icon/hicolor/128x128/apps/ai.storyteller.deckcraft.png"))
.build(),
)
}
impl SlideApp {
/// The framework's part of `App::raw_input_hook`, once per frame before the first pass: takes what the runtime
/// gathered since the last frame and gives the coming passes the root values (theme mode, interface scale).
pub fn before_input(&mut self, ctx: &egui::Context) {
embed::before_input(ctx, |output| self.frame_input(output));
}
/// The root values of this frame. DeckCraft registers no commands with the runtime and lets it toggle no chrome,
/// so the output carries nothing it acts on. The interface scale is DeckCraft's own (`UiState::ui_scale`, which
/// `ui_setup` applies), so the runtime's zoom and DeckCraft's agree.
fn frame_input(&mut self, _output: FrameOutput) -> FrameInput {
let mode = if self.ui.brightness == crate::theme::Brightness::Dark { craft_theme::Mode::Dark } else { craft_theme::Mode::Light };
// The slide show and the canvas read Ctrl/Cmd+wheel themselves, so a smooth Ctrl+wheel stays a wheel event.
let root = RootEnv::new().mode(mode).scale(Scale::new(self.ui.ui_scale.clamp(0.5, 3.0))).ctrl_wheel_pinch(false);
FrameInput::new(root).host(Arc::clone(&self.framework_host))
}
/// The framework's part of `App::logic`, after DeckCraft's own: the root window's close path. With unsaved
/// presentations the window stays open while the quit dialog asks; its answer closes the window again with
/// `quit_confirmed` set.
pub fn close_path(&mut self, ctx: &egui::Context) {
embed::logic(ctx, || {
if self.quit_confirmed || !self.session.documents().iter().any(|d| d.is_dirty()) {
return CloseDecision::Close;
}
self.show = None;
if self.dialog.as_ref().is_none_or(|d| d.id != "quit") {
self.dialog = Some(crate::dialogs::Dialog::new("quit"));
}
CloseDecision::Hold
});
}
}
/// Alt+1 to Alt+9, the Quick Access Toolbar's positions on Windows and Linux (`menus::ui_shortcut`). Claimed, so
/// the runtime's Alt+numpad code entry leaves them to DeckCraft's shortcuts.
const QUICK_ACCESS_KEYS: [Chord; 9] = [
Chord::new(Mods::ALT, Key::Num1),
Chord::new(Mods::ALT, Key::Num2),
Chord::new(Mods::ALT, Key::Num3),
Chord::new(Mods::ALT, Key::Num4),
Chord::new(Mods::ALT, Key::Num5),
Chord::new(Mods::ALT, Key::Num6),
Chord::new(Mods::ALT, Key::Num7),
Chord::new(Mods::ALT, Key::Num8),
Chord::new(Mods::ALT, Key::Num9),
];
/// The keys DeckCraft's document window keeps while it has the focus or is the window's key target: every clipboard
/// event and edit chord, and the Quick Access Toolbar's Alt+digits, which `SlideApp::keyboard` routes itself.
const DOCUMENT_KEYS: KeyUse = KeyUse::CANVAS.with_edits(EditSet::ALL).with_claims(&QUICK_ACCESS_KEYS);
/// The document window's widget: the slide canvas, the slide sorter or the notes page, whichever the view draws.
pub(crate) fn document_id() -> egui::Id {
egui::Id::unique("deckcraft_document")
}
/// Declares DeckCraft's document window, drawn in this pass, as the window's canvas. With nothing focused it is the
/// window's key target: the edit chords, the clipboard events and the claimed Alt+digits stay in egui's input for
/// DeckCraft. Tab and Shift+Tab stop at it; with `keeps_tab` the focused document keeps them in egui's input, else they
/// move on from it.
pub(crate) fn host_canvas(ctx: &egui::Context, keeps_tab: bool) {
let keys = if keeps_tab { DOCUMENT_KEYS.with_keep(KeepKeys::Tab) } else { DOCUMENT_KEYS };
focus::host_canvas(ctx, document_id(), keys);
}
/// Gives the document window the keyboard focus. It is the runtime's focus, which an Escape does not take away.
pub(crate) fn focus_document(ctx: &egui::Context) {
focus::request(ctx, FocusTarget::Id(document_id()));
}
/// The widget that has the keyboard, the document window left out: a focused document leaves the keyboard to
/// DeckCraft's own key routing, as with nothing focused.
pub(crate) fn focused_widget(ctx: &egui::Context) -> Option<egui::Id> {
ctx.memory(|m| m.focused()).filter(|id| *id != document_id())
}
/// Whether a widget other than the document window has the keyboard.
pub(crate) fn widget_has_keyboard(ctx: &egui::Context) -> bool {
focused_widget(ctx).is_some()
}
/// Whether Escape was pressed in this pass: from egui while one of DeckCraft's own widgets or popups has the keyboard,
/// otherwise the window's cancel, which the runtime routes to no component. Leaves it for later readers.
pub(crate) fn escape_pressed(ctx: &egui::Context) -> bool {
ctx.input(|i| i.key_pressed(egui::Key::Escape)) || window_escape(ctx)
}
/// Whether the window's cancel (an Escape while nothing has framework focus, which the runtime takes out of egui's
/// events) is there and untaken. Key loops that read egui's events add it as an Escape press.
pub(crate) fn window_escape(ctx: &egui::Context) -> bool {
window_cancel(ctx, false)
}
/// The Escape press [`window_escape`] stands for, for key loops over egui's events.
pub(crate) const ESCAPE_PRESS: egui::Event =
egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE };
/// Takes the window's cancel (an Escape while nothing has framework focus): whether there was one.
pub(crate) fn take_window_cancel(ctx: &egui::Context) -> bool {
window_cancel(ctx, true)
}
fn window_cancel(ctx: &egui::Context, take: bool) -> bool {
let mut pending = false;
with_window_intents(ctx, false, |intents| {
pending = intents.untaken(&Intent::Cancel);
take && pending && intents.take(Intent::Cancel)
});
pending
}
+1 -1
View File
@@ -13,7 +13,7 @@ fn harness(n: usize) -> egui_kittest::Harness<'static, SlideApp> {
for _ in 1..n {
s.execute("slide.new", &json!({})).unwrap();
}
egui_kittest::Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+22 -20
View File
@@ -11,13 +11,14 @@ use deckcraft_engine::Session;
/// Build the standard 1280×800 UI harness around a supplied session and run three frames.
fn harness(session: Session) -> egui_kittest::Harness<'static, SlideApp> {
let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1280.0, 800.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
SlideApp::new(session, Services::default()),
);
let mut h =
egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1280.0, 800.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
SlideApp::new(session, Services::default()),
);
crate::install_ime_pass_hooks(&h.ctx);
// The app keeps requesting repaints, so step frames instead of run().
h.run_steps(3);
@@ -191,19 +192,20 @@ fn a_discarded_pass_keeps_the_tombstone_until_a_settled_pass_publishes_the_inter
use std::sync::{Arc, Mutex};
let traces = Arc::new(Mutex::new(Vec::new()));
let seen = traces.clone();
let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1280.0, 800.0)).build_ui_state(
move |ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
seen.lock().unwrap().push((
app.ime_cancelled.is_some(),
app.ime_interrupt_pending,
app.ime_composition.is_none(),
ui.ctx().will_discard(),
));
},
SlideApp::new(Session::with_new(), Services::default()),
);
let mut h =
egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1280.0, 800.0)).build_ui_state(
move |ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
seen.lock().unwrap().push((
app.ime_cancelled.is_some(),
app.ime_interrupt_pending,
app.ime_composition.is_none(),
ui.ctx().will_discard(),
));
},
SlideApp::new(Session::with_new(), Services::default()),
);
h.run_steps(3);
let title = h.state().session.active().unwrap().doc.slides[0].shapes[0].id.0;
h.state_mut().run("text.edit", json!({"id": title})).unwrap();
+1 -1
View File
@@ -26,7 +26,7 @@ fn harness(tab: &str) -> (Harness<'static, SlideApp>, [ShapeId; 2]) {
s.execute("selection.select", &json!({"ids": [ids[0].0]})).unwrap();
let mut app = SlideApp::new(s, Services::default());
app.ui.tab = tab.into();
let mut h = Harness::builder().with_size(egui::vec2(1800.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+12 -1
View File
@@ -23,6 +23,7 @@ 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;
@@ -267,8 +268,11 @@ pub struct SlideApp {
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; a focus change retracts it.
/// 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.
@@ -300,6 +304,11 @@ pub struct SlideApp {
print_previews: app::files::PrintPreviews,
#[cfg(not(target_arch = "wasm32"))]
updates_rt: updates_ui::Runtime,
/// 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).
@@ -454,6 +463,8 @@ mod browsetheme_tests;
#[cfg(test)]
mod compare_tests;
#[cfg(test)]
mod document_focus_tests;
#[cfg(test)]
mod eyedropper_tests;
#[cfg(test)]
mod field_frame_tests;
+22 -14
View File
@@ -42,13 +42,17 @@ fn play_on_the_editor_media_bar_plays_the_selected_clip() {
let r = s.execute("insert.audio", &json!({"name": "tone.wav", "data": deckcraft_engine::cmd::base64_encode(&wav(2.0))})).unwrap();
let id = ShapeId(r["id"].as_u64().unwrap() as u32);
let app = SlideApp::new(s, Services::default());
let mut h = Harness::builder().with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(vec2(1400.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
let d = h.state().session.active().unwrap();
assert_eq!(d.selection.shapes, vec![id], "the inserted clip is selected");
@@ -88,13 +92,17 @@ fn the_media_bar_never_paints_or_clicks_into_the_notes_pane() {
let mut app = SlideApp::new(s, Services::default());
app.ui.notes = true;
app.ui.notes_height = 140.0;
let mut h = Harness::builder().with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(vec2(1400.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
let notes = h.query_all_by_role(Role::MultilineTextInput).next().map(|n| n.rect()).expect("the notes field");
let canvas = h.state().canvas_rect.unwrap();
+3 -8
View File
@@ -128,14 +128,9 @@ pub fn palette(app: &mut SlideApp, ctx: &egui::Context) {
r.request_focus();
let q = query.to_lowercase();
let items = palette_items(&app.session, &q);
let (down, up, enter, esc) = ui.input(|i| {
(
i.key_pressed(egui::Key::ArrowDown),
i.key_pressed(egui::Key::ArrowUp),
i.key_pressed(egui::Key::Enter),
i.key_pressed(egui::Key::Escape),
)
});
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));
}
+21 -15
View File
@@ -116,7 +116,7 @@ impl SlideApp {
cancel = ui.button("Cancel").clicked();
});
});
if cancel || ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape)) {
if cancel || ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape)) || crate::framework::take_window_cancel(ctx) {
self.cancel_opening();
}
ctx.request_repaint_after(std::time::Duration::from_millis(100));
@@ -200,13 +200,16 @@ mod tests {
// 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_size(egui::vec2(1000.0, 700.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
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();
@@ -284,13 +287,16 @@ mod tests {
for leave in [egui::Key::Escape, egui::Key::ArrowRight] {
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_size(egui::vec2(1000.0, 700.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
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);
assert!(harness.state().show.is_some(), "the show is running");
if leave == egui::Key::ArrowRight {
+11 -10
View File
@@ -193,7 +193,7 @@ mod tests {
let mut app = SlideApp::new(s, Services::default());
app.ui.pane = Some("format".into());
app.ui.format_tab = "fill".into();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
@@ -234,7 +234,7 @@ mod tests {
let mut app = SlideApp::new(s, Services::default());
app.ui.pane = Some("format".into());
app.ui.format_tab = "fill".into();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
@@ -345,13 +345,14 @@ mod tests {
let mut app = SlideApp::new(s, Services::default());
app.ui.pane = Some("format".into());
app.ui.format_tab = "fill".into();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h =
Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h
};
@@ -399,7 +400,7 @@ mod tests {
let mut app = SlideApp::new(s, Services::default());
app.ui.pane = Some("format".into());
app.ui.format_tab = "fill".into();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+2 -2
View File
@@ -156,7 +156,7 @@ fn picture_background_options(app: &mut SlideApp, ui: &mut Ui, pf: &deckcraft_mo
};
ui.horizontal(|ui| {
let field = ui.add_sized(vec2(72.0, 20.0), egui::Label::new("Alignment"));
let combo = craft_ui::ComboBox::from_id_salt("bg-align").selected_text(align_name).width(140.0).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt("bg-align").selected_text(align_name).width(140.0).show_ui(ui, |ui| {
for (k, l) in [
("tl", "Top Left"),
("t", "Top"),
@@ -183,7 +183,7 @@ fn picture_background_options(app: &mut SlideApp, ui: &mut Ui, pf: &deckcraft_mo
};
ui.horizontal(|ui| {
let field = ui.add_sized(vec2(72.0, 20.0), egui::Label::new("Mirror"));
let combo = craft_ui::ComboBox::from_id_salt("bg-mirror").selected_text(mirror_name).width(140.0).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt("bg-mirror").selected_text(mirror_name).width(140.0).show_ui(ui, |ui| {
for (k, l) in [("none", "None"), ("x", "Horizontal"), ("y", "Vertical"), ("xy", "Both")] {
if ui.selectable_label(flip == k, l).clicked() {
run(app, "design.background", json!({"pictureProps": {"mirror": k}}));
@@ -15,7 +15,7 @@ const PNG: &str = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z
fn harness(mut app: SlideApp) -> Harness<'static, SlideApp> {
app.ui.tab = "Design".into();
app.ui.pane = Some("background".into());
let mut h = Harness::builder().with_size(egui::vec2(1800.0, 1100.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 1100.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
@@ -17,7 +17,7 @@ fn harness() -> Harness<'static, SlideApp> {
let mut app = SlideApp::new(s, Services::default());
app.ui.pane = Some("format".into());
app.ui.format_tab = "effects".into();
let mut h = Harness::builder().with_size(egui::vec2(1800.0, 1100.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 1100.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+1 -1
View File
@@ -174,7 +174,7 @@ pub fn gradient_editor(ui: &mut Ui, id: &str, g: &Gradient, sc: &ColorScheme) ->
};
ui.horizontal(|ui| {
let field = ui.add_sized(vec2(70.0, 20.0), egui::Label::new("Type"));
let combo = craft_ui::ComboBox::from_id_salt((id, "kind")).selected_text(kind).width(120.0).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt((id, "kind")).selected_text(kind).width(120.0).show_ui(ui, |ui| {
for k in ["Linear", "Radial", "Rectangular", "Path"] {
if ui.selectable_label(kind == k, k).clicked() && kind != k {
let focus = match &g.shape {
+4 -4
View File
@@ -218,7 +218,7 @@ fn size_tab(app: &mut SlideApp, ui: &mut Ui, sh: &deckcraft_model::Shape, x: dec
ui.horizontal(|ui| {
ui.add_sized(vec2(90.0, 20.0), egui::Label::new("From"));
let combo =
craft_ui::ComboBox::from_id_salt("fmt-origin").selected_text(if center { "Center" } else { "Top Left Corner" }).show_ui(ui, |ui| {
egui::ComboBox::from_id_salt("fmt-origin").selected_text(if center { "Center" } else { "Top Left Corner" }).show_ui(ui, |ui| {
ui.selectable_value(&mut center, false, "Top Left Corner");
ui.selectable_value(&mut center, true, "Center");
});
@@ -493,7 +493,7 @@ fn line_choice(app: &mut SlideApp, ui: &mut Ui, label: &str, key: &str, current:
ui.horizontal(|ui| {
let field = ui.add_sized(vec2(90.0, 20.0), egui::Label::new(label));
let shown = items.iter().find(|(_, v)| *v == current).map_or(current, |(l, _)| *l);
let combo = craft_ui::ComboBox::from_id_salt(("fmt-line", key)).selected_text(shown).width(120.0).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt(("fmt-line", key)).selected_text(shown).width(120.0).show_ui(ui, |ui| {
for (l, v) in items {
if ui.selectable_label(*v == current, *l).clicked() {
run(app, "shape.line", json!({key: v}));
@@ -653,7 +653,7 @@ fn picture_fill_options(app: &mut SlideApp, ui: &mut Ui, id: u32, pf: &deckcraft
ui.horizontal(|ui| {
let field = ui.add_sized(vec2(90.0, 20.0), egui::Label::new(label));
let shown = opts.iter().find(|(k, _)| k == cur).map_or(opts[0].1, |(_, l)| *l);
let combo = craft_ui::ComboBox::from_id_salt(("picfill", id, key)).selected_text(shown).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt(("picfill", id, key)).selected_text(shown).show_ui(ui, |ui| {
for (k, l) in opts {
if ui.selectable_label(*k == cur.as_str(), *l).clicked() {
run(app, "shape.fill", json!({"pictureProps": {key: k}}));
@@ -705,7 +705,7 @@ fn preset_label(name: &str) -> String {
fn three_d_combo(app: &mut SlideApp, ui: &mut Ui, id: u32, label: &str, key: &str, cur: &str, options: &[&str]) {
ui.horizontal(|ui| {
let field = ui.add_sized(vec2(90.0, 20.0), egui::Label::new(label));
let combo = craft_ui::ComboBox::from_id_salt(("3d", id, key)).selected_text(preset_label(cur)).width(170.0).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt(("3d", id, key)).selected_text(preset_label(cur)).width(170.0).show_ui(ui, |ui| {
for o in options {
if ui.selectable_label(*o == cur, preset_label(o)).clicked() {
run(app, "shape.effects", json!({"threeD": {key: o}}));
@@ -15,7 +15,7 @@ use crate::{Services, SlideApp};
fn harness(mut app: SlideApp, pane: &str) -> Harness<'static, SlideApp> {
app.ui.pane = Some(pane.into());
let mut h = Harness::builder().with_size(egui::vec2(1800.0, 1100.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 1100.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+3 -3
View File
@@ -216,7 +216,7 @@ pub fn show(app: &mut SlideApp, ui: &mut Ui) {
}
app.selpane.rename_started = true;
}
let (enter, esc) = ui.input(|i| (i.key_pressed(egui::Key::Enter), i.key_pressed(egui::Key::Escape)));
let (enter, esc) = (ui.input(|i| i.key_pressed(egui::Key::Enter)), crate::framework::escape_pressed(ui.ctx()));
if out.lost_focus() || enter || esc {
app.selpane.renaming = None;
app.selpane.rename_started = false;
@@ -342,16 +342,16 @@ fn click(app: &mut SlideApp, rows: &[Row], k: usize, ctrl: bool, shift: bool) {
}
fn keys(app: &mut SlideApp, ui: &Ui, rows: &[Row], selected: &[u32], focused: u32) {
let (up, down, home, end, f2, esc) = ui.input(|i| {
let (up, down, home, end, f2) = ui.input(|i| {
(
i.key_pressed(egui::Key::ArrowUp),
i.key_pressed(egui::Key::ArrowDown),
i.key_pressed(egui::Key::Home),
i.key_pressed(egui::Key::End),
i.key_pressed(egui::Key::F2),
i.key_pressed(egui::Key::Escape),
)
});
let esc = crate::framework::escape_pressed(ui.ctx());
let cur = selected.last().and_then(|id| rows.iter().position(|r| r.id == *id));
let to = if up {
Some(cur.map(|c| c.saturating_sub(1)).unwrap_or(0))
+11 -7
View File
@@ -26,13 +26,17 @@ fn harness() -> (Harness<'static, SlideApp>, Vec<u32>) {
ids.push(g);
let mut app = SlideApp::new(s, Services::default());
app.ui.pane = Some("selection".into());
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1400.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
(h, ids)
}
+8 -5
View File
@@ -8,7 +8,7 @@ pub(super) fn smartart(app: &mut SlideApp, ui: &mut Ui) {
return;
};
let texts: Vec<String> = d.nodes.iter().map(|n| n.text.clone()).collect();
let focused_any = ui.ctx().memory(|m| m.focused().is_some()) || app.ui.smartart_focus.is_some();
let focused_any = crate::framework::widget_has_keyboard(ui.ctx()) || app.ui.smartart_focus.is_some();
if app.ui.smartart_drafts.0 != gid.0 || app.ui.smartart_drafts.1.len() != texts.len() || !focused_any {
app.ui.smartart_drafts = (gid.0, texts.clone());
}
@@ -24,7 +24,8 @@ pub(super) fn smartart(app: &mut SlideApp, ui: &mut Ui) {
ui.horizontal(|ui| {
ui.add_space(16.0 * node.level as f32);
ui.label("•");
let te = egui::TextEdit::singleline(draft).id(id).hint_text("Diagram text").desired_width(f32::INFINITY);
// The line keeps Tab for its own command; Escape leaves it.
let te = egui::TextEdit::singleline(draft).id(id).hint_text("Diagram text").desired_width(f32::INFINITY).lock_focus(true);
let r = ui.add(te);
if app.ui.smartart_focus == Some(i) {
r.request_focus();
@@ -39,13 +40,15 @@ pub(super) fn smartart(app: &mut SlideApp, ui: &mut Ui) {
action = Some(("smartArt.removeNode", json!({"index": i})));
focus_row = Some(i.saturating_sub(1));
}
}
if r.lost_focus() {
let (tab, shift) = ui.input(|inp| (inp.key_pressed(egui::Key::Tab), inp.modifiers.shift));
if tab {
action = Some((if shift { "smartArt.promote" } else { "smartArt.demote" }, json!({"index": i})));
focus_row = Some(i);
} else if ui.input(|inp| inp.key_pressed(egui::Key::Enter)) {
commit = Some(i);
}
}
if r.lost_focus() {
if ui.input(|inp| inp.key_pressed(egui::Key::Enter)) {
action = Some(("smartArt.addNode", json!({"index": i, "position": "after"})));
focus_row = Some(i + 1);
}
+33 -21
View File
@@ -25,13 +25,17 @@ fn text_pane_types_adds_and_demotes() {
s.execute("insert.smartArt", &json!({"kind": "list", "items": ["Plan", "Build"]})).unwrap();
let mut app = SlideApp::new(s, Services::default());
app.ui.pane = Some("smartart".into());
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1400.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
assert!(h.query_by_label("Text Pane").is_some());
@@ -58,13 +62,17 @@ fn home_convert_to_smartart_gallery_converts_the_text() {
s.execute("slide.new", &json!({"layout": "blank"})).unwrap();
s.execute("insert.textBox", &json!({"text": "Goals\nRevenue\nGrowth"})).unwrap();
let app = SlideApp::new(s, Services::default());
let mut h = Harness::builder().with_size(egui::vec2(1600.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1600.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h.get_by_label("Convert to Diagram").click();
h.run_steps(3);
@@ -84,13 +92,17 @@ fn layout_gallery_shows_cached_pictures_and_previews_on_hover() {
s.execute("insert.smartArt", &json!({"kind": "process", "items": ["Plan", "Build", "Ship"]})).unwrap();
let mut app = SlideApp::new(s, Services::default());
app.ui.tab = "SmartArt Design".into();
let mut h = Harness::builder().with_size(egui::vec2(1600.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1600.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h.get_by_label("Layouts").click();
h.run_steps(3);
+11 -7
View File
@@ -18,13 +18,17 @@ fn thesaurus_pane_swaps_the_word_at_the_caret() {
s.execute("text.edit", &json!({"id": id, "at": [0, 6]})).unwrap();
let mut app = SlideApp::new(s, Services::default());
app.ui.tab = "Review".into();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1400.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h.get_by_label("Thesaurus").click();
h.run_steps(3);
+12 -8
View File
@@ -437,7 +437,7 @@ mod tests {
use deckcraft_engine::Session;
fn harness() -> Harness<'static, SlideApp> {
let mut h = Harness::builder().with_size(egui::vec2(1200.0, 800.0)).build_ui_state(
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);
@@ -506,13 +506,17 @@ mod tests {
while s.doc().unwrap().doc.slides.len() < slides {
s.execute("slide.new", &json!({})).unwrap();
}
let mut h = Harness::builder().with_size(egui::vec2(1200.0, 1600.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
SlideApp::new(s, Services::default()),
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1200.0, 1600.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
SlideApp::new(s, Services::default()),
);
h.run_steps(3);
let ids = order(&h);
(h, ids)
+2 -2
View File
@@ -23,7 +23,7 @@ fn reflection_none_clears_after_a_second_preset() {
let mut app = SlideApp::new(s, Services::default());
app.ui.pane = Some("format".into());
app.ui.format_tab = "effects".into();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
@@ -51,7 +51,7 @@ fn reflection_none_stays_cleared_when_a_slider_only_had_focus() {
let mut app = SlideApp::new(s, Services::default());
app.ui.pane = Some("format".into());
app.ui.format_tab = "effects".into();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1400.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+11 -7
View File
@@ -19,13 +19,17 @@ fn harness() -> Harness<'static, SlideApp> {
// The product's default window. The Home ribbon overflows here with the bundled interface
// fonts; the ribbon's own edge chevron must make its Editing group reachable instead of the
// regression widening the fixture past the width the app actually opens at.
let mut h = Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1440.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h
}
+11 -7
View File
@@ -32,13 +32,17 @@ fn harness(file: &Rc<RefCell<Vec<u8>>>) -> Harness<'static, SlideApp> {
..Services::default()
};
let app = SlideApp::new(s, services);
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1400.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h
}
@@ -13,7 +13,7 @@ fn harness(size: egui::Vec2) -> Harness<'static, SlideApp> {
session.execute("edit.select", &json!({"ids": [id]})).unwrap();
let mut app = SlideApp::new(session, Services::default());
app.ui.tab = "Animations".into();
let mut h = Harness::builder().with_size(size).with_step_dt(1.0 / 60.0).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(size).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+1 -1
View File
@@ -26,7 +26,7 @@ fn harness(select: &[usize]) -> (Harness<'static, SlideApp>, Vec<ShapeId>) {
s.execute("selection.select", &json!({"ids": picked})).unwrap();
let mut app = SlideApp::new(s, Services::default());
app.ui.tab = "Shape Format".into();
let mut h = Harness::builder().with_size(egui::vec2(1800.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+11 -7
View File
@@ -35,13 +35,17 @@ fn draw_a_table_split_it_and_erase_the_border() {
s.execute("slide.new", &json!({"layout": "blank"})).unwrap();
let mut app = SlideApp::new(s, Services::default());
app.ui.tab = "Insert".into();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1400.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h.get_by_label("Table").click();
h.run_steps(2);
+1 -1
View File
@@ -9,7 +9,7 @@ use crate::{Services, SlideApp};
fn harness() -> Harness<'static, SlideApp> {
let mut app = SlideApp::new(Session::with_new(), Services::default());
app.ui.tab = "Design".into();
let mut h = Harness::builder().with_size(egui::vec2(1800.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
@@ -11,7 +11,7 @@ use crate::{Services, SlideApp};
fn clicking_inside_the_icons_popup_keeps_it_open() {
let mut app = SlideApp::new(Session::with_new(), Services::default());
app.ui.tab = "Insert".into();
let mut h = Harness::builder().with_size(egui::vec2(1800.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+11 -7
View File
@@ -16,13 +16,17 @@ fn pen_a_rectangle_then_ink_to_shape() {
s.execute("slide.new", &json!({"layout": "blank"})).unwrap();
let mut app = SlideApp::new(s, Services::default());
app.ui.tab = "Draw".into();
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h = Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(egui::vec2(1400.0, 900.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h.get_by_label("Black Pen").click();
h.run_steps(2);
@@ -11,7 +11,7 @@ use serde_json::json;
use crate::{Services, SlideApp};
fn harness(app: SlideApp) -> Harness<'static, SlideApp> {
let mut h = Harness::builder().with_size(egui::vec2(1800.0, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1800.0, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
@@ -22,7 +22,7 @@ fn picture_format(width: f32) -> (Harness<'static, SlideApp>, ShapeId) {
s.execute("edit.select", &json!({"ids": [id]})).unwrap();
let mut app = SlideApp::new(s, Services::default());
app.ui.tab = "Picture Format".into();
let mut h = Harness::builder().with_size(egui::vec2(width, 900.0)).build_ui_state(
let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(width, 900.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
+1 -1
View File
@@ -82,7 +82,7 @@ pub(super) fn transitions(app: &mut SlideApp, ui: &mut Ui) {
.and_then(|t| t.sound)
.and_then(|m| app.session.active().and_then(|d| d.doc.media(m).map(|i| i.name.trim_end_matches(".wav").to_string())))
.unwrap_or_else(|| if stop { "[Stop Previous Sound]".into() } else { "[No Sound]".into() });
let combo = craft_ui::ComboBox::from_id_salt("transition_sound").width(140.0).selected_text(name).show_ui(ui, |ui| {
let combo = egui::ComboBox::from_id_salt("transition_sound").width(140.0).selected_text(name).show_ui(ui, |ui| {
let none = cur.as_ref().is_none_or(|t| t.sound.is_none() && !t.stop_sound);
if ui.selectable_label(none, "[No Sound]").clicked() {
run(app, "transition.sound", json!({"none": true}));
+10 -7
View File
@@ -157,13 +157,16 @@ mod tests {
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_size(egui::vec2(1200.0, 800.0)).build_ui_state(
|ui, app: &mut crate::SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
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,
);
h.run_steps(4);
assert!(h.state().canvas_scale <= *crate::ZOOM_RANGE.end() + 1e-3, "{}", h.state().canvas_scale);
}
+4 -1
View File
@@ -6,12 +6,15 @@ use super::{Color32, Presentation, Show, ShowAction};
/// audience window and Presenter View use this path, including animation steps and end-of-show.
/// `presenter` is true for Presenter View, where G opens that window's own grid (#1130).
pub(super) fn keyboard(ctx: &egui::Context, show: &mut Show, doc: &Presentation, now: f64, presenter: bool) -> bool {
let keys: Vec<(egui::Key, egui::Modifiers)> = ctx.input(|i| {
let mut keys: Vec<(egui::Key, egui::Modifiers)> = ctx.input(|i| {
i.events
.iter()
.filter_map(|e| if let egui::Event::Key { key, pressed: true, modifiers, .. } = e { Some((*key, *modifiers)) } else { None })
.collect()
});
if crate::framework::window_escape(ctx) {
keys.push((egui::Key::Escape, egui::Modifiers::NONE));
}
let (keep, consumed) = handle_keys(show, doc, now, keys, presenter);
for (key, modifiers) in consumed {
ctx.input_mut(|i| i.consume_key(modifiers, key));
+92 -71
View File
@@ -35,13 +35,17 @@ fn a_still_cursor_hides_over_a_clickable_shape() {
let r = session.execute("shape.insert", &json!({"preset": "rect", "rect": [0.0, 0.0, size.width, size.height]})).unwrap();
session.execute("insert.hyperlink", &json!({"url": "https://example.org", "ids": [r["id"]]})).unwrap();
let app = SlideApp::new(session, crate::Services::default());
let mut harness = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(0.25).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut harness = egui_kittest::Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(vec2(1000.0, 700.0))
.with_step_dt(0.25)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
harness.run_steps(3);
harness.state_mut().start_show(0, false);
harness.run_steps(2);
@@ -65,13 +69,17 @@ fn keep_cursor_visible_leaves_a_still_cursor_over_a_link() {
let mut app = SlideApp::new(session, crate::Services::default());
app.ui.presenter_view = false;
app.run("show.keepCursor", json!({"on": true})).unwrap();
let mut harness = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(0.25).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut harness = egui_kittest::Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(vec2(1000.0, 700.0))
.with_step_dt(0.25)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
harness.run_steps(3);
harness.state_mut().start_show(0, false);
harness.run_steps(2);
@@ -90,13 +98,14 @@ fn set_up_slide_show_keeps_the_cursor_visible() {
use egui_kittest::kittest::Queryable;
let app = SlideApp::new(deckcraft_engine::Session::with_new(), crate::Services::default());
let mut harness = egui_kittest::Harness::builder().with_size(vec2(1200.0, 800.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut harness =
egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(1200.0, 800.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
for on in [true, false] {
harness.state_mut().run("app.dialog", json!({"id": "setupShow"})).unwrap();
harness.run_steps(6);
@@ -204,18 +213,19 @@ fn show_with_clip() -> (egui_kittest::Harness<'static, SlideApp>, ShapeId, Pos2,
// Presenter view opens an embedded window over the whole screen here, which takes the clicks.
let mut app = SlideApp::new(session, crate::Services::default());
app.ui.presenter_view = false;
let mut harness = egui_kittest::Harness::builder().with_size(size).with_step_dt(0.25).build_ui_state(
move |ui, app: &mut SlideApp| {
app.logic(ui.ctx());
if let (Some(show), Some(d)) = (app.show.as_ref(), app.session.active()) {
let now = ui.input(|i| i.time);
seen.set(pointer_on_media_bar(ui.ctx(), ui, &d.doc, show, now));
slide_seen.set(shown_slide_rect(ui, show, &d.doc));
}
app.ui(ui);
},
app,
);
let mut harness =
egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(size).with_step_dt(0.25).build_ui_state(
move |ui, app: &mut SlideApp| {
app.logic(ui.ctx());
if let (Some(show), Some(d)) = (app.show.as_ref(), app.session.active()) {
let now = ui.input(|i| i.time);
seen.set(pointer_on_media_bar(ui.ctx(), ui, &d.doc, show, now));
slide_seen.set(shown_slide_rect(ui, show, &d.doc));
}
app.ui(ui);
},
app,
);
harness.run_steps(3);
harness.state_mut().start_show(0, false);
harness.run_steps(2);
@@ -304,16 +314,20 @@ fn show_with_gif() -> (egui_kittest::Harness<'static, SlideApp>, ShapeId, Pos2)
let slide_seen = slide.clone();
let mut app = SlideApp::new(session, crate::Services::default());
app.ui.presenter_view = false;
let mut harness = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(0.25).build_ui_state(
move |ui, app: &mut SlideApp| {
app.logic(ui.ctx());
if let (Some(show), Some(d)) = (app.show.as_ref(), app.session.active()) {
slide_seen.set(shown_slide_rect(ui, show, &d.doc));
}
app.ui(ui);
},
app,
);
let mut harness = egui_kittest::Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(vec2(1000.0, 700.0))
.with_step_dt(0.25)
.build_ui_state(
move |ui, app: &mut SlideApp| {
app.logic(ui.ctx());
if let (Some(show), Some(d)) = (app.show.as_ref(), app.session.active()) {
slide_seen.set(shown_slide_rect(ui, show, &d.doc));
}
app.ui(ui);
},
app,
);
harness.run_steps(3);
harness.state_mut().start_show(1, false);
harness.run_steps(2);
@@ -415,13 +429,14 @@ fn slideshow_navigation_advances_once_with_presenter_view() {
session.execute("slide.new", &json!({})).unwrap();
let mut app = SlideApp::new(session, crate::Services::default());
app.ui.presenter_view = true;
let mut harness = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut harness =
egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(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.state_mut().start_show(0, false);
harness.run_steps(2);
@@ -810,13 +825,17 @@ fn show_of_three() -> egui_kittest::Harness<'static, SlideApp> {
session.execute("slide.new", &json!({})).unwrap();
let mut app = SlideApp::new(session, crate::Services::default());
app.ui.presenter_view = false;
let mut harness = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut harness = egui_kittest::Harness::builder()
.with_context_setup(crate::framework::install_headless)
.with_size(vec2(1000.0, 700.0))
.with_step_dt(1.0 / 60.0)
.build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
harness.run_steps(3);
harness.state_mut().start_show(0, false);
harness.run_steps(2);
@@ -1089,13 +1108,14 @@ fn back_leaves_a_slide_whose_first_animation_is_with_previous() {
.execute("animation.add", &json!({"effect": "fade", "class": "entrance", "ids": [id.0], "start": "withPrevious", "duration": 500}))
.unwrap();
let app = SlideApp::new(session, crate::Services::default());
let mut harness = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut harness =
egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(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.state_mut().start_show(0, false);
harness.run_steps(2);
@@ -1196,13 +1216,14 @@ fn remote_presenter_uses_the_audience_state_and_closes_with_the_show() {
let services = crate::Services { presenter: Some(Box::new(Mock(bridge.clone()))), ..Default::default() };
let mut app = SlideApp::new(session, services);
app.ui.presenter_view = true;
let mut h = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
let mut h =
egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(1000.0, 700.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);
},
app,
);
h.run_steps(3);
h.state_mut().start_show(0, false);
h.run_steps(2);
+1 -1
View File
@@ -18,7 +18,7 @@ fn open_with_size(w: f64, h: f64) -> egui_kittest::Harness<'static, SlideApp> {
let mut s = Session::new();
s.execute("file.open", &json!({"path": path.to_string_lossy()})).unwrap();
let _ = std::fs::remove_file(&path);
egui_kittest::Harness::builder().with_size(egui::vec2(1280.0, 800.0)).build_ui_state(
egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1280.0, 800.0)).build_ui_state(
|ui, app: &mut SlideApp| {
app.logic(ui.ctx());
app.ui(ui);

Some files were not shown because too many files have changed in this diff Show More