From 46b26d47e2581707f0cc7412e8982f2f61a17287 Mon Sep 17 00:00:00 2001 From: Sir Mallard <73789875+SirMallard@users.noreply.github.com> Date: Sat, 21 Dec 2024 02:15:07 +0000 Subject: [PATCH] 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. --- lib/widgets/Input.lua | 11 ++++++----- lib/widgets/Plot.lua | 28 ++++++++++++++++++---------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/lib/widgets/Input.lua b/lib/widgets/Input.lua index 7efbe55..650cb3d 100644 --- a/lib/widgets/Input.lua +++ b/lib/widgets/Input.lua @@ -195,9 +195,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) ]] local generateInputScalar: (dataType: InputDataTypes, components: number, defaultValue: any) -> Types.WidgetClass do - local function generateButtons(thisWidget: Types.Input, parent: GuiObject, rightPadding: number, textHeight: number) - rightPadding += 2 * Iris._config.ItemInnerSpacing.X + 2 * textHeight - + local function generateButtons(thisWidget: Types.Input, parent: GuiObject, textHeight: number) local SubButton = widgets.abstractButton.Generate(thisWidget) :: TextButton SubButton.Name = "SubButton" SubButton.ZIndex = 5 @@ -244,7 +242,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) thisWidget.lastNumberChangedTick = Iris._cycleTick + 1 end) - return rightPadding + return 2 * Iris._config.ItemInnerSpacing.X + 2 * textHeight end function generateInputScalar(dataType: InputDataTypes, components: number, defaultValue: any) @@ -280,7 +278,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) local textHeight: number = Iris._config.TextSize + 2 * Iris._config.FramePadding.Y if components == 1 then - rightPadding = generateButtons(thisWidget :: any, Input, rightPadding, textHeight) + rightPadding = generateButtons(thisWidget :: any, Input, textHeight) end -- 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) if components == 1 then Input.SubButton.Visible = not thisWidget.arguments.NoButtons Input.AddButton.Visible = not thisWidget.arguments.NoButtons + local rightPadding: number = if thisWidget.arguments.NoButtons then 0 else (2 * Iris._config.ItemInnerSpacing.X) + (2 * (Iris._config.TextSize + 2 * Iris._config.FramePadding.Y)) + local InputField: TextBox = Input.InputField1 + InputField.Size = UDim2.new(UDim.new(Iris._config.ContentWidth.Scale, Iris._config.ContentWidth.Offset - rightPadding), Iris._config.ContentHeight) end if thisWidget.arguments.Format and typeof(thisWidget.arguments.Format) ~= "table" then diff --git a/lib/widgets/Plot.lua b/lib/widgets/Plot.lua index bbfd55c..aad6c18 100644 --- a/lib/widgets/Plot.lua +++ b/lib/widgets/Plot.lua @@ -158,7 +158,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) end end - local function updateLine(thisWidget: Types.PlotLines) + local function updateLine(thisWidget: Types.PlotLines, silent: true?) local PlotLines = thisWidget.Instance :: Frame local Background = PlotLines.Background :: Frame local Plot = Background.Plot :: Frame @@ -171,7 +171,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) local line: Frame? = thisWidget.Lines[index] if line then - if line ~= thisWidget.HoveredLine then + if line ~= thisWidget.HoveredLine and not silent then clearLine(thisWidget) end local start: number? = thisWidget.state.values.value[index] @@ -186,7 +186,11 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) thisWidget.HoveredLine = line line.BackgroundColor3 = Iris._config.PlotLinesHoveredColor line.BackgroundTransparency = Iris._config.PlotLinesHoveredTransparency - thisWidget.state.hovered:set({ start, stop }) + if silent then + thisWidget.state.hovered.value = { start, stop } + else + thisWidget.state.hovered:set({ start, stop }) + end end end @@ -379,9 +383,9 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) end -- only update the hovered block if it exists. - -- if thisWidget.HoveredLine then - -- updateLine(thisWidget) - -- end + if thisWidget.HoveredLine then + updateLine(thisWidget, true) + end end end, Discard = function(thisWidget: Types.PlotLines) @@ -411,7 +415,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) end end - local function updateBlock(thisWidget: Types.PlotHistogram) + local function updateBlock(thisWidget: Types.PlotHistogram, silent: true?) local PlotHistogram = thisWidget.Instance :: Frame local Background = PlotHistogram.Background :: Frame local Plot = Background.Plot :: Frame @@ -424,7 +428,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) local block: Frame? = thisWidget.Blocks[index] if block then - if block ~= thisWidget.HoveredBlock then + if block ~= thisWidget.HoveredBlock and not silent then clearBlock(thisWidget) end local value: number? = thisWidget.state.values.value[index] @@ -434,7 +438,11 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) thisWidget.HoveredBlock = block block.BackgroundColor3 = Iris._config.PlotHistogramHoveredColor block.BackgroundTransparency = Iris._config.PlotHistogramHoveredTransparency - thisWidget.state.hovered:set(value) + if silent then + thisWidget.state.hovered.value = value + else + thisWidget.state.hovered:set(value) + end end end @@ -626,7 +634,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) -- only update the hovered block if it exists. if thisWidget.HoveredBlock then - updateBlock(thisWidget) + updateBlock(thisWidget, true) end end end,