Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.428.mcz ==================== Summary ==================== Name: Graphics-nice.428 Author: nice Time: 3 March 2020, 10:11:33.559746 pm UUID: b9310c73-f7b2-43d3-b457-16b9d8b0b0dc Ancestors: Graphics-nice.427 Really expunge ifNil: guards from LayoutFrame We can now do it, because we provided proper fixup for upgrading existing instances in previous commit/update map. Note: explicit the layout constraints that we want to respect when calculating #minWidthFrom: and #minHeightFrom: See how we can do it without having to revert to right or bottom fraction = 1. Those methods are unused in trunk image, but might be in additional packages, if you depend on it, please test it. =============== Diff against Graphics-nice.427 =============== Item was changed: ----- Method: LayoutFrame>>layout:in: (in category 'layout') ----- layout: oldBounds in: newBounds "Return the proportional rectangle insetting the given bounds" + | left right top bottom | + left := newBounds left + (newBounds width * leftFraction). + left := left + leftOffset. + right := newBounds right - (newBounds width * (1.0 - rightFraction)). + right := right + rightOffset. + top := newBounds top + (newBounds height * topFraction). + top := top + topOffset. + bottom := newBounds bottom - (newBounds height * (1.0 - bottomFraction)). + bottom := bottom + bottomOffset. - | left right top bottom | - leftFraction ifNotNil:[ - left := newBounds left + (newBounds width * leftFraction). - leftOffset ifNotNil:[left := left + leftOffset]]. - rightFraction ifNotNil:[ - right := newBounds right - (newBounds width * (1.0 - rightFraction)). - rightOffset ifNotNil:[right := right + rightOffset]]. - topFraction ifNotNil:[ - top := newBounds top + (newBounds height * topFraction). - topOffset ifNotNil:[top := top + topOffset]]. - bottomFraction ifNotNil:[ - bottom := newBounds bottom - (newBounds height * (1.0 - bottomFraction)). - bottomOffset ifNotNil:[bottom := bottom + bottomOffset]]. - left ifNil:[ right - ifNil:[left := oldBounds left. right := oldBounds right] - ifNotNil:[left := right - oldBounds width]]. - right ifNil:[right := left + oldBounds width]. - top ifNil:[ bottom - ifNil:[top := oldBounds top. bottom := oldBounds bottom] - ifNotNil:[top := bottom - oldBounds height]]. - bottom ifNil:[bottom := top + oldBounds height]. ^(left rounded @ top rounded) corner: (right rounded @ bottom rounded)! Item was changed: ----- Method: LayoutFrame>>minHeightFrom: (in category 'layout') ----- minHeightFrom: minHeight + "Return the minimal height the given bounds can be represented in + we have: + top = (height * topFraction + topOffset) + bottom = (height * bottomFraction + bottomOffset) + we want to fullfill those constraints if possible: + 0 <= top <= height + 0 <= bottom <= heigth + bottom - top >= minHeight" + | height | + height := bottomFraction = topFraction - "Return the minimal extent the given bounds can be represented in" - | height top bottom | - top := topFraction ifNil: [0.0]. - bottom := bottomFraction ifNil: [1.0]. - height := bottom = top ifTrue: [0] + ifFalse: [minHeight + topOffset - bottomOffset / (bottomFraction - topFraction) max: 0]. + topFraction < 1 ifTrue: [height := height max: topOffset / (1 - topFraction)]. + bottomFraction < 1 ifTrue: [height := height max: bottomOffset / (1 - bottomFraction)]. + topFraction > 0 ifTrue: [height := height max: topOffset negated / topFraction]. + bottomFraction > 0 ifTrue: [height := height max: bottomOffset negated / bottomFraction]. - ifFalse: [minHeight / (bottom - top)]. - topOffset ifNotNil:[height := height + topOffset]. - bottomOffset ifNotNil:[height := height + bottomOffset]. ^ height truncated! Item was changed: ----- Method: LayoutFrame>>minWidthFrom: (in category 'layout') ----- minWidthFrom: minWidth + "Return the minimal width the given bounds can be represented in + we have: + left = (width * leftFraction + leftOffset) + right = (width * rightFraction + rightOffset) + we want to fullfill those constraints if possible: + 0 <= left <= width + 0 <= right <= heigth + right - left >= minwidth" + | width | + width := rightFraction = leftFraction - "Return the minimal extent the given bounds can be represented in" - | width left right | - left := leftFraction ifNil: [0.0]. - right := rightFraction ifNil: [1.0]. - width := left = right ifTrue: [0] + ifFalse: [minWidth + leftOffset - rightOffset / (rightFraction - leftFraction) max: 0]. + leftFraction < 1 ifTrue: [width := width max: leftOffset / (1 - leftFraction)]. + rightFraction < 1 ifTrue: [width := width max: rightOffset / (1 - rightFraction)]. + leftFraction > 0 ifTrue: [width := width max: leftOffset negated / leftFraction]. + rightFraction > 0 ifTrue: [width := width max: rightOffset negated / rightFraction]. + ^ width truncated! - ifFalse: [minWidth / (right - left)]. - leftOffset ifNotNil:[width := width + leftOffset]. - rightOffset ifNotNil:[width := width + rightOffset]. - ^width truncated! Item was changed: ----- Method: LayoutFrame>>printOn: (in category 'printing') ----- printOn: aStream super printOn: aStream. aStream nextPutAll: '( '. { {'l'. self leftFraction. self leftOffset}. {'t'. self topFraction. self topOffset}. {'r'. self rightFraction. self rightOffset}. {'b'. self bottomFraction. self bottomOffset} } do: [:spec | aStream nextPutAll: spec first; space. + spec second printOn: aStream maxDecimalPlaces: 2. - (spec second ifNil: [0]) printOn: aStream maxDecimalPlaces: 2. + aStream nextPutAll: (spec third >= 0 ifTrue: ['+'] ifFalse: ['-']). + spec third abs printOn: aStream maxDecimalPlaces: 0] - aStream nextPutAll: ((spec third ifNil: [0]) >= 0 ifTrue: ['+'] ifFalse: ['-']). - (spec third ifNil: [0]) abs printOn: aStream maxDecimalPlaces: 0] separatedBy: [aStream space]. aStream nextPutAll: ' )'.! |
Free forum by Nabble | Edit this page |