From 7784e7ad06cc5b08f2bade0dd615b3ae307fbc68 Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Sun, 26 May 2024 21:40:15 +0900 Subject: [PATCH] introducing every-child slide action steps all of its children simultaneously. If one of them makes progress, keeps going. Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- dslide.el | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ test/demo.org | 19 +++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/dslide.el b/dslide.el index 4b5bd3f..432b3b1 100644 --- a/dslide.el +++ b/dslide.el @@ -1727,6 +1727,71 @@ Child headings become independent slides.") (mapc #'delete-overlay (oref obj overlays)) (mapc #'dslide-final (oref obj children))) +;; ** Every Child Action +(defclass dslide-slide-action-every-child (dslide-slide-action) + ((overlay + :initform nil) + (children + :initform nil + :documentation "Children that have been instantiated.")) + "Display children inline and step every child at once.") + +(cl-defmethod dslide-begin ((obj dslide-slide-action-every-child)) + (dslide-narrow obj t) + (oset obj overlay (dslide-hide-children (dslide-heading obj)))) + +;; TODO multi-progress, like babel blocks +(cl-defmethod dslide-forward ((obj dslide-slide-action-every-child)) + (let ((progress)) + (while-let ((child-heading (dslide-child-next obj)) + (child (dslide--make-slide + child-heading + :slide-action 'dslide-slide-action-every-child + :inline t))) + (dslide-begin child) + ;; TODO inline animate in + (setq progress child) + (push child (oref obj children))) + (when progress + (delete-overlay (oref obj overlay)) + (oset obj overlay nil)) + (unless progress + (let ((progresses (mapcar #'dslide-forward + (oref obj children)))) + (setq progress (seq-first progresses)))) + progress)) + +(cl-defmethod dslide-backward ((obj dslide-slide-action-every-child)) + (let (progress) + (let ((progresses (mapcar #'dslide-backward + (oref obj children)))) + (setq progress (seq-first progresses))) + (unless progress + (oset obj overlay (dslide-hide-children (dslide-heading obj))) + (mapc #'dslide-final (oref obj children)) + (oset obj children nil) + ;; TODO just noticed that the marker method could store a marker that is + ;; shared, which could result in actions clobbering each other's sense of + ;; progress. ☢️ + (set-marker (oref obj marker) nil) + (dslide-marker obj (copy-marker (oref obj begin)))) + progress)) + +(cl-defmethod dslide-end ((obj dslide-slide-action-every-child)) + (dslide-narrow obj t) + (while-let ((child-heading (dslide-child-next obj))) + (push (dslide--make-slide + child-heading + :slide-action 'dslide-slide-action-every-child + :inline t) + (oref obj children))) + (mapc #'dslide-end (oref obj children))) + +(cl-defmethod dslide-final :after ((obj dslide-slide-action-every-child)) + (when-let ((overlay (oref obj overlay))) + (delete-overlay overlay)) + (mapc #'dslide-final (oref obj children))) + ;; * Filters (defun dslide-built-in-filter (heading) diff --git a/test/demo.org b/test/demo.org index c7f590f..ccb735d 100644 --- a/test/demo.org +++ b/test/demo.org @@ -77,6 +77,25 @@ This slide shows its child headings inline. ** Red Team - Uses some metasploit and calls it a day - Failure is an option +* Every Child +:PROPERTIES: +:DSLIDE_SLIDE_ACTION: dslide-slide-action-every-child +:END: +This is not a test, but a testament to excellence. Note that the item reveal in the child slides is configured with =:inline t= automatically. +** Pen-Pineapple 🖊️🍍 +:PROPERTIES: +:DSLIDE_ACTIONS: dslide-action-item-reveal +:END: +- Pen 🖊 is an office utensil used to sign documents +- Pineapple is an office utensil used to enhance the water cooler +- Long-pen 🖊🖊 is an office utensil that connects fruit +** Apple-Pen 🍎🖊️ +:PROPERTIES: +:DSLIDE_ACTIONS: dslide-action-item-reveal +:END: +- Apple is a fruit that grows on a tree +- Pen 🖊 is a fruit that grows on paper +- Apple-pineapple is a fruit grows on a tree made out of paper * Reveal Items :PROPERTIES: :DSLIDE_ACTIONS: dslide-action-item-reveal