Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlElement: Deprecate outsets by margin & insets by padding #655

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Bloc-Layout/BlGridLayoutImpl.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ BlGridLayoutImpl >> layout: anElement in: aRectangle context: aBlElementBoundsUp
targetWidth := aRectangle width.
targetHeight := aRectangle height.

paddingLeft := anElement insets left.
paddingRight := anElement insets right.
paddingTop := anElement insets top.
paddingBottom := anElement insets bottom.
paddingLeft := anElement padding left.
paddingRight := anElement padding right.
paddingTop := anElement padding top.
paddingBottom := anElement padding bottom.

horizontalAxis applyLayoutWithin: targetWidth - paddingLeft - paddingRight.
verticalAxis applyLayoutWithin: targetHeight - paddingTop - paddingBottom.
Expand Down Expand Up @@ -274,8 +274,8 @@ BlGridLayoutImpl >> measure: anElement with: anExtentSpec [
self checkConsistency: anElement.
self invalidateValues.

hPadding := anElement insets width.
vPadding := anElement insets height.
hPadding := anElement padding width.
vPadding := anElement padding height.

widthSpecSansPadding := self adjust: widthSpec by: hPadding negated.
heightSpecSansPadding := self adjust: heightSpec by: vPadding negated.
Expand Down
26 changes: 15 additions & 11 deletions src/Bloc-Layout/BlLinearLayoutHorizontalOrientation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ BlLinearLayoutHorizontalOrientation >> layout: anElement in: aRectangle context:
"Layout subnodes vertically in column one by one
based on previousely measured extent"

top := anElement insets top.
left := anElement insets left.
top := anElement padding top.
left := anElement padding left.
right := left.
bottom := top.

Expand All @@ -59,8 +59,8 @@ BlLinearLayoutHorizontalOrientation >> layout: anElement in: aRectangle context:
self layout direction
with: theLayeredChildren
do: [ :child |
right := right + child measuredWidth + (child outsets width max: 0.0).
bottom := bottom max: child measuredHeight + (child outsets height max: 0.0) ].
right := right + child measuredWidth + (child margin width max: 0.0).
bottom := bottom max: child measuredHeight + (child margin height max: 0.0) ].

majorBounds := (left@top corner: right@bottom).
elementInnerBounds := anElement padding inset: anElement boundsInLocal.
Expand All @@ -81,8 +81,8 @@ BlLinearLayoutHorizontalOrientation >> layout: anElement in: aRectangle context:
into: [ :origin :child |
| childBounds childMarginBounds childConstraints interspacing |
childConstraints := child constraints linear.
childBounds := origin + (child outsets topLeft max: 0.0@0.0) extent: child measuredExtent.
childMarginBounds := origin extent: child measuredExtent + (child outsets extent max: 0.0@0.0).
childBounds := origin + (child margin topLeft max: 0.0@0.0) extent: child measuredExtent.
childMarginBounds := origin extent: child measuredExtent + (child margin extent max: 0.0@0.0).

self layout verticalAlignment ifNotNull: [
| translation allowedBounds |
Expand All @@ -108,7 +108,7 @@ BlLinearLayoutHorizontalOrientation >> layout: anElement in: aRectangle context:
child applyLayoutIn: childBounds context: aBlElementBoundsUpdateContext.
"translating origin horizontally right for next subnode"
turn := turn + 1.
(origin x + child measuredWidth + (child outsets width max: 0.0) + self layout cellSpacing) @ origin y ]
(origin x + child measuredWidth + (child margin width max: 0.0) + self layout cellSpacing) @ origin y ]
]

