Allow all property enums for get/setStyle (#299, #307)

This commit is contained in:
Nikolas 2026-04-03 13:06:56 +02:00
parent 0f16781145
commit aa9ee05f22
Failed to generate hash of commit
2 changed files with 28 additions and 6 deletions

View file

@ -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)),
};

View file

@ -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)),
};