DEFAULT_FORCED_GROUP_VALUES.caption=1 function Icon.setCaption(w,Z)assert(typeof(Z)=="\115\116\114\105\110\103"or Z==nil,"\069\120\112\101\099\116\101\100 \115\116\114\105\110\103\044 \103\111\116 "..typeof(Z))local z=Z or""local A=z~=""w.captionText=Z w.instances.captionLabel.Text=z w.instances.captionContainer.Parent=A and activeItems or w.instances.iconContainer w:_updateIconSize(nil,w:getIconState())local M=Maid.new()w._maid.captionMaid=M if A then M:give(w.hoverStarted:Connect(function()if not w.isSelected then w:displayCaption(true)end end))M:give(w.hoverEnded:Connect(function()w:displayCaption(false)end))M:give(w.selected:Connect(function()if w.hovering then w:displayCaption(false)end end))local Z=w.instances.iconContainer M:give((Z:GetPropertyChangedSignal("\065\098\115\111\108\117\116\101\083\105\122\101")):Connect(function()if w.hovering then w:displayCaption()end end))M:give((Z:GetPropertyChangedSignal("\065\098\115\111\108\117\116\101\080\111\115\105\116\105\111\110")):Connect(function()if w.hovering then w:displayCaption()end end))end local S=6 local I=.8 local v=.58 local D=w:get("\105\099\111\110\083\105\122\101")local g=w:get("\099\097\112\116\105\111\110\070\111\110\116")if D and g then local Z=D.Y.Offset local z=D.Y.Scale local M=w.instances.iconContainer local Y=w.instances.captionContainer if A then local A=Z+z*M.Parent.AbsoluteSize.Y local D=w.instances.captionLabel local U=A*I local W=U*v local E=(textService:GetTextSize(w.captionText,W,g,Vector2.new(10000,W))).X D.TextSize=W D.Size=UDim2.new(0,E,v,0)Y.Size=UDim2.new(0,E+S*2,0,A*I)else Y.Size=UDim2.new(0,0,0,0)end end w:displayCaption(w.hovering and A)return w end function Icon.displayCaption(w,Z)if userInputService.TouchEnabled and not w._draggingFinger then return end local z=8 if w._draggingFinger then z=z+THUMB_OFFSET end local A=w.instances.iconContainer local M=w.instances.captionContainer local S=UDim2.new(0,(A.AbsolutePosition.X+A.AbsoluteSize.X/2)-M.AbsoluteSize.X/2,0,(A.AbsolutePosition.Y+A.AbsoluteSize.Y*2)+z)M.Position=S local I=w.captionVisible or false if typeof(Z)=="\098\111\111\108\101\097\110"then I=Z end w.captionVisible=I local v=w:get("\099\097\112\116\105\111\110\070\097\100\101\073\110\102\111")for Z,z in pairs(w._groupSettings.caption)do local A=w._settingsDictionary[z]A.useForcedGroupValue=not I w:_update(z)end end
-- Captions
DEFAULT_FORCED_GROUP_VALUES["caption"] = 1

function Icon:setCaption(text)
	assert(typeof(text) == "string" or text == nil, "Expected string, got " .. typeof(text))
	local realText = text or ""
	local isVisible = realText ~= ""
	self.captionText = text
	self.instances.captionLabel.Text = realText
	self.instances.captionContainer.Parent = (isVisible and activeItems) or self.instances.iconContainer
	self:_updateIconSize(nil, self:getIconState())
	local captionMaid = Maid.new()
	self._maid.captionMaid = captionMaid
	if isVisible then
		captionMaid:give(self.hoverStarted:Connect(function()
			if not self.isSelected then
				self:displayCaption(true)
			end
		end))
		captionMaid:give(self.hoverEnded:Connect(function()
			self:displayCaption(false)
		end))
		captionMaid:give(self.selected:Connect(function()
			if self.hovering then
				self:displayCaption(false)
			end
		end))
		local iconContainer = self.instances.iconContainer
		captionMaid:give(iconContainer:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
			if self.hovering then
				self:displayCaption()
			end
		end))
		captionMaid:give(iconContainer:GetPropertyChangedSignal("AbsolutePosition"):Connect(function()
			if self.hovering then
				self:displayCaption()
			end
		end))
	end

	-- This adapts the caption size
	local CAPTION_X_MARGIN = 6
	local CAPTION_CONTAINER_Y_SIZE_SCALE = 0.8
	local CAPTION_LABEL_Y_SCALE = 0.58
	local iconSize = self:get("iconSize")
	local labelFont = self:get("captionFont")
	if iconSize and labelFont then
		local cellSizeYOffset = iconSize.Y.Offset
		local cellSizeYScale = iconSize.Y.Scale
		local iconContainer = self.instances.iconContainer
		local captionContainer = self.instances.captionContainer
		if isVisible then
			local cellHeight = cellSizeYOffset + (cellSizeYScale * iconContainer.Parent.AbsoluteSize.Y)
			local captionLabel = self.instances.captionLabel
			local captionContainerHeight = cellHeight * CAPTION_CONTAINER_Y_SIZE_SCALE
			local captionLabelHeight = captionContainerHeight * CAPTION_LABEL_Y_SCALE
			local textWidth = textService:GetTextSize(
				self.captionText,
				captionLabelHeight,
				labelFont,
				Vector2.new(10000, captionLabelHeight)
			).X
			captionLabel.TextSize = captionLabelHeight
			captionLabel.Size = UDim2.new(0, textWidth, CAPTION_LABEL_Y_SCALE, 0)
			captionContainer.Size =
				UDim2.new(0, textWidth + CAPTION_X_MARGIN * 2, 0, cellHeight * CAPTION_CONTAINER_Y_SIZE_SCALE)
		else
			captionContainer.Size = UDim2.new(0, 0, 0, 0)
		end
	end

	self:displayCaption(self.hovering and isVisible)
	return self
end

function Icon:displayCaption(bool)
	if userInputService.TouchEnabled and not self._draggingFinger then
		return
	end
	local yOffset = 8

	-- Determine caption position
	if self._draggingFinger then
		yOffset = yOffset + THUMB_OFFSET
	end
	local iconContainer = self.instances.iconContainer
	local captionContainer = self.instances.captionContainer
	local newPos = UDim2.new(
		0,
		iconContainer.AbsolutePosition.X + iconContainer.AbsoluteSize.X / 2 - captionContainer.AbsoluteSize.X / 2,
		0,
		iconContainer.AbsolutePosition.Y + (iconContainer.AbsoluteSize.Y * 2) + yOffset
	)
	captionContainer.Position = newPos

	-- Determine caption visibility
	local isVisible = self.captionVisible or false
	if typeof(bool) == "boolean" then
		isVisible = bool
	end
	self.captionVisible = isVisible

	-- Change transparency of relavent caption instances
	local captionFadeInfo = self:get("captionFadeInfo")
	for _, settingName in pairs(self._groupSettings.caption) do
		local settingDetail = self._settingsDictionary[settingName]
		settingDetail.useForcedGroupValue = not isVisible
		self:_update(settingName)
	end
end
