mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 01:45:36 +00:00
ui/app: implement window insets for iOS
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+5
-1
@@ -63,7 +63,7 @@ func onCreate(view C.CFTypeRef) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//export onDraw
|
//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 {
|
if width == 0 || height == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -83,6 +83,10 @@ func onDraw(view C.CFTypeRef, dpi, sdpi, width, height C.CGFloat, sync C.int) {
|
|||||||
X: int(width + .5),
|
X: int(width + .5),
|
||||||
Y: int(height + .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{
|
Config: ui.Config{
|
||||||
PxPerDp: float32(dpi) * inchPrDp,
|
PxPerDp: float32(dpi) * inchPrDp,
|
||||||
PxPerSp: float32(sdpi) * inchPrDp,
|
PxPerSp: float32(sdpi) * inchPrDp,
|
||||||
|
|||||||
+3
-2
@@ -27,7 +27,9 @@ static void redraw(CFTypeRef viewRef, BOOL sync) {
|
|||||||
UIFontMetrics *metrics = [UIFontMetrics defaultMetrics];
|
UIFontMetrics *metrics = [UIFontMetrics defaultMetrics];
|
||||||
sdpi = [metrics scaledValueForValue:sdpi];
|
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
|
@implementation GioAppDelegate
|
||||||
@@ -92,7 +94,6 @@ static void redraw(CFTypeRef viewRef, BOOL sync) {
|
|||||||
- (void)viewWillAppear:(BOOL)animated {
|
- (void)viewWillAppear:(BOOL)animated {
|
||||||
[super viewWillAppear:animated];
|
[super viewWillAppear:animated];
|
||||||
CFTypeRef viewRef = (__bridge CFTypeRef)self.view;
|
CFTypeRef viewRef = (__bridge CFTypeRef)self.view;
|
||||||
redraw(viewRef, YES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidDisappear:(BOOL)animated {
|
- (void)viewDidDisappear:(BOOL)animated {
|
||||||
|
|||||||
Reference in New Issue
Block a user