emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/dslide 659a5d1429 169/230: inline child action overhaul. m


From: ELPA Syncer
Subject: [nongnu] elpa/dslide 659a5d1429 169/230: inline child action overhaul. much better
Date: Sun, 7 Jul 2024 19:00:32 -0400 (EDT)

branch: elpa/dslide
commit 659a5d14293e98b59dff2f3579889d65920fab15
Author: Psionik K <73710933+psionic-k@users.noreply.github.com>
Commit: Psionik K <73710933+psionic-k@users.noreply.github.com>

    inline child action overhaul.  much better
    
    uses overlays now.  this design is much more apt to composing actions.  An
    inline child could have an inline child etc.
    
    Still need inline reveal animation for this, but this is better
    
    Also fixed a bug.
    
    Also simplied the number of places that touch the restriction
    
    Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com>
---
 dslide.el     | 54 ++++++++++++++++++++++++++++++++++--------------------
 test/demo.org |  1 +
 2 files changed, 35 insertions(+), 20 deletions(-)

diff --git a/dslide.el b/dslide.el
index 7c1cae59d6..55fa1f0761 100644
--- a/dslide.el
+++ b/dslide.el
@@ -1740,11 +1740,21 @@ state from being at the first child heading."
 
 ;; TODO override the child's own child action
 (defclass dslide-child-action-inline (dslide-child-action)
-  ((children
+  ((overlays
+    :initform nil)
+   (children
     :initform nil
     :documentation "Children that have been instantiated."))
   "Display children inline with the parent.")
 
+(cl-defmethod dslide-begin ((obj dslide-child-action-inline))
+  (let ((level (1+ (org-element-property :level (dslide-heading obj)))))
+    (oset obj overlays
+          (dslide--contents-map (dslide-heading obj) 'headline
+           (lambda (e)
+             (when (= (org-element-property :level e) level)
+               (dslide-hide-element e)))))))
+
 (cl-defmethod dslide-forward ((obj dslide-child-action-inline))
   (let (progress exhausted)
     (while (not (or progress exhausted))
@@ -1753,16 +1763,23 @@ state from being at the first child heading."
                        (dslide-forward child)))
       ;; If the child didn't make progress, try to load up the next child
       (unless progress
-        (if-let* ((child-heading (dslide-deck-forward-child obj))
+        (if-let* ((child-heading (dslide-child-next obj))
                   (child (dslide--make-slide
                           child-heading
-                          (oref dslide--deck slide)
-                          :slide-action #'dslide-action-narrow
+                          (oref dslide--deck slide) ; TODO hack
+                          :slide-action 'none
                           :inline t
-                          ;; TODO this won't compose at all
-                          :slide-action-args '(:include-restriction t 
:with-children t)
                           :child-action 'none)))
-            (progn (dslide-begin child)
+            (progn (mapc #'delete-overlay
+                         (seq-intersection (oref obj overlays)
+                                           (overlays-at (org-element-property
+                                                         :begin
+                                                         child-heading))))
+                   (dslide-begin child)
+                   (when dslide-slide-in-effect
+                     (dslide-animation-setup
+                      (org-element-property :begin child-heading)
+                      (org-element-property :end child-heading)))
                    (setq progress child)
                    (push child (oref obj children)))
           (setq exhausted t))))
@@ -1775,32 +1792,28 @@ state from being at the first child heading."
       (setq progress (when-let* ((child (car (oref obj children))))
                        (dslide-backward child)))
 
-      ;; If the child didn't make progress, narrow it away
+      ;; If the child didn't make progress, hide it with an overlay
       (unless progress
         (let* ((finished (pop (oref obj children)))
                (heading (dslide-heading finished)))
-          (dslide-deck-backward-child obj)       ; for marker effects 💡
-          ;; TODO do this with overlays in a nested child ☢️
-          (when heading
-            (narrow-to-region (point-min) (org-element-property :begin 
heading))
-            (run-hooks 'dslide-narrow-hook))
+          (dslide-child-previous obj) ; for marker effects 💡
+          (push (dslide-hide-element heading) (oref obj overlays))
           (dslide-final finished)
-          (setq progress (car (oref obj children))))))
+          (setq progress (or (car (oref obj children))
+                             (dslide-heading obj))))))
     progress))
 
-(cl-defmethod dslide-end :after ((obj dslide-child-action-inline))
+(cl-defmethod dslide-end ((obj dslide-child-action-inline))
   (dslide-marker obj (org-element-property :begin (dslide-heading obj)))
   (let (exhausted)
     (while (not exhausted)
       ;; If the child didn't make progress, try to load up the next child
-      (if-let* ((child-heading (dslide-deck-forward-child obj)))
+      (if-let* ((child-heading (dslide-child-next obj)))
           (let* ((child (dslide--make-slide
                          child-heading
-                         (oref dslide--deck slide)
+                         (oref dslide--deck slide) ; TODO hack.
+                         :slide-action 'none
                          :inline t
-                         ;; TODO this won't compose at all
-                         :slide-action #'dslide-action-narrow
-                         :slide-action-args '(:include-restriction t 
:with-children t)
                          :child-action 'none)))
             (let ((dslide-slide-in-effect nil))
               (dslide-end child))
@@ -1808,6 +1821,7 @@ state from being at the first child heading."
         (setq exhausted t)))))
 
 (cl-defmethod dslide-final :after ((obj dslide-child-action-inline))
+  (mapc #'delete-overlay (oref obj overlays))
   (mapc #'dslide-final (oref obj children)))
 
 ;; * Filters
diff --git a/test/demo.org b/test/demo.org
index 255eff7e8b..3d035d9a82 100644
--- a/test/demo.org
+++ b/test/demo.org
@@ -39,6 +39,7 @@ Be sure to customize the faces used for highlighting progress 
and babel block ex
 You probably want to define these in your theme, using ~set-face-attribute~.
 * Inline Children
 :PROPERTIES:
+:DSLIDE_SLIDE_ACTION: dslide-action-narrow :with-children t
 :DSLIDE_CHILD_ACTION: dslide-child-action-inline
 :END:
 - You won't believe these animations



reply via email to

[Prev in Thread] Current Thread [Next in Thread]