2121---- ------------------------------------
2222local GuiUtilities = require (script .Parent .GuiUtilities )
2323
24- local kRightButtonAsset = " rbxasset://textures/DeveloperFramework/button_arrow_right.png"
25- local kDownButtonAsset = " rbxasset://textures/DeveloperFramework/button_arrow_down.png"
24+ local kLightRightButtonAsset = " rbxasset://studio_svg_textures/Shared/Navigation/Light/Standard/ArrowRight.png"
25+ local kLightDownButtonAsset = " rbxasset://studio_svg_textures/Shared/Navigation/Light/Standard/ArrowDown.png"
26+ local kDarkRightButtonAsset = " rbxasset://studio_svg_textures/Shared/Navigation/Dark/Standard/ArrowRight.png"
27+ local kDarkDownButtonAsset = " rbxasset://studio_svg_textures/Shared/Navigation/Dark/Standard/ArrowDown.png"
2628
27- local kArrowSize = 7
29+ local kArrowSize = 16
2830
2931local CollapsibleTitledSectionClass = {}
3032CollapsibleTitledSectionClass .__index = CollapsibleTitledSectionClass
3133
32- function CollapsibleTitledSectionClass .new (nameSuffix , titleText , autoScalingList , minimizable , minimizedByDefault )
34+ -- Creates a new CollapsibleTitledSectionClass
35+ function CollapsibleTitledSectionClass .new (
36+ nameSuffix : string ,
37+ titleText : string ,
38+ autoScalingList : boolean ,
39+ minimizable : boolean ,
40+ minimizedByDefault : boolean
41+ )
3342 local self = {}
3443 setmetatable (self , CollapsibleTitledSectionClass )
3544
@@ -74,41 +83,56 @@ function CollapsibleTitledSectionClass.new(nameSuffix, titleText, autoScalingLis
7483 return self
7584end
7685
86+ -- Returns the frame of the section
7787function CollapsibleTitledSectionClass :GetSectionFrame ()
7888 return self ._frame
7989end
8090
91+ -- Returns the frame of the section's contents frame
8192function CollapsibleTitledSectionClass :GetContentsFrame ()
8293 return self ._contentsFrame
8394end
8495
96+ -- Updates the size of frame of the section
8597function CollapsibleTitledSectionClass :_UpdateSize ()
8698 local totalSize = self ._uiListLayout .AbsoluteContentSize .Y
8799 self ._frame .Size = UDim2 .new (1 , 0 , 0 , totalSize )
88100end
89101
102+ -- Updates the minimize button's image
90103function CollapsibleTitledSectionClass :_UpdateMinimizeButton ()
91104 -- We can't rotate it because rotated images don't get clipped by parents.
92105 -- This is all in a scroll widget.
93106 -- :(
94107 if self ._minimized then
95- self ._minimizeButton .Image = kRightButtonAsset
108+ if GuiUtilities .ShouldUseIconsForDarkerBackgrounds () then
109+ self ._minimizeButton .Image = kDarkRightButtonAsset
110+ else
111+ self ._minimizeButton .Image = kLightRightButtonAsset
112+ end
96113 else
97- self ._minimizeButton .Image = kDownButtonAsset
114+ if GuiUtilities .ShouldUseIconsForDarkerBackgrounds () then
115+ self ._minimizeButton .Image = kDarkDownButtonAsset
116+ else
117+ self ._minimizeButton .Image = kLightDownButtonAsset
118+ end
98119 end
99120end
100121
122+ -- Sets the state of the section to collapsed or not
101123function CollapsibleTitledSectionClass :SetCollapsedState (bool )
102124 self ._minimized = bool
103125 self ._contentsFrame .Visible = not bool
104126 self :_UpdateMinimizeButton ()
105127 self :_UpdateSize ()
106128end
107129
130+ -- Toggles the state of the section
108131function CollapsibleTitledSectionClass :_ToggleCollapsedState ()
109132 self :SetCollapsedState (not self ._minimized )
110133end
111134
135+ -- Creates the title bar of the section
112136function CollapsibleTitledSectionClass :_CreateTitleBar (titleText )
113137 local titleTextOffset = self ._titleBarHeight
114138
@@ -137,7 +161,6 @@ function CollapsibleTitledSectionClass:_CreateTitleBar(titleText)
137161
138162 self ._minimizeButton = Instance .new (" ImageButton" )
139163 self ._minimizeButton .Name = " MinimizeSectionButton"
140- self ._minimizeButton .Image = kRightButtonAsset -- TODO: input arrow image from spec
141164 self ._minimizeButton .Size = UDim2 .new (0 , kArrowSize , 0 , kArrowSize )
142165 self ._minimizeButton .AnchorPoint = Vector2 .new (0.5 , 0.5 )
143166 self ._minimizeButton .Position = UDim2 .new (0 , self ._titleBarHeight * 0.5 , 0 , self ._titleBarHeight * 0.5 )
@@ -153,21 +176,26 @@ function CollapsibleTitledSectionClass:_CreateTitleBar(titleText)
153176 settings ().Studio .ThemeChanged :Connect (_UpdateMinimizeButtonTheme )
154177 _UpdateMinimizeButtonTheme ()
155178
156- titleBar .InputBegan :Connect (function (input )
179+ titleBar .InputBegan :Connect (function (input : Enum.UserInputType )
157180 if input .UserInputType == Enum .UserInputType .MouseMovement then
158181 self ._hovered = true
159182 self :_updateButtonVisual ()
160183 end
161184 end )
162185
163- titleBar .InputEnded :Connect (function (input )
186+ titleBar .InputEnded :Connect (function (input : Enum.UserInputType )
164187 if input .UserInputType == Enum .UserInputType .MouseMovement then
165188 self ._hovered = false
166189 self ._clicked = false
167190 self :_updateButtonVisual ()
168191 end
169192 end )
170193
194+ self ._minimizeButton .MouseButton1Click :Connect (function ()
195+ self ._clicked = true
196+ self :_ToggleCollapsedState ()
197+ end )
198+
171199 titleBar .MouseButton1Down :Connect (function ()
172200 self ._clicked = true
173201 self :_updateButtonVisual ()
@@ -176,20 +204,15 @@ function CollapsibleTitledSectionClass:_CreateTitleBar(titleText)
176204 self :_ToggleCollapsedState ()
177205 end
178206 end )
179-
180- titleBar .MouseButton1Up :Connect (function ()
181- self ._clicked = false
182- self :_updateButtonVisual ()
183- end )
184207end
185208
209+ -- Updates the visual of the button
186210function CollapsibleTitledSectionClass :_updateButtonVisual ()
187211 local kTitlebarDefaultBackgroundColor =
188212 settings ().Studio .Theme :GetColor (Enum .StudioStyleGuideColor .CategoryItem , Enum .StudioStyleGuideModifier .Default )
189213 local kTitlebarHoverBackgroundColor =
190214 settings ().Studio .Theme :GetColor (Enum .StudioStyleGuideColor .Button , Enum .StudioStyleGuideModifier .Hover )
191215
192-
193216 if self ._hovered then
194217 self ._titleBar .BackgroundColor3 = kTitlebarHoverBackgroundColor
195218 else
0 commit comments