diff --git a/.gitignore b/.gitignore index 0050dc2..5ed29ae 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,10 @@ testWorkflows todo.txt Flexbox2.lua markdown.lua -markdown2.lua \ No newline at end of file +markdown2.lua +SplitPane.lua +Accordion.lua +Stepper.lua +Drawer.lua +Breadcrumb.lua +Dialog.lua \ No newline at end of file diff --git a/src/elements/SideNav.lua b/src/elements/SideNav.lua index b748cda..94894fe 100644 --- a/src/elements/SideNav.lua +++ b/src/elements/SideNav.lua @@ -2,7 +2,6 @@ local elementManager = require("elementManager") local VisualElement = require("elements/VisualElement") local Container = elementManager.getElement("Container") local tHex = require("libraries/colorHex") -local log = require("log") ---@configDescription A SideNav element that provides sidebar navigation with multiple content areas. --- The SideNav is a container that provides sidebar navigation functionality @@ -27,7 +26,7 @@ SideNav.defineProperty(SideNav, "activeTabBackground", {default = colors.white, SideNav.defineProperty(SideNav, "activeTabTextColor", {default = colors.black, type = "color", canTriggerRender = true}) ---@property sidebarScrollOffset number 0 Current scroll offset for navigation items in scrollable mode SideNav.defineProperty(SideNav, "sidebarScrollOffset", {default = 0, type = "number", canTriggerRender = true}) ----@property sidebarPosition string "left" Position of the sidebar ("left" or "right") +---@property sidebarPosition string left Position of the sidebar ("left" or "right") SideNav.defineProperty(SideNav, "sidebarPosition", {default = "left", type = "string", canTriggerRender = true}) SideNav.defineEvent(SideNav, "mouse_click") @@ -198,7 +197,7 @@ function SideNav:_getSidebarMetrics() for i, tab in ipairs(tabs) do local itemHeight = 1 - + local visualY = actualY - scrollOffset local startClip = 0 local endClip = 0 @@ -255,14 +254,14 @@ function SideNav:mouse_click(button, x, y) local baseRelX, baseRelY = VisualElement.getRelativePosition(self, x, y) local metrics = self:_getSidebarMetrics() local width = self.get("width") or 1 - + local inSidebar = false if metrics.sidebarPosition == "right" then inSidebar = baseRelX > (width - metrics.sidebarWidth) else inSidebar = baseRelX <= metrics.sidebarWidth end - + if inSidebar then if #metrics.positions == 0 then return true end for _, pos in ipairs(metrics.positions) do @@ -280,7 +279,7 @@ end function SideNav:getRelativePosition(x, y) local metrics = self:_getSidebarMetrics() local width = self.get("width") or 1 - + if x == nil or y == nil then return VisualElement.getRelativePosition(self) else @@ -363,14 +362,14 @@ function SideNav:mouse_up(button, x, y) local baseRelX, baseRelY = VisualElement.getRelativePosition(self, x, y) local metrics = self:_getSidebarMetrics() local width = self.get("width") or 1 - + local inSidebar = false if metrics.sidebarPosition == "right" then inSidebar = baseRelX > (width - metrics.sidebarWidth) else inSidebar = baseRelX <= metrics.sidebarWidth end - + if inSidebar then return true end @@ -382,14 +381,14 @@ function SideNav:mouse_release(button, x, y) local baseRelX, baseRelY = VisualElement.getRelativePosition(self, x, y) local metrics = self:_getSidebarMetrics() local width = self.get("width") or 1 - + local inSidebar = false if metrics.sidebarPosition == "right" then inSidebar = baseRelX > (width - metrics.sidebarWidth) else inSidebar = baseRelX <= metrics.sidebarWidth end - + if inSidebar then return end @@ -401,14 +400,14 @@ function SideNav:mouse_move(_, x, y) local baseRelX, baseRelY = VisualElement.getRelativePosition(self, x, y) local metrics = self:_getSidebarMetrics() local width = self.get("width") or 1 - + local inSidebar = false if metrics.sidebarPosition == "right" then inSidebar = baseRelX > (width - metrics.sidebarWidth) else inSidebar = baseRelX <= metrics.sidebarWidth end - + if inSidebar then return true end @@ -426,14 +425,14 @@ function SideNav:mouse_drag(button, x, y) local baseRelX, baseRelY = VisualElement.getRelativePosition(self, x, y) local metrics = self:_getSidebarMetrics() local width = self.get("width") or 1 - + local inSidebar = false if metrics.sidebarPosition == "right" then inSidebar = baseRelX > (width - metrics.sidebarWidth) else inSidebar = baseRelX <= metrics.sidebarWidth end - + if inSidebar then return true end @@ -487,7 +486,7 @@ function SideNav:setCursor(x, y, blink, color) if self.parent then local xPos, yPos = self:calculatePosition() local targetX, targetY - + if metrics.sidebarPosition == "right" then targetX = x + xPos - 1 targetY = y + yPos - 1 @@ -513,14 +512,12 @@ function SideNav:render() local metrics = self:_getSidebarMetrics() local sidebarW = metrics.sidebarWidth or 12 - -- Render sidebar background for y = 1, height do VisualElement.multiBlit(self, 1, y, sidebarW, 1, " ", tHex[self.get("foreground")], tHex[self.get("sidebarBackground")]) end local activeTab = self.get("activeTab") - -- Render navigation items for _, pos in ipairs(metrics.positions) do local bgColor = (pos.id == activeTab) and self.get("activeTabBackground") or self.get("sidebarBackground") local fgColor = (pos.id == activeTab) and self.get("activeTabTextColor") or self.get("foreground") @@ -530,12 +527,11 @@ function SideNav:render() VisualElement.multiBlit(self, 1, pos.y1 + dy, sidebarW, 1, " ", tHex[self.get("foreground")], tHex[bgColor]) end - -- Render title text (truncate if necessary) local displayTitle = pos.title if #displayTitle > sidebarW - 2 then displayTitle = displayTitle:sub(1, sidebarW - 2) end - + VisualElement.textFg(self, 2, pos.y1, displayTitle, fgColor) end diff --git a/src/elements/Tree.lua b/src/elements/Tree.lua index 3e15eaa..f28af11 100644 --- a/src/elements/Tree.lua +++ b/src/elements/Tree.lua @@ -199,8 +199,8 @@ function Tree:render() end local isSelected = node == selectedNode - local _bg = isSelected and self.get("selectedBackgroundColor") or self.get("background") - local _fg = isSelected and self.get("selectedForegroundColor") or self.get("foreground") + local _bg = isSelected and self.get("selectedBackgroundColor") or (node.background or node.bg or self.get("background")) + local _fg = isSelected and self.get("selectedForegroundColor") or (node.foreground or node.fg or self.get("foreground")) local fullText = indent .. symbol .. " " .. (node.text or "Node") local text = sub(fullText, horizontalOffset + 1, horizontalOffset + self.get("width")) @@ -216,5 +216,4 @@ function Tree:render() end end - -return Tree +return Tree \ No newline at end of file diff --git a/src/elements/VisualElement.lua b/src/elements/VisualElement.lua index b79b283..6e7dc19 100644 --- a/src/elements/VisualElement.lua +++ b/src/elements/VisualElement.lua @@ -536,7 +536,6 @@ function VisualElement:render() local fgHex = tHex[self.get("foreground")] local bgHex = tHex[self.get("background")] self:multiBlit(1, 1, width, height, " ", fgHex, bgHex) - -- Draw integrated border after background fill if (self.get("borderTop") or self.get("borderBottom") or self.get("borderLeft") or self.get("borderRight")) then local bColor = self.get("borderColor") or self.get("foreground") local bHex = tHex[bColor] or fgHex