From 1f7165df16e6894ae4d4e63d75316598b82751f9 Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Mon, 4 Jul 2011 06:55:52 -0600 Subject: [PATCH] unstable/gui/ppict: added abs-x, abs-y placer args, changed grid to 1-based --- collects/unstable/gui/ppict.rkt | 6 +++- collects/unstable/gui/private/ppict.rkt | 14 +++++---- .../unstable/scribblings/gui/pslide.scrbl | 30 ++++++++++++------- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/collects/unstable/gui/ppict.rkt b/collects/unstable/gui/ppict.rkt index 1a30bc4a0e..31a3cdae8e 100644 --- a/collects/unstable/gui/ppict.rkt +++ b/collects/unstable/gui/ppict.rkt @@ -46,12 +46,16 @@ [coord (->* (real? real?) (align/c + #:abs-x real? + #:abs-y real? #:compose procedure?) placer?)] [grid (->* (exact-positive-integer? exact-positive-integer? - exact-nonnegative-integer? exact-nonnegative-integer?) + exact-integer? exact-integer?) (align/c + #:abs-x real? + #:abs-y real? #:compose procedure?) placer?)] [cascade diff --git a/collects/unstable/gui/private/ppict.rkt b/collects/unstable/gui/private/ppict.rkt index 166aac4b29..de775dd4ba 100644 --- a/collects/unstable/gui/private/ppict.rkt +++ b/collects/unstable/gui/private/ppict.rkt @@ -66,7 +66,7 @@ In a placer function's arguments: (define valign (align->v align)) (define xfrac (/ (+ (sub1 col) (align->frac halign)) cols)) (define yfrac (/ (+ (sub1 row) (align->frac valign)) rows)) - (refpoint* xfrac yfrac abs-x abs-y halign valign compose sep)) + (refpoint* xfrac yfrac abs-x abs-y halign valign compose sep #f)) (define (coord xfrac yfrac [align 'cc] #:abs-x [abs-x 0] @@ -76,10 +76,10 @@ In a placer function's arguments: #:internal:skip [skip #f]) (define halign (align->h align)) (define valign (align->v align)) - (refpoint* xfrac yfrac abs-x abs-y halign valign compose sep)) + (refpoint* xfrac yfrac abs-x abs-y halign valign compose sep #f)) (define (refpoint* xfrac yfrac dxabs dyabs - halign valign compose sep) + halign valign compose sep continued?) (placer (lambda (scene picts) (define scene-w (pict-width scene)) @@ -87,7 +87,7 @@ In a placer function's arguments: (define dx (+ (* scene-w xfrac) dxabs)) (define dy (+ (* scene-h yfrac) dyabs)) (define-values (newpict newsep) - (apply-compose compose sep picts)) + (apply-compose compose sep (cons (and continued? (blank 0)) picts))) (define newpict-w (pict-width newpict)) (define newpict-h (pict-height newpict)) (define newscene @@ -98,11 +98,13 @@ In a placer function's arguments: (cond [(and (eq? valign 't) (eq? compose (halign->vcompose halign))) ;; ie, going top-down and compose is the natural compose for this align (mk-ppict result-pict - (refpoint* 0 0 dx (+ dy newpict-h) halign valign compose newsep))] + (refpoint* 0 0 dx (+ dy newpict-h) + halign valign compose newsep #t))] [(and (eq? halign 'l) (eq? compose (valign->hcompose valign))) ;; ie, going left-right and compose is the natural compose ... (mk-ppict result-pict - (refpoint* 0 0 (+ dx newpict-w) dy halign valign compose newsep))] + (refpoint* 0 0 (+ dx newpict-w) dy + halign valign compose newsep #t))] [else result-pict]))))) ;; ---- diff --git a/collects/unstable/scribblings/gui/pslide.scrbl b/collects/unstable/scribblings/gui/pslide.scrbl index 1f69ced7e0..ad39d93298 100644 --- a/collects/unstable/scribblings/gui/pslide.scrbl +++ b/collects/unstable/scribblings/gui/pslide.scrbl @@ -132,16 +132,20 @@ around it. Returns @racket[#t] if @racket[x] is a placer, @racket[#f] otherwise. } -@defproc[(coord [relx real?] [rely real?] +@defproc[(coord [rel-x real?] + [rel-y real?] [align (or/c 'lt 'ct 'rt 'lc 'cc 'rc 'lb 'cb 'rb) 'cc] + [#:abs-x abs-x real? 0] + [#:abs-y abs-y real? 0] [#:compose composer procedure? #, @elem{computed from @racket[align]}]) placer?]{ -Returns a placer that places picts according to a reference point -determined by @racket[relx] and @racket[rely], which are interpeted as -fractions of the width and height of the base @tech{progressive -pict}. That is, @racket[0], @racket[0] is the top left corner of the -base's bounding box, and @racket[1], @racket[1] is the bottom right. +Returns a placer that places picts according to @racket[rel-x] and +@racket[rel-y], which are interpeted as fractions of the width and +height of the base @tech{progressive pict}. That is, @racket[0], +@racket[0] is the top left corner of the base's bounding box, and +@racket[1], @racket[1] is the bottom right. Then @racket[abs-x] and +@racket[abs-y] offsets are added to get the final reference point. Additions are aligned according to @racket[align], a symbol whose name consists of a horizontal alignment character followed by a vertical @@ -165,10 +169,12 @@ another progressive pict only if @examples[#:eval the-eval (ppict-do base - #:go (coord 1/3 3/4 'cc) - (circle 20)) + #:go (coord 1/2 1/2 'rb) + (colorize (circle 20) "red") + #:go (coord 1/2 1/2 'lt) + (colorize (circle 20) "darkgreen")) (ppict-do base - #:go (coord 1 0 'rt) + #:go (coord 1 0 'rt #:abs-x -5 #:abs-y 10) 50 (code:comment "change spacing") (text "abc") (text "12345") @@ -184,9 +190,11 @@ another progressive pict only if @defproc[(grid [cols exact-positive-integer?] [rows exact-positive-integer?] - [col exact-nonnegative-integer?] - [row exact-nonnegative-integer?] + [col exact-integer?] + [row exact-integer?] [align (or/c 'lt 'ct 'rt 'lc 'cc 'rc 'lb 'cb 'rb) 'cc] + [#:abs-x abs-x real? 0] + [#:abs-y abs-y real? 0] [#:compose composer procedure? #, @elem{computed from @racket[align]}]) placer?]{