From aa9ee05f2246b813f75206bf817c9fbdfcb06101 Mon Sep 17 00:00:00 2001 From: Nikolas Date: Fri, 3 Apr 2026 13:06:56 +0200 Subject: [PATCH] Allow all property enums for get/setStyle (#299, #307) --- lib/preludes/raygui-prelude.zig | 17 ++++++++++++++--- lib/raygui.zig | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/lib/preludes/raygui-prelude.zig b/lib/preludes/raygui-prelude.zig index 8f6069b..83924cd 100644 --- a/lib/preludes/raygui-prelude.zig +++ b/lib/preludes/raygui-prelude.zig @@ -93,9 +93,20 @@ pub const DefaultProperty = enum(c_int) { text_wrap_mode, }; -pub const ControlOrDefaultProperty = union(enum) { +pub const Property = union(enum) { control: ControlProperty, default: DefaultProperty, + toggle: ToggleProperty, + slider: SliderProperty, + progressBar: ProgressBarProperty, + scrollBar: ScrollBarProperty, + checkBox: CheckBoxProperty, + comboBox: ComboBoxProperty, + dropdownBox: DropdownBoxProperty, + textBox: TextBoxProperty, + valueBox: ValueBoxProperty, + listView: ListViewProperty, + colorPicker: ColorPickerProperty, }; pub const ToggleProperty = enum(c_int) { @@ -425,7 +436,7 @@ pub const IconName = enum(c_int) { }; /// Set one style property -pub fn setStyle(control: Control, comptime property: ControlOrDefaultProperty, value: i32) void { +pub fn setStyle(control: Control, comptime property: Property, value: i32) void { const property_int: c_int = switch (property) { inline else => |val| @intCast(@intFromEnum(val)), }; @@ -434,7 +445,7 @@ pub fn setStyle(control: Control, comptime property: ControlOrDefaultProperty, v } /// Get one style property -pub fn getStyle(control: Control, comptime property: ControlOrDefaultProperty) i32 { +pub fn getStyle(control: Control, comptime property: Property) i32 { const property_int: c_int = switch (property) { inline else => |val| @intCast(@intFromEnum(val)), }; diff --git a/lib/raygui.zig b/lib/raygui.zig index fd0353d..837089d 100644 --- a/lib/raygui.zig +++ b/lib/raygui.zig @@ -93,9 +93,20 @@ pub const DefaultProperty = enum(c_int) { text_wrap_mode, }; -pub const ControlOrDefaultProperty = union(enum) { +pub const Property = union(enum) { control: ControlProperty, default: DefaultProperty, + toggle: ToggleProperty, + slider: SliderProperty, + progressBar: ProgressBarProperty, + scrollBar: ScrollBarProperty, + checkBox: CheckBoxProperty, + comboBox: ComboBoxProperty, + dropdownBox: DropdownBoxProperty, + textBox: TextBoxProperty, + valueBox: ValueBoxProperty, + listView: ListViewProperty, + colorPicker: ColorPickerProperty, }; pub const ToggleProperty = enum(c_int) { @@ -425,7 +436,7 @@ pub const IconName = enum(c_int) { }; /// Set one style property -pub fn setStyle(control: Control, comptime property: ControlOrDefaultProperty, value: i32) void { +pub fn setStyle(control: Control, comptime property: Property, value: i32) void { const property_int: c_int = switch (property) { inline else => |val| @intCast(@intFromEnum(val)), }; @@ -434,7 +445,7 @@ pub fn setStyle(control: Control, comptime property: ControlOrDefaultProperty, v } /// Get one style property -pub fn getStyle(control: Control, comptime property: ControlOrDefaultProperty) i32 { +pub fn getStyle(control: Control, comptime property: Property) i32 { const property_int: c_int = switch (property) { inline else => |val| @intCast(@intFromEnum(val)), };