Skip to content

Commit 87d678b

Browse files
authored
Added some necessary functions (#41)
1 parent ec1372b commit 87d678b

File tree

2 files changed

+206
-0
lines changed

2 files changed

+206
-0
lines changed

src/gui.zig

+84
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,9 @@ pub fn setNextWindowSize(args: SetNextWindowSize) void {
699699
}
700700
extern fn zguiSetNextWindowSize(w: f32, h: f32, cond: Condition) void;
701701
//--------------------------------------------------------------------------------------------------
702+
extern fn zguiSetNextWindowContentSize(w: f32, h: f32) void;
703+
pub const setNextWindowContentSize = zguiSetNextWindowContentSize;
704+
//--------------------------------------------------------------------------------------------------
702705
const SetNextWindowCollapsed = struct {
703706
collapsed: bool,
704707
cond: Condition = .none,
@@ -712,6 +715,9 @@ extern fn zguiSetNextWindowCollapsed(collapsed: bool, cond: Condition) void;
712715
pub const setNextWindowFocus = zguiSetNextWindowFocus;
713716
extern fn zguiSetNextWindowFocus() void;
714717
//--------------------------------------------------------------------------------------------------
718+
extern fn zguiSetNextWindowScroll(scroll_x: f32, scroll_y: f32) void;
719+
pub const setNextWindowScroll = zguiSetNextWindowScroll;
720+
//--------------------------------------------------------------------------------------------------
715721
const SetNextWindowBgAlpha = struct {
716722
alpha: f32,
717723
};
@@ -725,11 +731,19 @@ pub fn setWindowFocus(name: ?[:0]const u8) void {
725731
}
726732
extern fn zguiSetWindowFocus(name: ?[*:0]const u8) void;
727733
//-------------------------------------------------------------------------------------------------
734+
extern fn zguiSetWindowFontScale(scale: f32) void;
735+
pub const setWindowFontScale = zguiSetWindowFontScale;
736+
//-------------------------------------------------------------------------------------------------
728737
pub fn setKeyboardFocusHere(offset: i32) void {
729738
zguiSetKeyboardFocusHere(offset);
730739
}
731740
extern fn zguiSetKeyboardFocusHere(offset: c_int) void;
732741

742+
extern fn zguiSetNavCursorVisible(visible: bool) void;
743+
pub const setNavCursorVisible = zguiSetNavCursorVisible;
744+
745+
extern fn zguiSetNextItemAllowOverlap() void;
746+
pub const setNextItemAllowOverlap = zguiSetNextItemAllowOverlap;
733747
//--------------------------------------------------------------------------------------------------
734748
const Begin = struct {
735749
popen: ?*bool = null,
@@ -1457,6 +1471,9 @@ pub const getMouseCursor = zguiGetMouseCursor;
14571471
pub const setMouseCursor = zguiSetMouseCursor;
14581472
extern fn zguiGetMouseCursor() Cursor;
14591473
extern fn zguiSetMouseCursor(cursor: Cursor) void;
1474+
1475+
extern fn zguiSetNextFrameWantCaptureMouse(want_capture_mouse: bool) void;
1476+
pub const setNextFrameWantCaptureMouse = zguiSetNextFrameWantCaptureMouse;
14601477
//--------------------------------------------------------------------------------------------------
14611478
pub fn getMousePos() [2]f32 {
14621479
var pos: [2]f32 = undefined;
@@ -1746,6 +1763,13 @@ pub fn progressBar(args: ProgressBar) void {
17461763
zguiProgressBar(args.fraction, args.w, args.h, if (args.overlay) |o| o else null);
17471764
}
17481765
extern fn zguiProgressBar(fraction: f32, w: f32, h: f32, overlay: ?[*:0]const u8) void;
1766+
//--------------------------------------------------------------------------------------------------
1767+
extern fn zguiTextLink(label: [*:0]const u8) bool;
1768+
pub const textLink = zguiTextLink;
1769+
1770+
extern fn zguiTextLinkOpenURL(label: [*:0]const u8, url: ?[*:0]const u8) void;
1771+
pub const textLinkOpenURL = zguiTextLinkOpenURL;
1772+
17491773
//--------------------------------------------------------------------------------------------------
17501774
//
17511775
// Widgets: Combo Box
@@ -2995,6 +3019,9 @@ extern fn zguiTreePushPtrId(ptr_id: *const anyopaque) void;
29953019
pub const treePop = zguiTreePop;
29963020
extern fn zguiTreePop() void;
29973021
//--------------------------------------------------------------------------------------------------
3022+
extern fn zguiGetTreeNodeToLabelSpacing() f32;
3023+
pub const getTreeNodeToLabelSpacing = zguiGetTreeNodeToLabelSpacing;
3024+
//--------------------------------------------------------------------------------------------------
29983025
const CollapsingHeaderStatePtr = struct {
29993026
pvisible: *bool,
30003027
flags: TreeNodeFlags = .{},
@@ -3080,6 +3107,15 @@ pub fn beginListBox(label: [:0]const u8, args: BeginListBox) bool {
30803107
pub const endListBox = zguiEndListBox;
30813108
extern fn zguiBeginListBox(label: [*:0]const u8, w: f32, h: f32) bool;
30823109
extern fn zguiEndListBox() void;
3110+
extern fn zguiListBox(label: [*:0]const u8, current_item: *i32, items: [*]const [*:0]const u8, item_count: i32, height_in_items: i32) bool;
3111+
pub const ListBox = struct {
3112+
current_item: *i32,
3113+
items: []const [*:0]const u8,
3114+
height_in_items: i32 = -1,
3115+
};
3116+
pub fn listBox(label: [*:0]const u8, args: ListBox) bool {
3117+
return zguiListBox(label, args.current_item, args.items.ptr, @intCast(args.items.len), args.height_in_items);
3118+
}
30833119
//--------------------------------------------------------------------------------------------------
30843120
//
30853121
// Widgets: Tables
@@ -3313,6 +3349,9 @@ extern fn zguiTableGetColumnFlags(column_n: i32) TableColumnFlags;
33133349
pub const tableSetColumnEnabled = zguiTableSetColumnEnabled;
33143350
extern fn zguiTableSetColumnEnabled(column_n: i32, v: bool) void;
33153351

3352+
extern fn zguiTableGetHoveredColumn() i32;
3353+
pub const tableGetHoveredColumn = zguiTableGetHoveredColumn;
3354+
33163355
pub fn tableSetBgColor(args: struct {
33173356
target: TableBgTarget,
33183357
color: u32,
@@ -3322,6 +3361,37 @@ pub fn tableSetBgColor(args: struct {
33223361
}
33233362
extern fn zguiTableSetBgColor(target: TableBgTarget, color: c_uint, column_n: c_int) void;
33243363

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

34563533
extern fn zguiIsKeyDown(key: Key) bool;
34573534
extern fn zguiIsKeyPressed(key: Key, repeat: bool) bool;
@@ -3652,6 +3729,10 @@ extern fn zguiBeginTabItem(label: [*:0]const u8, p_open: ?*bool, flags: TabItemF
36523729
extern fn zguiEndTabItem() void;
36533730
extern fn zguiEndTabBar() void;
36543731
extern fn zguiSetTabItemClosed(tab_or_docked_window_label: [*:0]const u8) void;
3732+
3733+
extern fn zguiTabItemButton(label: [*:0]const u8, flags: TabItemFlags) bool;
3734+
pub const tabItemButton = zguiTabItemButton;
3735+
36553736
//--------------------------------------------------------------------------------------------------
36563737
//
36573738
// Viewport
@@ -3885,6 +3966,9 @@ pub const getWindowDrawList = zguiGetWindowDrawList;
38853966
pub const getBackgroundDrawList = zguiGetBackgroundDrawList;
38863967
pub const getForegroundDrawList = zguiGetForegroundDrawList;
38873968

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

0 commit comments

Comments
 (0)