mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
ui/app: introduce Insets for system decoration insets
Insets is like image.Rectangle, but with properly named fields and ui.Value instead of raw ints to make use with the layout package easier. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"gioui.org/ui"
|
||||
"gioui.org/ui/f32"
|
||||
"gioui.org/ui/key"
|
||||
"gioui.org/ui/pointer"
|
||||
@@ -36,7 +37,7 @@ type window struct {
|
||||
|
||||
dpi int
|
||||
fontScale float32
|
||||
insets image.Rectangle
|
||||
insets Insets
|
||||
|
||||
stage Stage
|
||||
started bool
|
||||
@@ -200,9 +201,11 @@ func onFocusChange(env *C.JNIEnv, class C.jclass, view C.jlong, focus C.jboolean
|
||||
//export onWindowInsets
|
||||
func onWindowInsets(env *C.JNIEnv, class C.jclass, view C.jlong, top, right, bottom, left C.jint) {
|
||||
w := views[view]
|
||||
w.insets = image.Rectangle{
|
||||
Min: image.Point{X: int(left), Y: int(top)},
|
||||
Max: image.Point{X: int(right), Y: int(bottom)},
|
||||
w.insets = Insets{
|
||||
Top: ui.Px(float32(top)),
|
||||
Right: ui.Px(float32(right)),
|
||||
Bottom: ui.Px(float32(bottom)),
|
||||
Left: ui.Px(float32(left)),
|
||||
}
|
||||
if w.stage >= StageRunning {
|
||||
w.draw(true)
|
||||
|
||||
Reference in New Issue
Block a user