@@ -2,7 +2,6 @@ local elementManager = require("elementManager")
22local VisualElement = require (" elements/VisualElement" )
33local Container = elementManager .getElement (" Container" )
44local tHex = require (" libraries/colorHex" )
5- local log = require (" log" )
65--- @configDescription A SideNav element that provides sidebar navigation with multiple content areas.
76
87--- The SideNav is a container that provides sidebar navigation functionality
@@ -27,7 +26,7 @@ SideNav.defineProperty(SideNav, "activeTabBackground", {default = colors.white,
2726SideNav .defineProperty (SideNav , " activeTabTextColor" , {default = colors .black , type = " color" , canTriggerRender = true })
2827--- @property sidebarScrollOffset number 0 Current scroll offset for navigation items in scrollable mode
2928SideNav .defineProperty (SideNav , " sidebarScrollOffset" , {default = 0 , type = " number" , canTriggerRender = true })
30- --- @property sidebarPosition string " left" Position of the sidebar ("left" or "right")
29+ --- @property sidebarPosition string left Position of the sidebar ("left" or "right")
3130SideNav .defineProperty (SideNav , " sidebarPosition" , {default = " left" , type = " string" , canTriggerRender = true })
3231
3332SideNav .defineEvent (SideNav , " mouse_click" )
@@ -198,7 +197,7 @@ function SideNav:_getSidebarMetrics()
198197
199198 for i , tab in ipairs (tabs ) do
200199 local itemHeight = 1
201-
200+
202201 local visualY = actualY - scrollOffset
203202 local startClip = 0
204203 local endClip = 0
@@ -255,14 +254,14 @@ function SideNav:mouse_click(button, x, y)
255254 local baseRelX , baseRelY = VisualElement .getRelativePosition (self , x , y )
256255 local metrics = self :_getSidebarMetrics ()
257256 local width = self .get (" width" ) or 1
258-
257+
259258 local inSidebar = false
260259 if metrics .sidebarPosition == " right" then
261260 inSidebar = baseRelX > (width - metrics .sidebarWidth )
262261 else
263262 inSidebar = baseRelX <= metrics .sidebarWidth
264263 end
265-
264+
266265 if inSidebar then
267266 if # metrics .positions == 0 then return true end
268267 for _ , pos in ipairs (metrics .positions ) do
280279function SideNav :getRelativePosition (x , y )
281280 local metrics = self :_getSidebarMetrics ()
282281 local width = self .get (" width" ) or 1
283-
282+
284283 if x == nil or y == nil then
285284 return VisualElement .getRelativePosition (self )
286285 else
@@ -363,14 +362,14 @@ function SideNav:mouse_up(button, x, y)
363362 local baseRelX , baseRelY = VisualElement .getRelativePosition (self , x , y )
364363 local metrics = self :_getSidebarMetrics ()
365364 local width = self .get (" width" ) or 1
366-
365+
367366 local inSidebar = false
368367 if metrics .sidebarPosition == " right" then
369368 inSidebar = baseRelX > (width - metrics .sidebarWidth )
370369 else
371370 inSidebar = baseRelX <= metrics .sidebarWidth
372371 end
373-
372+
374373 if inSidebar then
375374 return true
376375 end
@@ -382,14 +381,14 @@ function SideNav:mouse_release(button, x, y)
382381 local baseRelX , baseRelY = VisualElement .getRelativePosition (self , x , y )
383382 local metrics = self :_getSidebarMetrics ()
384383 local width = self .get (" width" ) or 1
385-
384+
386385 local inSidebar = false
387386 if metrics .sidebarPosition == " right" then
388387 inSidebar = baseRelX > (width - metrics .sidebarWidth )
389388 else
390389 inSidebar = baseRelX <= metrics .sidebarWidth
391390 end
392-
391+
393392 if inSidebar then
394393 return
395394 end
@@ -401,14 +400,14 @@ function SideNav:mouse_move(_, x, y)
401400 local baseRelX , baseRelY = VisualElement .getRelativePosition (self , x , y )
402401 local metrics = self :_getSidebarMetrics ()
403402 local width = self .get (" width" ) or 1
404-
403+
405404 local inSidebar = false
406405 if metrics .sidebarPosition == " right" then
407406 inSidebar = baseRelX > (width - metrics .sidebarWidth )
408407 else
409408 inSidebar = baseRelX <= metrics .sidebarWidth
410409 end
411-
410+
412411 if inSidebar then
413412 return true
414413 end
@@ -426,14 +425,14 @@ function SideNav:mouse_drag(button, x, y)
426425 local baseRelX , baseRelY = VisualElement .getRelativePosition (self , x , y )
427426 local metrics = self :_getSidebarMetrics ()
428427 local width = self .get (" width" ) or 1
429-
428+
430429 local inSidebar = false
431430 if metrics .sidebarPosition == " right" then
432431 inSidebar = baseRelX > (width - metrics .sidebarWidth )
433432 else
434433 inSidebar = baseRelX <= metrics .sidebarWidth
435434 end
436-
435+
437436 if inSidebar then
438437 return true
439438 end
@@ -487,7 +486,7 @@ function SideNav:setCursor(x, y, blink, color)
487486 if self .parent then
488487 local xPos , yPos = self :calculatePosition ()
489488 local targetX , targetY
490-
489+
491490 if metrics .sidebarPosition == " right" then
492491 targetX = x + xPos - 1
493492 targetY = y + yPos - 1
@@ -513,14 +512,12 @@ function SideNav:render()
513512 local metrics = self :_getSidebarMetrics ()
514513 local sidebarW = metrics .sidebarWidth or 12
515514
516- -- Render sidebar background
517515 for y = 1 , height do
518516 VisualElement .multiBlit (self , 1 , y , sidebarW , 1 , " " , tHex [self .get (" foreground" )], tHex [self .get (" sidebarBackground" )])
519517 end
520518
521519 local activeTab = self .get (" activeTab" )
522520
523- -- Render navigation items
524521 for _ , pos in ipairs (metrics .positions ) do
525522 local bgColor = (pos .id == activeTab ) and self .get (" activeTabBackground" ) or self .get (" sidebarBackground" )
526523 local fgColor = (pos .id == activeTab ) and self .get (" activeTabTextColor" ) or self .get (" foreground" )
@@ -530,12 +527,11 @@ function SideNav:render()
530527 VisualElement .multiBlit (self , 1 , pos .y1 + dy , sidebarW , 1 , " " , tHex [self .get (" foreground" )], tHex [bgColor ])
531528 end
532529
533- -- Render title text (truncate if necessary)
534530 local displayTitle = pos .title
535531 if # displayTitle > sidebarW - 2 then
536532 displayTitle = displayTitle :sub (1 , sidebarW - 2 )
537533 end
538-
534+
539535 VisualElement .textFg (self , 2 , pos .y1 , displayTitle , fgColor )
540536 end
541537
0 commit comments