Skip to content

Commit 46b26d4

Browse files
committed
Fixed InputNum and PlotLines issues.
Fixed an issue with InputNum where button padding remained even when the buttons were disabled. Fixed an issue with PlotLines where the hovered line would not update when the value changed but the mouse stayed hovered over.
1 parent 79ea7ae commit 46b26d4

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

lib/widgets/Input.lua

+6-5
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
195195
]]
196196
local generateInputScalar: <T>(dataType: InputDataTypes, components: number, defaultValue: any) -> Types.WidgetClass
197197
do
198-
local function generateButtons(thisWidget: Types.Input<number>, parent: GuiObject, rightPadding: number, textHeight: number)
199-
rightPadding += 2 * Iris._config.ItemInnerSpacing.X + 2 * textHeight
200-
198+
local function generateButtons(thisWidget: Types.Input<number>, parent: GuiObject, textHeight: number)
201199
local SubButton = widgets.abstractButton.Generate(thisWidget) :: TextButton
202200
SubButton.Name = "SubButton"
203201
SubButton.ZIndex = 5
@@ -244,7 +242,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
244242
thisWidget.lastNumberChangedTick = Iris._cycleTick + 1
245243
end)
246244

247-
return rightPadding
245+
return 2 * Iris._config.ItemInnerSpacing.X + 2 * textHeight
248246
end
249247

250248
function generateInputScalar<T>(dataType: InputDataTypes, components: number, defaultValue: any)
@@ -280,7 +278,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
280278
local textHeight: number = Iris._config.TextSize + 2 * Iris._config.FramePadding.Y
281279

282280
if components == 1 then
283-
rightPadding = generateButtons(thisWidget :: any, Input, rightPadding, textHeight)
281+
rightPadding = generateButtons(thisWidget :: any, Input, textHeight)
284282
end
285283

286284
-- we divide the total area evenly between each field. This includes accounting for any additional boxes and the offset.
@@ -369,6 +367,9 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
369367
if components == 1 then
370368
Input.SubButton.Visible = not thisWidget.arguments.NoButtons
371369
Input.AddButton.Visible = not thisWidget.arguments.NoButtons
370+
local rightPadding: number = if thisWidget.arguments.NoButtons then 0 else (2 * Iris._config.ItemInnerSpacing.X) + (2 * (Iris._config.TextSize + 2 * Iris._config.FramePadding.Y))
371+
local InputField: TextBox = Input.InputField1
372+
InputField.Size = UDim2.new(UDim.new(Iris._config.ContentWidth.Scale, Iris._config.ContentWidth.Offset - rightPadding), Iris._config.ContentHeight)
372373
end
373374

374375
if thisWidget.arguments.Format and typeof(thisWidget.arguments.Format) ~= "table" then

lib/widgets/Plot.lua

+18-10
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
158158
end
159159
end
160160

161-
local function updateLine(thisWidget: Types.PlotLines)
161+
local function updateLine(thisWidget: Types.PlotLines, silent: true?)
162162
local PlotLines = thisWidget.Instance :: Frame
163163
local Background = PlotLines.Background :: Frame
164164
local Plot = Background.Plot :: Frame
@@ -171,7 +171,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
171171
local line: Frame? = thisWidget.Lines[index]
172172

173173
if line then
174-
if line ~= thisWidget.HoveredLine then
174+
if line ~= thisWidget.HoveredLine and not silent then
175175
clearLine(thisWidget)
176176
end
177177
local start: number? = thisWidget.state.values.value[index]
@@ -186,7 +186,11 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
186186
thisWidget.HoveredLine = line
187187
line.BackgroundColor3 = Iris._config.PlotLinesHoveredColor
188188
line.BackgroundTransparency = Iris._config.PlotLinesHoveredTransparency
189-
thisWidget.state.hovered:set({ start, stop })
189+
if silent then
190+
thisWidget.state.hovered.value = { start, stop }
191+
else
192+
thisWidget.state.hovered:set({ start, stop })
193+
end
190194
end
191195
end
192196

@@ -379,9 +383,9 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
379383
end
380384

381385
-- only update the hovered block if it exists.
382-
-- if thisWidget.HoveredLine then
383-
-- updateLine(thisWidget)
384-
-- end
386+
if thisWidget.HoveredLine then
387+
updateLine(thisWidget, true)
388+
end
385389
end
386390
end,
387391
Discard = function(thisWidget: Types.PlotLines)
@@ -411,7 +415,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
411415
end
412416
end
413417

414-
local function updateBlock(thisWidget: Types.PlotHistogram)
418+
local function updateBlock(thisWidget: Types.PlotHistogram, silent: true?)
415419
local PlotHistogram = thisWidget.Instance :: Frame
416420
local Background = PlotHistogram.Background :: Frame
417421
local Plot = Background.Plot :: Frame
@@ -424,7 +428,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
424428
local block: Frame? = thisWidget.Blocks[index]
425429

426430
if block then
427-
if block ~= thisWidget.HoveredBlock then
431+
if block ~= thisWidget.HoveredBlock and not silent then
428432
clearBlock(thisWidget)
429433
end
430434
local value: number? = thisWidget.state.values.value[index]
@@ -434,7 +438,11 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
434438
thisWidget.HoveredBlock = block
435439
block.BackgroundColor3 = Iris._config.PlotHistogramHoveredColor
436440
block.BackgroundTransparency = Iris._config.PlotHistogramHoveredTransparency
437-
thisWidget.state.hovered:set(value)
441+
if silent then
442+
thisWidget.state.hovered.value = value
443+
else
444+
thisWidget.state.hovered:set(value)
445+
end
438446
end
439447
end
440448

@@ -626,7 +634,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
626634

627635
-- only update the hovered block if it exists.
628636
if thisWidget.HoveredBlock then
629-
updateBlock(thisWidget)
637+
updateBlock(thisWidget, true)
630638
end
631639
end
632640
end,

0 commit comments

Comments
 (0)