-
Notifications
You must be signed in to change notification settings - Fork 1
/
imgui.zig
125 lines (104 loc) · 2.25 KB
/
imgui.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
const std = @import ("std");
const c = @import ("c");
const imgui = @This ();
pub const glfw = @import ("glfw");
pub const vk = @import ("vk");
pub const Cond = c.ImGuiCond;
pub const Context = struct
{
pub fn create () !void
{
if (c.ImGui_CreateContext (null) == null) return error.ImGuiCreateContextFailure;
}
pub fn destroy () void
{
c.ImGui_DestroyContext (null);
}
};
pub const Col = struct
{
pub const WindowBg = c.ImGuiCol_WindowBg;
};
pub const DrawData = struct
{
pub fn get () *c.ImDrawData
{
return &(c.ImGui_GetDrawData ().*);
}
};
pub const Ex = struct
{
pub fn button (label: [] const u8, size: imgui.Vec2) bool
{
return c.ImGui_ButtonEx (label.ptr, size);
}
pub fn sameline (offset_from_start_x: f32, spacing: f32) void
{
c.ImGui_SameLineEx (offset_from_start_x, spacing);
}
};
pub const Frame = struct
{
pub fn new () void
{
c.ImGui_NewFrame ();
}
};
pub const IO = struct
{
pub fn get () *const c.ImGuiIO
{
return &(c.ImGui_GetIO ().*);
}
};
pub const NextWindow = struct
{
pub const Pos = struct
{
pub const Ex = struct
{
pub fn set (pos: imgui.Vec2, cond: imgui.Cond, pivot: imgui.Vec2) void
{
c.ImGui_SetNextWindowPosEx (pos, cond, pivot);
}
};
};
pub const Size = struct
{
pub fn set (size: imgui.Vec2, cond: imgui.Cond) void
{
c.ImGui_SetNextWindowSize (size, cond);
}
};
};
pub const Style = @import ("style").Style;
pub const Vec2 = c.ImVec2;
pub const Window = struct
{
//pub const Flags = c.ImGuiWindowFlags_;
pub const Flags = i32;
pub const Bit = enum (imgui.Window.Flags)
{
NO_COLLAPSE = c.ImGuiWindowFlags_NoCollapse,
NO_MOVE = c.ImGuiWindowFlags_NoMove,
NO_RESIZE = c.ImGuiWindowFlags_NoResize,
NO_TITLE_BAR = c.ImGuiWindowFlags_NoTitleBar,
};
};
pub fn begin (name: [] const u8, p_open: ?*bool, flags: imgui.Window.Flags) !void
{
if (!c.ImGui_Begin (name.ptr, p_open, flags)) return error.ImGuiBeginFailure;
}
pub fn end () void
{
c.ImGui_End ();
}
pub fn render () void
{
c.ImGui_Render ();
}
pub fn text (allocator: std.mem.Allocator, comptime fmt: [] const u8, args: anytype) !void
{
const str = try std.fmt.allocPrint (allocator, fmt, args);
c.ImGui_Text (str.ptr);
}