Skip to content

Commit f43a4d5

Browse files
author
Anthony Debucquoy
committed
24% of the file
1 parent 9bba464 commit f43a4d5

File tree

1 file changed

+123
-194
lines changed

1 file changed

+123
-194
lines changed

src/gui.zig

Lines changed: 123 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ pub const DrawData = *cimgui.ImDrawData;
388388
pub const Font = *cimgui.ImFont;
389389
pub const Ident = u32;
390390
pub const Vec2 = cimgui.ImVec2;
391+
pub const Vec4 = cimgui.ImVec4;
391392
pub const TextureIdent = cimgui.ImTextureID;
392393
pub const TextureRef = cimgui.ImTextureRef;
393394
pub const Wchar = if (@import("zgui_options").use_wchar32) u32 else u16;
@@ -884,7 +885,7 @@ pub const DockSpaceOverViewport = cimgui.igDockSpaceOverViewport;
884885
//
885886
//--------------------------------------------------------------------------------------------------
886887

887-
pub const ListClipper = extern struct {
888+
pub const ListClipper = struct {
888889
Base: cimgui.ImGuiListClipper,
889890

890891
pub fn init() ListClipper {
@@ -917,92 +918,95 @@ pub const ListClipper = extern struct {
917918
//
918919
//--------------------------------------------------------------------------------------------------
919920
pub const Style = extern struct {
920-
font_size_base: f32,
921-
font_scale_main: f32,
922-
font_scale_dpi: f32,
923-
alpha: f32,
924-
disabled_alpha: f32,
925-
window_padding: [2]f32,
926-
window_rounding: f32,
927-
window_border_size: f32,
928-
window_border_hover_padding: f32,
929-
window_min_size: [2]f32,
930-
window_title_align: [2]f32,
931-
window_menu_button_position: Direction,
932-
child_rounding: f32,
933-
child_border_size: f32,
934-
popup_rounding: f32,
935-
popup_border_size: f32,
936-
frame_padding: [2]f32,
937-
frame_rounding: f32,
938-
frame_border_size: f32,
939-
item_spacing: [2]f32,
940-
item_inner_spacing: [2]f32,
941-
cell_padding: [2]f32,
942-
touch_extra_padding: [2]f32,
943-
indent_spacing: f32,
944-
columns_min_spacing: f32,
945-
scrollbar_size: f32,
946-
scrollbar_rounding: f32,
947-
grab_min_size: f32,
948-
grab_rounding: f32,
949-
log_slider_deadzone: f32,
950-
image_border_size: f32,
951-
tab_rounding: f32,
952-
tab_border_size: f32,
953-
tab_close_button_min_width_selected: f32,
954-
tab_close_button_min_width_unselected: f32,
955-
tab_bar_border_size: f32,
956-
tab_bar_overline_size: f32,
957-
table_angled_header_angle: f32,
958-
table_angled_headers_text_align: [2]f32,
959-
tree_lines_flags: TreeNodeFlags,
960-
tree_lines_size: f32,
961-
tree_lines_rounding: f32,
962-
color_button_position: Direction,
963-
button_text_align: [2]f32,
964-
selectable_text_align: [2]f32,
965-
separator_text_border_size: f32,
966-
separator_text_align: [2]f32,
967-
separator_text_padding: [2]f32,
968-
display_window_padding: [2]f32,
969-
display_safe_area_padding: [2]f32,
970-
docking_separator_size: f32,
971-
mouse_cursor_scale: f32,
972-
anti_aliased_lines: bool,
973-
anti_aliased_lines_use_tex: bool,
974-
anti_aliased_fill: bool,
975-
curve_tessellation_tol: f32,
976-
circle_tessellation_max_error: f32,
977-
978-
colors: [@typeInfo(StyleCol).@"enum".fields.len][4]f32,
979-
980-
hover_stationary_delay: f32,
981-
hover_delay_short: f32,
982-
hover_delay_normal: f32,
983-
984-
hover_flags_for_tooltip_mouse: HoveredFlags,
985-
hover_flags_for_tooltip_nav: HoveredFlags,
986-
987-
_main_scale: f32,
988-
_next_frame_font_size_base: f32,
989-
990-
/// `pub fn init() Style`
991-
pub const init = zguiStyle_Init;
992-
extern fn zguiStyle_Init() Style;
993-
994-
/// `pub fn scaleAllSizes(style: *Style, scale_factor: f32) void`
995-
pub const scaleAllSizes = zguiStyle_ScaleAllSizes;
996-
extern fn zguiStyle_ScaleAllSizes(style: *Style, scale_factor: f32) void;
997-
998-
/// `pub fn styleColorsDark(*Style)`
999-
pub const setColorsDark = zguiStyleColorsDark;
1000-
1001-
/// `pub fn styleColorsLight(*Style)`
1002-
pub const setColorsLight = zguiStyleColorsLight;
1003-
1004-
/// `pub fn styleColorsClassic(*Style)`
1005-
pub const setColorsClassic = zguiStyleColorsClassic;
921+
base: cimgui.ImGuiStyle,
922+
// font_size_base: f32,
923+
// font_scale_main: f32,
924+
// font_scale_dpi: f32,
925+
// alpha: f32,
926+
// disabled_alpha: f32,
927+
// window_padding: [2]f32,
928+
// window_rounding: f32,
929+
// window_border_size: f32,
930+
// window_border_hover_padding: f32,
931+
// window_min_size: [2]f32,
932+
// window_title_align: [2]f32,
933+
// window_menu_button_position: Direction,
934+
// child_rounding: f32,
935+
// child_border_size: f32,
936+
// popup_rounding: f32,
937+
// popup_border_size: f32,
938+
// frame_padding: [2]f32,
939+
// frame_rounding: f32,
940+
// frame_border_size: f32,
941+
// item_spacing: [2]f32,
942+
// item_inner_spacing: [2]f32,
943+
// cell_padding: [2]f32,
944+
// touch_extra_padding: [2]f32,
945+
// indent_spacing: f32,
946+
// columns_min_spacing: f32,
947+
// scrollbar_size: f32,
948+
// scrollbar_rounding: f32,
949+
// grab_min_size: f32,
950+
// grab_rounding: f32,
951+
// log_slider_deadzone: f32,
952+
// image_border_size: f32,
953+
// tab_rounding: f32,
954+
// tab_border_size: f32,
955+
// tab_close_button_min_width_selected: f32,
956+
// tab_close_button_min_width_unselected: f32,
957+
// tab_bar_border_size: f32,
958+
// tab_bar_overline_size: f32,
959+
// table_angled_header_angle: f32,
960+
// table_angled_headers_text_align: [2]f32,
961+
// tree_lines_flags: TreeNodeFlags,
962+
// tree_lines_size: f32,
963+
// tree_lines_rounding: f32,
964+
// color_button_position: Direction,
965+
// button_text_align: [2]f32,
966+
// selectable_text_align: [2]f32,
967+
// separator_text_border_size: f32,
968+
// separator_text_align: [2]f32,
969+
// separator_text_padding: [2]f32,
970+
// display_window_padding: [2]f32,
971+
// display_safe_area_padding: [2]f32,
972+
// docking_separator_size: f32,
973+
// mouse_cursor_scale: f32,
974+
// anti_aliased_lines: bool,
975+
// anti_aliased_lines_use_tex: bool,
976+
// anti_aliased_fill: bool,
977+
// curve_tessellation_tol: f32,
978+
// circle_tessellation_max_error: f32,
979+
//
980+
// colors: [@typeInfo(StyleCol).@"enum".fields.len][4]f32,
981+
//
982+
// hover_stationary_delay: f32,
983+
// hover_delay_short: f32,
984+
// hover_delay_normal: f32,
985+
//
986+
// hover_flags_for_tooltip_mouse: HoveredFlags,
987+
// hover_flags_for_tooltip_nav: HoveredFlags,
988+
//
989+
// _main_scale: f32,
990+
// _next_frame_font_size_base: f32,
991+
//
992+
pub fn init() Style{
993+
.{.base = cimgui.ImGuiStyle_ImGuiStyle()};
994+
}
995+
996+
// `pub fn getStyle() *Style`
997+
pub const getStyle = cimgui.igGetStyle;
998+
999+
// fn ImGuiStyle_ScaleAllSizes(*Style, scale_factor: f32) void;
1000+
pub const scaleAllSizes = cimgui.ImGuiStyle_ScaleAllSizes;
1001+
1002+
/// fn styleColorsDark(*Style)`
1003+
pub const setColorsDark = cimgui.igStyleColorsDark;
1004+
1005+
/// fn styleColorsLight(*Style)`
1006+
pub const setColorsLight = cimgui.igStyleColorsLight;
1007+
1008+
/// fn styleColorsClassic(*Style)`
1009+
pub const setColorsClassic = cimgui.igStyleColorsClassic;
10061010

10071011
pub const StyleColorsBuiltin = enum {
10081012
dark,
@@ -1011,34 +1015,22 @@ pub const Style = extern struct {
10111015
};
10121016
pub fn setColorsBuiltin(style: *Style, variant: StyleColorsBuiltin) void {
10131017
switch (variant) {
1014-
.dark => zguiStyleColorsDark(style),
1015-
.light => zguiStyleColorsLight(style),
1016-
.classic => zguiStyleColorsClassic(style),
1018+
.dark => setColorsDark(style),
1019+
.light => setColorsLight(style),
1020+
.classic => setColorsDark(style),
10171021
}
10181022
}
10191023

10201024
pub fn getColor(style: Style, idx: StyleCol) [4]f32 {
1021-
return style.colors[@intCast(@intFromEnum(idx))];
1025+
return style.base.Colors[@intCast(@intFromEnum(idx))];
10221026
}
1027+
10231028
pub fn setColor(style: *Style, idx: StyleCol, color: [4]f32) void {
1024-
style.colors[@intCast(@intFromEnum(idx))] = color;
1029+
style.base.Colors[@intCast(@intFromEnum(idx))] = color;
10251030
}
1026-
};
1027-
/// `pub fn getStyle() *Style`
1028-
pub const getStyle = zguiGetStyle;
1029-
extern fn zguiGetStyle() *Style;
10301031

1031-
/// `pub fn styleColorsDark(*Style)`
1032-
pub const styleColorsDark = zguiStyleColorsDark;
1033-
extern fn zguiStyleColorsDark(style: *Style) void;
1034-
1035-
/// `pub fn styleColorsLight(*Style)`
1036-
pub const styleColorsLight = zguiStyleColorsLight;
1037-
extern fn zguiStyleColorsLight(style: *Style) void;
1032+
};
10381033

1039-
/// `pub fn styleColorsClassic(*Style)`
1040-
pub const styleColorsClassic = zguiStyleColorsClassic;
1041-
extern fn zguiStyleColorsClassic(style: *Style) void;
10421034
//--------------------------------------------------------------------------------------------------
10431035
pub const StyleCol = enum(c_int) {
10441036
text,
@@ -1103,36 +1095,11 @@ pub const StyleCol = enum(c_int) {
11031095
modal_window_dim_bg,
11041096
};
11051097

1106-
pub fn pushStyleColor4f(args: struct {
1107-
idx: StyleCol,
1108-
c: [4]f32,
1109-
}) void {
1110-
zguiPushStyleColor4f(args.idx, &args.c);
1111-
}
1112-
extern fn zguiPushStyleColor4f(idx: StyleCol, col: *const [4]f32) void;
1113-
1114-
pub fn pushStyleColor1u(args: struct {
1115-
idx: StyleCol,
1116-
c: u32,
1117-
}) void {
1118-
zguiPushStyleColor1u(args.idx, args.c);
1119-
}
1120-
extern fn zguiPushStyleColor1u(idx: StyleCol, col: c_uint) void;
1121-
1122-
pub fn popStyleColor(args: struct {
1123-
count: i32 = 1,
1124-
}) void {
1125-
zguiPopStyleColor(args.count);
1126-
}
1127-
extern fn zguiPopStyleColor(count: c_int) void;
1128-
1129-
/// `fn pushTextWrapPos(wrap_pos_x: f32) void`
1130-
pub const pushTextWrapPos = zguiPushTextWrapPos;
1131-
extern fn zguiPushTextWrapPos(wrap_pos_x: f32) void;
1132-
1133-
/// `fn popTextWrapPos() void`
1134-
pub const popTextWrapPos = zguiPopTextWrapPos;
1135-
extern fn zguiPopTextWrapPos() void;
1098+
pub const pushStyleColor4f = cimgui.igPushStyleColor_Vec4;
1099+
pub const pushStyleColor1u = cimgui.igPushStyleColor_U32;
1100+
pub const popStyleColor = cimgui.igPopStyleColor;
1101+
pub const pushTextWrapPos = cimgui.igPushTextWrapPos;
1102+
pub const popTextWrapPos = cimgui.igPopTextWrapPos;
11361103

11371104
//--------------------------------------------------------------------------------------------------
11381105
//--------------------------------------------------------------------------------------------------
@@ -1173,28 +1140,9 @@ pub const StyleVar = enum(c_int) {
11731140
docking_separator_size, // 1f
11741141
};
11751142

1176-
pub fn pushStyleVar1f(args: struct {
1177-
idx: StyleVar,
1178-
v: f32,
1179-
}) void {
1180-
zguiPushStyleVar1f(args.idx, args.v);
1181-
}
1182-
extern fn zguiPushStyleVar1f(idx: StyleVar, v: f32) void;
1183-
1184-
pub fn pushStyleVar2f(args: struct {
1185-
idx: StyleVar,
1186-
v: [2]f32,
1187-
}) void {
1188-
zguiPushStyleVar2f(args.idx, &args.v);
1189-
}
1190-
extern fn zguiPushStyleVar2f(idx: StyleVar, v: *const [2]f32) void;
1191-
1192-
pub fn popStyleVar(args: struct {
1193-
count: i32 = 1,
1194-
}) void {
1195-
zguiPopStyleVar(args.count);
1196-
}
1197-
extern fn zguiPopStyleVar(count: c_int) void;
1143+
pub const pushStyleVar1f = cimgui.igPushStyleVar_Float;
1144+
pub const pushStyleVar2f = cimgui.igPushStyleVar_Vec2;
1145+
pub const popStyleVar = cimgui.igPopStyleVar;
11981146

11991147
//--------------------------------------------------------------------------------------------------
12001148
pub const ItemFlag = enum(c_int) {
@@ -1206,44 +1154,25 @@ pub const ItemFlag = enum(c_int) {
12061154
auto_close_popups = 1 << 4,
12071155
allow_duplicate_id = 1 << 5,
12081156
};
1209-
/// `void pushItemFlag(item_flag: ItemFlag, enabled: bool) void`
1210-
pub const pushItemFlag = zguiPushItemFlag;
1211-
/// `void popItemFlag() void`
1212-
pub const popItemFlag = zguiPopItemFlag;
1213-
/// `void pushItemWidth(item_width: f32) void`
1214-
pub const pushItemWidth = zguiPushItemWidth;
1215-
/// `void popItemWidth() void`
1216-
pub const popItemWidth = zguiPopItemWidth;
1217-
/// `void setNextItemWidth(item_width: f32) void`
1218-
pub const setNextItemWidth = zguiSetNextItemWidth;
1219-
/// `void setItemDefaultFocus() void`
1220-
pub const setItemDefaultFocus = zguiSetItemDefaultFocus;
1221-
extern fn zguiPushItemFlag(item_flag: ItemFlag, enabled: bool) void;
1222-
extern fn zguiPopItemFlag() void;
1223-
extern fn zguiPushItemWidth(item_width: f32) void;
1224-
extern fn zguiPopItemWidth() void;
1225-
extern fn zguiSetNextItemWidth(item_width: f32) void;
1226-
extern fn zguiSetItemDefaultFocus() void;
1227-
//--------------------------------------------------------------------------------------------------
1228-
/// `pub fn getFont() Font`
1229-
pub const getFont = zguiGetFont;
1230-
extern fn zguiGetFont() Font;
1231-
/// `pub fn getFontSize() f32`
1232-
pub const getFontSize = zguiGetFontSize;
1233-
extern fn zguiGetFontSize() f32;
1234-
/// `void pushFont(font: Font, font_size_base_unscaled: f32) void`
1235-
pub const pushFont = zguiPushFont;
1236-
extern fn zguiPushFont(font: Font, font_size_base_unscaled: f32) void;
1237-
/// `void popFont() void`
1238-
pub const popFont = zguiPopFont;
1239-
extern fn zguiPopFont() void;
1240-
1241-
pub fn getFontTexUvWhitePixel() [2]f32 {
1242-
var uv: [2]f32 = undefined;
1243-
zguiGetFontTexUvWhitePixel(&uv);
1157+
pub fn pushItemFlag(item_flag: ItemFlag, enabled: bool) void{
1158+
cimgui.igPushItemFlag(@intFromEnum(item_flag), enabled);
1159+
}
1160+
pub const popItemFlag = cimgui.igPopItemFlag;
1161+
pub const pushItemWidth = cimgui.igPushItemWidth;
1162+
pub const popItemWidth = cimgui.igPopItemWidth;
1163+
pub const setNextItemWidth = cimgui.igSetNextItemWidth;
1164+
pub const setItemDefaultFocus = cimgui.igSetItemDefaultFocus;
1165+
//--------------------------------------------------------------------------------------------------
1166+
pub const getFont = cimgui.igGetFont;
1167+
pub const getFontSize = cimgui.igGetFontSize;
1168+
pub const pushFont = cimgui.igPushFont;
1169+
pub const popFont = cimgui.igPopFont;
1170+
1171+
pub fn getFontTexUvWhitePixel() Vec2 {
1172+
var uv: Vec2 = undefined;
1173+
cimgui.igGetFontTexUvWhitePixel(&uv);
12441174
return uv;
12451175
}
1246-
extern fn zguiGetFontTexUvWhitePixel(uv: *[2]f32) void;
12471176
//--------------------------------------------------------------------------------------------------
12481177
//--------------------------------------------------------------------------------------------------
12491178
const BeginDisabled = struct {

0 commit comments

Comments
 (0)