-
Notifications
You must be signed in to change notification settings - Fork 154
New Window and DialogWindow APIs #2938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 74 commits
45775b4
99ed5b1
0cfc7b3
bbf2923
1f592f9
c24aa00
739bb7a
bacd18b
4dbdb6e
73164bf
0be5208
9b333cc
1f99636
054b597
961ec7a
035af0f
c3e5e73
b8c3c00
74145f5
dd8d912
f362649
fac88db
6fe808c
a0babea
7c22eaf
b573a33
1e526a9
2eea0a9
b2d7dbd
beb808b
f4b3c67
63428e6
acf1360
2f0b5db
4a8e882
ca82deb
a0022a0
dcba2f2
e00fcaf
f2e86dd
60f1c2f
7be9fdc
580021b
578ad64
c937810
7eb63f7
18c0843
8fab237
9a5475d
79ab162
4547ce3
a91887e
56feeb9
f142c94
795fa9c
55412c6
d12833e
979af57
651c35c
d4ece2a
e538784
22491bb
5ae2d40
7b2bda6
86ee8bf
f15f296
412214c
2039c9d
c1034aa
5acbe24
fc33341
7563ed2
91a3569
5ef92d6
c0b6f48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's just data structure (not window-insets or so), probably it should be part of
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,86 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * Copyright 2026 The Android Open Source Project | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * you may not use this file except in compliance with the License. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * You may obtain a copy of the License at | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * limitations under the License. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| package androidx.compose.ui.unit | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| import androidx.compose.runtime.Immutable | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import androidx.compose.ui.ExperimentalComposeUiApi | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * Represents a set of insets in [Dp] units. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| @ExperimentalComposeUiApi | ||||||||||||||||||||||||||||||||||||||||||||||||||
| @Immutable | ||||||||||||||||||||||||||||||||||||||||||||||||||
| class DpInsets( | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We must not introduce such API one more time as desktop only. Please reuse the existing one
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The one in ios is internal; this one is public (but experimental). We could change ios to use this one, but I wouldn't say it's a "must". There are plenty of places where we have internal copies of code because we don't want to create a dependency. Up to the ios team... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's public and in skikoMain Lines 112 to 116 in 78845ae
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Line 1104 in 78845ae
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Personally, I’m fine with having If this new API is being used for window/platform insets, then I think we should use the existing If we decide to introduce a public dp-based insets API, then I think it should live in common, at the same level as something like As for
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
These are types for a concrete purpose, not generic geometry types like, for example, So I see no reason to forcibly use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we have an issue with I am also fine with keeping the current Another option is to rename them to
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see anything wrong with |
||||||||||||||||||||||||||||||||||||||||||||||||||
| val top: Dp, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| val left: Dp, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| val bottom: Dp, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| val right: Dp | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * Returns the sum of the insets. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| operator fun plus(other: DpInsets) = DpInsets( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| top = top + other.top, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| left = left + other.left, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| bottom = bottom + other.bottom, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| right = right + other.right | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| override fun equals(other: Any?): Boolean { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (this === other) return true | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (other !is DpInsets) return false | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if (top != other.top) return false | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (left != other.left) return false | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (bottom != other.bottom) return false | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (right != other.right) return false | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| return true | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| override fun hashCode(): Int { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| var result = top.hashCode() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| result = 31 * result + left.hashCode() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| result = 31 * result + bottom.hashCode() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| result = 31 * result + right.hashCode() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return result | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * Returns the rectangle remaining after applying the given insets. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| @ExperimentalComposeUiApi | ||||||||||||||||||||||||||||||||||||||||||||||||||
| operator fun DpRect.minus(insets: DpInsets): DpRect = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| DpRect( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| top = top + insets.top, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| left = left + insets.left, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| bottom = bottom - insets.bottom, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| right = right - insets.right | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * Returns the size after adding the given insets. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| @ExperimentalComposeUiApi | ||||||||||||||||||||||||||||||||||||||||||||||||||
| operator fun DpSize.plus(insets: DpInsets): DpSize = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| DpSize( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| width = width + insets.left + insets.right, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| height = height + insets.top + insets.bottom | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DpInsets.skiko.kt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done