[plt-scheme] Ugly hacks in slideshow?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Jun 22 12:56:16 EDT 2004

At Mon, 21 Jun 2004 23:38:49 +0100, Paulo Jorge O. C. Matos wrote:
> Why is the title also shifted in the second slide?

Because the second test creates an item that is wider than client-w,
and your slide assembler right-aligns the title with the slide content
(after the content is superimposed with the client area). So the title
ends up on the right edge of a pict that is wider than the client area.
Finally, the result of a slide assembler is always left-aligned with
the client area), so the title gets shifted right.

Perhaps the simplest solution is to pretend that the content fits into
the client area (as assembled by `orig'):

  (let ([orig (current-slide-assembler)]
        [my-full-page (launder full-page)])
    (current-slide-assembler
     (lambda (title sep content)
       (let* ((titlepic (if (not title)
                            full-page
                            (titlet title)))
              (title-w (if (not title) 0 (pict-width titlepic))))
         (rt-superimpose 
          (inset titlepic 0 (+ 25 margin))
          (refocus
           (cc-superimpose
            my-full-page
            (orig #f sep content))
           my-full-page))))))

where `refocus', which is built in for v299, but can be implemented as
follows for v20x:

  ;; Draws like p, but the bounding box is the same as c, which
  ;;  appears within p:
  (define (refocus p c)
    (let-values ([(x y) (find-lt p c)])
      (let ([p (inset p 
		      (- x) (- y (pict-height p)) 
		      (- (- (pict-width p) x (pict-width c)))
		      (- (pict-height c) y))])
	(make-pict (pict-draw p)
		   (pict-width c) (pict-height c)
		   (pict-ascent c) (pict-descent c)
		   (pict-children p)))))


> Another question, made already in another thread to which I
> received no answer yet 

[Answered in the other thread.]

Matthew



Posted on the users mailing list.