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

to the debugger
This commit is contained in:
Robby Findler 2011-10-02 14:29:21 -05:00
parent 721cdba2c1
commit 951de8cc51
3 changed files with 52 additions and 8 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

@ -24,6 +24,10 @@
(define-local-member-name debug-callback)
(preferences:set-default 'plt:debug-tool:stack/variable-area
9/10
(λ (x) (and (real? x) (<= 0 x 1))))
(define tool@
(unit
(import drscheme:tool^)
@ -1215,8 +1219,21 @@
(define mouse-over-frame #f)
(define/override (get-definitions/interactions-panel-parent)
(set! debug-grandparent-panel
(make-object horizontal-panel%
(super get-definitions/interactions-panel-parent)))
(new (class panel:horizontal-dragable%
(inherit get-percentages)
(define/augment (get-default-percentages i)
(cond
[(= i 2)
(define p (preferences:get 'plt:debug-tool:stack/variable-area))
(list p (- 1 p))]
[else (build-list i (λ (x) (/ i)))]))
(define/augment (after-percentage-change)
(define ps (get-percentages))
(when (= (length ps) 2)
(preferences:set 'plt:debug-tool:stack/variable-area (car ps)))
(inner (void) after-percentage-change))
(super-new))
[parent (super get-definitions/interactions-panel-parent)]))
(set! stack-view-panel
(new panel:vertical-dragable%
[parent debug-grandparent-panel]

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