racket/gui: change placement of children in panel%
and pane%
The `panel%` and `pane%` classes were not originally intended for direct instantiation; instead, `horizontal-pane[l]%` and `vertical-pane[l]%` provide basic placements that make sense for multiple children. Adjusting `pane[l]%` to just overlay all children seems both sensible and useful (if only one child is shown at a time, for example). As suggested by David Nelson.
This commit is contained in:
parent
fdf1a1f7ae
commit
32ae3f8308
|
@ -8,12 +8,17 @@ A pane is a both a container and a containee area. It serves only
|
|||
cannot be hidden or disabled like a @racket[panel%] object.
|
||||
|
||||
A @racket[pane%] object has a degenerate placement strategy for
|
||||
managing its children; it places them all in the upper left corner
|
||||
and does not stretch any of them. The @racket[horizontal-pane%] and
|
||||
@racket[vertical-pane%] classes provide useful geometry management.
|
||||
managing its children: it places each child as if it was the only
|
||||
child of the panel. The @racket[horizontal-pane%] and
|
||||
@racket[vertical-pane%] classes provide useful geometry management
|
||||
for multiple children.
|
||||
|
||||
See also @racket[grow-box-spacer-pane%].
|
||||
|
||||
@history[#:changed "1.3" @elem{Changed the placement strategy to
|
||||
stretch and align children, instead of
|
||||
placing all children at the top-left
|
||||
corner.}]
|
||||
|
||||
@defconstructor[([parent (or/c (is-a?/c frame%) (is-a?/c dialog%)
|
||||
(is-a?/c panel%) (is-a?/c pane%))]
|
||||
|
|
|
@ -11,11 +11,15 @@ A panel is a both a container and a containee window. It serves mainly
|
|||
object can be hidden or disabled.
|
||||
|
||||
A @racket[panel%] object has a degenerate placement strategy for
|
||||
managing its children; it places them all in the upper left corner
|
||||
and does not stretch any of them. The @racket[horizontal-panel%]
|
||||
and @racket[vertical-panel%] classes provide useful geometry
|
||||
management.
|
||||
managing its children: it places each child as if it was the only
|
||||
child of the panel. The @racket[horizontal-panel%] and
|
||||
@racket[vertical-panel%] classes provide useful geometry management
|
||||
for multiple children.
|
||||
|
||||
@history[#:changed "1.3" @elem{Changed the placement strategy to
|
||||
stretch and align children, instead of
|
||||
placing all children at the top-left
|
||||
corner.}]
|
||||
|
||||
@defconstructor[([parent (or/c (is-a?/c frame%) (is-a?/c dialog%)
|
||||
(is-a?/c panel%) (is-a?/c pane%))]
|
||||
|
|
|
@ -29,4 +29,4 @@
|
|||
|
||||
(define pkg-authors '(mflatt robby))
|
||||
|
||||
(define version "1.2")
|
||||
(define version "1.3")
|
||||
|
|
|
@ -389,15 +389,37 @@
|
|||
[do-place-children
|
||||
(lambda (children-info width height)
|
||||
(check-place-children children-info width height)
|
||||
(define m (border))
|
||||
(define w (- width (* 2 m)))
|
||||
(define h (- height (* 2 m)))
|
||||
(let loop ([children-info children-info])
|
||||
(if (null? children-info)
|
||||
null
|
||||
(let ([curr-info (car children-info)])
|
||||
(define cw (car curr-info))
|
||||
(define ch (cadr curr-info))
|
||||
(define w-stretch? (caddr curr-info))
|
||||
(define h-stretch? (cadddr curr-info))
|
||||
(cons
|
||||
(list
|
||||
0 0
|
||||
(car curr-info) ; child-info-x-min
|
||||
(cadr curr-info)) ; child-info-y-min
|
||||
(if w-stretch?
|
||||
m
|
||||
(case h-align
|
||||
[(center) (quotient (- w cw) 2)]
|
||||
[(right) (- w cw)]
|
||||
[else 0]))
|
||||
(if h-stretch?
|
||||
m
|
||||
(case v-align
|
||||
[(center) (quotient (- h ch) 2)]
|
||||
[(bottom) (- h ch)]
|
||||
[else 0]))
|
||||
(if w-stretch?
|
||||
w
|
||||
cw)
|
||||
(if h-stretch?
|
||||
h
|
||||
ch))
|
||||
(loop (cdr children-info)))))))])
|
||||
|
||||
(define curr-spacing const-default-spacing)
|
||||
|
|
Loading…
Reference in New Issue
Block a user