Skip to content

Commit

Permalink
introducing every-child slide action
Browse files Browse the repository at this point in the history
steps all of its children simultaneously.  If one of them makes progress, keeps
going.

Signed-off-by: Psionik K <[email protected]>
  • Loading branch information
psionic-k committed May 26, 2024
1 parent 935224a commit 7784e7a
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
65 changes: 65 additions & 0 deletions dslide.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions test/demo.org
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7784e7a

Please sign in to comment.