diff options
Diffstat (limited to 'src/Window.zig')
-rw-r--r-- | src/Window.zig | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/Window.zig b/src/Window.zig index 6f4a313..d5bb8e7 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -1,5 +1,5 @@ // Window manipulation -// Copyright (C) 2021-2022 Nguyễn Gia Phong +// Copyright (C) 2021-2023 Nguyễn Gia Phong // // This file is part of gfz. // @@ -51,16 +51,16 @@ fn fnCast(comptime DestType: type, comptime fun: anytype) DestType { pub fn callback(window: ?*Impl, key: c_int, scancode: c_int, action: c_int, mods: c_int) callconv(.C) void { fun(@fieldParentPtr(Self, "pimpl", &window.?).*, - @intToEnum(Key, key), scancode, - @intToEnum(KeyAction, action), Mods.fromInt(mods)); + @enumFromInt(key), scancode, + @enumFromInt(action), Mods.fromInt(mods)); } }, c.GLFWmousebuttonfun => struct { pub fn callback(window: ?*Impl, button: c_int, action: c_int, mods: c_int) callconv(.C) void { fun(@fieldParentPtr(Self, "pimpl", &window.?).*, - @intToEnum(MouseButton, button), - @intToEnum(MouseButton.Action, action), Mods.fromInt(mods)); + @enumFromInt(button), + @enumFromInt(action), Mods.fromInt(mods)); } }, c.GLFWwindowsizefun => struct { @@ -153,7 +153,7 @@ fn setHint(hint: c_int, value: anytype) Error!void { c.glfwWindowHint(hint, switch (@TypeOf(value)) { c_int, comptime_int => value, bool => if (value) c.GLFW_TRUE else c.GLFW_FALSE, - else => @enumToInt(value), + else => @intFromEnum(value), }); try checkError(); } @@ -258,7 +258,7 @@ const InputMode = enum(c_int) { /// Return the value of an input option. pub fn getInputMode(self: Self, mode: InputMode) Error!bool { - const value = c.glfwGetInputMode(self.pimpl, @enumToInt(mode)); + const value = c.glfwGetInputMode(self.pimpl, @intFromEnum(mode)); try checkError(); return value == c.GLFW_TRUE; } @@ -266,7 +266,7 @@ pub fn getInputMode(self: Self, mode: InputMode) Error!bool { /// Set an input option. pub fn setInputMode(self: Self, mode: InputMode, flag: bool) Error!void { const value = if (flag) c.GLFW_TRUE else c.GLFW_FALSE; - c.glfwSetInputMode(self.pimpl, @enumToInt(mode), value); + c.glfwSetInputMode(self.pimpl, @intFromEnum(mode), value); try checkError(); } @@ -280,12 +280,12 @@ const CursorMode = enum(c_int) { pub fn getCursorMode(self: Self) Error!CursorMode { const value = c.glfwGetInputMode(self.pimpl, c.GLFW_CURSOR); try checkError(); - return @intToEnum(CursorMode, value); + return @enumFromInt(value); } /// Set the cursor mode. pub fn setCursorMode(self: Self, value: CursorMode) Error!void { - c.glfwSetInputMode(self.pimpl, c.GLFW_CURSOR, @enumToInt(value)); + c.glfwSetInputMode(self.pimpl, c.GLFW_CURSOR, @intFromEnum(value)); try checkError(); } @@ -321,9 +321,9 @@ const State = enum(c_int) { /// Return the last reported state of a mouse button. pub fn getMouseButton(self: Self, button: MouseButton) Error!State { - const state = c.glfwGetMouseButton(self.pimpl, @enumToInt(button)); + const state = c.glfwGetMouseButton(self.pimpl, @intFromEnum(button)); try checkError(); - return @intToEnum(State, state); + return @enumFromInt(state); } /// Set the mouse button callback. @@ -336,9 +336,9 @@ pub fn setMouseButtonCallback(self: Self, /// Return the last reported state of a keyboard key. pub fn getKey(self: Self, key: Key) Error!State { - const state = c.glfwGetKey(self.pimpl, @enumToInt(key)); + const state = c.glfwGetKey(self.pimpl, @intFromEnum(key)); try checkError(); - return @intToEnum(State, state); + return @enumFromInt(state); } /// Set the key callback. |