Skip to content
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
23 changes: 16 additions & 7 deletions src/Bloc-Layout/BlFrameLayout.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -186,32 +186,41 @@ BlFrameLayout >> measureParentNode: aParentNode [
{ #category : #private }
BlFrameLayout >> measurementSpecFor: aChildNode parentExtent: aParentExtent [

| aParentWidth aParentHeight childWidthMeasureSpec childHeightMeasureSpec |
| aParentWidth aParentHeight childWidthMeasureSpec childHeightMeasureSpec aParentPadding aParentWidthSpec aParentHeightSpec |
aParentWidth := aParentExtent x.
aParentHeight := aParentExtent y.
aParentPadding := aChildNode parent
ifNil: [ BlInsets empty ]
ifNotNil: [ :p | p padding ].
aParentWidthSpec := aChildNode parent
ifNil: [ BlMeasurementSpec unspecified ]
ifNotNil: [ :p | p widthSpec ].
aParentHeightSpec := aChildNode parent
ifNil: [ BlMeasurementSpec unspecified ]
ifNotNil: [ :p | p heightSpec ].

aChildNode isHorizontalMatchParent
ifTrue: [
| weight width |
weight := (aChildNode constraints frame horizontal weight max: 0.0).
width := ((aParentWidth - aChildNode parent padding width - aChildNode margin width) * weight) max: aChildNode constraints minWidth.
width := ((aParentWidth - aParentPadding width - aChildNode margin width) * weight) max: aChildNode constraints minWidth.
childWidthMeasureSpec := BlMeasurementSpec exact: width ]
ifFalse: [
childWidthMeasureSpec := self
measurementSpecFor: aChildNode parent widthSpec
usedSize: aChildNode parent padding width + aChildNode padding width
measurementSpecFor: aParentWidthSpec
usedSize: aParentPadding width + aChildNode padding width
resizer: aChildNode horizontalResizer ].

aChildNode isVerticalMatchParent
ifTrue: [
| weight height |
weight := (aChildNode constraints frame vertical weight max: 0.0).
height := ((aParentHeight - aChildNode parent padding height - aChildNode margin height) * weight) max: aChildNode constraints minHeight.
height := ((aParentHeight - aParentPadding height - aChildNode margin height) * weight) max: aChildNode constraints minHeight.
childHeightMeasureSpec := BlMeasurementSpec exact: height ]
ifFalse: [
childHeightMeasureSpec := self
measurementSpecFor: aChildNode parent heightSpec
usedSize: aChildNode parent padding height + aChildNode margin height
measurementSpecFor: aParentHeightSpec
usedSize: aParentPadding height + aChildNode margin height
resizer: aChildNode verticalResizer ].

^ childWidthMeasureSpec @ childHeightMeasureSpec
Expand Down
9 changes: 6 additions & 3 deletions src/Bloc-Layout/BlRelativeLayout.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,19 @@ BlRelativeLayout >> measureRelativePositions: aParentLayoutNode [
{ #category : #measure }
BlRelativeLayout >> measurementSpecFor: aChildNode parentSpec: aParentSpec [

| childWidthMeasureSpec childHeightMeasureSpec |
| childWidthMeasureSpec childHeightMeasureSpec aParentPadding |
aParentPadding := aChildNode parent
ifNil: [ BlInsets empty ]
ifNotNil: [ :p | p padding ].

childWidthMeasureSpec := self
measurementSpecFor: aParentSpec widthSpec
usedSize: aChildNode parent padding width + aChildNode padding width
usedSize: aParentPadding width + aChildNode padding width
resizer: aChildNode horizontalResizer.

childHeightMeasureSpec := self
measurementSpecFor: aParentSpec heightSpec
usedSize: aChildNode parent padding height + aChildNode margin height
usedSize: aParentPadding height + aChildNode margin height
resizer: aChildNode verticalResizer.

^ childWidthMeasureSpec @ childHeightMeasureSpec
Expand Down
9 changes: 7 additions & 2 deletions src/Bloc-Text-Elements/BlTextElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,15 @@ BlTextElement >> onPostMeasure: anExtentMeasurementSpec [
"If I am executed it means that measurement specification changed.
We have to recreate a text layout with new parameters"

| measuredWidth measuredHeight maxWidth maxHeight widthSpec heightSpec padding paragraphBounds |
| measuredWidth measuredHeight maxWidth maxHeight widthSpec heightSpec padding paragraphBounds localParagraph |
localParagraph := paragraph.
localParagraph ifNil: [
self measuredExtent: 0@0.
^ self ].

widthSpec := anExtentMeasurementSpec widthSpec.
heightSpec := anExtentMeasurementSpec heightSpec.
paragraphBounds := measurement boundsOf: paragraph.
paragraphBounds := measurement boundsOf: localParagraph.

"If measurement spec is exact I must ignore size measured by textLayout"
widthSpec isExact
Expand Down
11 changes: 8 additions & 3 deletions src/Bloc/BlLayout.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,17 @@ BlLayout >> measureChildWithMargins: anElement parentSpec: parentSpec [
BlLayout >> measureChildWithMargins: anElement parentSpec: parentSpec widthUsed: widthUsed heightUsed: heightUsed [
"Measure anElement based on provided parent's extent measurement specification and used width and height
taking into account element's margin and parent's padding."


| aParentPadding |
aParentPadding := anElement parent
ifNil: [ BlInsets empty ]
ifNotNil: [ :aParent | aParent padding ].

self
measureChild: anElement
parentSpec: parentSpec
widthUsed: anElement parent padding width + anElement margin width + widthUsed
heightUsed: anElement parent padding height + anElement margin height + heightUsed
widthUsed: aParentPadding width + anElement margin width + widthUsed
heightUsed: aParentPadding height + anElement margin height + heightUsed
]

{ #category : #'private - measurement' }
Expand Down
1 change: 1 addition & 0 deletions src/BlocHost-Morphic/BlMorphicWindow.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ BlMorphicWindow >> spaceExtent [

| aDelta |
"we compute decorations extent first"
spaceHostMorph extent isZero ifTrue: [ ^ self extent ].
aDelta := self fullBounds extent - spaceHostMorph extent.
^ self extent - aDelta
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ BlOSWindowSDL2HostSpace >> position [
"Return window's position in screen coordinates"
<return: #Point>

^ window position
^ window ifNotNil: [ :w | w position ] ifNil: [ 0@0 ]
]

{ #category : #'host space - geometry' }
Expand Down
2 changes: 2 additions & 0 deletions src/BlocHost-OSWindow/BlOSWindowEventHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ BlOSWindowEventHandler >> enqueueSpaceResized: aBlSpaceResizedEvent extent: aPoi

{ #category : #events }
BlOSWindowEventHandler >> handleEvent: anEvent [

window isValid ifFalse: [ ^ self ].
anEvent accept: self
]

Expand Down
Loading