@@ -11,11 +11,18 @@ local kMinTextSize = 14
1111local kMinHeight = 24
1212local kMinLabelWidth = GuiUtilities .kCheckboxMinLabelWidth
1313local kMinMargin = GuiUtilities .kCheckboxMinMargin
14- local kMinButtonWidth = kCheckboxWidth ;
15-
16- local kButtonDefaultBackgroundColor = settings ().Studio .Theme :GetColor (Enum .StudioStyleGuideColor .FilterButtonDefault , Enum .StudioStyleGuideModifier .Default )
17- local kButtonHoverBackgroundColor = settings ().Studio .Theme :GetColor (Enum .StudioStyleGuideColor .FilterButtonHover , Enum .StudioStyleGuideModifier .Hover )
18- local kButtonPressedBackgroundColor = settings ().Studio .Theme :GetColor (Enum .StudioStyleGuideColor .FilterButtonChecked , Enum .StudioStyleGuideModifier .Pressed )
14+ local kMinButtonWidth = kCheckboxWidth
15+
16+ local kButtonDefaultBackgroundColor = settings ().Studio .Theme :GetColor (
17+ Enum .StudioStyleGuideColor .FilterButtonDefault ,
18+ Enum .StudioStyleGuideModifier .Default
19+ )
20+ local kButtonHoverBackgroundColor =
21+ settings ().Studio .Theme :GetColor (Enum .StudioStyleGuideColor .FilterButtonHover , Enum .StudioStyleGuideModifier .Hover )
22+ local kButtonPressedBackgroundColor = settings ().Studio .Theme :GetColor (
23+ Enum .StudioStyleGuideColor .FilterButtonChecked ,
24+ Enum .StudioStyleGuideModifier .Pressed
25+ )
1926
2027LabeledButtonClass = {}
2128LabeledButtonClass .__index = LabeledButtonClass
@@ -45,7 +52,7 @@ function LabeledButtonClass.new(nameSuffix, labelText, initValue, initDisabled)
4552 local label = Instance .new (" TextButton" )
4653 label .Text = labelText
4754 label .RichText = true
48- label .Name = ' Label'
55+ label .Name = " Label"
4956 label .Font = GuiUtilities .kDefaultFontFace
5057 label .TextSize = GuiUtilities .kDefaultFontSize
5158 label .BackgroundTransparency = 1
@@ -91,19 +98,18 @@ function LabeledButtonClass:_MaybeToggleState()
9198 if not self ._disabled then
9299 self :SetValue (not self ._value )
93100 end
94-
95101end
96102
97103function LabeledButtonClass :_SetupMouseClickHandling ()
98104 self ._label .InputBegan :Connect (function (input )
99- if ( input .UserInputType == Enum .UserInputType .MouseMovement ) then
105+ if input .UserInputType == Enum .UserInputType .MouseMovement then
100106 self ._hovered = true
101107 self :_updateCheckboxVisual ()
102108 end
103109 end )
104110
105111 self ._label .InputEnded :Connect (function (input )
106- if ( input .UserInputType == Enum .UserInputType .MouseMovement ) then
112+ if input .UserInputType == Enum .UserInputType .MouseMovement then
107113 self ._hovered = false
108114 self ._clicked = false
109115 self :_updateCheckboxVisual ()
@@ -120,36 +126,45 @@ end
120126function LabeledButtonClass :_HandleUpdatedValue ()
121127 self ._button .Visible = self :GetValue ()
122128
123- if ( self ._valueChangedFunction ) then
129+ if self ._valueChangedFunction then
124130 self ._valueChangedFunction (self :GetValue ())
125131 end
126132end
127133
128134-- Too buggy with other GuiObjects to be used.
129135function LabeledButtonClass :_updateCheckboxVisual ()
130- local kButtonDefaultBackgroundColor = settings ().Studio .Theme :GetColor (Enum .StudioStyleGuideColor .FilterButtonDefault , Enum .StudioStyleGuideModifier .Default )
131- local kButtonHoverBackgroundColor = settings ().Studio .Theme :GetColor (Enum .StudioStyleGuideColor .FilterButtonHover , Enum .StudioStyleGuideModifier .Hover )
132- local kButtonPressedBackgroundColor = settings ().Studio .Theme :GetColor (Enum .StudioStyleGuideColor .FilterButtonChecked , Enum .StudioStyleGuideModifier .Pressed )
133-
134- if (self ._value ) then
136+ local kButtonDefaultBackgroundColor = settings ().Studio .Theme :GetColor (
137+ Enum .StudioStyleGuideColor .FilterButtonDefault ,
138+ Enum .StudioStyleGuideModifier .Default
139+ )
140+ local kButtonHoverBackgroundColor = settings ().Studio .Theme :GetColor (
141+ Enum .StudioStyleGuideColor .FilterButtonHover ,
142+ Enum .StudioStyleGuideModifier .Hover
143+ )
144+ local kButtonPressedBackgroundColor = settings ().Studio .Theme :GetColor (
145+ Enum .StudioStyleGuideColor .FilterButtonChecked ,
146+ Enum .StudioStyleGuideModifier .Pressed
147+ )
148+
149+ if self ._value then
135150 self ._button .BackgroundColor3 = kButtonPressedBackgroundColor
136- elseif ( self ._clicked ) then
151+ elseif self ._clicked then
137152 self ._button .BackgroundColor3 = kButtonPressedBackgroundColor
138- elseif ( self ._hovered ) then
153+ elseif self ._hovered then
139154 self ._button .BackgroundColor3 = kButtonHoverBackgroundColor
140155 else
141156 self ._button .BackgroundColor3 = kButtonDefaultBackgroundColor
142157 end
143158end
144159
145160function LabeledButtonClass :_HandleUpdatedValue ()
146- if ( self :GetValue ()) then
161+ if self :GetValue () then
147162 self ._button .BackgroundColor3 = kButtonPressedBackgroundColor
148163 else
149164 self ._button .BackgroundColor3 = kButtonDefaultBackgroundColor
150165 end
151166
152- if ( self ._valueChangedFunction ) then
167+ if self ._valueChangedFunction then
153168 self ._valueChangedFunction (self :GetValue ())
154169 end
155170end
@@ -159,9 +174,9 @@ function LabeledButtonClass:GetFrame()
159174end
160175
161176function LabeledButtonClass :GetValue ()
162- -- If button is disabled, and we should be using a disabled override,
177+ -- If button is disabled, and we should be using a disabled override,
163178 -- use the disabled override.
164- if ( self ._disabled and self ._useDisabledOverride ) then
179+ if self ._disabled and self ._useDisabledOverride then
165180 return self ._disabledOverride
166181 else
167182 return self ._value
@@ -176,7 +191,7 @@ function LabeledButtonClass:GetButton()
176191 return self ._button
177192end
178193
179- function LabeledButtonClass :SetValueChangedFunction (vcFunction )
194+ function LabeledButtonClass :SetValueChangedFunction (vcFunction )
180195 self ._valueChangedFunction = vcFunction
181196end
182197
@@ -188,28 +203,30 @@ function LabeledButtonClass:SetDisabled(newDisabled)
188203 if newDisabled ~= self ._disabled then
189204 self ._disabled = newDisabled
190205
191- -- if we are no longer disabled, then we don't need or want
206+ -- if we are no longer disabled, then we don't need or want
192207 -- the override any more. Forget it.
193- if ( not self ._disabled ) then
208+ if not self ._disabled then
194209 self ._useDisabledOverride = false
195210 end
196211
197212 self :UpdateFontColors ()
198- self ._button .BackgroundColor3 = self ._disabled and GuiUtilities .kButtonDisabledBackgroundColor or GuiUtilities .kButtonDefaultBackgroundColor
199- self ._button .BorderColor3 = self ._disabled and GuiUtilities .kButtonDisabledBorderColor or GuiUtilities .kButtonDefaultBorderColor
213+ self ._button .BackgroundColor3 = self ._disabled and GuiUtilities .kButtonDisabledBackgroundColor
214+ or GuiUtilities .kButtonDefaultBackgroundColor
215+ self ._button .BorderColor3 = self ._disabled and GuiUtilities .kButtonDisabledBorderColor
216+ or GuiUtilities .kButtonDefaultBorderColor
200217 if self ._disabledChangedFunction then
201218 self ._disabledChangedFunction (self ._disabled )
202219 end
203220 end
204221
205222 local newValue = self :GetValue ()
206- if ( newValue ~= originalValue ) then
223+ if newValue ~= originalValue then
207224 self :_HandleUpdatedValue ()
208225 end
209226end
210227
211228function LabeledButtonClass :UpdateFontColors ()
212- if self ._disabled then
229+ if self ._disabled then
213230 self ._label .TextColor3 = settings ().Studio .Theme :GetColor (Enum .StudioStyleGuideColor .DimmedText )
214231 else
215232 self ._label .TextColor3 = settings ().Studio .Theme :GetColor (Enum .StudioStyleGuideColor .MainText )
@@ -224,9 +241,9 @@ function LabeledButtonClass:DisableWithOverrideValue(overrideValue)
224241 self ._disabledOverride = overrideValue
225242 self :SetDisabled (true )
226243 local newValue = self :GetValue ()
227- if ( oldValue ~= newValue ) then
244+ if oldValue ~= newValue then
228245 self :_HandleUpdatedValue ()
229- end
246+ end
230247end
231248
232249function LabeledButtonClass :GetDisabled ()
@@ -235,12 +252,12 @@ end
235252
236253function LabeledButtonClass :SetValue (newValue )
237254 local newValue = not not newValue
238-
255+
239256 if newValue ~= self ._value then
240257 self ._value = newValue
241258
242259 self :_HandleUpdatedValue ()
243260 end
244261end
245262
246- return LabeledButtonClass
263+ return LabeledButtonClass
0 commit comments