Skip to content

Commit a178125

Browse files
Nefistofelesckrowland
authored andcommitted
Added some necessary functions (zig-gamedev#41)
1 parent cee7e99 commit a178125

File tree

2 files changed

+206
-0
lines changed

2 files changed

+206
-0
lines changed

src/gui.zig

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,9 @@ pub fn setNextWindowSize(args: SetNextWindowSize) void {
698698
}
699699
extern fn zguiSetNextWindowSize(w: f32, h: f32, cond: Condition) void;
700700
//--------------------------------------------------------------------------------------------------
701+
extern fn zguiSetNextWindowContentSize(w: f32, h: f32) void;
702+
pub const setNextWindowContentSize = zguiSetNextWindowContentSize;
703+
//--------------------------------------------------------------------------------------------------
701704
const SetNextWindowCollapsed = struct {
702705
collapsed: bool,
703706
cond: Condition = .none,
@@ -711,6 +714,9 @@ extern fn zguiSetNextWindowCollapsed(collapsed: bool, cond: Condition) void;
711714
pub const setNextWindowFocus = zguiSetNextWindowFocus;
712715
extern fn zguiSetNextWindowFocus() void;
713716
//--------------------------------------------------------------------------------------------------
717+
extern fn zguiSetNextWindowScroll(scroll_x: f32, scroll_y: f32) void;
718+
pub const setNextWindowScroll = zguiSetNextWindowScroll;
719+
//--------------------------------------------------------------------------------------------------
714720
const SetNextWindowBgAlpha = struct {
715721
alpha: f32,
716722
};
@@ -724,11 +730,19 @@ pub fn setWindowFocus(name: ?[:0]const u8) void {
724730
}
725731
extern fn zguiSetWindowFocus(name: ?[*:0]const u8) void;
726732
//-------------------------------------------------------------------------------------------------
733+
extern fn zguiSetWindowFontScale(scale: f32) void;
734+
pub const setWindowFontScale = zguiSetWindowFontScale;
735+
//-------------------------------------------------------------------------------------------------
727736
pub fn setKeyboardFocusHere(offset: i32) void {
728737
zguiSetKeyboardFocusHere(offset);
729738
}
730739
extern fn zguiSetKeyboardFocusHere(offset: c_int) void;
731740

741+
extern fn zguiSetNavCursorVisible(visible: bool) void;
742+
pub const setNavCursorVisible = zguiSetNavCursorVisible;
743+
744+
extern fn zguiSetNextItemAllowOverlap() void;
745+
pub const setNextItemAllowOverlap = zguiSetNextItemAllowOverlap;
732746
//--------------------------------------------------------------------------------------------------
733747
const Begin = struct {
734748
popen: ?*bool = null,
@@ -1456,6 +1470,9 @@ pub const getMouseCursor = zguiGetMouseCursor;
14561470
pub const setMouseCursor = zguiSetMouseCursor;
14571471
extern fn zguiGetMouseCursor() Cursor;
14581472
extern fn zguiSetMouseCursor(cursor: Cursor) void;
1473+
1474+
extern fn zguiSetNextFrameWantCaptureMouse(want_capture_mouse: bool) void;
1475+
pub const setNextFrameWantCaptureMouse = zguiSetNextFrameWantCaptureMouse;
14591476
//--------------------------------------------------------------------------------------------------
14601477
pub fn getMousePos() [2]f32 {
14611478
var pos: [2]f32 = undefined;
@@ -1745,6 +1762,13 @@ pub fn progressBar(args: ProgressBar) void {
17451762
zguiProgressBar(args.fraction, args.w, args.h, if (args.overlay) |o| o else null);
17461763
}
17471764
extern fn zguiProgressBar(fraction: f32, w: f32, h: f32, overlay: ?[*:0]const u8) void;
1765+
//--------------------------------------------------------------------------------------------------
1766+
extern fn zguiTextLink(label: [*:0]const u8) bool;
1767+
pub const textLink = zguiTextLink;
1768+
1769+
extern fn zguiTextLinkOpenURL(label: [*:0]const u8, url: ?[*:0]const u8) void;
1770+
pub const textLinkOpenURL = zguiTextLinkOpenURL;
1771+
17481772
//--------------------------------------------------------------------------------------------------
17491773
//
17501774
// Widgets: Combo Box
@@ -2994,6 +3018,9 @@ extern fn zguiTreePushPtrId(ptr_id: *const anyopaque) void;
29943018
pub const treePop = zguiTreePop;
29953019
extern fn zguiTreePop() void;
29963020
//--------------------------------------------------------------------------------------------------
3021+
extern fn zguiGetTreeNodeToLabelSpacing() f32;
3022+
pub const getTreeNodeToLabelSpacing = zguiGetTreeNodeToLabelSpacing;
3023+
//--------------------------------------------------------------------------------------------------
29973024
const CollapsingHeaderStatePtr = struct {
29983025
pvisible: *bool,
29993026
flags: TreeNodeFlags = .{},
@@ -3079,6 +3106,15 @@ pub fn beginListBox(label: [:0]const u8, args: BeginListBox) bool {
30793106
pub const endListBox = zguiEndListBox;
30803107
extern fn zguiBeginListBox(label: [*:0]const u8, w: f32, h: f32) bool;
30813108
extern fn zguiEndListBox() void;
3109+
extern fn zguiListBox(label: [*:0]const u8, current_item: *i32, items: [*]const [*:0]const u8, item_count: i32, height_in_items: i32) bool;
3110+
pub const ListBox = struct {
3111+
current_item: *i32,
3112+
items: []const [*:0]const u8,
3113+
height_in_items: i32 = -1,
3114+
};
3115+
pub fn listBox(label: [*:0]const u8, args: ListBox) bool {
3116+
return zguiListBox(label, args.current_item, args.items.ptr, @intCast(args.items.len), args.height_in_items);
3117+
}
30823118
//--------------------------------------------------------------------------------------------------
30833119
//
30843120
// Widgets: Tables
@@ -3312,6 +3348,9 @@ extern fn zguiTableGetColumnFlags(column_n: i32) TableColumnFlags;
33123348
pub const tableSetColumnEnabled = zguiTableSetColumnEnabled;
33133349
extern fn zguiTableSetColumnEnabled(column_n: i32, v: bool) void;
33143350

3351+
extern fn zguiTableGetHoveredColumn() i32;
3352+
pub const tableGetHoveredColumn = zguiTableGetHoveredColumn;
3353+
33153354
pub fn tableSetBgColor(args: struct {
33163355
target: TableBgTarget,
33173356
color: u32,
@@ -3321,6 +3360,37 @@ pub fn tableSetBgColor(args: struct {
33213360
}
33223361
extern fn zguiTableSetBgColor(target: TableBgTarget, color: c_uint, column_n: c_int) void;
33233362

3363+
pub const Columns = struct {
3364+
count: i32 = 1,
3365+
id: ?[*:0]const u8 = null,
3366+
borders: bool = true,
3367+
};
3368+
extern fn zguiColumns(count: i32, id: ?[*:0]const u8, borders: bool) void;
3369+
pub fn columns(args: Columns) void {
3370+
zguiColumns(args.count, args.id, args.borders);
3371+
}
3372+
3373+
extern fn zguiNextColumn() void;
3374+
pub const nextColumn = zguiNextColumn;
3375+
3376+
extern fn zguiGetColumnIndex() i32;
3377+
pub const getColumnIndex = zguiGetColumnIndex;
3378+
3379+
extern fn zguiGetColumnWidth(column_index: i32) f32;
3380+
pub const getColumnWidth = zguiGetColumnWidth;
3381+
3382+
extern fn zguiSetColumnWidth(column_index: i32, width: f32) void;
3383+
pub const setColumnWidth = zguiSetColumnWidth;
3384+
3385+
extern fn zguiGetColumnOffset(column_index: i32) f32;
3386+
pub const getColumnOffset = zguiGetColumnOffset;
3387+
3388+
extern fn zguiSetColumnOffset(column_index: i32, offset_x: f32) void;
3389+
pub const setColumnOffset = zguiSetColumnOffset;
3390+
3391+
extern fn zguiGetColumnsCount() i32;
3392+
pub const getColumnsCount = zguiGetColumnsCount;
3393+
33243394
//--------------------------------------------------------------------------------------------------
33253395
//
33263396
// Item/Widgets Utilities and Query Functions
@@ -3349,6 +3419,7 @@ pub const isMouseReleased = zguiIsMouseReleased;
33493419
pub const isMouseDoubleClicked = zguiIsMouseDoubleClicked;
33503420
/// `pub fn getMouseClickedCount(mouse_button: MouseButton) bool`
33513421
pub const getMouseClickedCount = zguiGetMouseClickedCount;
3422+
pub const isAnyMouseDown = zguiIsAnyMouseDown;
33523423
/// `pub fn isMouseDragging(mouse_button: MouseButton, lock_threshold: f32) bool`
33533424
pub const isMouseDragging = zguiIsMouseDragging;
33543425
/// `pub fn isItemClicked(mouse_button: MouseButton) bool`
@@ -3376,6 +3447,7 @@ extern fn zguiIsMouseClicked(mouse_button: MouseButton) bool;
33763447
extern fn zguiIsMouseReleased(mouse_button: MouseButton) bool;
33773448
extern fn zguiIsMouseDoubleClicked(mouse_button: MouseButton) bool;
33783449
extern fn zguiGetMouseClickedCount(mouse_button: MouseButton) u32;
3450+
extern fn zguiIsAnyMouseDown() bool;
33793451
extern fn zguiIsMouseDragging(mouse_button: MouseButton, lock_threshold: f32) bool;
33803452
extern fn zguiIsItemHovered(flags: HoveredFlags) bool;
33813453
extern fn zguiIsItemActive() bool;
@@ -3451,6 +3523,11 @@ pub fn isKeyReleased(key: Key) bool {
34513523
pub fn setNextFrameWantCaptureKeyboard(want_capture_keyboard: bool) void {
34523524
zguiSetNextFrameWantCaptureKeyboard(want_capture_keyboard);
34533525
}
3526+
extern fn zguiGetKeyPressedAmount(key: Key, repeat_delay: f32, rate: f32) i32;
3527+
pub const getKeyPressedAmount = zguiGetKeyPressedAmount;
3528+
3529+
extern fn zguiSetItemKeyOwner(key: Key) void;
3530+
pub const setItemKeyOwner = zguiSetItemKeyOwner;
34543531

34553532
extern fn zguiIsKeyDown(key: Key) bool;
34563533
extern fn zguiIsKeyPressed(key: Key, repeat: bool) bool;
@@ -3651,6 +3728,10 @@ extern fn zguiBeginTabItem(label: [*:0]const u8, p_open: ?*bool, flags: TabItemF
36513728
extern fn zguiEndTabItem() void;
36523729
extern fn zguiEndTabBar() void;
36533730
extern fn zguiSetTabItemClosed(tab_or_docked_window_label: [*:0]const u8) void;
3731+
3732+
extern fn zguiTabItemButton(label: [*:0]const u8, flags: TabItemFlags) bool;
3733+
pub const tabItemButton = zguiTabItemButton;
3734+
36543735
//--------------------------------------------------------------------------------------------------
36553736
//
36563737
// Viewport
@@ -3884,6 +3965,9 @@ pub const getWindowDrawList = zguiGetWindowDrawList;
38843965
pub const getBackgroundDrawList = zguiGetBackgroundDrawList;
38853966
pub const getForegroundDrawList = zguiGetForegroundDrawList;
38863967

3968+
extern fn zguiGetWindowDpiScale() f32;
3969+
pub const getWindowDpiScale = zguiGetWindowDpiScale;
3970+
38873971
pub const createDrawList = zguiCreateDrawList;
38883972
pub fn destroyDrawList(draw_list: DrawList) void {
38893973
if (draw_list.getOwnerName()) |owner| {

0 commit comments

Comments
 (0)