diff --git a/src/line.zig b/src/line.zig index 68638c5..a0efd99 100644 --- a/src/line.zig +++ b/src/line.zig @@ -4,15 +4,22 @@ const term = @import("term.zig"); const borders = @import("borders.zig"); const Pane = pane.Pane; +const Style = pane.Style; const TermIO = term.TermIO; pub const HorizontalLine = struct { pane: Pane, border: borders.Border, - pub fn create(mem: *HorizontalLine, border: borders.Border) *Pane { - mem.border = border; + const Config = struct { + border: borders.Border, + style: Style, + }; + + pub fn create(mem: *HorizontalLine, config: Config) *Pane { + mem.border = config.border; mem.pane = Pane{ + .style = config.style, .vtable = .{ .draw = draw, }, @@ -36,9 +43,15 @@ pub const VerticalLine = struct { pane: Pane, border: borders.Border, - pub fn create(mem: *VerticalLine, border: borders.Border) *Pane { - mem.border = border; + const Config = struct { + border: borders.Border, + style: Style, + }; + + pub fn create(mem: *VerticalLine, config: Config) *Pane { + mem.border = config.border; mem.pane = Pane{ + .style = config.style, .vtable = .{ .draw = draw, }, diff --git a/src/main.zig b/src/main.zig index e4e82ac..4e88cc2 100644 --- a/src/main.zig +++ b/src/main.zig @@ -57,29 +57,30 @@ pub fn main() !void { var items2 = [_]menu.MenuItem{ .{ .name = "Item 1" }, .{ .name = "Item ab" } }; var tabs_ = [_]tabs.Tab{ .{ .name = "Tab 1", .pane = &side_menu.pane }, .{ .name = "Tab 2", .pane = &child.pane }, .{ .name = "Tab 3", .pane = &child.pane }, .{ .name = "Tab 4", .pane = &child.pane }, .{ .name = "Tab 5", .pane = &child.pane } }; + const gray = color.RGB(80, 80, 80); const green = color.RGB(0, 255, 0); - const purple = color.RGB(125, 0, 125); - const orange = color.RGB(255, 125, 10); + const s = pane.Style{ .background = gray, .foreground = green }; + const sb = pane.Style{ .border = borders.BoldBorder, .background = gray, .foreground = green }; - _ = stack.Stack.create(&top, .{ .direction = .Horizontal, .style = .{ .border = borders.BoldBorder, .background = color.RGB(30, 30, 30), .foreground = green } }, &[_]stack.StackedPane{ + _ = stack.Stack.create(&top, .{ .direction = .Horizontal, .style = sb }, &[_]stack.StackedPane{ .{ - .pane = menu.Menu.create(&side_menu, .{ .title = "Menu", .style = .{ .background = color.RGB(80, 80, 80), .foreground = green }, .align_text = .Center, .expand_highlight = true, .on_select = on_side_select }, &items2), + .pane = menu.Menu.create(&side_menu, .{ .title = "Menu", .style = s, .align_text = .Center, .expand_highlight = true, .on_select = on_side_select }, &items2), .dimensions = .{ .width = .{ .type = .Fill, .value = 1 }, .height = .{ .type = .Fill, .value = 100 } }, }, - .{ .pane = line.VerticalLine.create(&lineV, borders.BoldBorder), .dimensions = .{ .width = .{ .type = .Absolute, .value = 1 }, .height = .{ .type = .Fill, .value = 100 } } }, + .{ .pane = line.VerticalLine.create(&lineV, .{ .border = borders.BoldBorder, .style = s }), .dimensions = .{ .width = .{ .type = .Absolute, .value = 1 }, .height = .{ .type = .Fill, .value = 100 } } }, .{ - .pane = stack.Stack.create(&child, .{ .direction = .Vertical, .style = .{ .border = borders.BoldBorder, .background = purple, .foreground = orange } }, &[_]stack.StackedPane{ + .pane = stack.Stack.create(&child, .{ .direction = .Vertical, .style = sb }, &[_]stack.StackedPane{ .{ - .pane = tabs.TabBar.create(&tabbar, .{ .highlight_color = color.RGB(0, 0, 255) }, &tabs_), + .pane = tabs.TabBar.create(&tabbar, .{ .highlight_color = color.RGB(0, 125, 0), .style = .{ .background = gray } }, &tabs_), .dimensions = .{ .width = .{ .type = .Fill, .value = 100 }, .height = .{ .type = .Absolute, .value = 1 } }, }, .{ - .pane = menu.Menu.create(&m, .{ .title = "Test", .style = .{ .background = purple, .foreground = orange }, .align_text = .Left, .expand_highlight = true, .on_select = on_select }, &items), + .pane = menu.Menu.create(&m, .{ .title = "Test", .style = s, .align_text = .Left, .expand_highlight = true, .on_select = on_select }, &items), .dimensions = .{ .width = .{ .type = .Fill, .value = 100 }, .height = .{ .type = .Fill, .value = 1 } }, }, - .{ .pane = line.HorizontalLine.create(&lineH, borders.BoldBorder), .dimensions = .{ .width = .{ .type = .Fill, .value = 100 }, .height = .{ .type = .Absolute, .value = 1 } } }, + .{ .pane = line.HorizontalLine.create(&lineH, .{ .border = borders.BoldBorder, .style = s }), .dimensions = .{ .width = .{ .type = .Fill, .value = 100 }, .height = .{ .type = .Absolute, .value = 1 } } }, .{ - .pane = btn.Button.create(&button, .{ .text = "