From a027cc2f0a6d5dfe55bd4b6ce175168aa49788a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 23 Apr 2019 23:14:51 +0200 Subject: Minor movement in fix-event-widths./module/main.scm 2>/dev/pts/0 --- module/output/html.scm | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/module/output/html.scm b/module/output/html.scm index 812e9d79..614fc1cb 100644 --- a/module/output/html.scm +++ b/module/output/html.scm @@ -39,24 +39,23 @@ ;; Takes a list of vcomponents, sets their widths and x-positions to optimally ;; fill out the space, without any overlaps. (define (fix-event-widths! start-of-day lst) + ;; The tree construction is greedy. This means + ;; that if a smaller event preceeds a longer + ;; event it would capture the longer event to + ;; only find events which also overlaps the + ;; smaller event. ;; @var{x} is how for left in the container we are. - (define (inner x tree) + (let inner ((x 0) + (tree (make-tree (lambda (head e) (overlapping? head e)) + (sort* lst time>? (lambda (e) (event-length/day e start-of-day)))))) (if (null? tree) #f (let ((w (/ (- 1 x) (+ 1 (length-of-longst-branch (left-subtree tree)))))) (set! (width (car tree)) w (x-pos (car tree)) x) (inner (+ x w) (left-subtree tree)) - (inner x (right-subtree tree))))) - - (inner 0 (make-tree (lambda (head e) (overlapping? head e)) - ;; The tree construction is greedy. This means - ;; that if a smaller event preceeds a longer - ;; event it would capture the longer event to - ;; only find events which also overlaps the - ;; smaller event. - (sort* lst time>? (lambda (e) (event-length/day e start-of-day)))))) + (inner x (right-subtree tree)))))) ;; This should only be used on time intervals, never on absolute times. ;; For that see @var{date->decimal-hour}. -- cgit v1.2.3