Skip to content
This repository was archived by the owner on Aug 20, 2024. It is now read-only.

Commit 31295d4

Browse files
committed
Dark theme support.
1 parent c156085 commit 31295d4

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

src/Workspace/SignsInternal/StudioWidgets/CustomTextButton.lua

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
----------------------------------------
88
GuiUtilities = require(script.Parent.GuiUtilities)
99

10-
local kButtonImageIdDefault = "rbxasset://textures/TerrainTools/button_default.png"
10+
local kButtonImageIdDefault = "rbxasset://textures/StudioToolbox/RoundedBackground.png"
1111
local kButtonImageIdHovered = "rbxasset://textures/TerrainTools/button_hover.png"
1212
local kButtonImageIdPressed = "rbxasset://textures/TerrainTools/button_pressed.png"
1313

14+
local kButtonBorder = "rbxasset://textures/StudioToolbox/RoundedBorder.png"
15+
1416
CustomTextButtonClass = {}
1517
CustomTextButtonClass.__index = CustomTextButtonClass
1618

@@ -23,33 +25,42 @@ function CustomTextButtonClass.new(buttonName, labelText)
2325
button.Image = kButtonImageIdDefault
2426
button.BackgroundTransparency = 1
2527
button.ScaleType = Enum.ScaleType.Slice
26-
button.SliceCenter = Rect.new(7, 7, 156, 36)
28+
button.SliceCenter = Rect.new(3, 3, 13, 13)
2729
button.AutoButtonColor = false
2830

31+
local border = Instance.new('ImageLabel')
32+
border.Size = UDim2.new(1, 0, 1, 0)
33+
border.BackgroundTransparency = 1
34+
border.ScaleType = Enum.ScaleType.Slice
35+
border.SliceCenter = Rect.new(3, 3, 13, 13)
36+
border.Image = kButtonBorder
37+
border.Parent = button
38+
2939
local label = Instance.new('TextLabel')
3040
label.Text = labelText
3141
label.BackgroundTransparency = 1
3242
label.Size = UDim2.new(1, 0, 1, 0) -- 1, 0, 1, GuiUtilities.kButtonVerticalFudge
33-
label.Font = Enum.Font.SourceSans
34-
label.TextSize = 15
43+
label.Font = Enum.Font.SourceSans
44+
label.TextSize = 15
3545
label.Parent = button
3646

3747
self._label = label
48+
self._border = border
3849
self._button = button
3950

4051
self._clicked = false
4152
self._hovered = false
4253

4354
button.InputBegan:Connect(function(input)
44-
if (input.UserInputType == Enum.UserInputType.MouseMovement) then
55+
if (input.UserInputType == Enum.UserInputType.MouseMovement) then
4556
self._hovered = true
4657
self:_updateButtonVisual()
4758
end
4859
end)
4960

5061

5162
button.InputEnded:Connect(function(input)
52-
if (input.UserInputType == Enum.UserInputType.MouseMovement) then
63+
if (input.UserInputType == Enum.UserInputType.MouseMovement) then
5364
self._hovered = false
5465
self._clicked = false
5566
self:_updateButtonVisual()
@@ -66,20 +77,22 @@ function CustomTextButtonClass.new(buttonName, labelText)
6677
self:_updateButtonVisual()
6778
end)
6879

80+
settings().Studio.ThemeChanged:Connect(self:_updateButtonVisual())
6981
self:_updateButtonVisual()
7082

7183
return self
7284
end
7385

7486
function CustomTextButtonClass:_updateButtonVisual()
87+
self._border.ImageColor3 = GuiUtilities.kButtonStandardBorderColor
7588
if (self._clicked) then
76-
self._button.Image = kButtonImageIdPressed
77-
self._label.TextColor3 = GuiUtilities.kPressedButtonTextColor
89+
self._button.ImageColor3 = GuiUtilities.kButtonPressedBackgroundColor
90+
self._label.TextColor3 = GuiUtilities.kStandardButtonTextColor
7891
elseif (self._hovered) then
79-
self._button.Image = kButtonImageIdHovered
92+
self._button.ImageColor3 = GuiUtilities.kButtonHoverBackgroundColor
8093
self._label.TextColor3 = GuiUtilities.kStandardButtonTextColor
8194
else
82-
self._button.Image = kButtonImageIdDefault
95+
self._button.ImageColor3 = GuiUtilities.kButtonStandardBackgroundColor
8396
self._label.TextColor3 = GuiUtilities.kStandardButtonTextColor
8497
end
8598
end

src/Workspace/SignsInternal/StudioWidgets/GuiUtilities.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.kStandardHMargin = 16
1313

1414
module.kCheckboxMinLabelWidth = 52
1515
module.kCheckboxMinMargin = 16 -- Default: 12
16-
module.kCheckboxWidth = 16 -- Default: 12
16+
module.kCheckboxWidth = module.kCheckboxMinMargin -- Default: 12
1717

1818
module.kRadioButtonsHPadding = 54
1919

@@ -33,14 +33,14 @@ module.kButtonVerticalFudge = -5
3333

3434
module.kBottomButtonsWidth = 100
3535

36-
module.kDisabledTextColor = Color3.new(.4, .4, .4) --todo: input spec disabled text color
37-
module.kStandardButtonTextColor = Color3.new(0, 0, 0) --todo: input spec disabled text color
38-
module.kPressedButtonTextColor = Color3.new(1, 1, 1) --todo: input spec disabled text color
36+
module.kDisabledTextColor = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.ButtonText, Enum.StudioStyleGuideModifier.Disabled)
37+
module.kStandardButtonTextColor = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.ButtonText, Enum.StudioStyleGuideModifier.Default)
3938

40-
module.kButtonStandardBackgroundColor = Color3.new(1, 1, 1) --todo: sync with spec
41-
module.kButtonStandardBorderColor = Color3.new(.4,.4,.4) --todo: sync with spec
42-
module.kButtonDisabledBackgroundColor = Color3.new(.7,.7,.7) --todo: sync with spec
43-
module.kButtonDisabledBorderColor = Color3.new(.6,.6,.6) --todo: sync with spec
39+
module.kButtonStandardBorderColor = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.ButtonBorder, Enum.StudioStyleGuideModifier.Default)
40+
module.kButtonStandardBackgroundColor = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.Button, Enum.StudioStyleGuideModifier.Default)
41+
module.kButtonPressedBackgroundColor = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.Button, Enum.StudioStyleGuideModifier.Pressed)
42+
module.kButtonHoverBackgroundColor = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.Button, Enum.StudioStyleGuideModifier.Hover)
43+
module.kButtonDisabledBackgroundColor = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.Button, Enum.StudioStyleGuideModifier.Disabled)
4444

4545
module.kButtonBackgroundTransparency = 0.5
4646
module.kButtonBackgroundIntenseTransparency = 0.4

0 commit comments

Comments
 (0)