@@ -4,7 +4,8 @@ local Common = require("TimMenu.Common") -- EndSector might need this for DrawLi
44
55local Sector = {}
66
7- -- Forward declaration for helper usage if needed, though likely not for static helpers
7+ -- Spacing between consecutive sectors (larger than internal padding for visual separation)
8+ local SECTOR_SPACING = Globals .Defaults .WINDOW_CONTENT_PADDING
89
910--[[ ----------------------------------------------------------------------------
1011-- Private Helper Functions for Sector.End
@@ -89,16 +90,15 @@ local function _enqueueBorderDraw(win, sector_data, depth, persistentWidth, pers
8990end
9091
9192local function _finalizeCursorAndLayout (win , sector_data , width , height , pad )
92- win . cursorX = sector_data . startX + width + pad
93- -- Keep cursorY at the top of this sector for side-by-side placement
94- -- The window's own lineHeight tracking will handle vertical wrapping
93+ -- Treat sector as a single widget occupying the computed width/height
94+ local horizontalSpacing = Globals . Defaults . ITEM_SPACING or 0
95+ win . cursorX = sector_data . startX + width + horizontalSpacing
9596 win .cursorY = sector_data .startY
96- win .lineHeight = math.max (win . lineHeight or 0 , height )
97+ win .lineHeight = math.max (sector_data . preLineHeight or 0 , height )
9798
9899 if # win ._sectorStack > 0 then
99100 local parentSector = win ._sectorStack [# win ._sectorStack ]
100101 parentSector .maxX = math.max (parentSector .maxX , sector_data .startX + width )
101- -- Use actual bottom of child sector, not reset cursor position
102102 parentSector .maxY = math.max (parentSector .maxY , sector_data .startY + height )
103103 end
104104end
@@ -113,10 +113,10 @@ function Sector.Begin(win, label)
113113 -- persistent storage for sector sizes
114114 win ._sectorSizes = win ._sectorSizes or {}
115115
116- -- Increase padding inside sectors by 5 pixels vertically for better spacing
116+ -- Internal padding for content inside sector borders
117117 local pad = Globals .Defaults .WINDOW_CONTENT_PADDING
118- -- capture current cursor as sector origin (shifted down by pad)
119- local startX , startY = win .cursorX , win .cursorY + pad
118+ -- Sector starts at current cursor position
119+ local startX , startY = win .cursorX , win .cursorY
120120
121121 -- Start with current cursor position as initial extents (no stored sizes)
122122 local sector_data = {
@@ -127,9 +127,13 @@ function Sector.Begin(win, label)
127127 label = label ,
128128 padding = pad ,
129129 origAdd = win .AddWidget , -- Store original AddWidget
130+ preLineHeight = win .lineHeight ,
130131 }
131132 table.insert (win ._sectorStack , sector_data )
132133
134+ -- Reset lineHeight for clean sector start
135+ win .lineHeight = 0
136+
133137 -- override AddWidget & NextLine to track extents within this sector
134138 sector_data .origNext = win .NextLine -- Store original NextLine
135139 win .AddWidget = function (self , w , h )
@@ -141,16 +145,12 @@ function Sector.Begin(win, label)
141145 end
142146
143147 win .NextLine = function (self , spacing )
144- -- Directly update cursor within sector boundaries without calling origNext
145- local extra = 5 -- add 5px more between lines inside sector
148+ -- Advance to next line within sector
146149 local baseSpacing = spacing or Globals .Defaults .WINDOW_CONTENT_PADDING
147- -- Update cursorY manually to avoid origNext resetting cursorX to window padding
148- self .cursorY = self .cursorY + self .lineHeight + baseSpacing + extra
149- -- Keep cursorX constrained to sector's indented start position
150+ self .cursorY = self .cursorY + self .lineHeight + baseSpacing
151+ -- Keep cursor aligned to sector's left edge
150152 self .cursorX = sector_data .startX + sector_data .padding
151- -- Don't update maxY here - let AddWidget expand bounds only when widgets are actually added
152- -- This prevents empty space when conditionals hide content after NextLine
153- -- Reset lineHeight for the new line (matches Window:NextLine behavior)
153+ -- Reset lineHeight for new line
154154 self .lineHeight = 0
155155 end
156156
0 commit comments