1
0
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:
Alexander Medvednikov 2020-12-03 23:17:00 +01:00
parent b37550c279
commit e160f6e7d2
3 changed files with 27 additions and 0 deletions

View File

@ -581,6 +581,15 @@ pub fn (ctx &Context) draw_empty_rounded_rect(x f32, y f32, w f32, h f32, radius
sgl.end() sgl.end()
} }
pub fn screen_size() Size {
$if macos {
return C.gg_get_screen_size()
}
// TODO windows, linux, etc
return Size{}
}
fn C.WaitMessage() fn C.WaitMessage()
/* /*

4
vlib/gg/gg_darwin.c.v Normal file
View 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
View 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;
}