mirror of
https://github.com/Not-Nik/raylib-zig.git
synced 2025-09-09 03:57:29 +00:00
[raygui] Allow GuiControlProperty and GuiDefaultProperty as types for property in GuiGetStyle/GuiSetStyle (#131)
This commit is contained in:
parent
16a388c9c2
commit
57041e707c
@ -367,6 +367,8 @@ def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str,
|
||||
"DrawSplineBezierQuadratic",
|
||||
"DrawSplineBezierCubic",
|
||||
"ImageKernelConvolution",
|
||||
"GuiSetStyle",
|
||||
"GuiGetStyle"
|
||||
]
|
||||
|
||||
if func_name in manual or "FromMemory" in func_name:
|
||||
|
@ -418,6 +418,40 @@ pub const GuiIconName = enum(c_int) {
|
||||
icon_255 = 255,
|
||||
};
|
||||
|
||||
/// Set one style property
|
||||
pub fn guiSetStyle(control: GuiControl, comptime property: anytype, value: i32) void {
|
||||
comptime var property_int: c_int = undefined;
|
||||
|
||||
comptime {
|
||||
if (@TypeOf(property) == GuiControlProperty) {
|
||||
property_int = @intCast(@intFromEnum(property));
|
||||
} else if (@TypeOf(property) == GuiDefaultProperty) { // comparison can't be chained :(
|
||||
property_int = @intCast(@intFromEnum(property));
|
||||
} else {
|
||||
@compileError("Invalid property type for guiSetStyle");
|
||||
}
|
||||
}
|
||||
|
||||
cdef.GuiSetStyle(control, property_int, @as(c_int, value));
|
||||
}
|
||||
|
||||
/// Get one style property
|
||||
pub fn guiGetStyle(control: GuiControl, comptime property: anytype) i32 {
|
||||
comptime var property_int: c_int = undefined;
|
||||
|
||||
comptime {
|
||||
if (@TypeOf(property) == GuiControlProperty) {
|
||||
property_int = @intCast(@intFromEnum(property));
|
||||
} else if (@TypeOf(property) == GuiDefaultProperty) { // comparison can't be chained :(
|
||||
property_int = @intCast(@intFromEnum(property));
|
||||
} else {
|
||||
@compileError("Invalid property type for guiGetStyle");
|
||||
}
|
||||
}
|
||||
|
||||
return @as(i32, cdef.GuiGetStyle(control, property_int));
|
||||
}
|
||||
|
||||
/// Get raygui icons data pointer
|
||||
pub fn guiGetIcons() RayguiError![]u32 {
|
||||
var res: []u32 = undefined;
|
||||
|
@ -418,6 +418,40 @@ pub const GuiIconName = enum(c_int) {
|
||||
icon_255 = 255,
|
||||
};
|
||||
|
||||
/// Set one style property
|
||||
pub fn guiSetStyle(control: GuiControl, comptime property: anytype, value: i32) void {
|
||||
comptime var property_int: c_int = undefined;
|
||||
|
||||
comptime {
|
||||
if (@TypeOf(property) == GuiControlProperty) {
|
||||
property_int = @intCast(@intFromEnum(property));
|
||||
} else if (@TypeOf(property) == GuiDefaultProperty) { // comparison can't be chained :(
|
||||
property_int = @intCast(@intFromEnum(property));
|
||||
} else {
|
||||
@compileError("Invalid property type for guiSetStyle");
|
||||
}
|
||||
}
|
||||
|
||||
cdef.GuiSetStyle(control, property_int, @as(c_int, value));
|
||||
}
|
||||
|
||||
/// Get one style property
|
||||
pub fn guiGetStyle(control: GuiControl, comptime property: anytype) i32 {
|
||||
comptime var property_int: c_int = undefined;
|
||||
|
||||
comptime {
|
||||
if (@TypeOf(property) == GuiControlProperty) {
|
||||
property_int = @intCast(@intFromEnum(property));
|
||||
} else if (@TypeOf(property) == GuiDefaultProperty) { // comparison can't be chained :(
|
||||
property_int = @intCast(@intFromEnum(property));
|
||||
} else {
|
||||
@compileError("Invalid property type for guiGetStyle");
|
||||
}
|
||||
}
|
||||
|
||||
return @as(i32, cdef.GuiGetStyle(control, property_int));
|
||||
}
|
||||
|
||||
/// Get raygui icons data pointer
|
||||
pub fn guiGetIcons() RayguiError![]u32 {
|
||||
var res: []u32 = undefined;
|
||||
@ -514,16 +548,6 @@ pub fn guiGetFont() Font {
|
||||
return cdef.GuiGetFont();
|
||||
}
|
||||
|
||||
/// Set one style property
|
||||
pub fn guiSetStyle(control: GuiControl, property: i32, value: i32) void {
|
||||
cdef.GuiSetStyle(control, @as(c_int, property), @as(c_int, value));
|
||||
}
|
||||
|
||||
/// Get one style property
|
||||
pub fn guiGetStyle(control: GuiControl, property: i32) i32 {
|
||||
return @as(i32, cdef.GuiGetStyle(control, @as(c_int, property)));
|
||||
}
|
||||
|
||||
/// Load style file over global style variable (.rgs)
|
||||
pub fn guiLoadStyle(fileName: [*:0]const u8) void {
|
||||
cdef.GuiLoadStyle(@as([*c]const u8, @ptrCast(fileName)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user