Re: [squeak-dev] The Trunk: Morphic-ar.195.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] The Trunk: Morphic-ar.195.mcz

Hans-Martin Mosner
[hidden email] schrieb:
> Andreas Raab uploaded a new version of Morphic to project The Trunk:
> http://source.squeak.org/trunk/Morphic-ar.195.mcz
>  
The method LayoutFrame>>minExtentFrom: in that version raises a division
by zero exception if leftFraction=rightFraction or
topFraction=bottomFraction.
The following version avoids this.

Cheers,
Hans-Martin

minExtentFrom: minExtent
    "Return the minimal extent the given bounds can be represented in"
    | width height left right top bottom |
    left := leftFraction ifNil: [0.0].
    right := rightFraction ifNil: [1.0].
    width := left = right
        ifTrue: [0]
        ifFalse: [minExtent x / (right - left)].
    top := topFraction ifNil: [0.0].
    bottom := bottomFraction ifNil: [1.0].
    height := top = bottom
        ifTrue: [0]
        ifFalse: [minExtent y / (bottom - top)].
    leftOffset ifNotNil:[width := width + leftOffset].
    rightOffset ifNotNil:[width := width + rightOffset].
    topOffset ifNotNil:[height := height + topOffset].
    bottomOffset ifNotNil:[height := height + bottomOffset].
    ^width truncated @ height truncated