<body><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
What about "0.0" instead of "0" for fractions to indicate the expected value?<div><br></div><div>Best,</div><div>Marcel</div><div class="mb_sig"></div><blockquote class="history_container" type="cite" style="border-left-style:solid;border-width:1px; margin-top:20px; margin-left:0px;padding-left:10px;">
<p style="color: #AAAAAA; margin-top: 10px;">Am 17.02.2020 16:45:50 schrieb commits@source.squeak.org <commits@source.squeak.org>:</p><div style="font-family:Arial,Helvetica,sans-serif">Nicolas Cellier uploaded a new version of Graphics to project The Inbox:<br>http://source.squeak.org/inbox/Graphics-nice.425.mcz<br><br>==================== Summary ====================<br><br>Name: Graphics-nice.425<br>Author: nice<br>Time: 17 February 2020, 4:44:09.459532 pm<br>UUID: 39f72c43-38db-9344-857e-1a109cbedfa2<br>Ancestors: Graphics-pre.424<br><br>Expunge the nil protection out of the LayoutFrame.<br><br>Those additional states (to be or not to be nil...) are gratuitous complexifications. YAGNI.<br>Let's initialize all inst var to zero instead.<br>This will provide a reasonable default (the least surprising one).<br><br>leftOffset = rightOffset = 0 ==> pure proportional layout (no nil offset required).<br><br>leftFraction = rightFraction ==> pure absolute layout (no nil fraction required)<br><br>all zero ==> empty layout.<br><br>Every other combination is possible.<br><br>=============== Diff against Graphics-pre.424 ===============<br><br>Item was added:<br>+ ----- Method: LayoutFrame>>fixup (in category 'initialize-release') -----<br>+ fixup<br>+ "Set-up default value for un-initialized layout frames"<br>+ <br>+ "LayoutFrame allInstancesDo: [:e | e fixup]."<br>+ <br>+ leftFraction ifNil: [leftFraction := 0].<br>+ leftOffset ifNil: [leftOffset := 0].<br>+ topFraction ifNil: [topFraction := 0].<br>+ topOffset ifNil: [topOffset := 0].<br>+ rightFraction ifNil: [rightFraction := 0].<br>+ rightOffset ifNil: [rightOffset := 0].<br>+ bottomFraction ifNil: [bottomFraction := 0].<br>+ bottomOffset ifNil: [bottomOffset := 0].!<br><br>Item was added:<br>+ ----- Method: LayoutFrame>>initialize (in category 'initialize-release') -----<br>+ initialize<br>+ "By defalut, let the frame be empty"<br>+ <br>+ leftFraction := leftOffset := topFraction := topOffset := rightFraction := rightOffset := bottomFraction := bottomOffset := 0!<br><br>Item was changed:<br> ----- Method: LayoutFrame>>layout:in: (in category 'layout') -----<br> layout: oldBounds in: newBounds<br> "Return the proportional rectangle insetting the given bounds"<br>+ | left right top bottom | <br>+ left := newBounds left + (newBounds width * leftFraction).<br>+ left := left + leftOffset.<br>+ right := newBounds right - (newBounds width * (1.0 - rightFraction)).<br>+ right := right + rightOffset.<br>+ top := newBounds top + (newBounds height * topFraction).<br>+ top := top + topOffset.<br>+ bottom := newBounds bottom - (newBounds height * (1.0 - bottomFraction)).<br>+ bottom := bottom + bottomOffset.<br>- | left right top bottom |<br>- leftFraction ifNotNil:[<br>- left := newBounds left + (newBounds width * leftFraction).<br>- leftOffset ifNotNil:[left := left + leftOffset]].<br>- rightFraction ifNotNil:[<br>- right := newBounds right - (newBounds width * (1.0 - rightFraction)).<br>- rightOffset ifNotNil:[right := right + rightOffset]].<br>- topFraction ifNotNil:[<br>- top := newBounds top + (newBounds height * topFraction).<br>- topOffset ifNotNil:[top := top + topOffset]].<br>- bottomFraction ifNotNil:[<br>- bottom := newBounds bottom - (newBounds height * (1.0 - bottomFraction)).<br>- bottomOffset ifNotNil:[bottom := bottom + bottomOffset]].<br>- left ifNil:[ right <br>- ifNil:[left := oldBounds left. right := oldBounds right]<br>- ifNotNil:[left := right - oldBounds width]].<br>- right ifNil:[right := left + oldBounds width].<br>- top ifNil:[ bottom <br>- ifNil:[top := oldBounds top. bottom := oldBounds bottom]<br>- ifNotNil:[top := bottom - oldBounds height]].<br>- bottom ifNil:[bottom := top + oldBounds height].<br> ^(left rounded @ top rounded) corner: (right rounded @ bottom rounded)!<br><br>Item was changed:<br> ----- Method: LayoutFrame>>minHeightFrom: (in category 'layout') -----<br> minHeightFrom: minHeight<br> "Return the minimal extent the given bounds can be represented in"<br>+ | height |<br>+ height := bottomFraction = topFraction<br>- | height top bottom |<br>- top := topFraction ifNil: [0.0].<br>- bottom := bottomFraction ifNil: [1.0].<br>- height := bottom = top<br> ifTrue: [0]<br>+ ifFalse: [minHeight / (bottomFraction - topFraction)].<br>+ height := height + topOffset + bottomOffset.<br>- ifFalse: [minHeight / (bottom - top)].<br>- topOffset ifNotNil:[height := height + topOffset].<br>- bottomOffset ifNotNil:[height := height + bottomOffset].<br> ^ height truncated!<br><br>Item was changed:<br> ----- Method: LayoutFrame>>minWidthFrom: (in category 'layout') -----<br> minWidthFrom: minWidth<br> "Return the minimal extent the given bounds can be represented in"<br>+ | width |<br>+ width := leftFraction = rightFraction<br>- | width left right |<br>- left := leftFraction ifNil: [0.0].<br>- right := rightFraction ifNil: [1.0].<br>- width := left = right<br> ifTrue: [0]<br>+ ifFalse: [minWidth / (rightFraction - leftFraction)].<br>+ width := width + leftOffset + rightOffset.<br>- ifFalse: [minWidth / (right - left)].<br>- leftOffset ifNotNil:[width := width + leftOffset].<br>- rightOffset ifNotNil:[width := width + rightOffset].<br> ^width truncated!<br><br>Item was changed:<br> ----- Method: LayoutFrame>>printOn: (in category 'printing') -----<br> printOn: aStream<br> <br> super printOn: aStream.<br> <br> aStream nextPutAll: '( '.<br> <br> { {'l'. self leftFraction. self leftOffset}. {'t'. self topFraction. self topOffset}. {'r'. self rightFraction. self rightOffset}. {'b'. self bottomFraction. self bottomOffset} } do: [:spec |<br> aStream nextPutAll: spec first; space.<br> <br> spec second printOn: aStream maxDecimalPlaces: 2.<br> <br>+ aStream nextPutAll: (spec third >= 0 ifTrue: ['+'] ifFalse: ['-']).<br>+ spec third abs printOn: aStream maxDecimalPlaces: 0]<br>- aStream nextPutAll: ((spec third ifNil: [0]) >= 0 ifTrue: ['+'] ifFalse: ['-']).<br>- (spec third ifNil: [0]) abs printOn: aStream maxDecimalPlaces: 0]<br> separatedBy: [aStream space].<br> <br> aStream nextPutAll: ' )'.!<br><br><br></div></blockquote>
</div></body>