Compare commits

..
Author SHA1 Message Date
Luis 497582406d Gradient stops: double-clicking a stop opens its colour menu (#2175) (#2196)
Double-clicking a stop marker in the Format pane's gradient editor did nothing. It now selects the stop and opens the colour menu of the selected stop, as in PowerPoint. The menu button is also named for screen readers.
2026-11-17 08:36:53 +00:00
Luis e1ca71495c Slide show: a slide's animations wait for its transition (#2089) (#2197)
A first step that starts With or After Previous began with the slide, so its effects played under the transition. Its clock now starts when the transition has finished, as in PowerPoint. Slides without a transition, and Show without animation, start the step at once as before.
2026-11-17 08:35:55 +00:00
Dylan M. Taylor 5c698493bc ci: lock workflow actions through an actions.lock lockfile (#2078) 2026-11-16 21:58:00 -05:00
Dylan M. Taylor f964d06cc5 docs: prefer shared Craft libraries for reusable features (#2178) 2026-11-16 21:57:57 -05:00
Dylan M. Taylor ac73229ef4 pptx: reuse shared custom-geometry path tokenization (#2192) 2026-11-16 21:57:53 -05:00
9 changed files with 185 additions and 7 deletions
+31
View File
@@ -0,0 +1,31 @@
# This file is machine-generated by `gh actions-lock`.
# Do not edit by hand; run `gh actions-lock` to update.
# Docs: https://gh.io/actions-lockfile
version: 'v0.0.3'
workflows:
'.github/workflows/ci.yml':
- 'actions/checkout@v7.0.1'
- 'step-security/harden-runner@v2.22.4'
'.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/nix.yml': []
'.github/workflows/packaging-lint.yml':
- 'actions/checkout@v7.0.1'
- 'step-security/harden-runner@v2.22.4'
'.github/workflows/release.yml': []
'.github/workflows/sonarcloud.yml': []
'.github/workflows/windows-arm64.yml': []
dependencies:
'actions/checkout@v7.0.1':
ref: 'v7.0.1'
commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
owner_id: 44036562
repo_id: 197814629
'step-security/harden-runner@v2.22.4':
ref: 'v2.22.4'
commit: 'sha1-1d88384fd173af6ecb012dfd0264a306b711241a'
owner_id: 88700172
repo_id: 422287306
+2 -2
View File
@@ -27,11 +27,11 @@ jobs:
CRAFT_FONTS_REF: 37827adc41fd165f9a9234ac40f94dbad353aa69
steps:
- name: Harden runner
uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
uses: step-security/harden-runner@v2.22.4
with:
egress-policy: audit
- name: Check out craft-fonts
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
uses: actions/checkout@v7.0.1
with:
repository: storytold/craft-fonts
ref: ${{ env.CRAFT_FONTS_REF }}
+34
View File
@@ -0,0 +1,34 @@
name: Lockfile
# Fails when .github/workflows/actions.lock is out of sync with the workflows, or when a locked pin
# no longer verifies upstream, so a moved tag cannot slip a different commit into a run.
# Docs: https://gh.io/actions-lockfile
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
env:
GH_TOKEN: ${{ github.token }}
jobs:
lockfile:
name: Lockfile is in sync
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- name: Harden runner
uses: step-security/harden-runner@v2.22.4
with:
egress-policy: audit
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- name: Install gh-actions-lock
run: gh extension install github/gh-actions-lock --pin v0.4.1
- name: Verify the lockfile
run: gh actions-lock --verify
+2 -2
View File
@@ -28,10 +28,10 @@ jobs:
runs-on: windows-latest
steps:
- name: Harden runner
uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
uses: step-security/harden-runner@v2.22.4
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- name: Install the pinned packaging toolchain
+4
View File
@@ -239,3 +239,7 @@ the `ROADMAP.md` progress log, and update each touched doc's status line and rev
- Workflows in `.github/workflows/` call the shared workflows in [`storytold/craft-common-actions`](https://github.com/storytold/craft-common-actions) at `@main`, with their inputs and secrets. No other jobs: if no shared workflow does what's needed, it doesn't go here.
- Don't add or change CI in a feature or fix PR. If the existing workflows can't build or test a change, link an existing craft-common-actions issue or PR, or open a new issue, or a PR only for a small fix that is safe for every app and does not increase CI time.
- Some workflow files here still run their own jobs. Don't add to them. Moving a job into craft-common-actions is its own task, never part of another PR, and the job stays here until a shared workflow runs it.
## Shared libraries
Before adding or changing file-format, codec, protocol, or reusable UI code, check `storytold/craft-libs` and its open PRs first; reuse or extend the shared library rather than duplicating it locally, keep app-specific policy and model mapping in the app, and preserve behavior, security/resource limits, attribution, and regression coverage during cutovers.
+63 -1
View File
@@ -232,6 +232,8 @@ pub fn gradient_editor(ui: &mut Ui, id: &str, g: &Gradient, sc: &ColorScheme) ->
let (marks, _) = ui.allocate_exact_size(vec2(bar.width(), 14.0), Sense::hover());
let drag_id = ui.scope_id().with((id, "drag"));
let mut dragging: Option<(usize, f64)> = ui.data_mut(|d| d.get_temp(drag_id));
// A double-clicked stop opens its colour menu, as in PowerPoint (#2175).
let mut open_color = false;
for (i, s) in g.stops.iter().enumerate() {
let pos = dragging.filter(|d| d.0 == i).map_or(s.pos, |d| d.1);
let x = bar.min.x + pos as f32 * bar.width();
@@ -245,6 +247,10 @@ pub fn gradient_editor(ui: &mut Ui, id: &str, g: &Gradient, sc: &ColorScheme) ->
if resp.clicked() || resp.drag_started() {
sel = i;
}
if resp.double_clicked() {
sel = i;
open_color = true;
}
if resp.dragged()
&& let Some(p) = resp.interact_pointer_pos()
{
@@ -287,7 +293,12 @@ pub fn gradient_editor(ui: &mut Ui, id: &str, g: &Gradient, sc: &ColorScheme) ->
let (sw, _) = ui.allocate_exact_size(vec2(18.0, 18.0), Sense::hover());
ui.painter().rect(sw, CornerRadius::same(3), c32(&s.color, sc), Stroke::new(1.0, t.border), egui::StrokeKind::Inside);
let r = widgets::drop_button(ui, "", vec2(24.0, 20.0), true);
widgets::color_popup(&r).show(|ui| {
r.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, "Stop color"));
let mut popup = widgets::color_popup(&r);
if open_color {
popup = popup.open_memory(egui::SetOpenCommand::Bool(true));
}
popup.show(|ui| {
if let Some(Some(c)) = widgets::color_grid(ui, sc, None) {
let mut ng = g.clone();
ng.stops[sel].color = with_alpha(c, alpha_of(&s.color));
@@ -516,7 +527,58 @@ pub fn pattern_editor(ui: &mut Ui, pt: &PatternFill, sc: &ColorScheme) -> Option
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used, clippy::expect_used)]
use super::*;
use egui_kittest::Harness;
use egui_kittest::kittest::Queryable;
/// #2175: double-clicking a gradient stop selects it and opens its colour menu; a colour
/// picked there colours that stop.
#[test]
fn double_clicking_a_stop_opens_its_color_menu() {
let sc = deckcraft_model::Theme::default().colors;
let start = Gradient {
stops: vec![
GradientStop { pos: 0.0, color: ColorRef::scheme(SchemeSlot::Accent1) },
GradientStop { pos: 1.0, color: ColorRef::scheme(SchemeSlot::Accent2) },
],
..default_gradient(ColorRef::scheme(SchemeSlot::Accent1), 90.0)
};
// The gradient, and whether the interface fonts are in (they apply from the next frame).
let mut h = Harness::builder().with_size(vec2(400.0, 700.0)).with_step_dt(1.0 / 60.0).build_ui_state(
move |ui, (g, fonts): &mut (Gradient, bool)| {
if !*fonts {
theme::install_fonts(ui.ctx());
*fonts = true;
return;
}
if let Some(ng) = gradient_editor(ui, "test-grad", &g.clone(), &sc) {
*g = ng;
}
},
(start, false),
);
h.run_steps(3);
assert!(h.query_by_label("Theme Colors").is_none(), "the menu starts closed");
let stop = h.get_by_label("Gradient stop 2").rect().center();
h.hover_at(stop);
h.run_steps(1);
for _ in 0..2 {
for pressed in [true, false] {
h.event(egui::Event::PointerButton { pos: stop, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE });
h.run_steps(1);
}
}
h.run_steps(2);
assert!(h.query_by_label("Theme Colors").is_some(), "the colour menu opened");
h.get_by_label(SchemeSlot::Accent6.label()).click();
h.run_steps(2);
let g = &h.state().0;
assert_eq!(g.stops.len(), 2, "no stop was added");
assert_eq!(g.stops[1].color, ColorRef::scheme(SchemeSlot::Accent6), "the double-clicked stop took the colour");
assert_eq!(g.stops[0].color, ColorRef::scheme(SchemeSlot::Accent1));
}
#[test]
fn gradient_json_retains_flip_mode() {
+5 -2
View File
@@ -552,7 +552,8 @@ impl Show {
true
}
/// On entering a slide: auto-play its first step when it begins With/After Previous.
/// On entering a slide: auto-play its first step when it begins With/After Previous, once the
/// slide's transition is over.
/// `ShowState` already starts such a step when it enters the slide (#631: asking it for the
/// next step again finished the step at once, so the slide appeared fully built), so only
/// its clock starts here. Autoplay previews start an On Click first step themselves.
@@ -568,7 +569,9 @@ impl Show {
None
};
if let Some(k) = started {
self.step_start = now;
// The slide's transition plays first; its animations start when it has finished, as
// in PowerPoint (#2089).
self.step_start = self.trans.as_ref().map_or(now, |t| now.max(t.start + t.dur));
self.media_clock = Some((k, f64::NEG_INFINITY));
}
}
+35
View File
@@ -516,6 +516,41 @@ fn a_transition_keeps_the_old_slide_in_its_own_texture() {
assert!(show.tex.is_none(), "the new slide gets a texture of its own instead of overwriting the old one");
}
/// #2089: a slide's With Previous entrance waits for the slide's transition to finish, as in
/// PowerPoint, instead of playing under it.
#[test]
fn animations_start_after_the_slides_transition() {
let mut s = deckcraft_engine::Session::with_new();
s.execute("slide.new", &json!({})).unwrap();
s.execute("transition.set", &json!({"kind": "fade", "index": 1, "duration": 400})).unwrap();
let id = s.active().unwrap().doc.slides[1].shapes[0].id;
s.execute("animation.add", &json!({"effect": "fade", "class": "entrance", "ids": [id.0], "start": "withPrevious", "duration": 500})).unwrap();
let doc = s.active().unwrap().doc.clone();
let mut show = Show::new(&doc, 0, false, false);
let a = show.state.next(&doc);
assert_eq!(a, ShowAction::Slide(1));
assert!(show.apply(a, &doc, 10.0));
assert!(show.trans.is_some(), "the fade plays");
assert!(show.state.playing, "the With Previous step is under way");
assert!((show.clock_snapshot().step_start - 10.4).abs() < 1e-9, "its clock starts when the 0.4 s fade ends");
let tl = ShowState::timeline(&doc, 1);
let at = |now: f64| state_for(&tl, id, show.state.step, now - show.clock_snapshot().step_start, &[], &[]);
assert!(!at(10.3).visible, "hidden while the transition plays");
assert!(at(10.6).visible && at(10.6).opacity < 1.0, "fading in after it");
// The step is not cut short by the time the transition took.
let mut actions = Vec::new();
assert!(show.queue_clock_actions(&doc, 10.8, &mut actions));
assert!(actions.is_empty(), "0.4 s into a 0.5 s step: still playing");
// Without a transition the step starts at once, as before.
s.execute("transition.set", &json!({"kind": "none", "index": 1})).unwrap();
let doc = s.active().unwrap().doc.clone();
let mut show = Show::new(&doc, 0, false, false);
let a = show.state.next(&doc);
assert!(show.apply(a, &doc, 10.0));
assert_eq!(show.clock_snapshot().step_start, 10.0);
}
#[test]
fn going_back_plays_the_left_slides_transition_reversed() {
// #1531: Back from B to A played A's own entrance transition. PowerPoint plays the one B came
+9
View File
@@ -1,2 +1,11 @@
sonar.projectKey=storytold_deckcraft
sonar.organization=storytold
# githubactions:S7637 asks for every action to be pinned to a commit SHA. A workflow covered by
# .github/workflows/actions.lock runs the commit the lockfile records, so its tag refs are pinned
# and the lockfile covers the actions those actions use too. Sonar does not read lockfiles yet, so
# the rule flags the tag refs anyway:
# https://community.sonarsource.com/t/githubactions-s7637-false-positives-for-actions-pinned-through-native-actions-lock/190814
sonar.issue.ignore.multicriteria=gha-lockfile
sonar.issue.ignore.multicriteria.gha-lockfile.ruleKey=githubactions:S7637
sonar.issue.ignore.multicriteria.gha-lockfile.resourceKey=.github/workflows/**