Skip to content

Commit

Permalink
Reformat doUpdateLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
tinchodias committed Oct 5, 2023
1 parent e02aee2 commit b6b0bcc
Showing 1 changed file with 39 additions and 28 deletions.
67 changes: 39 additions & 28 deletions src/Bloc/BlSpace.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -844,43 +844,54 @@ BlSpace >> doUpdateFocus [

{ #category : #'change - layout' }
BlSpace >> doUpdateLayout [

| elementsToLayout aBlElementBoundsUpdater |

self elementsNeedingLayout copy do: [ :eachElement |
eachElement privatePreviousMeasurementSpec
ifNil: [
self elementsNeedingLayout remove: eachElement.
eachElement requestLayout ] ].

elementsToLayout := self elementsNeedingLayout reject: [ :eachElement |
| shouldIgnore |

shouldIgnore := false.

self elementsNeedingLayout do: [ :eachPotentialParent |
(eachElement hasParent: eachPotentialParent)
ifTrue: [
eachElement
allParentsTo: eachPotentialParent
do: [ :eachParent | eachParent privateRequestingLayout: true ].
shouldIgnore := true ] ].

shouldIgnore ].

"we should clear the elements needing layout before we compute layout to support multiple layout passes"
eachElement privatePreviousMeasurementSpec ifNil: [
self elementsNeedingLayout remove: eachElement.
eachElement requestLayout ] ].

elementsToLayout :=
self elementsNeedingLayout reject: [ :eachElement |
| shouldIgnore |
shouldIgnore := false.

self elementsNeedingLayout do: [ :eachPotentialParent |
(eachElement hasParent: eachPotentialParent)
ifTrue: [
eachElement
allParentsTo: eachPotentialParent
do: [ :eachParent |
eachParent privateRequestingLayout: true ].
shouldIgnore := true ] ].

shouldIgnore ].

"we should clear the elements needing layout before we compute layout
to support multiple layout passes"
self elementsNeedingLayout removeAll.

elementsToLayout := elementsToLayout
collect: [ :eachElement | eachElement -> eachElement compositionDepth ] as: Array.
elementsToLayout := (elementsToLayout sort: [ :a :b | a value > b value ]) collect: [ :each | each key ].
elementsToLayout :=
elementsToLayout
collect: [ :eachElement | eachElement -> eachElement compositionDepth ]
as: Array.
elementsToLayout :=
(elementsToLayout
sort: [ :a :b | a value > b value ])
collect: [ :each | each key ].

aBlElementBoundsUpdater := BlElementBoundsUpdater new.

elementsToLayout do: [ :eachElement |
self doUpdateLayoutBoundary: eachElement context: aBlElementBoundsUpdater ].
self
doUpdateLayoutBoundary: eachElement
context: aBlElementBoundsUpdater ].

self root isLayoutRequested
ifTrue: [ self doUpdateLayout: self root context: aBlElementBoundsUpdater ].
self root isLayoutRequested ifTrue: [
self
doUpdateLayout: self root
context: aBlElementBoundsUpdater ].

aBlElementBoundsUpdater commitChanges
]
Expand Down

0 comments on commit b6b0bcc

Please sign in to comment.