{ #category : #orientation }
Expand All @@ -133,12 +133,14 @@ BlLinearLayoutHorizontalOrientation >> lengthSpec: anExtentSpec [

{ #category : #orientation }
BlLinearLayoutHorizontalOrientation >> marginBreadth: anElement [
^ anElement outsets height

^ anElement margin height
]

{ #category : #orientation }
BlLinearLayoutHorizontalOrientation >> marginLength: anElement [
^ anElement outsets width

^ anElement margin width
]

{ #category : #orientation }
Expand Down Expand Up @@ -172,10 +174,12 @@ BlLinearLayoutHorizontalOrientation >> minimalLength: anElement [

{ #category : #orientation }
BlLinearLayoutHorizontalOrientation >> paddingBreadth: anElement [
^ anElement insets height

^ anElement padding height
]

{ #category : #orientation }
BlLinearLayoutHorizontalOrientation >> paddingLength: anElement [
^ anElement insets width

^ anElement padding width
]
26 changes: 15 additions & 11 deletions src/Bloc-Layout/BlLinearLayoutVerticalOrientation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ BlLinearLayoutVerticalOrientation >> layout: anElement in: aRectangle context: a
"Layout subnodes vertically in column one by one
based on previously measured extent"

top := anElement insets top.
left := anElement insets left.
top := anElement padding top.
left := anElement padding left.
right := left.
bottom := top.

Expand All @@ -59,8 +59,8 @@ BlLinearLayoutVerticalOrientation >> layout: anElement in: aRectangle context: a
self layout direction
with: theLayeredChildren
do: [ :child |
right := right max: child measuredWidth + (child outsets width max: 0.0).
bottom := bottom + child measuredHeight + (child outsets height max: 0.0) ].
right := right max: child measuredWidth + (child margin width max: 0.0).
bottom := bottom + child measuredHeight + (child margin height max: 0.0) ].

majorBounds := (left@top corner: right@bottom).
elementInnerBounds := anElement padding inset: anElement boundsInLocal.
Expand All @@ -81,8 +81,8 @@ BlLinearLayoutVerticalOrientation >> layout: anElement in: aRectangle context: a
into: [ :origin :child |
| childBounds childMarginBounds childConstraints interspacing |
childConstraints := child constraints linear.
childBounds := origin + (child outsets topLeft max: 0.0@0.0) extent: child measuredExtent.
childMarginBounds := origin extent: child measuredExtent + (child outsets extent max: 0.0@0.0).
childBounds := origin + (child margin topLeft max: 0.0@0.0) extent: child measuredExtent.
childMarginBounds := origin extent: child measuredExtent + (child margin extent max: 0.0@0.0).

self layout horizontalAlignment ifNotNull: [
| translation allowedBounds |
Expand All @@ -109,7 +109,7 @@ BlLinearLayoutVerticalOrientation >> layout: anElement in: aRectangle context: a
child applyLayoutIn: childBounds context: aBlElementBoundsUpdateContext.
"translating origin vertically down for next subnode"
turn := turn + 1.
origin x @(origin y + child measuredHeight + self layout cellSpacing + (child outsets height max: 0.0)) ]
origin x @(origin y + child measuredHeight + self layout cellSpacing + (child margin height max: 0.0)) ]
]

{ #category : #orientation }
Expand All @@ -134,12 +134,14 @@ BlLinearLayoutVerticalOrientation >> lengthSpec: anExtentSpec [

{ #category : #orientation }
BlLinearLayoutVerticalOrientation >> marginBreadth: anElement [
^ anElement outsets width

^ anElement margin width
]

{ #category : #orientation }
BlLinearLayoutVerticalOrientation >> marginLength: anElement [
^ anElement outsets height

^ anElement margin height
]

{ #category : #orientation }
Expand Down Expand Up @@ -173,10 +175,12 @@ BlLinearLayoutVerticalOrientation >> minimalLength: anElement [

{ #category : #orientation }
BlLinearLayoutVerticalOrientation >> paddingBreadth: anElement [
^ anElement insets width

^ anElement padding width
]

{ #category : #orientation }
BlLinearLayoutVerticalOrientation >> paddingLength: anElement [
^ anElement insets height

^ anElement padding height
]
10 changes: 10 additions & 0 deletions src/Bloc/BlElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1987,6 +1987,11 @@ BlElement >> initializeEventDispatcher [

{ #category : #'geometry bounds' }
BlElement >> insets [

self
deprecated: 'Use #padding instead of current one'
transformWith: '`@receiver insets' -> '`@receiver padding'.

^ self padding
]

Expand Down Expand Up @@ -2994,6 +2999,11 @@ BlElement >> openInSpace [

{ #category : #'geometry bounds' }
BlElement >> outsets [

self
deprecated: 'Use #margin instead of current one'
transformWith: '`@receiver outsets' -> '`@receiver margin'.

^ self margin
]

Expand Down
4 changes: 2 additions & 2 deletions src/Bloc/BlLayout.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ BlLayout >> measureChildWithMargins: anElement parentSpec: parentSpec widthUsed:
self
measureChild: anElement
parentSpec: parentSpec
widthUsed: anElement parent insets width + anElement outsets width + widthUsed
heightUsed: anElement parent insets height + anElement outsets height + heightUsed
widthUsed: anElement parent padding width + anElement margin width + widthUsed
heightUsed: anElement parent padding height + anElement margin height + heightUsed
]

{ #category : #'private - measurement' }
Expand Down
Loading