Skip to content

Commit

Permalink
Fix up SquooshLayout and TreeBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyfroehlich committed Dec 26, 2024
1 parent d1a9016 commit bdf479b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,14 @@ private fun updateLayoutTree(

layoutNodes.add(
layoutNode {
layoutId
parentLayoutId
-1 // not childIdx!
resolvedNode.style.layoutStyle
resolvedNode.view.name
useMeasureFunc
null
null
this.layoutId = layoutId
this.parentLayoutId = parentLayoutId
this.childIndex = -1 // not childIdx!
this.style = resolvedNode.style.layoutStyle
this.name = resolvedNode.view.name
this.useMeasureFunc = useMeasureFunc
clearFixedWidth()
clearFixedHeight()
}
)
layoutCache[layoutId] = layoutCacheKey
Expand Down Expand Up @@ -296,8 +296,8 @@ internal fun layoutTree(
val layoutParentChildren = arrayListOf<LayoutParentChildren>()
updateLayoutTree(manager, root, layoutCache, layoutNodes, layoutParentChildren)
val layoutNodeList = layoutNodeList {
layoutNodes
layoutParentChildren
this.layoutNodes.addAll(layoutNodes)
parentChildren.addAll(layoutParentChildren)
}

// Now we can give the new layoutNodeList to the Rust JNI layout implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import com.android.designcompose.definition.view.View
import com.android.designcompose.definition.view.ViewDataKt.container
import com.android.designcompose.definition.view.ViewStyle
import com.android.designcompose.definition.view.containerOrNull
import com.android.designcompose.definition.view.copy
import com.android.designcompose.definition.view.frameExtrasOrNull
import com.android.designcompose.definition.view.overridesOrNull
import com.android.designcompose.definition.view.styleOrNull
Expand Down Expand Up @@ -566,24 +567,26 @@ private fun generateOverlayNode(
}
}

val nodeStyleBuilder = node.style.nodeStyle.toBuilder()
nodeStyleBuilder.overflow = Overflow.OVERFLOW_VISIBLE
nodeStyleBuilder.backgroundsList.clear()

overlay.overlayBackgroundOrNull?.colorOrNull?.let {
val bgColor =
com.android.designcompose.definition.element.color {
r = (it.r * 255.0).toInt()
g = (it.g * 255.0).toInt()
b = (it.b * 255.0).toInt()
a = (it.a * 255.0).toInt()
}
nodeStyleBuilder.backgroundsList.add(background { solid = colorOrVar { color = bgColor } })
val newNodeStyle = node.style.nodeStyle.copy {
overflow = Overflow.OVERFLOW_VISIBLE
this.backgrounds.clear()

overlay.overlayBackgroundOrNull?.colorOrNull?.let {
val bgColor =
com.android.designcompose.definition.element.color {
r = (it.r * 255.0).toInt()
g = (it.g * 255.0).toInt()
b = (it.b * 255.0).toInt()
a = (it.a * 255.0).toInt()
}
this.backgrounds.add(background { solid = colorOrVar { color = bgColor } })
}
}


val overlayStyle = viewStyle {
layoutStyle = layoutStyleBuilder.build()
nodeStyle = nodeStyleBuilder.build()
nodeStyle = newNodeStyle
}

// Now synthesize a view.
Expand Down

0 comments on commit bdf479b

Please sign in to comment.