chore: update upstream

This commit is contained in:
2023-03-26 19:24:04 -05:00
parent 9491b6193e
commit 7e957cd16b
17 changed files with 1427 additions and 900 deletions

View File

@@ -50,6 +50,17 @@ pub fn deinit() void {
mem_allocator = null;
}
}
pub fn initNoContext(allocator: std.mem.Allocator) void {
if (temp_buffer == null) {
temp_buffer = std.ArrayList(u8).init(allocator);
temp_buffer.?.resize(3 * 1024 + 1) catch unreachable;
}
}
pub fn deinitNoContext() void {
if (temp_buffer) |buf| {
buf.deinit();
}
}
extern fn zguiCreateContext(shared_font_atlas: ?*const anyopaque) Context;
extern fn zguiDestroyContext(ctx: ?Context) void;
extern fn zguiGetCurrentContext() ?Context;
@@ -92,16 +103,17 @@ extern fn zguiSetAllocatorFunctions(
free_func: ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void,
) void;
//--------------------------------------------------------------------------------------------------
pub const ConfigFlags = enum(u32) {
none = 0,
nav_enable_keyboard = 1 << 0,
nav_enable_gamepad = 1 << 1,
nav_enable_set_mouse_pos = 1 << 2,
nav_no_capture_keyboard = 1 << 3,
no_mouse = 1 << 4,
no_mouse_cursor_change = 1 << 5,
is_srgb = 1 << 20,
is_touch_screen = 1 << 21,
pub const ConfigFlags = packed struct(u32) {
nav_enable_keyboard: bool = false,
nav_enable_gamepad: bool = false,
nav_enable_set_mouse_pos: bool = false,
nav_no_capture_keyboard: bool = false,
no_mouse: bool = false,
no_mouse_cursor_change: bool = false,
user_storage: u14 = 0,
is_srgb: bool = false,
is_touch_screen: bool = false,
_padding: u10 = 0,
};
pub const FontConfig = extern struct {
@@ -787,6 +799,9 @@ pub const Style = extern struct {
color_button_position: Direction,
button_text_align: [2]f32,
selectable_text_align: [2]f32,
separator_text_border_size: f32,
separator_text_align: [2]f32,
separator_text_padding: [2]f32,
display_window_padding: [2]f32,
display_safe_area_padding: [2]f32,
mouse_cursor_scale: f32,
@@ -892,9 +907,16 @@ const PopStyleColor = struct {
pub fn popStyleColor(args: PopStyleColor) void {
zguiPopStyleColor(args.count);
}
/// `fn pushTextWrapPos(wrap_pos_x: f32) void`
pub const pushTextWrapPos = zguiPushTextWrapPos;
/// `fn popTextWrapPos() void`
pub const popTextWrapPos = zguiPopTextWrapPos;
extern fn zguiPushStyleColor4f(idx: StyleCol, col: *const [4]f32) void;
extern fn zguiPushStyleColor1u(idx: StyleCol, col: u32) void;
extern fn zguiPopStyleColor(count: i32) void;
extern fn zguiPushTextWrapPos(wrap_pos_x: f32) void;
extern fn zguiPopTextWrapPos() void;
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
pub const StyleVar = enum(u32) {
alpha, // 1f
@@ -922,6 +944,9 @@ pub const StyleVar = enum(u32) {
tab_rounding, // 1f
button_text_align, // 2f
selectable_text_align, // 2f
separator_text_border_size, // 1f
separator_text_align, // 2f
separator_text_padding, // 2f
};
const PushStyleVar1f = struct {
idx: StyleVar,
@@ -972,6 +997,13 @@ extern fn zguiPushFont(font: Font) void;
/// `void popFont() void`
pub const popFont = zguiPopFont;
extern fn zguiPopFont() void;
pub fn getFontTexUvWhitePixel() [2]f32 {
var uv: [2]f32 = undefined;
zguiGetFontTexUvWhitePixel(&uv);
return uv;
}
extern fn zguiGetFontTexUvWhitePixel(uv: *[2]f32) void;
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
const BeginDisabled = struct {
@@ -992,6 +1024,11 @@ extern fn zguiEndDisabled() void;
/// `pub fn separator() void`
pub const separator = zguiSeparator;
extern fn zguiSeparator() void;
pub fn separatorText(label: [:0]const u8) void {
zguiSeparatorText(label);
}
extern fn zguiSeparatorText(label: [*:0]const u8) void;
//--------------------------------------------------------------------------------------------------
const SameLine = struct {
offset_from_start_x: f32 = 0.0,
@@ -2041,6 +2078,7 @@ pub const InputTextFlags = packed struct(u32) {
};
//--------------------------------------------------------------------------------------------------
pub const InputTextCallbackData = extern struct {
ctx: *Context,
event_flag: InputTextFlags,
flags: InputTextFlags,
user_data: ?*anyopaque,
@@ -3047,6 +3085,15 @@ pub fn menuItem(label: [:0]const u8, args: MenuItem) bool {
return zguiMenuItem(label, if (args.shortcut) |s| s.ptr else null, args.selected, args.enabled);
}
const MenuItemPtr = struct {
shortcut: ?[:0]const u8 = null,
selected: *bool,
enabled: bool = true,
};
pub fn menuItemPtr(label: [:0]const u8, args: MenuItemPtr) bool {
return zguiMenuItemPtr(label, if (args.shortcut) |s| s.ptr else null, args.selected, args.enabled);
}
extern fn zguiBeginMenuBar() bool;
extern fn zguiEndMenuBar() void;
extern fn zguiBeginMainMenuBar() bool;
@@ -3054,6 +3101,7 @@ extern fn zguiEndMainMenuBar() void;
extern fn zguiBeginMenu(label: [*:0]const u8, enabled: bool) bool;
extern fn zguiEndMenu() void;
extern fn zguiMenuItem(label: [*:0]const u8, shortcut: ?[*:0]const u8, selected: bool, enabled: bool) bool;
extern fn zguiMenuItemPtr(label: [*:0]const u8, shortcut: ?[*:0]const u8, selected: *bool, enabled: bool) bool;
//--------------------------------------------------------------------------------------------------
//
// Popups
@@ -3063,11 +3111,13 @@ extern fn zguiMenuItem(label: [*:0]const u8, shortcut: ?[*:0]const u8, selected:
pub const beginTooltip = zguiBeginTooltip;
/// `pub fn endTooltip() void`
pub const endTooltip = zguiEndTooltip;
extern fn zguiBeginTooltip() void;
extern fn zguiBeginTooltip() bool;
extern fn zguiEndTooltip() void;
/// `pub fn beginPopupContextWindow() bool`
pub const beginPopupContextWindow = zguiBeginPopupContextWindow;
/// `pub fn beginPopupContextItem() bool`
pub const beginPopupContextItem = zguiBeginPopupContextItem;
pub const PopupFlags = packed struct(u32) {
mouse_button_left: bool = false,
mouse_button_right: bool = false,
@@ -3092,6 +3142,7 @@ pub const endPopup = zguiEndPopup;
/// `pub fn closeCurrentPopup() void`
pub const closeCurrentPopup = zguiCloseCurrentPopup;
extern fn zguiBeginPopupContextWindow() bool;
extern fn zguiBeginPopupContextItem() bool;
extern fn zguiBeginPopupModal(name: [*:0]const u8, popen: ?*bool, flags: WindowFlags) bool;
extern fn zguiEndPopup() void;
extern fn zguiOpenPopup(str_id: [*:0]const u8, flags: PopupFlags) void;
@@ -3323,6 +3374,8 @@ pub const DrawList = *opaque {
extern fn zguiDrawList_GetIndexBufferLength(draw_list: DrawList) i32;
pub const getIndexBufferData = zguiDrawList_GetIndexBufferData;
extern fn zguiDrawList_GetIndexBufferData(draw_list: DrawList) [*]const DrawIdx;
pub const getCurrentIndex = zguiDrawList_GetCurrentIndex;
extern fn zguiDrawList_GetCurrentIndex(draw_list: DrawList) u32;
pub const getCmdBufferLength = zguiDrawList_GetCmdBufferLength;
extern fn zguiDrawList_GetCmdBufferLength(draw_list: DrawList) i32;