Skip to content

Commit

Permalink
Renamed instances and fixes.
Browse files Browse the repository at this point in the history
Renamed ChildContainer names to make them easier to see in the explorer and small fixes.
  • Loading branch information
SirMallard committed Aug 6, 2024
1 parent 4b1acfe commit b620096
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 103 deletions.
1 change: 0 additions & 1 deletion .styluaignore

This file was deleted.

18 changes: 11 additions & 7 deletions lib/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
155 changes: 77 additions & 78 deletions lib/demoWindow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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" })
Expand Down
15 changes: 8 additions & 7 deletions lib/widgets/Tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
21 changes: 11 additions & 10 deletions lib/widgets/Window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit b620096

Please sign in to comment.