66--
77---- ------------------------------------
88local GuiUtilities = require (script .Parent .GuiUtilities )
9-
109local VerticallyScalingListFrame = require (script .Parent .VerticallyScalingListFrame )
1110
11+ local kLightHelpImage = " rbxasset://studio_svg_textures/Shared/Navigation/Light/Large/Help.png"
12+ local kDarkHelpImage = " rbxasset://studio_svg_textures/Shared/Navigation/Dark/Large/Help.png"
13+ local kLightArrowImage = " rbxasset://studio_svg_textures/Shared/Navigation/Light/Large/Arrow.png" -- Check to see if this directory exists
14+ local kDarkArrowImage = " rbxasset://studio_svg_textures/Shared/Navigation/Dark/Large/Arrow.png" -- Do the same here
15+
1216local ItemClass = {}
1317ItemClass .__index = ItemClass
1418
@@ -23,22 +27,25 @@ function ItemClass.new(nameSuffix: string, labelText: string, multiLine: boolean
2327 -- Frame that contains the label and the content
2428 local frame = Instance .new (" TextButton" )
2529 frame .Name = " Item" .. nameSuffix
30+ frame .BorderSizePixel = 0
2631 frame .Text = " "
2732 frame .AutoButtonColor = false
33+ frame .AutomaticSize = Enum .AutomaticSize .Y
2834 frame .Size = UDim2 .new (1 , 0 , 0 , GuiUtilities .kDefaultPropertyHeight )
2935 GuiUtilities .syncGuiElementBackgroundColor (frame )
30- GuiUtilities .syncGuiElementShadowColor (frame )
36+ -- GuiUtilities.syncGuiElementShadowColor(frame)
3137 self ._frame = frame
3238
3339 -- Frame that contains the label so label can auto clip to size.
3440 local labelFrame = Instance .new (" Frame" )
3541 labelFrame .Name = " LabelFrame"
36- labelFrame .Size = UDim2 .new (1 , 0 , 0 , GuiUtilities .kDefaultPropertyHeight )
42+ labelFrame .Size = UDim2 .new (0.5 , 0 , 0 , GuiUtilities .kDefaultPropertyHeight )
3743 labelFrame .BackgroundTransparency = 1
3844 labelFrame .Position = UDim2 .new (0 , 0 , 0 , 0 )
3945 labelFrame .ClipsDescendants = true
4046 labelFrame .Parent = frame
4147
48+ -- Label that contains the property text
4249 local label = Instance .new (" TextLabel" )
4350 label .Name = " Label"
4451 label .BackgroundTransparency = 1
@@ -55,21 +62,24 @@ function ItemClass.new(nameSuffix: string, labelText: string, multiLine: boolean
5562 GuiUtilities .syncGuiElementFontColor (label )
5663 self ._label = label
5764
58- if not multiLine then
59- local contentFrame = Instance .new (" Frame" )
60- contentFrame .Name = " ContentFrame"
61- contentFrame .Size = UDim2 .new (0.5 , 0 , 0 , GuiUtilities .kDefaultPropertyHeight )
62- contentFrame .Position = UDim2 .new (0.5 , 0 , 0 , 0 )
63- contentFrame .Parent = frame
64- GuiUtilities .syncGuiElementBackgroundColor (contentFrame )
65- GuiUtilities .syncGuiElementShadowColor (contentFrame )
66- frame :GetPropertyChangedSignal (" BackgroundColor3" ):Connect (function ()
67- contentFrame .BackgroundColor3 = frame .BackgroundColor3
68- end )
69- else
70- VerticallyScalingListFrame .new (" ItemFrame" .. nameSuffix )
71- end
65+ -- This is a bad way of doing this. I've removed this as this sucks and needs a better way of doing this.
7266
67+ -- if not multiLine then
68+ -- local contentFrame = Instance.new("Frame")
69+ -- contentFrame.Name = "ContentFrame"
70+ -- contentFrame.Size = UDim2.new(0.5, 0, 0, GuiUtilities.kDefaultPropertyHeight)
71+ -- contentFrame.Position = UDim2.new(0.5, 0, 0, 0)
72+ -- contentFrame.Parent = frame
73+ -- GuiUtilities.syncGuiElementBackgroundColor(contentFrame)
74+ -- GuiUtilities.syncGuiElementShadowColor(contentFrame)
75+ -- frame:GetPropertyChangedSignal("BackgroundColor3"):Connect(function()
76+ -- contentFrame.BackgroundColor3 = frame.BackgroundColor3
77+ -- end)
78+ -- else
79+ -- VerticallyScalingListFrame.new("ItemFrame" .. nameSuffix)
80+ -- end
81+
82+ -- Move this down to a function
7383 if url then
7484 local help = Instance .new (" ImageButton" )
7585 help .Name = " Help"
@@ -86,9 +96,9 @@ function ItemClass.new(nameSuffix: string, labelText: string, multiLine: boolean
8696
8797 local function updateImages ()
8898 if GuiUtilities :ShouldUseIconsForDarkerBackgrounds () then
89- help .Image = " rbxasset://studio_svg_textures/Shared/Navigation/Dark/Large/Help.png "
99+ help .Image = kDarkHelpImage
90100 else
91- help .Image = " rbxasset://studio_svg_textures/Shared/Navigation/Light/Large/Help.png "
101+ help .Image = kLightHelpImage
92102 end
93103 help .ImageColor3 = label .TextColor3
94104 end
@@ -120,13 +130,14 @@ end
120130-- Setup the mouse click handling for the CollapsibleItem
121131function ItemClass :_SetupMouseClickHandling ()
122132 self ._frame .InputBegan :Connect (function ()
123- self ._hovered = true
124- self :_UpdateVisualState ()
133+ self ._hovered = true
134+ self :_UpdateVisualState ()
125135 end )
126136
127137 self ._frame .InputEnded :Connect (function ()
128- self ._hovered = false
129- self :_UpdateVisualState ()
138+ self ._hovered = false
139+ self :SetValue (false )
140+ self :_UpdateVisualState ()
130141 end )
131142
132143 self ._frame .MouseButton1Down :Connect (function ()
@@ -137,16 +148,83 @@ end
137148
138149-- Update the visual state of the CollapsibleItem
139150function ItemClass :_UpdateVisualState ()
140- if self ._selected then
141- self ._frame .BackgroundColor3 =
142- settings ().Studio .Theme :GetColor (Enum .StudioStyleGuideColor .Item , Enum .StudioStyleGuideModifier .Selected )
143- elseif self ._hovered then
144- self ._frame .BackgroundColor3 =
145- settings ().Studio .Theme :GetColor (Enum .StudioStyleGuideColor .Item , Enum .StudioStyleGuideModifier .Hover )
146- else
147- self ._frame .BackgroundColor3 =
148- settings ().Studio .Theme :GetColor (Enum .StudioStyleGuideColor .Item , Enum .StudioStyleGuideModifier .Default )
151+ -- TODO: Fix this or cut it out
152+
153+ -- if self._selected then
154+ -- self._frame.BackgroundColor3 =
155+ -- settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.Item, Enum.StudioStyleGuideModifier.Selected)
156+ -- elseif self._hovered then
157+ -- self._frame.BackgroundColor3 =
158+ -- settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.Item, Enum.StudioStyleGuideModifier.Hover)
159+ -- else
160+ -- self._frame.BackgroundColor3 =
161+ -- settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.Item, Enum.StudioStyleGuideModifier.Default)
162+ -- end
163+ end
164+
165+ -- Use the help icon. This will open the url in the wiki when clicked
166+ function ItemClass :UseHelp (url : string )
167+
168+ end
169+
170+ -- Use the CollapsibleItem as a toggleable frame
171+ function ItemClass :UseCollapsible ()
172+ -- Create a frame that is toggleable on click
173+ local toggleFrame = Instance .new (" Frame" )
174+ toggleFrame .Name = " ToggleFrame"
175+ toggleFrame .Size = UDim2 .new (1 , 0 , 0 , GuiUtilities .kDefaultPropertyHeight )
176+ toggleFrame .Position = UDim2 .new (0 , 0 , 0 , 0 )
177+ toggleFrame .Parent = self ._frame
178+
179+ local toggle = Instance .new (" ImageButton" )
180+ toggle .Name = " Toggle"
181+ toggle .BackgroundTransparency = 1
182+ toggle .Size = UDim2 .new (0 , GuiUtilities .kDefaultFontSize , 0 , GuiUtilities .kDefaultFontSize )
183+ toggle .Position = UDim2 .new (0 , 0 , 0.5 , 0 )
184+ toggle .AnchorPoint = Vector2 .new (0 , 0.5 )
185+ toggle .Parent = toggleFrame
186+ self ._toggle = toggle
187+
188+ local function updateImages ()
189+ if GuiUtilities :ShouldUseIconsForDarkerBackgrounds () then
190+ toggle .Image = kLightArrowImage
191+ else
192+ toggle .Image = kDarkArrowImage
193+ end
194+ toggle .ImageColor3 = settings ().Studio .Theme :GetColor (Enum .StudioStyleGuideColor .MainText )
195+ end
196+ settings ().Studio .ThemeChanged :Connect (updateImages )
197+ updateImages ()
198+
199+ local function updateTogglePosition ()
200+ local labelWidth = self ._label .TextBounds .X
201+ toggle .Position = UDim2 .new (0 , labelWidth + 4 , 0.5 , 0 )
149202 end
203+ self ._label :GetPropertyChangedSignal (" TextBounds" ):Connect (updateTogglePosition )
204+ updateTogglePosition ()
205+
206+ self ._selected = true
207+
208+ self :_UpdateVisualState ()
209+
210+ -- Create a frame that is the content of the CollapsibleItem
211+ local contentFrame = Instance .new (" Frame" )
212+ contentFrame .Name = " ContentFrame"
213+ contentFrame .Size = UDim2 .new (1 , 0 , 0 , 0 )
214+ contentFrame .Position = UDim2 .new (0 , 0 , 1 , 0 )
215+ contentFrame .Parent = self ._frame
216+ self ._contentFrame = contentFrame
217+
218+ toggle .MouseButton1Click :Connect (function ()
219+ self ._selected = not self ._selected
220+ self :_UpdateVisualState ()
221+ self :_UpdateContentVisualState ()
222+ if self ._valueChangedFunction then
223+ self ._valueChangedFunction (self ._selected )
224+ end
225+ end )
226+
227+ self :_UpdateContentVisualState ()
150228end
151229
152230-- Fires when the CollapsibleItem is selected
0 commit comments