Skip to content

Commit 0187eb8

Browse files
committed
update to zig0.11
1 parent b4d22df commit 0187eb8

31 files changed

+225
-204
lines changed

README.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ If you're using the official package manager:
2323
.version = "0.0.1",
2424
.dependencies = .{
2525
.zfltk = .{
26-
.url = "https://github.com/MoAlyousef/zfltk/archive/refs/tags/pkg0.0.8.tar.gz",
26+
.url = "https://github.com/MoAlyousef/zfltk/archive/refs/tags/pkg0.1.0.tar.gz",
2727
},
2828
}
2929
}
@@ -154,12 +154,12 @@ Using the Zig wrapper (under development):
154154
```zig
155155
const zfltk = @import("zfltk");
156156
const app = zfltk.app;
157-
const Window = zfltk.Window;
158-
const Button = zfltk.Button;
159-
const Box = zfltk.Box;
157+
const Window = zfltk.window.Window;
158+
const Button = zfltk.button.Button;
159+
const Box = zfltk.box.Box;
160160
const Color = zfltk.enums.Color;
161161
162-
fn butCb(but: *Button(.normal), data: ?*anyopaque) void {
162+
fn butCb(but: *Button, data: ?*anyopaque) void {
163163
var box = Box.fromRaw(data.?);
164164
165165
box.setLabel("Hello World!");
@@ -177,8 +177,9 @@ pub fn main() !void {
177177
178178
.label = "Hello",
179179
});
180+
win.freePosition();
180181
181-
var but = try Button(.normal).init(.{
182+
var but = try Button.init(.{
182183
.x = 160,
183184
.y = 220,
184185
.w = 80,
@@ -187,6 +188,8 @@ pub fn main() !void {
187188
.label = "Click me!",
188189
});
189190
191+
but.setDownBox(.flat);
192+
190193
var box = try Box.init(.{
191194
.x = 10,
192195
.y = 10,
@@ -210,10 +213,9 @@ The messaging api can also be used:
210213
```zig
211214
const zfltk = @import("zfltk");
212215
const app = zfltk.app;
213-
const Widget = zfltk.Widget;
214-
const Window = zfltk.Window;
215-
const Button = zfltk.Button;
216-
const Box = zfltk.Box;
216+
const Window = zfltk.window.Window;
217+
const Button = zfltk.button.Button;
218+
const Box = zfltk.box.Box;
217219
const enums = zfltk.enums;
218220
219221
pub const Message = enum(usize) {
@@ -233,7 +235,7 @@ pub fn main() !void {
233235
.label = "Hello",
234236
});
235237
236-
var but1 = try Button(.normal).init(.{
238+
var but1 = try Button.init(.{
237239
.x = 100,
238240
.y = 220,
239241
.w = 80,
@@ -242,7 +244,7 @@ pub fn main() !void {
242244
.label = "Button 1",
243245
});
244246
245-
var but2 = try Button(.normal).init(.{
247+
var but2 = try Button.init(.{
246248
.x = 200,
247249
.y = 220,
248250
.w = 80,
@@ -307,7 +309,7 @@ You can also mix and match for any missing functionalities in the Zig wrapper (s
307309

308310
Widgets also provide a `call` method which allows to call any method that wasn't wrapped yet in the bindings:
309311
```zig
310-
var flex = try Group(.flex).init(.{
312+
var flex = try Flex.init(.{
311313
.w = 400,
312314
.h = 300,
313315
.orientation = .vertical,

examples/browser.zig

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const zfltk = @import("zfltk");
22
const app = zfltk.app;
3-
const Window = zfltk.Window;
4-
const Browser = zfltk.Browser;
3+
const Window = zfltk.window.Window;
4+
const MultiBrowser = zfltk.browser.MultiBrowser;
55

66
pub fn main() !void {
77
try app.init();
@@ -12,7 +12,7 @@ pub fn main() !void {
1212
});
1313

1414
// Available browsers are: normal, select, hold, multi and file
15-
var browser = try Browser(.multi).init(.{
15+
var browser = try MultiBrowser.init(.{
1616
.x = 10,
1717
.y = 10,
1818
.w = 900 - 20,

examples/channels.zig

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
const zfltk = @import("zfltk");
22
const app = zfltk.app;
3-
const Widget = zfltk.Widget;
4-
const Window = zfltk.Window;
5-
const Button = zfltk.Button;
6-
const Box = zfltk.Box;
3+
const Window = zfltk.window.Window;
4+
const Button = zfltk.button.Button;
5+
const Box = zfltk.box.Box;
76
const enums = zfltk.enums;
87

98
pub const Message = enum(usize) {
@@ -23,7 +22,7 @@ pub fn main() !void {
2322
.label = "Hello",
2423
});
2524

26-
var but1 = try Button(.normal).init(.{
25+
var but1 = try Button.init(.{
2726
.x = 100,
2827
.y = 220,
2928
.w = 80,
@@ -32,7 +31,7 @@ pub fn main() !void {
3231
.label = "Button 1",
3332
});
3433

35-
var but2 = try Button(.normal).init(.{
34+
var but2 = try Button.init(.{
3635
.x = 200,
3736
.y = 220,
3837
.w = 80,

examples/customwidget.zig

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const zfltk = @import("zfltk");
22
const app = zfltk.app;
33
const draw = zfltk.draw;
4-
const Window = zfltk.Window;
5-
const Widget = zfltk.Widget;
6-
const Button = zfltk.Button;
7-
const Box = zfltk.Box;
4+
const Window = zfltk.window.Window;
5+
const Widget = zfltk.widget.Widget;
6+
const Button = zfltk.button.Button;
7+
const Box = zfltk.box.Box;
88
const enums = zfltk.enums;
99
const Color = enums.Color;
1010
const Event = enums.Event;

examples/editor.zig

+20-21
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
const zfltk = @import("zfltk");
55
const app = zfltk.app;
66
const widget = zfltk.widget;
7-
const Widget = widget.Widget;
8-
const Window = zfltk.Window;
9-
const Menu = zfltk.Menu;
7+
const Window = zfltk.window.Window;
8+
const MenuBar = zfltk.menu.MenuBar;
109
const enums = zfltk.enums;
1110
const Color = enums.Color;
12-
const TextDisplay = zfltk.TextDisplay;
11+
const TextEditor = zfltk.text.TextEditor;
1312
const dialog = zfltk.dialog;
14-
const FileDialog = zfltk.FileDialog;
13+
const FileDialog = zfltk.dialog.FileDialog;
1514
const std = @import("std");
1615

1716
// To avoid exiting when hitting escape.
@@ -22,13 +21,13 @@ pub fn winCb(w: *Window) void {
2221
}
2322
}
2423

25-
fn newCb(_: *Menu(.menu_bar), data: ?*anyopaque) void {
26-
var editor = TextDisplay(.editor).fromRaw(data.?);
24+
fn newCb(_: *MenuBar, data: ?*anyopaque) void {
25+
var editor = TextEditor.fromRaw(data.?);
2726
editor.buffer().?.setText("");
2827
}
2928

30-
pub fn openCb(_: *Menu(.menu_bar), data: ?*anyopaque) void {
31-
var editor = TextDisplay(.editor).fromRaw(data.?);
29+
pub fn openCb(_: *MenuBar, data: ?*anyopaque) void {
30+
var editor = TextEditor.fromRaw(data.?);
3231
var dlg = try FileDialog(.file).init(.{});
3332
dlg.setFilter("*.{txt,zig}");
3433
dlg.show();
@@ -38,8 +37,8 @@ pub fn openCb(_: *Menu(.menu_bar), data: ?*anyopaque) void {
3837
}
3938
}
4039

41-
pub fn saveCb(_: *Menu(.menu_bar), data: ?*anyopaque) void {
42-
var editor = TextDisplay(.editor).fromRaw(data.?);
40+
pub fn saveCb(_: *MenuBar, data: ?*anyopaque) void {
41+
var editor = TextEditor.fromRaw(data.?);
4342
var dlg = try FileDialog(.save_file).init(.{ .save_as_confirm = true });
4443
dlg.setFilter("*.{txt,zig}");
4544
dlg.show();
@@ -49,27 +48,27 @@ pub fn saveCb(_: *Menu(.menu_bar), data: ?*anyopaque) void {
4948
}
5049
}
5150

52-
pub fn quitCb(_: *Menu(.menu_bar), data: ?*anyopaque) void {
51+
pub fn quitCb(_: *MenuBar, data: ?*anyopaque) void {
5352
var win = widget.Widget.fromRaw(data.?);
5453
win.hide();
5554
}
5655

57-
pub fn cutCb(_: *Menu(.menu_bar), data: ?*anyopaque) void {
58-
const editor = TextDisplay(.editor).fromRaw(data.?);
56+
pub fn cutCb(_: *MenuBar, data: ?*anyopaque) void {
57+
const editor = TextEditor.fromRaw(data.?);
5958
editor.cut();
6059
}
6160

62-
pub fn copyCb(_: *Menu(.menu_bar), data: ?*anyopaque) void {
63-
const editor = TextDisplay(.editor).fromRaw(data.?);
61+
pub fn copyCb(_: *MenuBar, data: ?*anyopaque) void {
62+
const editor = TextEditor.fromRaw(data.?);
6463
_ = editor.copy();
6564
}
6665

67-
pub fn pasteCb(_: *Menu(.menu_bar), data: ?*anyopaque) void {
68-
const editor = TextDisplay(.editor).fromRaw(data.?);
66+
pub fn pasteCb(_: *MenuBar, data: ?*anyopaque) void {
67+
const editor = TextEditor.fromRaw(data.?);
6968
editor.paste();
7069
}
7170

72-
pub fn helpCb(_: *Menu(.menu_bar)) void {
71+
pub fn helpCb(_: *MenuBar) void {
7372
dialog.message(300, 200, "This editor was built using fltk and zig!");
7473
}
7574

@@ -86,9 +85,9 @@ pub fn main() !void {
8685
});
8786

8887
win.freePosition();
89-
var mymenu = try Menu(.menu_bar).init(.{ .w = 800, .h = 35 });
88+
var mymenu = try MenuBar.init(.{ .w = 800, .h = 35 });
9089

91-
var editor = try TextDisplay(.editor).init(.{
90+
var editor = try TextEditor.init(.{
9291
.x = 2,
9392
.y = 37,
9493
.w = 800 - 2,

examples/editormsgs.zig

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
const zfltk = @import("zfltk");
22
const app = zfltk.app;
33
const widget = zfltk.widget;
4-
const Widget = widget.Widget;
54
const window = zfltk.window;
65
const menu = zfltk.menu;
76
const enums = zfltk.enums;
87
const Color = enums.Color;
98
const text = zfltk.text;
109
const dialog = zfltk.dialog;
11-
const FileDialog = zfltk.FileDialog;
10+
const FileDialog = zfltk.dialog.FileDialog;
1211
const std = @import("std");
1312

1413
pub const Message = enum(usize) {
@@ -38,10 +37,10 @@ pub fn main() !void {
3837
app.setBackground(Color.fromRgb(211, 211, 211));
3938
var win = try window.Window.init(.{ .w = 800, .h = 600, .label = "Editor" });
4039
win.freePosition();
41-
var mymenu = try menu.Menu(.menu_bar).init(.{ .w = 800, .h = 35 });
40+
var mymenu = try menu.MenuBar.init(.{ .w = 800, .h = 35 });
4241
var buf = try text.TextBuffer.init();
4342
defer buf.deinit();
44-
var editor = try text.TextDisplay(.editor).init(.{
43+
var editor = try text.TextEditor.init(.{
4544
.x = 2,
4645
.y = 37,
4746
.w = 800 - 2,

examples/flex.zig

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
const zfltk = @import("zfltk");
22
const app = zfltk.app;
3-
const Window = zfltk.Window;
4-
const Box = zfltk.Box;
5-
const Button = zfltk.Button;
6-
const Group = zfltk.Group;
7-
const Color = enums.Color;
8-
const enums = zfltk.enums;
3+
const Window = zfltk.window.Window;
4+
const Box = zfltk.box.Box;
5+
const Button = zfltk.button.Button;
6+
const Flex = zfltk.group.Flex;
7+
const Color = zfltk.enums.Color;
98

109
pub fn main() !void {
1110
try app.init();
@@ -17,7 +16,7 @@ pub fn main() !void {
1716
.label = "Hello",
1817
});
1918

20-
var flex = try Group(.flex).init(.{
19+
var flex = try Flex.init(.{
2120
.w = 400,
2221
.h = 300,
2322

@@ -29,7 +28,7 @@ pub fn main() !void {
2928

3029
win.resizable(flex);
3130

32-
var btn = try Button(.normal).init(.{
31+
var btn = try Button.init(.{
3332
.h = 48,
3433
.label = "Button",
3534
});

examples/flutterlike.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const HEIGHT: i32 = 400;
1717

1818
var COUNT: i32 = 0;
1919

20-
fn btnCb(_: *button.Button(.normal), data: ?*anyopaque) void {
20+
fn btnCb(_: *button.Button, data: ?*anyopaque) void {
2121
var count = box.Box.fromRaw(data.?);
2222
COUNT += 1;
2323
var buf: [250]u8 = undefined;
@@ -38,7 +38,7 @@ pub fn main() !void {
3838
bar.setLabelAlign(Align.left | Align.inside);
3939
var text = try box.Box.init(.{ .x = 250, .y = 180, .w = 100, .h = 40, .label = "You have pushed the button this many times:" });
4040
var count = try box.Box.init(.{ .x = 250, .y = 220, .w = 100, .h = 40, .label = "0" });
41-
var but = try button.Button(.normal).init(.{ .x = WIDTH - 100, .y = HEIGHT - 100, .w = 60, .h = 60, .label = "@+6plus" });
41+
var but = try button.Button.init(.{ .x = WIDTH - 100, .y = HEIGHT - 100, .w = 60, .h = 60, .label = "@+6plus" });
4242
win.end();
4343
win.resizable(win);
4444
win.show();

examples/glwin.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const zfltk = @import("zfltk");
22
const app = zfltk.app;
3-
const GlutWindow = zfltk.GlutWindow;
3+
const GlutWindow = zfltk.window.GlutWindow;
44
const Mode = zfltk.enums.Mode;
55

66
extern fn glClearColor(r: f32, g: f32, b: f32, a: f32) void;

examples/handle.zig

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
const zfltk = @import("zfltk");
22
const app = zfltk.app;
3-
const Window = zfltk.Window;
4-
const Button = zfltk.Button;
5-
const Box = zfltk.Box;
3+
const Window = zfltk.window.Window;
4+
const Button = zfltk.button.Button;
5+
const Box = zfltk.box.Box;
66
const Color = zfltk.enums.Color;
77
const Event = zfltk.enums.Event;
88
const std = @import("std");
99
const draw = zfltk.draw;
1010

11-
fn butCb(but: *Button(.normal), data: ?*anyopaque) void {
11+
fn butCb(but: *Button, data: ?*anyopaque) void {
1212
var box = Box.fromRaw(data.?);
1313

1414
box.setLabel("Hello World!");
@@ -17,7 +17,7 @@ fn butCb(but: *Button(.normal), data: ?*anyopaque) void {
1717
}
1818

1919
fn boxEventHandler(_: *Box, ev: Event, data: ?*anyopaque) bool {
20-
const btn = Button(.normal).fromRaw(data.?);
20+
const btn = Button.fromRaw(data.?);
2121
switch (ev) {
2222
.push => {
2323
std.debug.print("Click the button: {s}\n", .{btn.label()});
@@ -43,7 +43,7 @@ pub fn main() !void {
4343
.label = "Hello",
4444
});
4545

46-
var but = try Button(.normal).init(.{
46+
var but = try Button.init(.{
4747
.x = 160,
4848
.y = 220,
4949
.w = 80,

examples/image.zig

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const zfltk = @import("zfltk");
22
const app = zfltk.app;
33
const SharedImage = zfltk.image.SharedImage;
4-
const Image = zfltk.Image;
5-
const Window = zfltk.Window;
6-
const Box = zfltk.Box;
7-
const Group = zfltk.Group;
4+
const Image = zfltk.image.Image;
5+
const Window = zfltk.window.Window;
6+
const Box = zfltk.box.Box;
7+
const Scroll = zfltk.group.Scroll;
88
const Align = zfltk.enums.Align;
99
const std = @import("std");
1010

@@ -18,7 +18,7 @@ pub fn main() !void {
1818
.label = "Image demo",
1919
});
2020

21-
var scroll = try Group(.scroll).init(.{
21+
var scroll = try Scroll.init(.{
2222
.w = 415,
2323
.h = 140,
2424
});

0 commit comments

Comments
 (0)