Skip to content

Commit 85533fe

Browse files
committed
sokol, gg: min window width and height
1 parent 872bcbc commit 85533fe

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

thirdparty/sokol/sokol_app.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1728,6 +1728,8 @@ typedef struct sapp_desc {
17281728
bool ios_keyboard_resizes_canvas; // if true, showing the iOS keyboard shrinks the canvas
17291729
// __v_ start
17301730
bool __v_native_render; // V patch to allow for native rendering
1731+
int min_width;
1732+
int min_height;
17311733
// __v_ end
17321734
} sapp_desc;
17331735

@@ -3936,6 +3938,8 @@ _SOKOL_PRIVATE void _sapp_macos_frame(void) {
39363938
_sapp.macos.window.restorable = YES;
39373939

39383940
// __v_ start
3941+
// Set min width/height
3942+
[_sapp.macos.window setMinSize:NSMakeSize(_sapp.desc.min_width, _sapp.desc.min_height)];
39393943
// Quit menu
39403944
NSMenu* menu_bar = [[NSMenu alloc] init];
39413945
NSMenuItem* app_menu_item = [[NSMenuItem alloc] init];
@@ -3950,6 +3954,16 @@ _SOKOL_PRIVATE void _sapp_macos_frame(void) {
39503954
action:@selector(terminate:)
39513955
keyEquivalent:@"q"];
39523956
[app_menu addItem:quit_menu_item];
3957+
// Paste menu
3958+
/*
3959+
NSMenuItem *paste_menu_item = [[NSMenuItem alloc] initWithTitle:@"Paste" action:@selector(paste:)
3960+
keyEquivalent:@"v"];
3961+
//[paste_menu_item setKeyEquivalentModifierMask:NSEventModifierFlagCommand];
3962+
//[paste_menu_item setTarget:self];
3963+
[paste_menu_item setEnabled:true];
3964+
[app_menu addItem:paste_menu_item];
3965+
*/
3966+
39533967
app_menu_item.submenu = app_menu;
39543968
_SAPP_OBJC_RELEASE( window_title_as_nsstring );
39553969
_SAPP_OBJC_RELEASE( app_menu );
@@ -4075,6 +4089,7 @@ _SOKOL_PRIVATE void _sapp_macos_frame(void) {
40754089
[overlayWindow setOpaque:YES];
40764090
[_sapp.macos.window setIgnoresMouseEvents:NO];
40774091
g_view = [[MyView2 alloc] init];
4092+
g_view.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
40784093
overlayWindow.contentView = g_view;
40794094

40804095
[ contentView addSubview:g_view];
@@ -4083,7 +4098,7 @@ _SOKOL_PRIVATE void _sapp_macos_frame(void) {
40834098
}
40844099
//////////////////////////////////
40854100
// __v_ end
4086-
4101+
40874102

40884103
[_sapp.macos.window makeKeyAndOrderFront:nil];
40894104
_sapp_macos_update_dimensions();

vlib/gg/gg.c.v

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ pub struct Config {
5252
pub:
5353
width int
5454
height int
55-
use_ortho bool // unused, still here just for backwards compatibility
5655
retina bool
5756
resizable bool
5857
user_data voidptr
@@ -105,6 +104,9 @@ pub:
105104
enable_dragndrop bool // enable file dropping (drag'n'drop), default is false
106105
max_dropped_files int = 1 // max number of dropped files to process (default: 1)
107106
max_dropped_file_path_length int = 2048 // max length in bytes of a dropped UTF-8 file path (default: 2048)
107+
//
108+
min_width int
109+
min_height int
108110
}
109111

110112
@[heap]
@@ -477,6 +479,8 @@ pub fn new_context(cfg Config) &Context {
477479
high_dpi: true
478480
fullscreen: cfg.fullscreen
479481
__v_native_render: cfg.native_rendering
482+
min_width: cfg.min_width
483+
min_height: cfg.min_height
480484
// drag&drop
481485
enable_dragndrop: cfg.enable_dragndrop
482486
max_dropped_files: cfg.max_dropped_files

vlib/gg/gg.js.v

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ pub struct Config {
202202
pub:
203203
width int
204204
height int
205-
use_ortho bool // unused, still here just for backwards compatibility
206205
retina bool
207206
resizable bool
208207
user_data voidptr
@@ -250,7 +249,7 @@ pub:
250249
font_bytes_italic []u8
251250
native_rendering bool // Cocoa on macOS/iOS, GDI+ on Windows
252251
// drag&drop
253-
enable_dragndrop bool // enable file dropping (drag'n'drop), default is false
252+
enable_dragndrop bool // enable file dropping (drag'n'drop), default is false
254253
max_dropped_files int = 1 // max number of dropped files to process (default: 1)
255254
max_dropped_file_path_length int = 2048 // max length in bytes of a dropped UTF-8 file path (default: 2048)
256255
html5_canvas_name string = 'canvas' // the id/name of the canvas element, that will be used to render GG apps

vlib/sokol/sapp/sapp_structs.c.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ pub:
7777
ios_keyboard_resizes_canvas bool // if true, showing the iOS keyboard shrinks the canvas
7878
// V patches
7979
__v_native_render bool // V patch to allow for native rendering
80+
min_width int // V patch to allow for min window width
81+
min_height int // V patch to allow for min window height
8082
pub mut:
8183
allocator C.sapp_allocator // optional memory allocation overrides (default: malloc/free)
8284
logger C.sapp_logger // optional log callback overrides (default: SAPP_LOG(message))

0 commit comments

Comments
 (0)