Skip to content

Commit

Permalink
Use proper enums for GuiGetStyle/GuiSetStyle (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
Not-Nik committed Jul 27, 2024
1 parent 6efc03f commit c96627f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
6 changes: 5 additions & 1 deletion lib/generate_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ def add_namespace_to_type(t: str) -> str:
t = t[6:]
pre += "const "

if t[0].isupper():
if t.startswith("Gui"):
t = "rgui." + t
elif t[0].isupper():
t = "rl." + t
elif t in ["float3", "float16"]:
t = "rlm." + t
Expand Down Expand Up @@ -168,6 +170,8 @@ def fix_pointer(name: str, t: str):
("flags", "Gesture", r"SetGesturesEnabled"),
("button", "GamepadButton", r".*GamepadButton.*"),
("button", "MouseButton", r".*MouseButton.*"),
("control", "GuiState", r"Gui.etStyle"),
("property", "GuiControlProperty", r"Gui.etStyle"),
]
def fix_enums(arg_name, arg_type, func_name):
if func_name.startswith("rl"):
Expand Down
3 changes: 3 additions & 0 deletions lib/preludes/raygui-ext-prelude.zig
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
// raylib-zig (c) Nikolas Wipper 2024

const rl = @import("raylib-zig");
const rgui = @import("raygui.zig");
7 changes: 5 additions & 2 deletions lib/raygui-ext.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// raylib-zig (c) Nikolas Wipper 2024

const rl = @import("raylib-zig");
const rgui = @import("raygui.zig");

pub extern "c" fn GuiEnable() void;
pub extern "c" fn GuiDisable() void;
Expand All @@ -10,8 +13,8 @@ pub extern "c" fn GuiSetState(state: c_int) void;
pub extern "c" fn GuiGetState() c_int;
pub extern "c" fn GuiSetFont(font: rl.Font) void;
pub extern "c" fn GuiGetFont() rl.Font;
pub extern "c" fn GuiSetStyle(control: c_int, property: c_int, value: c_int) void;
pub extern "c" fn GuiGetStyle(control: c_int, property: c_int) c_int;
pub extern "c" fn GuiSetStyle(control: rgui.GuiState, property: rgui.GuiControlProperty, value: c_int) void;
pub extern "c" fn GuiGetStyle(control: rgui.GuiState, property: rgui.GuiControlProperty) c_int;
pub extern "c" fn GuiLoadStyle(fileName: [*c]const u8) void;
pub extern "c" fn GuiLoadStyleDefault() void;
pub extern "c" fn GuiEnableTooltip() void;
Expand Down
8 changes: 4 additions & 4 deletions lib/raygui.zig
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,13 @@ pub fn guiGetFont() Font {
}

/// Set one style property
pub fn guiSetStyle(control: i32, property: i32, value: i32) void {
cdef.GuiSetStyle(@as(c_int, control), @as(c_int, property), @as(c_int, value));
pub fn guiSetStyle(control: GuiState, property: GuiControlProperty, value: i32) void {
cdef.GuiSetStyle(control, property, @as(c_int, value));
}

/// Get one style property
pub fn guiGetStyle(control: i32, property: i32) i32 {
return @as(i32, cdef.GuiGetStyle(@as(c_int, control), @as(c_int, property)));
pub fn guiGetStyle(control: GuiState, property: GuiControlProperty) i32 {
return @as(i32, cdef.GuiGetStyle(control, property));
}

/// Load style file over global style variable (.rgs)
Expand Down

0 comments on commit c96627f

Please sign in to comment.