Skip to content

Commit dc36058

Browse files
TimMenu/Wi: fixed offset of color picker
1 parent 48d6f17 commit dc36058

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

TimMenu/Widgets/ColorPicker.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,17 @@ local function ColorPicker(win, label, initColor)
6969
draw.SetFont(Globals.Style.Font)
7070
local txtW, txtH = draw.GetTextSize(label)
7171
local padding = Globals.Style.ItemPadding
72-
local extraVerticalInset = math.ceil((Globals.Style.ItemSpacingY or padding) * 0.5)
73-
local verticalInset = padding + extraVerticalInset
7472
local colorSize = math.max(Globals.Style.ItemSize, txtH)
75-
local height = colorSize + (verticalInset * 2)
73+
local height = colorSize + (padding * 2)
7674
local previewBlockW = colorSize + (padding * 2)
7775
local arrowBoxW = height
7876
local width = previewBlockW + padding + txtW + padding + arrowBoxW
7977

8078
local ctx = WidgetBase.Setup(win, "ColorPicker", label, width, height)
8179
local absX, absY = ctx.absX, ctx.absY
80+
local baseSpacing = Globals.Style.ItemSpacingY or Globals.Defaults.WINDOW_CONTENT_PADDING
81+
local spacingBoost = baseSpacing + padding
82+
win._nextLineSpacingBoost = math.max(win._nextLineSpacingBoost or 0, spacingBoost)
8283

8384
-- State management
8485
local state = Utils.GetState(win, ctx.widgetKey, {
@@ -185,7 +186,7 @@ local function ColorPicker(win, label, initColor)
185186
end
186187
local mainW = width - arrowBoxW
187188
local arrowX = px + mainW
188-
local colorY = py + verticalInset
189+
local colorY = py + padding
189190
local colorX = px + padding
190191
local colorX2 = colorX + colorSize
191192
Common.QueueRect(win, Globals.Layers.WidgetBackground, px, py, px + mainW, py + height, bg, nil)

TimMenu/Window.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ end
180180
function Window:NextLine(spacing)
181181
local baseSpacing = Globals.Style.ItemSpacingY or Globals.Defaults.WINDOW_CONTENT_PADDING
182182
spacing = spacing or baseSpacing
183+
if self._nextLineSpacingBoost then
184+
spacing = math.max(spacing, self._nextLineSpacingBoost)
185+
self._nextLineSpacingBoost = nil
186+
end
183187
self.cursorY = self.cursorY + self.lineHeight + spacing
184188
self.cursorX = Globals.Defaults.WINDOW_CONTENT_PADDING -- reset to left padding
185189
local endOfLineY = self.cursorY -- Y position *before* resetting lineHeight

0 commit comments

Comments
 (0)