ui/app: introduce DrawEvent.Insets and add Android implementation

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-07-07 23:30:38 +02:00
parent 491d81e0c8
commit c884b7d4f0
6 changed files with 35 additions and 3 deletions
+14
View File
@@ -37,6 +37,7 @@ type window struct {
dpi int
fontScale float32
insets image.Rectangle
stage Stage
started bool
@@ -197,6 +198,18 @@ func onFocusChange(env *C.JNIEnv, class C.jclass, view C.jlong, focus C.jboolean
w.event(key.FocusEvent{Focus: focus == C.JNI_TRUE})
}
//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)},
}
if w.stage >= StageRunning {
w.draw(true)
}
}
func (w *window) setVisible() {
win := w.aNativeWindow()
width, height := C.ANativeWindow_getWidth(win), C.ANativeWindow_getHeight(win)
@@ -275,6 +288,7 @@ func (w *window) draw(sync bool) {
X: int(width),
Y: int(height),
},
Insets: w.insets,
Config: ui.Config{
PxPerDp: ppdp,
PxPerSp: w.fontScale * ppdp,