diff --git a/bindings.json b/bindings.json index 615db63..4d82da1 100644 --- a/bindings.json +++ b/bindings.json @@ -374,7 +374,7 @@ } ], "returnType": "i32", - "description": "Label control, shows text", + "description": "Label control", "custom": false }, { @@ -406,7 +406,7 @@ } ], "returnType": "i32", - "description": "Label button control, show true when clicked", + "description": "Label button control, returns true when clicked", "custom": false }, { @@ -426,7 +426,7 @@ } ], "returnType": "i32", - "description": "Toggle Button control, returns true when active", + "description": "Toggle Button control", "custom": false }, { @@ -446,7 +446,7 @@ } ], "returnType": "i32", - "description": "Toggle Group control, returns active toggle index", + "description": "Toggle Group control", "custom": false }, { @@ -466,7 +466,7 @@ } ], "returnType": "i32", - "description": "Toggle Slider control, returns true when clicked", + "description": "Toggle Slider control", "custom": false }, { @@ -506,7 +506,7 @@ } ], "returnType": "i32", - "description": "Combo Box control, returns selected item index", + "description": "Combo Box control", "custom": false }, { @@ -530,7 +530,7 @@ } ], "returnType": "i32", - "description": "Dropdown Box control, returns selected item", + "description": "Dropdown Box control", "custom": false }, { @@ -562,7 +562,7 @@ } ], "returnType": "i32", - "description": "Spinner control, returns selected value", + "description": "Spinner control", "custom": false }, { @@ -650,7 +650,7 @@ } ], "returnType": "i32", - "description": "Slider control, returns selected value", + "description": "Slider control", "custom": false }, { @@ -682,7 +682,7 @@ } ], "returnType": "i32", - "description": "Slider Bar control, returns selected value", + "description": "Slider Bar control", "custom": false }, { @@ -714,7 +714,7 @@ } ], "returnType": "i32", - "description": "Progress Bar control, shows current progress value", + "description": "Progress Bar control", "custom": false }, { @@ -774,7 +774,7 @@ } ], "returnType": "i32", - "description": "Grid control, returns mouse cell position", + "description": "Grid control", "custom": false }, { @@ -798,7 +798,7 @@ } ], "returnType": "i32", - "description": "List View control, returns selected list item index", + "description": "List View control", "custom": false }, { @@ -1010,7 +1010,7 @@ } ], "returnType": "i32", - "description": "Color Panel control that returns HSV color value, used by GuiColorPickerHSV()", + "description": "Color Panel control that updates Hue-Saturation-Value color value, used by GuiColorPickerHSV()", "custom": false } ], @@ -2635,17 +2635,17 @@ "description": "" }, { - "name": "ICON_220", + "name": "ICON_WARNING", "value": 220, "description": "" }, { - "name": "ICON_221", + "name": "ICON_HELP_BOX", "value": 221, "description": "" }, { - "name": "ICON_222", + "name": "ICON_INFO_BOX", "value": 222, "description": "" }, @@ -3296,6 +3296,13 @@ "description": "", "custom": false }, + { + "name": "RAYGUI_MIN_MOUSE_WHEEL_SPEED", + "typ": "i32", + "value": "20", + "description": "", + "custom": false + }, { "name": "RAYGUI_TOGGLEGROUP_MAX_ITEMS", "typ": "i32", @@ -3369,7 +3376,7 @@ { "name": "RAYGUI_GRID_ALPHA", "typ": "f32", - "value": "0.15", + "value": "1.5e-1", "description": "", "custom": false }, diff --git a/build.zig b/build.zig index c830f66..e1962c3 100644 --- a/build.zig +++ b/build.zig @@ -10,7 +10,7 @@ pub fn build(b: *std.Build) !void { const jsons = b.step("parse", "parse raygui headers and generate raylib parser output as json"); const raylib_parser_build = b.addExecutable(.{ .name = "raylib_parser", - .root_source_file = std.build.FileSource.relative("raylib_parser.zig"), + .root_source_file = std.Build.LazyPath.relative("raylib_parser.zig"), .target = target, .optimize = .ReleaseFast, }); @@ -31,7 +31,7 @@ pub fn build(b: *std.Build) !void { const intermediate = b.step("intermediate", "generate intermediate representation of the results from 'zig build parse' (keep custom=true)"); var intermediateZig = b.addRunArtifact(b.addExecutable(.{ .name = "intermediate", - .root_source_file = std.build.FileSource.relative("intermediate.zig"), + .root_source_file = std.Build.LazyPath.relative("intermediate.zig"), .target = target, })); intermediate.dependOn(&intermediateZig.step); @@ -40,7 +40,7 @@ pub fn build(b: *std.Build) !void { const bindings = b.step("bindings", "generate bindings in from bindings.json"); var generateZig = b.addRunArtifact(b.addExecutable(.{ .name = "generate", - .root_source_file = std.build.FileSource.relative("generate.zig"), + .root_source_file = std.Build.LazyPath.relative("generate.zig"), .target = target, })); const fmt = b.addFmt(.{ .paths = &.{generate.outputFile} }); @@ -65,22 +65,34 @@ const sep = std.fs.path.sep_str; const dir_raygui = cwd ++ sep ++ "raygui/src"; /// add this package to lib -pub fn addTo(b: *std.Build, lib: *std.Build.Step.Compile, target: std.Target.Query, optimize: std.builtin.Mode) void { - _ = b; - _ = optimize; - _ = target; - +pub fn addTo( + b: *std.Build, + lib: *std.Build.Step.Compile, + target: std.Target.Query, + optimize: std.builtin.Mode, +) void { if (lib.root_module.import_table.get("raylib") orelse lib.root_module.import_table.get("raylib.zig") orelse lib.root_module.import_table.get("raylib-zig")) |raylib| { - lib.root_module.addAnonymousImport("raygui", .{ - .root_source_file = .{ .path = cwd ++ sep ++ "raygui.zig" }, - .imports = &.{ - .{ .name = "raylib", .module = raylib }, + const rayguiLib = b.addStaticLibrary( + .{ + .name = "raygui.zig", + .target = b.resolveTargetQuery(target), + .optimize = optimize, + .root_source_file = .{ .path = cwd ++ sep ++ "raygui.zig" }, }, - }); - lib.addIncludePath(.{ .path = dir_raygui }); - lib.addIncludePath(.{ .path = cwd }); - lib.linkLibC(); - lib.addCSourceFile(.{ .file = .{ .path = cwd ++ sep ++ "raygui_marshal.c" }, .flags = &.{"-DRAYGUI_IMPLEMENTATION"} }); + ); + + rayguiLib.linkLibC(); + + for (raylib.include_dirs.items) |includedItem| { + rayguiLib.addIncludePath(includedItem.path); + } + + rayguiLib.addIncludePath(.{ .path = dir_raygui }); + rayguiLib.addIncludePath(.{ .path = cwd }); + rayguiLib.addCSourceFile(.{ .file = .{ .path = cwd ++ sep ++ "raygui_marshal.c" }, .flags = &.{"-DRAYGUI_IMPLEMENTATION"} }); + rayguiLib.root_module.addImport("raylib", raylib); + + lib.root_module.addImport("raygui", &rayguiLib.root_module); } else { std.debug.panic("lib needs to have 'raylib', 'raylib.zig' or 'raylib-zig' as module dependency", .{}); } diff --git a/generate.zig b/generate.zig index fa044f0..ca4bd3e 100644 --- a/generate.zig +++ b/generate.zig @@ -177,7 +177,7 @@ fn writeFunctions( //--- body ------------------------------ if (isPointer(func.returnType)) { - try file.writeAll(try allocPrint(allocator, "return @ptrCast({s},\n", .{func.returnType})); + try file.writeAll(try allocPrint(allocator, "return @as({s},@ptrCast(\n", .{func.returnType})); } else if (isPrimitiveOrPointer(func.returnType)) { try file.writeAll("return "); } else if (!returnTypeIsVoid) { @@ -187,9 +187,9 @@ fn writeFunctions( if (!isPrimitiveOrPointer(func.returnType)) { if (bindings.containsStruct(stripType(func.returnType))) { - try file.writeAll(try allocPrint(allocator, "@ptrCast([*c]raygui.{s}, &out),\n", .{func.returnType})); + try file.writeAll(try allocPrint(allocator, "@as([*c]raygui.{s}, @ptrCast(&out)),\n", .{func.returnType})); } else if (!returnTypeIsVoid) { - try file.writeAll(try allocPrint(allocator, "@ptrCast([*c]{s}, &out),\n", .{func.returnType})); + try file.writeAll(try allocPrint(allocator, "@as([*c]{s}, @ptrCast(&out)),\n", .{func.returnType})); } } @@ -197,16 +197,18 @@ fn writeFunctions( if (isFunctionPointer(param.typ)) { try file.writeAll(try allocPrint(allocator, "@ptrCast({s}),\n", .{param.name})); } else if (bindings.containsStruct(stripType(param.typ)) and isPointer(param.typ)) { - try file.writeAll(try allocPrint(allocator, "@intToPtr([*c]raygui.{s}, @ptrToInt({s})),\n", .{ stripType(param.typ), param.name })); + try file.writeAll(try allocPrint(allocator, "@as([*c]raygui.{s}, @ptrFromInt(@intFromPtr({s}))),\n", .{ stripType(param.typ), param.name })); } else if (bindings.containsEnum(param.typ)) { - try file.writeAll(try allocPrint(allocator, "@enumToInt({s}),\n", .{param.name})); + try file.writeAll(try allocPrint(allocator, "@intFromEnum({s}),\n", .{param.name})); } else if (bindings.containsStruct(stripType(param.typ))) { - try file.writeAll(try allocPrint(allocator, "@intToPtr([*c]raygui.{s}, @ptrToInt(&{s})),\n", .{ stripType(param.typ), param.name })); + try file.writeAll(try allocPrint(allocator, "@as([*c]raygui.{s}, @ptrFromInt(@intFromPtr(&{s}))),\n", .{ stripType(param.typ), param.name })); } else if (isPointer(param.typ)) { - if (isConst(param.typ)) { - try file.writeAll(try allocPrint(allocator, "@intToPtr([*c]const {s}, @ptrToInt({s})),\n", .{ stripType(param.typ), param.name })); + if (std.mem.endsWith(u8, param.typ, "anyopaque")) { + try file.writeAll(try allocPrint(allocator, "{s},\n", .{param.name})); + } else if (isConst(param.typ)) { + try file.writeAll(try allocPrint(allocator, "@as([*c]const {s}, @ptrFromInt(@intFromPtr({s}))),\n", .{ stripType(param.typ), param.name })); } else { - try file.writeAll(try allocPrint(allocator, "@ptrCast([*c]{s}, {s}),\n", .{ stripType(param.typ), param.name })); + try file.writeAll(try allocPrint(allocator, "@as([*c]{s}, @ptrCast({s})),\n", .{ stripType(param.typ), param.name })); } } else { try file.writeAll(try allocPrint(allocator, "{s},\n", .{param.name})); @@ -214,7 +216,7 @@ fn writeFunctions( } if (isPointer(func.returnType)) { - try file.writeAll("),\n);\n"); + try file.writeAll("),\n));\n"); } else { try file.writeAll(");\n"); } diff --git a/raygui b/raygui index 45e7f96..176ab3d 160000 --- a/raygui +++ b/raygui @@ -1 +1 @@ -Subproject commit 45e7f967e62088b9fec02ac38c07d4b67d6466b0 +Subproject commit 176ab3db60e1c61fb33bc5e0cbba98adf054cd5e diff --git a/raygui.json b/raygui.json index 32f83e0..6f45b22 100644 --- a/raygui.json +++ b/raygui.json @@ -9,19 +9,19 @@ { "name": "RAYGUI_VERSION_MAJOR", "type": "INT", - "value": "4", + "value": 4, "description": "" }, { "name": "RAYGUI_VERSION_MINOR", "type": "INT", - "value": "0", + "value": 0, "description": "" }, { "name": "RAYGUI_VERSION_PATCH", "type": "INT", - "value": "0", + "value": 0, "description": "" }, { @@ -69,13 +69,13 @@ { "name": "SCROLLBAR_LEFT_SIDE", "type": "INT", - "value": "0", + "value": 0, "description": "" }, { "name": "SCROLLBAR_RIGHT_SIDE", "type": "INT", - "value": "1", + "value": 1, "description": "" }, { @@ -93,19 +93,19 @@ { "name": "RAYGUI_ICON_SIZE", "type": "INT", - "value": "16", + "value": 16, "description": "Size of icons in pixels (squared)" }, { "name": "RAYGUI_ICON_MAX_ICONS", "type": "INT", - "value": "256", + "value": 256, "description": "Maximum number of icons" }, { "name": "RAYGUI_ICON_MAX_NAME_LENGTH", "type": "INT", - "value": "32", + "value": 32, "description": "Maximum length of icon name id" }, { @@ -117,181 +117,187 @@ { "name": "RAYGUI_MAX_CONTROLS", "type": "INT", - "value": "16", + "value": 16, "description": "Maximum number of controls" }, { "name": "RAYGUI_MAX_PROPS_BASE", "type": "INT", - "value": "16", + "value": 16, "description": "Maximum number of base properties" }, { "name": "RAYGUI_MAX_PROPS_EXTENDED", "type": "INT", - "value": "8", + "value": 8, "description": "Maximum number of extended properties" }, { "name": "KEY_RIGHT", "type": "INT", - "value": "262", + "value": 262, "description": "" }, { "name": "KEY_LEFT", "type": "INT", - "value": "263", + "value": 263, "description": "" }, { "name": "KEY_DOWN", "type": "INT", - "value": "264", + "value": 264, "description": "" }, { "name": "KEY_UP", "type": "INT", - "value": "265", + "value": 265, "description": "" }, { "name": "KEY_BACKSPACE", "type": "INT", - "value": "259", + "value": 259, "description": "" }, { "name": "KEY_ENTER", "type": "INT", - "value": "257", + "value": 257, "description": "" }, { "name": "MOUSE_LEFT_BUTTON", "type": "INT", - "value": "0", + "value": 0, "description": "" }, { "name": "RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT", "type": "INT", - "value": "24", + "value": 24, "description": "" }, { "name": "RAYGUI_GROUPBOX_LINE_THICK", "type": "INT", - "value": "1", + "value": 1, "description": "" }, { "name": "RAYGUI_LINE_MARGIN_TEXT", "type": "INT", - "value": "12", + "value": 12, "description": "" }, { "name": "RAYGUI_LINE_TEXT_PADDING", "type": "INT", - "value": "4", + "value": 4, "description": "" }, { "name": "RAYGUI_PANEL_BORDER_WIDTH", "type": "INT", - "value": "1", + "value": 1, "description": "" }, { "name": "RAYGUI_TABBAR_ITEM_WIDTH", "type": "INT", - "value": "160", + "value": 160, "description": "" }, { "name": "RAYGUI_MIN_SCROLLBAR_WIDTH", "type": "INT", - "value": "40", + "value": 40, "description": "" }, { "name": "RAYGUI_MIN_SCROLLBAR_HEIGHT", "type": "INT", - "value": "40", + "value": 40, + "description": "" + }, + { + "name": "RAYGUI_MIN_MOUSE_WHEEL_SPEED", + "type": "INT", + "value": 20, "description": "" }, { "name": "RAYGUI_TOGGLEGROUP_MAX_ITEMS", "type": "INT", - "value": "32", + "value": 32, "description": "" }, { "name": "RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN", "type": "INT", - "value": "40", + "value": 40, "description": "Frames to wait for autocursor movement" }, { "name": "RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY", "type": "INT", - "value": "1", + "value": 1, "description": "Frames delay for autocursor movement" }, { "name": "RAYGUI_VALUEBOX_MAX_CHARS", "type": "INT", - "value": "32", + "value": 32, "description": "" }, { "name": "RAYGUI_COLORBARALPHA_CHECKED_SIZE", "type": "INT", - "value": "10", + "value": 10, "description": "" }, { "name": "RAYGUI_MESSAGEBOX_BUTTON_HEIGHT", "type": "INT", - "value": "24", + "value": 24, "description": "" }, { "name": "RAYGUI_MESSAGEBOX_BUTTON_PADDING", "type": "INT", - "value": "12", + "value": 12, "description": "" }, { "name": "RAYGUI_TEXTINPUTBOX_BUTTON_HEIGHT", "type": "INT", - "value": "24", + "value": 24, "description": "" }, { "name": "RAYGUI_TEXTINPUTBOX_BUTTON_PADDING", "type": "INT", - "value": "12", + "value": 12, "description": "" }, { "name": "RAYGUI_TEXTINPUTBOX_HEIGHT", "type": "INT", - "value": "26", + "value": 26, "description": "" }, { "name": "RAYGUI_GRID_ALPHA", "type": "FLOAT", - "value": "0.15", + "value": 0.15, "description": "" }, { "name": "MAX_LINE_BUFFER_SIZE", "type": "INT", - "value": "256", + "value": 256, "description": "" }, { @@ -303,13 +309,13 @@ { "name": "ICON_TEXT_PADDING", "type": "INT", - "value": "4", + "value": 4, "description": "" }, { "name": "RAYGUI_MAX_TEXT_LINES", "type": "INT", - "value": "128", + "value": 128, "description": "" }, { @@ -321,19 +327,19 @@ { "name": "RAYGUI_TEXTSPLIT_MAX_ITEMS", "type": "INT", - "value": "128", + "value": 128, "description": "" }, { "name": "RAYGUI_TEXTSPLIT_MAX_TEXT_SIZE", "type": "INT", - "value": "1024", + "value": 1024, "description": "" }, { "name": "RAYGUI_TEXTFORMAT_MAX_SIZE", "type": "INT", - "value": "256", + "value": 256, "description": "" } ], @@ -2220,17 +2226,17 @@ "description": "" }, { - "name": "ICON_220", + "name": "ICON_WARNING", "value": 220, "description": "" }, { - "name": "ICON_221", + "name": "ICON_HELP_BOX", "value": 221, "description": "" }, { - "name": "ICON_222", + "name": "ICON_INFO_BOX", "value": 222, "description": "" }, @@ -2729,7 +2735,7 @@ }, { "name": "GuiLabel", - "description": "Label control, shows text", + "description": "Label control", "returnType": "int", "params": [ { @@ -2759,7 +2765,7 @@ }, { "name": "GuiLabelButton", - "description": "Label button control, show true when clicked", + "description": "Label button control, returns true when clicked", "returnType": "int", "params": [ { @@ -2774,7 +2780,7 @@ }, { "name": "GuiToggle", - "description": "Toggle Button control, returns true when active", + "description": "Toggle Button control", "returnType": "int", "params": [ { @@ -2793,7 +2799,7 @@ }, { "name": "GuiToggleGroup", - "description": "Toggle Group control, returns active toggle index", + "description": "Toggle Group control", "returnType": "int", "params": [ { @@ -2812,7 +2818,7 @@ }, { "name": "GuiToggleSlider", - "description": "Toggle Slider control, returns true when clicked", + "description": "Toggle Slider control", "returnType": "int", "params": [ { @@ -2850,7 +2856,7 @@ }, { "name": "GuiComboBox", - "description": "Combo Box control, returns selected item index", + "description": "Combo Box control", "returnType": "int", "params": [ { @@ -2869,7 +2875,7 @@ }, { "name": "GuiDropdownBox", - "description": "Dropdown Box control, returns selected item", + "description": "Dropdown Box control", "returnType": "int", "params": [ { @@ -2892,7 +2898,7 @@ }, { "name": "GuiSpinner", - "description": "Spinner control, returns selected value", + "description": "Spinner control", "returnType": "int", "params": [ { @@ -2977,7 +2983,7 @@ }, { "name": "GuiSlider", - "description": "Slider control, returns selected value", + "description": "Slider control", "returnType": "int", "params": [ { @@ -3008,7 +3014,7 @@ }, { "name": "GuiSliderBar", - "description": "Slider Bar control, returns selected value", + "description": "Slider Bar control", "returnType": "int", "params": [ { @@ -3039,7 +3045,7 @@ }, { "name": "GuiProgressBar", - "description": "Progress Bar control, shows current progress value", + "description": "Progress Bar control", "returnType": "int", "params": [ { @@ -3100,7 +3106,7 @@ }, { "name": "GuiGrid", - "description": "Grid control, returns mouse cell position", + "description": "Grid control", "returnType": "int", "params": [ { @@ -3127,7 +3133,7 @@ }, { "name": "GuiListView", - "description": "List View control, returns selected list item index", + "description": "List View control", "returnType": "int", "params": [ { @@ -3334,7 +3340,7 @@ }, { "name": "GuiColorPanelHSV", - "description": "Color Panel control that returns HSV color value, used by GuiColorPickerHSV()", + "description": "Color Panel control that updates Hue-Saturation-Value color value, used by GuiColorPickerHSV()", "returnType": "int", "params": [ { diff --git a/raygui.zig b/raygui.zig index 0363212..27d8066 100644 --- a/raygui.zig +++ b/raygui.zig @@ -1,9 +1,9 @@ const std = @import("std"); +const raylib = @import("raylib"); const raygui = @cImport({ @cInclude("raygui.h"); @cInclude("raygui_marshal.h"); }); -const raylib = @import("raylib"); pub const Rectangle = raylib.Rectangle; pub const Vector2 = raylib.Vector2; @@ -197,13 +197,12 @@ pub fn GuiIconText( iconId: i32, text: [*:0]const u8, ) [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raygui.mGuiIconText( + return @as([*:0]const u8, @ptrCast( + raygui.mGuiIconText( iconId, @as([*c]const u8, @ptrFromInt(@intFromPtr(text))), - )), - ); + ), + )); } /// Set default icon drawing size @@ -217,10 +216,9 @@ pub fn GuiSetIconScale( /// Get raygui icons data pointer pub fn GuiGetIcons() *u32 { - return @as( - *u32, - @ptrCast(raygui.mGuiGetIcons()), - ); + return @as(*u32, @ptrCast( + raygui.mGuiGetIcons(), + )); } /// Load raygui icons file (.rgi) into internal icons data @@ -228,13 +226,12 @@ pub fn GuiLoadIcons( fileName: [*:0]const u8, loadIconsName: bool, ) [*][*:0]u8 { - return @as( - [*][*:0]u8, - @ptrCast(raygui.mGuiLoadIcons( + return @as([*][*:0]u8, @ptrCast( + raygui.mGuiLoadIcons( @as([*c]const u8, @ptrFromInt(@intFromPtr(fileName))), loadIconsName, - )), - ); + ), + )); } /// Window Box control, shows a window that can be closed @@ -313,7 +310,7 @@ pub fn GuiScrollPanel( ); } -/// Label control, shows text +/// Label control pub fn GuiLabel( bounds: Rectangle, text: [*:0]const u8, @@ -335,7 +332,7 @@ pub fn GuiButton( ); } -/// Label button control, show true when clicked +/// Label button control, returns true when clicked pub fn GuiLabelButton( bounds: Rectangle, text: [*:0]const u8, @@ -346,7 +343,7 @@ pub fn GuiLabelButton( ); } -/// Toggle Button control, returns true when active +/// Toggle Button control pub fn GuiToggle( bounds: Rectangle, text: [*:0]const u8, @@ -359,7 +356,7 @@ pub fn GuiToggle( ); } -/// Toggle Group control, returns active toggle index +/// Toggle Group control pub fn GuiToggleGroup( bounds: Rectangle, text: [*:0]const u8, @@ -372,7 +369,7 @@ pub fn GuiToggleGroup( ); } -/// Toggle Slider control, returns true when clicked +/// Toggle Slider control pub fn GuiToggleSlider( bounds: Rectangle, text: [*:0]const u8, @@ -398,7 +395,7 @@ pub fn GuiCheckBox( ); } -/// Combo Box control, returns selected item index +/// Combo Box control pub fn GuiComboBox( bounds: Rectangle, text: [*:0]const u8, @@ -411,7 +408,7 @@ pub fn GuiComboBox( ); } -/// Dropdown Box control, returns selected item +/// Dropdown Box control pub fn GuiDropdownBox( bounds: Rectangle, text: [*:0]const u8, @@ -426,7 +423,7 @@ pub fn GuiDropdownBox( ); } -/// Spinner control, returns selected value +/// Spinner control pub fn GuiSpinner( bounds: Rectangle, text: [*:0]const u8, @@ -479,7 +476,7 @@ pub fn GuiTextBox( ); } -/// Slider control, returns selected value +/// Slider control pub fn GuiSlider( bounds: Rectangle, textLeft: [*:0]const u8, @@ -498,7 +495,7 @@ pub fn GuiSlider( ); } -/// Slider Bar control, returns selected value +/// Slider Bar control pub fn GuiSliderBar( bounds: Rectangle, textLeft: [*:0]const u8, @@ -517,7 +514,7 @@ pub fn GuiSliderBar( ); } -/// Progress Bar control, shows current progress value +/// Progress Bar control pub fn GuiProgressBar( bounds: Rectangle, textLeft: [*:0]const u8, @@ -558,7 +555,7 @@ pub fn GuiDummyRec( ); } -/// Grid control, returns mouse cell position +/// Grid control pub fn GuiGrid( bounds: Rectangle, text: [*:0]const u8, @@ -575,7 +572,7 @@ pub fn GuiGrid( ); } -/// List View control, returns selected list item index +/// List View control pub fn GuiListView( bounds: Rectangle, text: [*:0]const u8, @@ -710,7 +707,7 @@ pub fn GuiColorPickerHSV( ); } -/// Color Panel control that returns HSV color value, used by GuiColorPickerHSV() +/// Color Panel control that updates Hue-Saturation-Value color value, used by GuiColorPickerHSV() pub fn GuiColorPanelHSV( bounds: Rectangle, text: [*:0]const u8, @@ -1488,11 +1485,11 @@ pub const GuiIconName = enum(i32) { /// ICON_SAND_TIMER = 219, /// - ICON_220 = 220, + ICON_WARNING = 220, /// - ICON_221 = 221, + ICON_HELP_BOX = 221, /// - ICON_222 = 222, + ICON_INFO_BOX = 222, /// ICON_223 = 223, /// @@ -1642,6 +1639,9 @@ pub const RAYGUI_MIN_SCROLLBAR_WIDTH: i32 = 40; /// pub const RAYGUI_MIN_SCROLLBAR_HEIGHT: i32 = 40; +/// +pub const RAYGUI_MIN_MOUSE_WHEEL_SPEED: i32 = 20; + /// pub const RAYGUI_TOGGLEGROUP_MAX_ITEMS: i32 = 32; @@ -1673,7 +1673,7 @@ pub const RAYGUI_TEXTINPUTBOX_BUTTON_PADDING: i32 = 12; pub const RAYGUI_TEXTINPUTBOX_HEIGHT: i32 = 26; /// -pub const RAYGUI_GRID_ALPHA: f32 = 0.15; +pub const RAYGUI_GRID_ALPHA: f32 = 1.5e-1; /// pub const MAX_LINE_BUFFER_SIZE: i32 = 256; diff --git a/raygui_marshal.h b/raygui_marshal.h index f4cfd77..05caf9a 100644 --- a/raygui_marshal.h +++ b/raygui_marshal.h @@ -81,34 +81,34 @@ int mGuiTabBar(Rectangle *bounds, const char ** text, int count, int * active); // Scroll Panel control int mGuiScrollPanel(Rectangle *bounds, const char * text, Rectangle *content, Vector2 * scroll, Rectangle * view); -// Label control, shows text +// Label control int mGuiLabel(Rectangle *bounds, const char * text); // Button control, returns true when clicked int mGuiButton(Rectangle *bounds, const char * text); -// Label button control, show true when clicked +// Label button control, returns true when clicked int mGuiLabelButton(Rectangle *bounds, const char * text); -// Toggle Button control, returns true when active +// Toggle Button control int mGuiToggle(Rectangle *bounds, const char * text, bool * active); -// Toggle Group control, returns active toggle index +// Toggle Group control int mGuiToggleGroup(Rectangle *bounds, const char * text, int * active); -// Toggle Slider control, returns true when clicked +// Toggle Slider control int mGuiToggleSlider(Rectangle *bounds, const char * text, int * active); // Check Box control, returns true when active int mGuiCheckBox(Rectangle *bounds, const char * text, bool * checked); -// Combo Box control, returns selected item index +// Combo Box control int mGuiComboBox(Rectangle *bounds, const char * text, int * active); -// Dropdown Box control, returns selected item +// Dropdown Box control int mGuiDropdownBox(Rectangle *bounds, const char * text, int * active, bool editMode); -// Spinner control, returns selected value +// Spinner control int mGuiSpinner(Rectangle *bounds, const char * text, int * value, int minValue, int maxValue, bool editMode); // Value Box control, updates input text with numbers @@ -117,13 +117,13 @@ int mGuiValueBox(Rectangle *bounds, const char * text, int * value, int minValue // Text Box control, updates input text int mGuiTextBox(Rectangle *bounds, char * text, int textSize, bool editMode); -// Slider control, returns selected value +// Slider control int mGuiSlider(Rectangle *bounds, const char * textLeft, const char * textRight, float * value, float minValue, float maxValue); -// Slider Bar control, returns selected value +// Slider Bar control int mGuiSliderBar(Rectangle *bounds, const char * textLeft, const char * textRight, float * value, float minValue, float maxValue); -// Progress Bar control, shows current progress value +// Progress Bar control int mGuiProgressBar(Rectangle *bounds, const char * textLeft, const char * textRight, float * value, float minValue, float maxValue); // Status Bar control, shows info text @@ -132,10 +132,10 @@ int mGuiStatusBar(Rectangle *bounds, const char * text); // Dummy control for placeholders int mGuiDummyRec(Rectangle *bounds, const char * text); -// Grid control, returns mouse cell position +// Grid control int mGuiGrid(Rectangle *bounds, const char * text, float spacing, int subdivs, Vector2 * mouseCell); -// List View control, returns selected list item index +// List View control int mGuiListView(Rectangle *bounds, const char * text, int * scrollIndex, int * active); // List View with extended parameters @@ -162,6 +162,6 @@ int mGuiColorBarHue(Rectangle *bounds, const char * text, float * value); // Color Picker control that avoids conversion to RGB on each call (multiple color controls) int mGuiColorPickerHSV(Rectangle *bounds, const char * text, Vector3 * colorHsv); -// Color Panel control that returns HSV color value, used by GuiColorPickerHSV() +// Color Panel control that updates Hue-Saturation-Value color value, used by GuiColorPickerHSV() int mGuiColorPanelHSV(Rectangle *bounds, const char * text, Vector3 * colorHsv); diff --git a/type_mapping.zig b/type_mapping.zig index f53f7c9..ff3c1ef 100644 --- a/type_mapping.zig +++ b/type_mapping.zig @@ -85,7 +85,7 @@ pub const Intermediate = struct { continue :outer; } } - const define = parseRaylibDefine(allocator, d) orelse continue :outer; + const define = try parseRaylibDefine(allocator, d) orelse continue :outer; if (i < defines.items.len) { try defines.insert(i, define); @@ -248,31 +248,38 @@ pub const Define = struct { custom: bool = false, }; -pub fn parseRaylibDefine(allocator: Allocator, s: RaylibDefine) ?Define { +pub fn parseRaylibDefine(allocator: Allocator, s: RaylibDefine) !?Define { var typ: []const u8 = undefined; var value: []const u8 = undefined; + const strValue = try jsonStringify(allocator, s.value); + defer allocator.free(strValue); if (eql("INT", s.type)) { typ = "i32"; - value = std.fmt.allocPrint(allocator, "{s}", .{s.value}) catch return null; + std.debug.print("i32: {s}", .{strValue}); + value = std.fmt.allocPrint(allocator, "{s}", .{strValue}) catch return null; } else if (eql("LONG", s.type)) { typ = "i64"; - value = std.fmt.allocPrint(allocator, "{s}", .{s.value}) catch return null; + std.debug.print("i64: {s}", .{strValue}); + value = std.fmt.allocPrint(allocator, "{s}", .{strValue}) catch return null; } else if (eql("FLOAT", s.type)) { typ = "f32"; - value = std.fmt.allocPrint(allocator, "{s}", .{s.value}) catch return null; + std.debug.print("f32: {s}", .{strValue}); + value = std.fmt.allocPrint(allocator, "{s}", .{strValue}) catch return null; } else if (eql("DOUBLE", s.type)) { typ = "f64"; - value = std.fmt.allocPrint(allocator, "{s}", .{s.value}) catch return null; + std.debug.print("f64: {s}", .{strValue}); + value = std.fmt.allocPrint(allocator, "{s}", .{strValue}) catch return null; } else if (eql("STRING", s.type)) { typ = "[]const u8"; - value = std.fmt.allocPrint(allocator, "\"{s}\"", .{s.value}) catch return null; + std.debug.print("[]const u8: {s}", .{strValue}); + value = std.fmt.allocPrint(allocator, "\"{s}\"", .{strValue}) catch return null; } else if (eql("COLOR", s.type)) { typ = "Color"; - std.debug.assert(startsWith(s.value, "CLITERAL(Color){")); - std.debug.assert(endsWith(s.value, "}")); + std.debug.assert(startsWith(strValue, "CLITERAL(Color){")); + std.debug.assert(endsWith(strValue, "}")); - const componentString = s.value["CLITERAL(Color){".len .. s.value.len - 1]; + const componentString = strValue["CLITERAL(Color){".len .. strValue.len - 1]; var spliterator = std.mem.split(u8, componentString, ","); var r = spliterator.next() orelse return null; r = std.mem.trim(u8, r, " \t\r\n"); @@ -654,7 +661,7 @@ pub const RaylibFunctionParam = struct { pub const RaylibDefine = struct { name: []const u8, type: []const u8, - value: []const u8, + value: std.json.Value, description: ?[]const u8 = null, }; @@ -692,3 +699,8 @@ fn startsWith(haystack: []const u8, needle: []const u8) bool { fn endsWith(haystack: []const u8, needle: []const u8) bool { return std.mem.endsWith(u8, haystack, needle); } + +fn jsonStringify(allocator: Allocator, value: std.json.Value) ![]const u8 { + const jsonString = try json.stringifyAlloc(allocator, value, .{}); + return std.mem.trim(u8, jsonString, "\""); +}