Skip to content

Commit

Permalink
Set composition locals before popup window content
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-grouchnikov committed Nov 12, 2021
1 parent 3f22898 commit a9f9e3e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
Expand Up @@ -214,7 +214,7 @@ internal fun <E> AuroraComboBox(
)
)
val contentModelState = rememberUpdatedState(commandMenuContentModel)
val currentLocals by rememberUpdatedState(currentCompositionLocalContext)
val compositionLocalContext by rememberUpdatedState(currentCompositionLocalContext)

Box(
modifier = modifier
Expand All @@ -230,7 +230,7 @@ internal fun <E> AuroraComboBox(
skinColors = skinColors,
skinPainters = painters,
decorationAreaType = decorationAreaType,
locals = currentLocals,
compositionLocalContext = compositionLocalContext,
anchorBoundsInWindow = Rect(
offset = comboBoxTopLeftOffset.asOffset(density),
size = comboBoxSize.asSize(density)
Expand Down
Expand Up @@ -381,7 +381,7 @@ internal fun AuroraCommandButton(
}

val hasIcon = preLayoutInfo.showIcon
val currentLocals by rememberUpdatedState(currentCompositionLocalContext)
val compositionLocalContext by rememberUpdatedState(currentCompositionLocalContext)

Layout(
modifier = modifier.commandButtonLocator(buttonTopLeftOffset, buttonSize),
Expand Down Expand Up @@ -634,7 +634,7 @@ internal fun AuroraCommandButton(
skinColors = skinColors,
skinPainters = painters,
decorationAreaType = decorationAreaType,
locals = currentLocals,
compositionLocalContext = compositionLocalContext,
anchorBoundsInWindow = Rect(
offset = buttonTopLeftOffset.asOffset(density),
size = buttonSize.asSize(density)
Expand Down
Expand Up @@ -54,7 +54,7 @@ fun Modifier.auroraContextMenu(
val painters = AuroraSkin.painters
val decorationAreaType = AuroraSkin.decorationAreaType
val window = LocalWindow.current
val currentLocals by rememberUpdatedState(currentCompositionLocalContext)
val compositionLocalContext by rememberUpdatedState(currentCompositionLocalContext)

val resolvedTextStyle = remember { resolveDefaults(mergedTextStyle, layoutDirection) }

Expand All @@ -72,7 +72,7 @@ fun Modifier.auroraContextMenu(
skinColors = skinColors,
skinPainters = painters,
decorationAreaType = decorationAreaType,
locals = currentLocals,
compositionLocalContext = compositionLocalContext,
anchorBoundsInWindow = Rect(
offset = Offset(
x = lastMouseEvent.x.toFloat(),
Expand Down
Expand Up @@ -70,7 +70,7 @@ internal fun displayPopupContent(
skinColors: AuroraSkinColors,
skinPainters: AuroraPainters,
decorationAreaType: DecorationAreaType,
locals: CompositionLocalContext,
compositionLocalContext: CompositionLocalContext,
anchorBoundsInWindow: Rect,
contentModel: State<CommandMenuContentModel?>,
presentationModel: CommandPopupMenuPresentationModel,
Expand Down Expand Up @@ -367,18 +367,17 @@ internal fun displayPopupContent(
}
}

popupContentWindow.compositionLocalContext = compositionLocalContext
popupContentWindow.setContent {
CompositionLocalProvider(locals) {
TopLevelPopupContent(
popupContentWindow = popupContentWindow,
menuContentModel = contentModel,
menuPresentationModel = presentationModel,
toDismissPopupsOnActivation = toDismissPopupsOnActivation,
toUseBackgroundStriping = toUseBackgroundStriping,
overlays = overlays,
contentLayoutInfo = contentLayoutInfo
)
}
TopLevelPopupContent(
popupContentWindow = popupContentWindow,
menuContentModel = contentModel,
menuPresentationModel = presentationModel,
toDismissPopupsOnActivation = toDismissPopupsOnActivation,
toUseBackgroundStriping = toUseBackgroundStriping,
overlays = overlays,
contentLayoutInfo = contentLayoutInfo
)
}

popupContentWindow.invalidate()
Expand Down

0 comments on commit a9f9e3e

Please sign in to comment.