Do you any materials to better understand how to r...
# compose-desktop
o
Do you any materials to better understand how to reach "low level" related to """""view bounds"""""" in the Compose world? I need 2 distinct things • where is the "view" on the Window (I'd like to anchor a dialog to a view) • what is the size of my "view" (≃`View.getMeasuredWidth()` or the value we get from
View.onSizeChanged()
), what is the DPI of the screen where my "view" is (≃`Context.resources.displayMetrics`) → I'm aware there is no such "view" in the 100% Compose world, what I'd like is the have such thing within the layout for the result of a given composable Slack Conversation
I'm crossposting this is since it might depends on how the dialog is managed, on Android world or Desktop world for the anchor part of the question.
t
There is a modifier: and you get LayoutCoordinates which you can use to calculate position in window
Copy code
.onGloballyPositioned {
                    val rootOffset = it.localToWindow(Offset.Zero)
                    imagePosition = Rect(rootOffset, it.size.toSize())
                }
👍 1
o
Fantastic, works like a charm!