mach: Make size limits part of runtime options (mach.Options)
Removed method Engine.setSizeLimits and added two new fields to mach.Options called ``size_min`` and ``size_max`` which does the same thing.
This commit is contained in:
parent
ed0e6f5c61
commit
176554fe4d
4 changed files with 11 additions and 13 deletions
|
|
@ -71,10 +71,6 @@ pub fn getWindowSize(engine: *Engine) structs.Size {
|
|||
return engine.internal.getWindowSize();
|
||||
}
|
||||
|
||||
pub fn setSizeLimits(engine: *Engine, min: structs.SizeOptional, max: structs.SizeOptional) !void {
|
||||
return engine.internal.setSizeLimits(min, max);
|
||||
}
|
||||
|
||||
pub fn pollEvent(engine: *Engine) ?structs.Event {
|
||||
return engine.internal.pollEvent();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,6 +238,10 @@ pub const Platform = struct {
|
|||
pub fn setOptions(platform: *Platform, options: structs.Options) !void {
|
||||
try platform.window.setSize(.{ .width = options.width, .height = options.height });
|
||||
try platform.window.setTitle(options.title);
|
||||
try platform.window.setSizeLimits(
|
||||
@bitCast(glfw.Window.SizeOptional, options.size_min),
|
||||
@bitCast(glfw.Window.SizeOptional, options.size_max),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn setShouldClose(platform: *Platform, value: bool) void {
|
||||
|
|
@ -252,13 +256,6 @@ pub const Platform = struct {
|
|||
return platform.last_window_size;
|
||||
}
|
||||
|
||||
pub fn setSizeLimits(platform: *Platform, min: structs.SizeOptional, max: structs.SizeOptional) !void {
|
||||
try platform.window.setSizeLimits(
|
||||
@bitCast(glfw.Window.SizeOptional, min),
|
||||
@bitCast(glfw.Window.SizeOptional, max),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn pollEvent(platform: *Platform) ?structs.Event {
|
||||
if (platform.events.popFirst()) |n| {
|
||||
defer platform.allocator.destroy(n);
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ pub const Platform = struct {
|
|||
}
|
||||
|
||||
pub fn setOptions(platform: *Platform, options: structs.Options) !void {
|
||||
// NOTE: size limits do not exists on wasm
|
||||
js.machCanvasSetSize(platform.id, options.width, options.height);
|
||||
|
||||
const title = std.mem.span(options.title);
|
||||
|
|
@ -65,8 +66,6 @@ pub const Platform = struct {
|
|||
};
|
||||
}
|
||||
|
||||
pub fn setSizeLimits(_: *Platform, _: structs.SizeOptional, _: structs.SizeOptional) !void {}
|
||||
|
||||
pub fn pollEvent(_: *Platform) ?structs.Event {
|
||||
const event_type = js.machEventShift();
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,12 @@ pub const Options = struct {
|
|||
/// The height of the window.
|
||||
height: u32 = 480,
|
||||
|
||||
/// The minimum allowed size for the window.
|
||||
size_min: SizeOptional = .{ .width = null, .height = null },
|
||||
|
||||
/// The maximum allowed size for the window.
|
||||
size_max: SizeOptional = .{ .width = null, .height = null },
|
||||
|
||||
/// Monitor synchronization modes.
|
||||
vsync: enums.VSyncMode = .double,
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue