an experimental irc client
at ec2fb6ec28aa8aa40e3c97fa3ebb23afeba605bf 26 lines 692 B view raw
1const vaxis = @import("vaxis"); 2 3const Button = @This(); 4 5label: []const u8, 6style: vaxis.Style = .{}, 7 8pub fn draw(self: Button, win: vaxis.Window) !void { 9 win.fill(.{ 10 .char = .{ 11 .grapheme = " ", 12 .width = 1, 13 }, 14 .style = self.style, 15 }); 16 const label_width = win.gwidth(self.label); 17 const label_win = vaxis.widgets.alignment.center(win, label_width, 1); 18 _ = try label_win.print(&.{.{ .text = self.label, .style = self.style }}, .{}); 19} 20 21pub fn clicked(_: Button, win: vaxis.Window, mouse: ?vaxis.Mouse) bool { 22 if (win.hasMouse(mouse)) |m| { 23 return m.button == .left and m.type == .press; 24 } 25 return false; 26}