fix(raygui): strip "Gui" prefix from Zig functions

This commit is contained in:
Daniel Hill 2025-04-19 15:48:27 -04:00 committed by Nikolas
parent f4b69764db
commit 67fd5af55a
3 changed files with 65 additions and 56 deletions

View File

@ -43,13 +43,18 @@ pub fn main() !void {
rl.clearBackground(getColor(color_int));
if (rg.guiButton(.init(24, 24, 120, 30), "#191#Show Message") > 0) show_message_box = true;
if (rg.button(.init(24, 24, 120, 30), "#191#Show Message") > 0)
show_message_box = true;
if (show_message_box) {
const result = rg.guiMessageBox(.init(85, 70, 250, 100), "#191#Message Box", "Hi! This is a message", "Nice;Cool");
const result = rg.messageBox(
.init(85, 70, 250, 100),
"#191#Message Box",
"Hi! This is a message",
"Nice;Cool",
);
if (result >= 0) show_message_box = false;
}
}
}

View File

@ -275,8 +275,12 @@ def fix_enums(arg_name, arg_type, func_name):
return arg_type
def convert_name_case(name):
return name[:1].lower() + name[1:] if name else ''
def convert_name(name):
if not name:
return ''
if name.startswith("Gui"):
name = name[3:]
return name[:1].lower() + name[1:]
def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str, prelude_file: str, ext_prelude_file: str, skip_after: str = "#/never\\#"):
@ -409,7 +413,7 @@ def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str,
ext_ret = add_namespace_to_type(return_type)
ext_heads.append(f"pub extern \"c\" fn {func_name}({zig_c_arguments}) {ext_ret};")
zig_name = convert_name_case(func_name)
zig_name = convert_name(func_name)
func_prelude = ""

View File

