ui/app: implement window insets for iOS

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-07-07 23:50:16 +02:00
parent c884b7d4f0
commit 2292fd0c63
2 changed files with 8 additions and 3 deletions
+5 -1
View File
@@ -63,7 +63,7 @@ func onCreate(view C.CFTypeRef) {
}
//export onDraw
func onDraw(view C.CFTypeRef, dpi, sdpi, width, height C.CGFloat, sync C.int) {
func onDraw(view C.CFTypeRef, dpi, sdpi, width, height C.CGFloat, sync C.int, top, right, bottom, left C.CGFloat) {
if width == 0 || height == 0 {
return
}
@@ -83,6 +83,10 @@ func onDraw(view C.CFTypeRef, dpi, sdpi, width, height C.CGFloat, sync C.int) {
X: int(width + .5),
Y: int(height + .5),
},
Insets: image.Rectangle{
Min: image.Point{X: int(left + .5), Y: int(top + .5)},
Max: image.Point{X: int(right + .5), Y: int(bottom + .5)},
},
Config: ui.Config{
PxPerDp: float32(dpi) * inchPrDp,
PxPerSp: float32(sdpi) * inchPrDp,
+3 -2
View File
@@ -27,7 +27,9 @@ static void redraw(CFTypeRef viewRef, BOOL sync) {
UIFontMetrics *metrics = [UIFontMetrics defaultMetrics];
sdpi = [metrics scaledValueForValue:sdpi];
}
onDraw(viewRef, dpi, sdpi, v.bounds.size.width*scale, v.bounds.size.height*scale, sync);
UIEdgeInsets insets = v.layoutMargins;
onDraw(viewRef, dpi, sdpi, v.bounds.size.width*scale, v.bounds.size.height*scale, sync,
insets.top*scale, insets.right*scale, insets.bottom*scale, insets.left*scale);
}
@implementation GioAppDelegate
@@ -92,7 +94,6 @@ static void redraw(CFTypeRef viewRef, BOOL sync) {
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
CFTypeRef viewRef = (__bridge CFTypeRef)self.view;
redraw(viewRef, YES);
}
- (void)viewDidDisappear:(BOOL)animated {