Use proper enums for GuiGetStyle/GuiSetStyle (#125)

This commit is contained in:
Not-Nik 2024-07-27 23:27:00 +02:00
parent 6efc03f6fe
commit c96627f91a
No known key found for this signature in database
GPG Key ID: E95F679E3CDD9784
4 changed files with 17 additions and 7 deletions

View File

@ -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
@ -168,6 +170,8 @@ _fix_enums_data = [
("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"):

View File

@ -1 +1,4 @@
// raylib-zig (c) Nikolas Wipper 2024
const rl = @import("raylib-zig");
const rgui = @import("raygui.zig");

View File

@ -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;
@ -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;

View File

@ -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)