@ -489,251 +489,251 @@ pub fn scrollPanel(bounds: Rectangle, text: ?[*:0]const u8, content: Rectangle,
}
/// Enable gui controls (global state)
pub fn guiEnable() void {
pub fn enable() void {
cdef.GuiEnable();
}
/// Disable gui controls (global state)
pub fn guiDisable() void {
pub fn disable() void {
cdef.GuiDisable();
}
/// Lock gui controls (global state)
pub fn guiLock() void {
pub fn lock() void {
cdef.GuiLock();
}
/// Unlock gui controls (global state)
pub fn guiUnlock() void {
pub fn unlock() void {
cdef.GuiUnlock();
}
/// Check if gui is locked (global state)
pub fn guiIsLocked() bool {
pub fn isLocked() bool {
return cdef.GuiIsLocked();
}
/// Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f
pub fn guiSetAlpha(alpha: f32) void {
pub fn setAlpha(alpha: f32) void {
cdef.GuiSetAlpha(alpha);
}
/// Set gui state (global state)
pub fn guiSetState(state: i32) void {
pub fn setState(state: i32) void {
cdef.GuiSetState(@as(c_int, state));
}
/// Get gui state (global state)
pub fn guiGetState() i32 {
pub fn getState() i32 {
return @as(i32, cdef.GuiGetState());
}
/// Set gui custom font (global state)
pub fn guiSetFont(font: Font) void {
pub fn setFont(font: Font) void {
cdef.GuiSetFont(font);
}
/// Get gui custom font (global state)
pub fn guiGetFont() Font {
pub fn getFont() Font {
return cdef.GuiGetFont();
}
/// Load style file over global style variable (.rgs)
pub fn guiLoadStyle(fileName: [:0]const u8) void {
pub fn loadStyle(fileName: [:0]const u8) void {
cdef.GuiLoadStyle(@as([*c]const u8, @ptrCast(fileName)));
}
/// Load style default over global style
pub fn guiLoadStyleDefault() void {
pub fn loadStyleDefault() void {
cdef.GuiLoadStyleDefault();
}
/// Enable gui tooltips (global state)
pub fn guiEnableTooltip() void {
pub fn enableTooltip() void {
cdef.GuiEnableTooltip();
}
/// Disable gui tooltips (global state)
pub fn guiDisableTooltip() void {
pub fn disableTooltip() void {
cdef.GuiDisableTooltip();
}
/// Set tooltip string
pub fn guiSetTooltip(tooltip: [:0]const u8) void {
pub fn setTooltip(tooltip: [:0]const u8) void {
cdef.GuiSetTooltip(@as([*c]const u8, @ptrCast(tooltip)));
}
/// Get text with icon id prepended (if supported)
pub fn guiIconText(iconId: i32, text: [:0]const u8) [:0]const u8 {
pub fn iconText(iconId: i32, text: [:0]const u8) [:0]const u8 {
return std.mem.span(cdef.GuiIconText(@as(c_int, iconId), @as([*c]const u8, @ptrCast(text))));
}
/// Set default icon drawing size
pub fn guiSetIconScale(scale: i32) void {
pub fn setIconScale(scale: i32) void {
cdef.GuiSetIconScale(@as(c_int, scale));
}
/// Draw icon using pixel size at specified position
pub fn guiDrawIcon(iconId: i32, posX: i32, posY: i32, pixelSize: i32, color: Color) void {
pub fn drawIcon(iconId: i32, posX: i32, posY: i32, pixelSize: i32, color: Color) void {
cdef.GuiDrawIcon(@as(c_int, iconId), @as(c_int, posX), @as(c_int, posY), @as(c_int, pixelSize), color);
}
/// Window Box control, shows a window that can be closed
pub fn guiWindowBox(bounds: Rectangle, title: [:0]const u8) i32 {
pub fn windowBox(bounds: Rectangle, title: [:0]const u8) i32 {
return @as(i32, cdef.GuiWindowBox(bounds, @as([*c]const u8, @ptrCast(title))));
}
/// Group Box control with text name
pub fn guiGroupBox(bounds: Rectangle, text: [:0]const u8) i32 {
pub fn groupBox(bounds: Rectangle, text: [:0]const u8) i32 {
return @as(i32, cdef.GuiGroupBox(bounds, @as([*c]const u8, @ptrCast(text))));
}
/// Line separator control, could contain text
pub fn guiLine(bounds: Rectangle, text: [:0]const u8) i32 {
pub fn line(bounds: Rectangle, text: [:0]const u8) i32 {
return @as(i32, cdef.GuiLine(bounds, @as([*c]const u8, @ptrCast(text))));
}
/// Label control
pub fn guiLabel(bounds: Rectangle, text: [:0]const u8) i32 {
pub fn label(bounds: Rectangle, text: [:0]const u8) i32 {
return @as(i32, cdef.GuiLabel(bounds, @as([*c]const u8, @ptrCast(text))));
}
/// Button control, returns true when clicked
pub fn guiButton(bounds: Rectangle, text: [:0]const u8) i32 {
pub fn button(bounds: Rectangle, text: [:0]const u8) i32 {
return @as(i32, cdef.GuiButton(bounds, @as([*c]const u8, @ptrCast(text))));
}
/// Label button control, returns true when clicked
pub fn guiLabelButton(bounds: Rectangle, text: [:0]const u8) i32 {
pub fn labelButton(bounds: Rectangle, text: [:0]const u8) i32 {
return @as(i32, cdef.GuiLabelButton(bounds, @as([*c]const u8, @ptrCast(text))));
}
/// Toggle Button control
pub fn guiToggle(bounds: Rectangle, text: [:0]const u8, active: *bool) i32 {
pub fn toggle(bounds: Rectangle, text: [:0]const u8, active: *bool) i32 {
return @as(i32, cdef.GuiToggle(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]bool, @ptrCast(active))));
}
/// Toggle Group control
pub fn guiToggleGroup(bounds: Rectangle, text: [:0]const u8, active: *i32) i32 {
pub fn toggleGroup(bounds: Rectangle, text: [:0]const u8, active: *i32) i32 {
return @as(i32, cdef.GuiToggleGroup(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(active))));
}
/// Toggle Slider control
pub fn guiToggleSlider(bounds: Rectangle, text: [:0]const u8, active: *i32) i32 {
pub fn toggleSlider(bounds: Rectangle, text: [:0]const u8, active: *i32) i32 {
return @as(i32, cdef.GuiToggleSlider(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(active))));
}
/// Check Box control, returns true when active
pub fn guiCheckBox(bounds: Rectangle, text: [:0]const u8, checked: *bool) i32 {
pub fn checkBox(bounds: Rectangle, text: [:0]const u8, checked: *bool) i32 {
return @as(i32, cdef.GuiCheckBox(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]bool, @ptrCast(checked))));
}
/// Combo Box control
pub fn guiComboBox(bounds: Rectangle, text: [:0]const u8, active: *i32) i32 {
pub fn comboBox(bounds: Rectangle, text: [:0]const u8, active: *i32) i32 {
return @as(i32, cdef.GuiComboBox(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(active))));
}
/// Dropdown Box control
pub fn guiDropdownBox(bounds: Rectangle, text: [:0]const u8, active: *i32, editMode: bool) i32 {
pub fn dropdownBox(bounds: Rectangle, text: [:0]const u8, active: *i32, editMode: bool) i32 {
return @as(i32, cdef.GuiDropdownBox(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(active)), editMode));
}
/// Spinner control
pub fn guiSpinner(bounds: Rectangle, text: [:0]const u8, value: *i32, minValue: i32, maxValue: i32, editMode: bool) i32 {
pub fn spinner(bounds: Rectangle, text: [:0]const u8, value: *i32, minValue: i32, maxValue: i32, editMode: bool) i32 {
return @as(i32, cdef.GuiSpinner(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(value)), @as(c_int, minValue), @as(c_int, maxValue), editMode));
}
/// Value Box control, updates input text with numbers
pub fn guiValueBox(bounds: Rectangle, text: [:0]const u8, value: *i32, minValue: i32, maxValue: i32, editMode: bool) i32 {
pub fn valueBox(bounds: Rectangle, text: [:0]const u8, value: *i32, minValue: i32, maxValue: i32, editMode: bool) i32 {
return @as(i32, cdef.GuiValueBox(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(value)), @as(c_int, minValue), @as(c_int, maxValue), editMode));
}
/// Value box control for float values
pub fn guiValueBoxFloat(bounds: Rectangle, text: [:0]const u8, textValue: [:0]u8, value: *f32, editMode: bool) i32 {
pub fn valueBoxFloat(bounds: Rectangle, text: [:0]const u8, textValue: [:0]u8, value: *f32, editMode: bool) i32 {
return @as(i32, cdef.GuiValueBoxFloat(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]u8, @ptrCast(textValue)), @as([*c]f32, @ptrCast(value)), editMode));
}
/// Text Box control, updates input text
pub fn guiTextBox(bounds: Rectangle, text: [:0]u8, textSize: i32, editMode: bool) i32 {
pub fn textBox(bounds: Rectangle, text: [:0]u8, textSize: i32, editMode: bool) i32 {
return @as(i32, cdef.GuiTextBox(bounds, @as([*c]u8, @ptrCast(text)), @as(c_int, textSize), editMode));
}
/// Slider control
pub fn guiSlider(bounds: Rectangle, textLeft: [:0]const u8, textRight: [:0]const u8, value: *f32, minValue: f32, maxValue: f32) i32 {
pub fn slider(bounds: Rectangle, textLeft: [:0]const u8, textRight: [:0]const u8, value: *f32, minValue: f32, maxValue: f32) i32 {
return @as(i32, cdef.GuiSlider(bounds, @as([*c]const u8, @ptrCast(textLeft)), @as([*c]const u8, @ptrCast(textRight)), @as([*c]f32, @ptrCast(value)), minValue, maxValue));
}
/// Slider control with extended parameters
pub fn guiSliderPro(bounds: Rectangle, textLeft: [:0]const u8, textRight: [:0]const u8, value: *f32, minValue: f32, maxValue: f32, sliderWidth: i32) i32 {
pub fn sliderPro(bounds: Rectangle, textLeft: [:0]const u8, textRight: [:0]const u8, value: *f32, minValue: f32, maxValue: f32, sliderWidth: i32) i32 {
return @as(i32, cdef.GuiSliderPro(bounds, @as([*c]const u8, @ptrCast(textLeft)), @as([*c]const u8, @ptrCast(textRight)), @as([*c]f32, @ptrCast(value)), minValue, maxValue, @as(c_int, sliderWidth)));
}
/// Slider Bar control
pub fn guiSliderBar(bounds: Rectangle, textLeft: [:0]const u8, textRight: [:0]const u8, value: *f32, minValue: f32, maxValue: f32) i32 {
pub fn sliderBar(bounds: Rectangle, textLeft: [:0]const u8, textRight: [:0]const u8, value: *f32, minValue: f32, maxValue: f32) i32 {
return @as(i32, cdef.GuiSliderBar(bounds, @as([*c]const u8, @ptrCast(textLeft)), @as([*c]const u8, @ptrCast(textRight)), @as([*c]f32, @ptrCast(value)), minValue, maxValue));
}
/// Progress Bar control
pub fn guiProgressBar(bounds: Rectangle, textLeft: [:0]const u8, textRight: [:0]const u8, value: *f32, minValue: f32, maxValue: f32) i32 {
pub fn progressBar(bounds: Rectangle, textLeft: [:0]const u8, textRight: [:0]const u8, value: *f32, minValue: f32, maxValue: f32) i32 {
return @as(i32, cdef.GuiProgressBar(bounds, @as([*c]const u8, @ptrCast(textLeft)), @as([*c]const u8, @ptrCast(textRight)), @as([*c]f32, @ptrCast(value)), minValue, maxValue));
}
/// Status Bar control, shows info text
pub fn guiStatusBar(bounds: Rectangle, text: [:0]const u8) i32 {
pub fn statusBar(bounds: Rectangle, text: [:0]const u8) i32 {
return @as(i32, cdef.GuiStatusBar(bounds, @as([*c]const u8, @ptrCast(text))));
}
/// Dummy control for placeholders
pub fn guiDummyRec(bounds: Rectangle, text: [:0]const u8) i32 {
pub fn dummyRec(bounds: Rectangle, text: [:0]const u8) i32 {
return @as(i32, cdef.GuiDummyRec(bounds, @as([*c]const u8, @ptrCast(text))));
}
/// Grid control
pub fn guiGrid(bounds: Rectangle, text: [:0]const u8, spacing: f32, subdivs: i32, mouseCell: *Vector2) i32 {
pub fn grid(bounds: Rectangle, text: [:0]const u8, spacing: f32, subdivs: i32, mouseCell: *Vector2) i32 {
return @as(i32, cdef.GuiGrid(bounds, @as([*c]const u8, @ptrCast(text)), spacing, @as(c_int, subdivs), @as([*c]Vector2, @ptrCast(mouseCell))));
}
/// List View control
pub fn guiListView(bounds: Rectangle, text: [:0]const u8, scrollIndex: *i32, active: *i32) i32 {
pub fn listView(bounds: Rectangle, text: [:0]const u8, scrollIndex: *i32, active: *i32) i32 {
return @as(i32, cdef.GuiListView(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]c_int, @ptrCast(scrollIndex)), @as([*c]c_int, @ptrCast(active))));
}
/// Message Box control, displays a message
pub fn guiMessageBox(bounds: Rectangle, title: [:0]const u8, message: [:0]const u8, buttons: [:0]const u8) i32 {
pub fn messageBox(bounds: Rectangle, title: [:0]const u8, message: [:0]const u8, buttons: [:0]const u8) i32 {
return @as(i32, cdef.GuiMessageBox(bounds, @as([*c]const u8, @ptrCast(title)), @as([*c]const u8, @ptrCast(message)), @as([*c]const u8, @ptrCast(buttons))));
}
/// Text Input Box control, ask for text, supports secret
pub fn guiTextInputBox(bounds: Rectangle, title: [:0]const u8, message: [:0]const u8, buttons: [:0]const u8, text: [:0]u8, textMaxSize: i32, secretViewActive: ?*bool) i32 {
pub fn textInputBox(bounds: Rectangle, title: [:0]const u8, message: [:0]const u8, buttons: [:0]const u8, text: [:0]u8, textMaxSize: i32, secretViewActive: ?*bool) i32 {
return @as(i32, cdef.GuiTextInputBox(bounds, @as([*c]const u8, @ptrCast(title)), @as([*c]const u8, @ptrCast(message)), @as([*c]const u8, @ptrCast(buttons)), @as([*c]u8, @ptrCast(text)), @as(c_int, textMaxSize), @as([*c]bool, @ptrCast(secretViewActive))));
}
/// Color Picker control (multiple color controls)
pub fn guiColorPicker(bounds: Rectangle, text: [:0]const u8, color: *Color) i32 {
pub fn colorPicker(bounds: Rectangle, text: [:0]const u8, color: *Color) i32 {
return @as(i32, cdef.GuiColorPicker(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]Color, @ptrCast(color))));
}
/// Color Panel control
pub fn guiColorPanel(bounds: Rectangle, text: [:0]const u8, color: *Color) i32 {
pub fn colorPanel(bounds: Rectangle, text: [:0]const u8, color: *Color) i32 {
return @as(i32, cdef.GuiColorPanel(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]Color, @ptrCast(color))));
}
/// Color Bar Alpha control
pub fn guiColorBarAlpha(bounds: Rectangle, text: [:0]const u8, alpha: *f32) i32 {
pub fn colorBarAlpha(bounds: Rectangle, text: [:0]const u8, alpha: *f32) i32 {
return @as(i32, cdef.GuiColorBarAlpha(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]f32, @ptrCast(alpha))));
}
/// Color Bar Hue control
pub fn guiColorBarHue(bounds: Rectangle, text: [:0]const u8, value: *f32) i32 {
pub fn colorBarHue(bounds: Rectangle, text: [:0]const u8, value: *f32) i32 {
return @as(i32, cdef.GuiColorBarHue(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]f32, @ptrCast(value))));
}
/// Color Picker control that avoids conversion to RGB on each call (multiple color controls)
pub fn guiColorPickerHSV(bounds: Rectangle, text: [:0]const u8, colorHsv: *Vector3) i32 {
pub fn colorPickerHSV(bounds: Rectangle, text: [:0]const u8, colorHsv: *Vector3) i32 {
return @as(i32, cdef.GuiColorPickerHSV(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]Vector3, @ptrCast(colorHsv))));
}
/// Color Panel control that updates Hue-Saturation-Value color value, used by GuiColorPickerHSV()
pub fn guiColorPanelHSV(bounds: Rectangle, text: [:0]const u8, colorHsv: *Vector3) i32 {
pub fn colorPanelHSV(bounds: Rectangle, text: [:0]const u8, colorHsv: *Vector3) i32 {
return @as(i32, cdef.GuiColorPanelHSV(bounds, @as([*c]const u8, @ptrCast(text)), @as([*c]Vector3, @ptrCast(colorHsv))));
}