improved resized problem
original commit: ed042154ae6b68fcdb7729dbf4790506cf53a3fe
This commit is contained in:
parent
d714691859
commit
0c1f2f9018
|
@ -10,4 +10,5 @@
|
||||||
aligned-editor-canvas%
|
aligned-editor-canvas%
|
||||||
aligned-pasteboard<%>
|
aligned-pasteboard<%>
|
||||||
aligned-pasteboard-parent<%>
|
aligned-pasteboard-parent<%>
|
||||||
aligned-snip<%>))
|
aligned-snip<%>
|
||||||
|
aligned-snip-mixin))
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
|
|
||||||
(provide
|
(provide
|
||||||
aligned-editor-canvas%
|
aligned-editor-canvas%
|
||||||
aligned-editor-snip%)
|
aligned-editor-snip%
|
||||||
|
aligned-snip-mixin)
|
||||||
|
|
||||||
;; a canvas that can contain an aligned-pasteboard<%>
|
;; a canvas that can contain an aligned-pasteboard<%>
|
||||||
(define aligned-editor-canvas%
|
(define aligned-editor-canvas%
|
||||||
|
@ -153,4 +154,59 @@
|
||||||
|
|
||||||
(super-instantiate ())
|
(super-instantiate ())
|
||||||
))
|
))
|
||||||
|
|
||||||
|
(define (aligned-snip-mixin super%)
|
||||||
|
(class* super% (aligned-snip<%>)
|
||||||
|
(inherit get-editor get-margin)
|
||||||
|
|
||||||
|
(init
|
||||||
|
(stretchable-width true)
|
||||||
|
(stretchable-height true))
|
||||||
|
|
||||||
|
(field
|
||||||
|
(stretchable-width-field stretchable-width)
|
||||||
|
(stretchable-height-field stretchable-height))
|
||||||
|
|
||||||
|
(public (stretchable-width-method stretchable-width)
|
||||||
|
(stretchable-height-method stretchable-height))
|
||||||
|
|
||||||
|
;; stretchable-width (case-> (Boolean . -> . (void)) (-> Boolean))
|
||||||
|
;; get or set the stretchablity of the pasteboards width
|
||||||
|
(define stretchable-width-method
|
||||||
|
(case-lambda
|
||||||
|
[(value) (set! stretchable-width-field value)]
|
||||||
|
[() stretchable-width-field]))
|
||||||
|
|
||||||
|
;; stretchable-height (case-> (Boolean . -> .(void)) (-> Boolean))
|
||||||
|
;; get or set the stretchablity of the pasteboards height
|
||||||
|
(define stretchable-height-method
|
||||||
|
(case-lambda
|
||||||
|
[(value) (set! stretchable-height-field value)]
|
||||||
|
[() stretchable-height-field]))
|
||||||
|
|
||||||
|
;; get-aligned-min-width (-> number?)
|
||||||
|
;; the minimum width of the snip based on the children
|
||||||
|
(define/public (get-aligned-min-width)
|
||||||
|
(let ([left (box 0)]
|
||||||
|
[top (box 0)]
|
||||||
|
[right (box 0)]
|
||||||
|
[bottom (box 0)])
|
||||||
|
(get-margin left top right bottom)
|
||||||
|
(+ (unbox left) (unbox right))))
|
||||||
|
|
||||||
|
;; get-aligned-min-height (-> number?)
|
||||||
|
;; the minimum height of the snip based on the children
|
||||||
|
(define/public (get-aligned-min-height)
|
||||||
|
(let ([left (box 0)]
|
||||||
|
[top (box 0)]
|
||||||
|
[right (box 0)]
|
||||||
|
[bottom (box 0)]
|
||||||
|
[editor (get-editor)])
|
||||||
|
(get-margin left top right bottom)
|
||||||
|
(+ (unbox top) (unbox bottom)
|
||||||
|
(* (send editor line-location 0 false)
|
||||||
|
(add1 (send editor last-line))))))
|
||||||
|
|
||||||
|
(super-instantiate ())
|
||||||
|
))
|
||||||
)
|
)
|
|
@ -20,11 +20,13 @@
|
||||||
begin-edit-sequence end-edit-sequence)
|
begin-edit-sequence end-edit-sequence)
|
||||||
|
|
||||||
(field
|
(field
|
||||||
(alloted-width 0)
|
[needs-realign? false]
|
||||||
(alloted-height 0)
|
[ignore-resizing? false]
|
||||||
(aligned-min-width 0)
|
[alloted-width 0]
|
||||||
(aligned-min-height 0)
|
[alloted-height 0]
|
||||||
(aligned-rects empty))
|
[aligned-min-width 0]
|
||||||
|
[aligned-min-height 0]
|
||||||
|
[aligned-rects empty])
|
||||||
|
|
||||||
;; get-aligned-min-width (-> number?)
|
;; get-aligned-min-width (-> number?)
|
||||||
;; the aligned-min-width of the pasteboard
|
;; the aligned-min-width of the pasteboard
|
||||||
|
@ -47,6 +49,7 @@
|
||||||
[()
|
[()
|
||||||
(when (and (positive? alloted-width)
|
(when (and (positive? alloted-width)
|
||||||
(positive? alloted-height))
|
(positive? alloted-height))
|
||||||
|
(set! needs-realign? false)
|
||||||
(realign-to-alloted))]))
|
(realign-to-alloted))]))
|
||||||
|
|
||||||
;; realign-to-alloted (-> void?)
|
;; realign-to-alloted (-> void?)
|
||||||
|
@ -57,14 +60,18 @@
|
||||||
(align type alloted-width alloted-height
|
(align type alloted-width alloted-height
|
||||||
(map-snip build-rect first-snip)))
|
(map-snip build-rect first-snip)))
|
||||||
(begin-edit-sequence)
|
(begin-edit-sequence)
|
||||||
|
(set! ignore-resizing? true)
|
||||||
(for-each-snip move/resize first-snip aligned-rects)
|
(for-each-snip move/resize first-snip aligned-rects)
|
||||||
|
(set! ignore-resizing? false)
|
||||||
(end-edit-sequence)))
|
(end-edit-sequence)))
|
||||||
|
|
||||||
;; set-algined-min-sizes (-> void?)
|
;; set-algined-min-sizes (-> void?)
|
||||||
;; set the aligned min width and height of the pasteboard based on it's children snips
|
;; set the aligned min width and height of the pasteboard based on it's children snips
|
||||||
(define/public (set-aligned-min-sizes)
|
(define/public (set-aligned-min-sizes)
|
||||||
|
(set! ignore-resizing? true)
|
||||||
(set!-values (aligned-min-width aligned-min-height)
|
(set!-values (aligned-min-width aligned-min-height)
|
||||||
(get-aligned-min-sizes type (find-first-snip))))
|
(get-aligned-min-sizes type (find-first-snip)))
|
||||||
|
(set! ignore-resizing? false))
|
||||||
|
|
||||||
;;move/resize (snip-pos? rect? . -> . void?)
|
;;move/resize (snip-pos? rect? . -> . void?)
|
||||||
;;moves and resizes the snips with in pasteboard
|
;;moves and resizes the snips with in pasteboard
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
(define editor? (is-a?/c editor<%>))
|
(define editor? (is-a?/c editor<%>))
|
||||||
|
|
||||||
(provide/contract
|
(provide/contract
|
||||||
|
(snip-width (snip? . -> . number?))
|
||||||
|
(snip-height (snip? . -> . number?))
|
||||||
(snip-min-width (snip? . -> . number?))
|
(snip-min-width (snip? . -> . number?))
|
||||||
(snip-min-height (snip? . -> . number?))
|
(snip-min-height (snip? . -> . number?))
|
||||||
(snip-parent (snip? . -> . editor?))
|
(snip-parent (snip? . -> . editor?))
|
||||||
|
@ -30,7 +32,6 @@
|
||||||
(stretchable-height? (snip? . -> . boolean?)))
|
(stretchable-height? (snip? . -> . boolean?)))
|
||||||
|
|
||||||
;; the width of a snip in the parent pasteboard
|
;; the width of a snip in the parent pasteboard
|
||||||
;; snip-width (snip? . -> . number?)
|
|
||||||
(define (snip-width snip)
|
(define (snip-width snip)
|
||||||
(let ([left (box 0)]
|
(let ([left (box 0)]
|
||||||
[right (box 0)]
|
[right (box 0)]
|
||||||
|
@ -40,7 +41,6 @@
|
||||||
(- (unbox right) (unbox left))))
|
(- (unbox right) (unbox left))))
|
||||||
|
|
||||||
;; the height of a snip in the parent pasteboard
|
;; the height of a snip in the parent pasteboard
|
||||||
;; snip-height (snip? . -> . number?)
|
|
||||||
(define (snip-height snip)
|
(define (snip-height snip)
|
||||||
(let ([top (box 0)]
|
(let ([top (box 0)]
|
||||||
[bottom (box 0)]
|
[bottom (box 0)]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user