mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
gg: screen_size()
This commit is contained in:
parent
b37550c279
commit
e160f6e7d2
@ -581,6 +581,15 @@ pub fn (ctx &Context) draw_empty_rounded_rect(x f32, y f32, w f32, h f32, radius
|
||||
sgl.end()
|
||||
}
|
||||
|
||||
|
||||
pub fn screen_size() Size {
|
||||
$if macos {
|
||||
return C.gg_get_screen_size()
|
||||
}
|
||||
// TODO windows, linux, etc
|
||||
return Size{}
|
||||
}
|
||||
|
||||
fn C.WaitMessage()
|
||||
|
||||
/*
|
||||
|
4
vlib/gg/gg_darwin.c.v
Normal file
4
vlib/gg/gg_darwin.c.v
Normal file
@ -0,0 +1,4 @@
|
||||
module gg
|
||||
|
||||
#include "@VROOT/vlib/gg/gg_darwin.m"
|
||||
fn C.gg_get_screen_size() Size
|
14
vlib/gg/gg_darwin.m
Normal file
14
vlib/gg/gg_darwin.m
Normal file
@ -0,0 +1,14 @@
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
||||
gg__Size gg_get_screen_size() {
|
||||
NSScreen *screen = [NSScreen mainScreen];
|
||||
NSDictionary *description = [screen deviceDescription];
|
||||
NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
|
||||
CGSize displayPhysicalSize = CGDisplayScreenSize(
|
||||
[[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
|
||||
gg__Size res;
|
||||
res.width = displayPixelSize.width;
|
||||
res.height = displayPixelSize.height;
|
||||
return res;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user