-
Notifications
You must be signed in to change notification settings - Fork 4
/
tabs_example.zig
102 lines (94 loc) · 2.54 KB
/
tabs_example.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
/// From original example in C
/// https://tecgraf.puc-rio.br/iup/examples/C/tabs.c
const std = @import("std");
const iup = @import("iup.zig");
const MainLoop = iup.MainLoop;
const Dialog = iup.Dialog;
const Button = iup.Button;
const MessageDlg = iup.MessageDlg;
const Multiline = iup.Multiline;
const Label = iup.Label;
const Text = iup.Text;
const VBox = iup.VBox;
const HBox = iup.HBox;
const Menu = iup.Menu;
const SubMenu = iup.SubMenu;
const Separator = iup.Separator;
const Fill = iup.Fill;
const Item = iup.Item;
const FileDlg = iup.FileDlg;
const Toggle = iup.Toggle;
const Tabs = iup.Tabs;
const ScreenSize = iup.ScreenSize;
const Image = iup.Image;
const ImageRgb = iup.ImageRgb;
const ImageRgba = iup.ImageRgba;
pub fn main() !void {
try MainLoop.open();
defer MainLoop.close();
var dlg = try create_dialog();
defer dlg.deinit();
try dlg.showXY(.Center, .Center);
try MainLoop.beginLoop();
}
fn create_dialog() !*Dialog {
var tabs1 = Tabs.init()
.setTabTitle(0, "TAB A")
.setTabTitle(1, "TAB B")
.setChildren(
.{
VBox.init()
.setChildren(
.{
Label.init().setTitle("Inside Tab A"),
Button.init().setTitle("Button A"),
},
),
VBox.init()
.setChildren(
.{
Label.init().setTitle("Inside Tab B"),
Button.init().setTitle("Button B"),
},
),
},
);
var tabs2 = Tabs.init()
.setTabType(.Left)
.setTabTitle(0, "TAB C")
.setTabTitle(1, "TAB D")
.setChildren(
.{
VBox.init()
.setChildren(
.{
Label.init().setTitle("Inside Tab C"),
Button.init().setTitle("Button C"),
},
),
VBox.init()
.setChildren(
.{
Label.init().setTitle("Inside Tab D"),
Button.init().setTitle("Button D"),
},
),
},
);
return try (Dialog.init()
.setTitle("IUP for Zig - Tabs")
.setSize(ScreenSize{ .Size = 200 }, ScreenSize{ .Size = 90 })
.setChildren(
.{
HBox.init()
.setMargin(10, 10)
.setGap(10)
.setChildren(
.{
tabs1,
tabs2,
},
),
},
).unwrap());
}