From b6200966fb1e5cfb0b11f719011289100ac29d42 Mon Sep 17 00:00:00 2001 From: Sir Mallard <73789875+SirMallard@users.noreply.github.com> Date: Tue, 6 Aug 2024 18:14:08 +0100 Subject: [PATCH] Renamed instances and fixes. Renamed ChildContainer names to make them easier to see in the explorer and small fixes. --- .styluaignore | 1 - lib/config.lua | 18 +++-- lib/demoWindow.lua | 155 ++++++++++++++++++++--------------------- lib/widgets/Tree.lua | 15 ++-- lib/widgets/Window.lua | 21 +++--- 5 files changed, 107 insertions(+), 103 deletions(-) delete mode 100644 .styluaignore diff --git a/.styluaignore b/.styluaignore deleted file mode 100644 index 79bd370..0000000 --- a/.styluaignore +++ /dev/null @@ -1 +0,0 @@ -src\client\Iris\DemoWindow.lua \ No newline at end of file diff --git a/lib/config.lua b/lib/config.lua index 09d156f..da126a0 100644 --- a/lib/config.lua +++ b/lib/config.lua @@ -5,18 +5,20 @@ local TemplateConfig = { TextDisabledColor = Color3.fromRGB(128, 128, 128), TextDisabledTransparency = 0, - BorderColor = Color3.fromRGB(110, 110, 125), -- Dear ImGui uses 110, 110, 125 -- The Roblox window selection highlight is 67, 191, 254 + BorderColor = Color3.fromRGB(110, 110, 125), BorderActiveColor = Color3.fromRGB(160, 160, 175), -- does not exist in Dear ImGui - BorderTransparency = 0.5, - BorderActiveTransparency = 0.3, -- BorderTransparency will be problematic for non UIStroke border implimentations -- is not implimented because of this + BorderTransparency = 0.5, + BorderActiveTransparency = 0.3, WindowBgColor = Color3.fromRGB(15, 15, 15), - WindowBgTransparency = 0.072, + WindowBgTransparency = 0.06, + PopupBgColor = Color3.fromRGB(20, 20, 20), + PopupBgTransparency = 0.06, ScrollbarGrabColor = Color3.fromRGB(128, 128, 128), ScrollbarGrabTransparency = 0, @@ -96,18 +98,20 @@ local TemplateConfig = { TextDisabledColor = Color3.fromRGB(153, 153, 153), TextDisabledTransparency = 0, - BorderColor = Color3.fromRGB(64, 64, 64), -- Dear ImGui uses 0, 0, 0, 77 -- The Roblox window selection highlight is 67, 191, 254 + BorderColor = Color3.fromRGB(64, 64, 64), BorderActiveColor = Color3.fromRGB(64, 64, 64), -- does not exist in Dear ImGui - BorderTransparency = 0.5, - BorderActiveTransparency = 0.2, -- BorderTransparency will be problematic for non UIStroke border implimentations -- will not be implimented because of this + BorderTransparency = 0.5, + BorderActiveTransparency = 0.2, WindowBgColor = Color3.fromRGB(240, 240, 240), WindowBgTransparency = 0, + PopupBgColor = Color3.fromRGB(255, 255, 255), + PopupBgTransparency = 0.02, TitleBgColor = Color3.fromRGB(245, 245, 245), TitleBgTransparency = 0, diff --git a/lib/demoWindow.lua b/lib/demoWindow.lua index 84045a3..61d7b5b 100644 --- a/lib/demoWindow.lua +++ b/lib/demoWindow.lua @@ -136,6 +136,82 @@ return function(Iris: Types.Iris) Iris.End() end, + Selectable = function() + Iris.Tree({ "Selectable" }) + do + local sharedIndex = Iris.State(2) + Iris.Selectable({ "Selectable #1", 1 }, { index = sharedIndex }) + Iris.Selectable({ "Selectable #2", 2 }, { index = sharedIndex }) + if Iris.Selectable({ "Double click Selectable", 3, true }, { index = sharedIndex }).doubleClicked() then + sharedIndex:set(3) + end + + Iris.Selectable({ "Impossible to select", 4, true }, { index = sharedIndex }) + if Iris.Button({ "Select last" }).clicked() then + sharedIndex:set(4) + end + + Iris.Selectable({ "Independent Selectable" }) + end + Iris.End() + end, + + Combo = function() + Iris.Tree({ "Combo" }) + do + Iris.PushConfig({ ContentWidth = UDim.new(1, -200) }) + local sharedComboIndex = Iris.State("No Selection") + + local NoPreview, NoButton + Iris.SameLine() + do + NoPreview = Iris.Checkbox({ "No Preview" }) + NoButton = Iris.Checkbox({ "No Button" }) + if NoPreview.checked() and NoButton.isChecked.value == true then + NoButton.isChecked:set(false) + end + if NoButton.checked() and NoPreview.isChecked.value == true then + NoPreview.isChecked:set(false) + end + end + Iris.End() + + Iris.Combo({ "Basic Usage", NoButton.isChecked:get(), NoPreview.isChecked:get() }, { index = sharedComboIndex }) + do + Iris.Selectable({ "Select 1", "One" }, { index = sharedComboIndex }) + Iris.Selectable({ "Select 2", "Two" }, { index = sharedComboIndex }) + Iris.Selectable({ "Select 3", "Three" }, { index = sharedComboIndex }) + end + Iris.End() + + Iris.ComboArray({ "Using ComboArray" }, { index = "No Selection" }, { "Red", "Green", "Blue" }) + + local sharedComboIndex2 = Iris.State("7 AM") + + Iris.Combo({ "Combo with Inner widgets" }, { index = sharedComboIndex2 }) + do + Iris.Tree({ "Morning Shifts" }) + do + Iris.Selectable({ "Shift at 7 AM", "7 AM" }, { index = sharedComboIndex2 }) + Iris.Selectable({ "Shift at 11 AM", "11 AM" }, { index = sharedComboIndex2 }) + Iris.Selectable({ "Shift at 3 PM", "3 PM" }, { index = sharedComboIndex2 }) + end + Iris.End() + Iris.Tree({ "Night Shifts" }) + do + Iris.Selectable({ "Shift at 6 PM", "6 PM" }, { index = sharedComboIndex2 }) + Iris.Selectable({ "Shift at 9 PM", "9 PM" }, { index = sharedComboIndex2 }) + end + Iris.End() + end + Iris.End() + + local ComboEnum = Iris.ComboEnum({ "Using ComboEnum" }, { index = Enum.UserInputState.Begin }, Enum.UserInputState) + Iris.Text({ "Selected: " .. ComboEnum.index:get().Name }) + Iris.PopConfig() + end + Iris.End() + end, Tree = function() Iris.Tree({ "Trees" }) do @@ -386,83 +462,6 @@ return function(Iris: Types.Iris) Iris.PopConfig() end, - Selectable = function() - Iris.Tree({ "Selectable" }) - do - local sharedIndex = Iris.State(2) - Iris.Selectable({ "Selectable #1", 1 }, { index = sharedIndex }) - Iris.Selectable({ "Selectable #2", 2 }, { index = sharedIndex }) - if Iris.Selectable({ "Double click Selectable", 3, true }, { index = sharedIndex }).doubleClicked() then - sharedIndex:set(3) - end - - Iris.Selectable({ "Impossible to select", 4, true }, { index = sharedIndex }) - if Iris.Button({ "Select last" }).clicked() then - sharedIndex:set(4) - end - - Iris.Selectable({ "Independent Selectable" }) - end - Iris.End() - end, - - Combo = function() - Iris.Tree({ "Combo" }) - do - Iris.PushConfig({ ContentWidth = UDim.new(1, -120) }) - local sharedComboIndex = Iris.State("No Selection") - - local NoPreview, NoButton - Iris.SameLine() - do - NoPreview = Iris.Checkbox({ "No Preview" }) - NoButton = Iris.Checkbox({ "No Button" }) - if NoPreview.checked() and NoButton.isChecked.value == true then - NoButton.isChecked:set(false) - end - if NoButton.checked() and NoPreview.isChecked.value == true then - NoPreview.isChecked:set(false) - end - end - Iris.End() - - Iris.Combo({ "Basic Usage", NoButton.isChecked:get(), NoPreview.isChecked:get() }, { index = sharedComboIndex }) - do - Iris.Selectable({ "Select 1", "One" }, { index = sharedComboIndex }) - Iris.Selectable({ "Select 2", "Two" }, { index = sharedComboIndex }) - Iris.Selectable({ "Select 3", "Three" }, { index = sharedComboIndex }) - end - Iris.End() - - Iris.ComboArray({ "Using ComboArray" }, { index = "No Selection" }, { "Red", "Green", "Blue" }) - - local sharedComboIndex2 = Iris.State("7 AM") - - Iris.Combo({ "Combo with Inner widgets" }, { index = sharedComboIndex2 }) - do - Iris.Tree({ "Morning Shifts" }) - do - Iris.Selectable({ "Shift at 7 AM", "7 AM" }, { index = sharedComboIndex2 }) - Iris.Selectable({ "Shift at 11 AM", "11 AM" }, { index = sharedComboIndex2 }) - Iris.Selectable({ "Shift at 3 PM", "3 PM" }, { index = sharedComboIndex2 }) - end - Iris.End() - Iris.Tree({ "Night Shifts" }) - do - Iris.Selectable({ "Shift at 6 PM", "6 PM" }, { index = sharedComboIndex2 }) - Iris.Selectable({ "Shift at 9 PM", "9 PM" }, { index = sharedComboIndex2 }) - end - Iris.End() - end - Iris.End() - - local ComboEnum = Iris.ComboEnum({ "Using ComboEnum" }, { index = Enum.UserInputState.Begin }, Enum.UserInputState) - Iris.Text({ "Selected: " .. ComboEnum.index:get().Name }) - Iris.PopConfig() - end - Iris.End() - end, - Plotting = function() Iris.Tree({ "Plotting" }) do @@ -479,7 +478,7 @@ return function(Iris: Types.Iris) Iris.End() end, } - local widgetDemosOrder = { "Basic", "Image", "Tree", "CollapsingHeader", "Group", "Indent", "Input", "MultiInput", "InputText", "Tooltip", "Selectable", "Combo", "Plotting" } + local widgetDemosOrder = { "Basic", "Image", "Selectable", "Combo", "Tree", "CollapsingHeader", "Group", "Indent", "Input", "MultiInput", "InputText", "Tooltip", "Plotting" } local function recursiveTree() local theTree = Iris.Tree({ "Recursive Tree" }) diff --git a/lib/widgets/Tree.lua b/lib/widgets/Tree.lua index e4d7a71..cce3cfb 100644 --- a/lib/widgets/Tree.lua +++ b/lib/widgets/Tree.lua @@ -25,9 +25,8 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) thisWidget.Instance:Destroy() widgets.discardState(thisWidget) end, - ChildAdded = function(thisWidget: Types.Widget) - local Tree = thisWidget.Instance :: Frame - local ChildContainer: Frame = Tree.ChildContainer + ChildAdded = function(thisWidget: Types.Widget, _otherWidget: Types.Widget) + local ChildContainer = thisWidget.ChildContainer :: Frame ChildContainer.Visible = thisWidget.state.isUncollapsed.value @@ -36,7 +35,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) UpdateState = function(thisWidget: Types.Widget) local isUncollapsed: boolean = thisWidget.state.isUncollapsed.value local Tree = thisWidget.Instance :: Frame - local ChildContainer: Frame = Tree.ChildContainer + local ChildContainer = thisWidget.ChildContainer :: Frame local Header = Tree.Header :: Frame local Button = Header.Button :: TextButton local Arrow: ImageLabel = Button.Arrow @@ -78,7 +77,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) widgets.UIListLayout(Tree, Enum.FillDirection.Vertical, UDim.new(0, 0)) local ChildContainer: Frame = Instance.new("Frame") - ChildContainer.Name = "ChildContainer" + ChildContainer.Name = "TreeContainer" ChildContainer.Size = UDim2.fromScale(1, 0) ChildContainer.AutomaticSize = Enum.AutomaticSize.Y ChildContainer.BackgroundTransparency = 1 @@ -152,14 +151,15 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) thisWidget.state.isUncollapsed:set(not thisWidget.state.isUncollapsed.value) end) + thisWidget.ChildContainer = ChildContainer return Tree end, Update = function(thisWidget: Types.Widget) local Tree = thisWidget.Instance :: Frame + local ChildContainer = thisWidget.ChildContainer :: Frame local Header = Tree.Header :: Frame local Button = Header.Button :: TextButton local TextLabel: TextLabel = Button.TextLabel - local ChildContainer = Tree.ChildContainer :: Frame local Padding: UIPadding = ChildContainer.UIPadding TextLabel.Text = thisWidget.arguments.Text or "Tree" @@ -199,7 +199,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) widgets.UIListLayout(CollapsingHeader, Enum.FillDirection.Vertical, UDim.new(0, 0)) local ChildContainer: Frame = Instance.new("Frame") - ChildContainer.Name = "ChildContainer" + ChildContainer.Name = "CollapsingHeaderContainer" ChildContainer.Size = UDim2.fromScale(1, 0) ChildContainer.AutomaticSize = Enum.AutomaticSize.Y ChildContainer.BackgroundTransparency = 1 @@ -278,6 +278,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) thisWidget.state.isUncollapsed:set(not thisWidget.state.isUncollapsed.value) end) + thisWidget.ChildContainer = ChildContainer return CollapsingHeader end, Update = function(thisWidget: Types.Widget) diff --git a/lib/widgets/Window.lua b/lib/widgets/Window.lua index 6f3bc1d..9852123 100644 --- a/lib/widgets/Window.lua +++ b/lib/widgets/Window.lua @@ -43,8 +43,8 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) TooltipText.Name = "TooltipText" TooltipText.Size = UDim2.fromOffset(0, 0) TooltipText.AutomaticSize = Enum.AutomaticSize.XY - TooltipText.BackgroundColor3 = Iris._config.WindowBgColor - TooltipText.BackgroundTransparency = Iris._config.WindowBgTransparency + TooltipText.BackgroundColor3 = Iris._config.PopupBgColor + TooltipText.BackgroundTransparency = Iris._config.PopupBgTransparency TooltipText.BorderSizePixel = Iris._config.PopupBorderSize TooltipText.TextWrapped = Iris._config.TextWrapped @@ -199,7 +199,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) if TitleBar.Visible then widgets.GuiService:Select(TitleBar) else - widgets.GuiService:Select(Window.ChildContainer) + widgets.GuiService:Select(thisWidget.ChildContainer) end end end @@ -448,7 +448,7 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) UIListLayout.VerticalAlignment = Enum.VerticalAlignment.Top local ChildContainer: ScrollingFrame = Instance.new("ScrollingFrame") - ChildContainer.Name = "ChildContainer" + ChildContainer.Name = "WindowContainer" ChildContainer.Size = UDim2.fromScale(1, 1) ChildContainer.Position = UDim2.fromOffset(0, 0) ChildContainer.BackgroundColor3 = Iris._config.WindowBgColor @@ -697,16 +697,17 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) end end) + thisWidget.ChildContainer = ChildContainer return Window end, Update = function(thisWidget: Types.Widget) - local WindowGui = thisWidget.Instance :: GuiObject - local WindowButton = WindowGui.WindowButton :: TextButton + local Window = thisWidget.Instance :: GuiObject + local ChildContainer = thisWidget.ChildContainer :: ScrollingFrame + local WindowButton = Window.WindowButton :: TextButton local Content = WindowButton.Content :: Frame local TitleBar = Content.TitleBar :: Frame local Title: TextLabel = TitleBar.Title local MenuBar: Frame? = Content:FindFirstChild("MenuBar") - local ChildContainer: ScrollingFrame = Content.ChildContainer local ResizeGrip: TextButton = WindowButton.ResizeGrip if thisWidget.arguments.NoResize ~= true then @@ -773,12 +774,12 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) local WindowButton = Window.WindowButton :: TextButton local Content = WindowButton.Content :: Frame if thisChid.type == "MenuBar" then - local ChildContainer: ScrollingFrame = Content.ChildContainer + local ChildContainer = thisWidget.ChildContainer :: ScrollingFrame thisChid.Instance.ZIndex = ChildContainer.ZIndex + 1 thisChid.Instance.LayoutOrder = ChildContainer.LayoutOrder - 1 return Content end - return Content.ChildContainer + return thisWidget.ChildContainer end, UpdateState = function(thisWidget: Types.Widget) local stateSize: Vector2 = thisWidget.state.size.value @@ -788,11 +789,11 @@ return function(Iris: Types.Internal, widgets: Types.WidgetUtility) local stateScrollDistance: number = thisWidget.state.scrollDistance.value local Window = thisWidget.Instance :: Frame + local ChildContainer = thisWidget.ChildContainer :: ScrollingFrame local WindowButton = Window.WindowButton :: TextButton local Content = WindowButton.Content :: Frame local TitleBar = Content.TitleBar :: Frame local MenuBar: Frame? = Content:FindFirstChild("MenuBar") - local ChildContainer: ScrollingFrame = Content.ChildContainer local ResizeGrip: TextButton = WindowButton.ResizeGrip WindowButton.Size = UDim2.fromOffset(stateSize.X, stateSize.Y)