add get-default-percentages to panel:dragable and then add a dragable panel

to the debugger

original commit: 951de8cc51b446b6041e64bc37356392266a3532
This commit is contained in:
Robby Findler 2011-10-02 14:29:21 -05:00
parent c4deab2e67
commit 57b74886e6
2 changed files with 33 additions and 6 deletions

View File

@ -1,6 +1,7 @@
#lang racket/unit
(require mzlib/class
(require racket/class
racket/list
"sig.rkt"
mred/mred-sig)
@ -169,7 +170,8 @@
after-percentage-change
set-percentages
get-percentages
get-vertical?))
get-vertical?
get-default-percentages))
(define vertical-dragable<%>
(interface (dragable<%>)))
@ -244,12 +246,23 @@
(unless (= len-children (length percentages))
(cond
[(zero? len-children)
'()]
(set! percentages '())]
[else
(let ([rat (/ 1 len-children)])
(set! percentages (build-list len-children (λ (i) (make-percentage rat)))))])
(set! percentages (map make-percentage (get-default-percentages len-children)))])
(after-percentage-change))))
(define/pubment (get-default-percentages i)
(define res (inner (if (zero? i) '() (make-list i (/ i)))
get-default-percentages i))
(unless (and (list? res)
(andmap (λ (x) (and (real? x) (<= 0 x 1))) res)
(= 1 (apply + res))
(= (length res) i))
(error 'get-default-percentages
"expected inner call to return a list of real numbers that sum to 1 and has length ~a"
i))
res)
(define/override (after-new-child child)
(update-percentages))

View File

@ -45,7 +45,12 @@
}
@defmixin[panel:single-window-mixin (panel:single<%> window<%>) (panel:single-window<%>)]{
@defmethod*[#:mode override (((container-size (info (listof (list/c exact-integer? exact-integer? boolean? boolean?)))) (values exact-integer? exact-integer?)))]{
@defmethod*[#:mode override
(((container-size (info (listof (list/c exact-integer?
exact-integer?
boolean?
boolean?))))
(values exact-integer? exact-integer?)))]{
Factors the border width into the size calculation.
}
}
@ -66,6 +71,15 @@
Use @method[panel:dragable<%> get-percentages] to find the current
percentages.
}
@defmethod[(get-default-percentages [subwindow-count exact-positive-integer?])
(listof (and/c real? (between/c 0 1)))]{
Called when the number of children in the panel changes;
the result is used as the initial percentages for each of the new
windows.
The numbers in the result list must sum to @racket[1].
}
@defmethod*[(((set-percentages (new-percentages (listof number?))) void?))]{
Call this method to set the percentages that each window takes up of the