function Icon.setDropdown(A,p)for p,A in pairs(A.dropdownIcons)do A:leave()end if type(p)=="\116\097\098\108\101"then for p,l in pairs(p)do l:join(A,"\100\114\111\112\100\111\119\110",true)end end A:_updateDropdown()return A end function Icon._updateDropdown(p)local A={maxIconsBeforeScroll=p:get("\100\114\111\112\100\111\119\110\077\097\120\073\099\111\110\115\066\101\102\111\114\101\083\099\114\111\108\108")or"\095\078\073\076",minWidth=p:get("\100\114\111\112\100\111\119\110\077\105\110\087\105\100\116\104")or"\095\078\073\076",padding=p:get("\100\114\111\112\100\111\119\110\076\105\115\116\080\097\100\100\105\110\103")or"\095\078\073\076";dropdownAlignment=p:get("\100\114\111\112\100\111\119\110\065\108\105\103\110\109\101\110\116")or"\095\078\073\076",iconAlignment=p:get("\097\108\105\103\110\109\101\110\116")or"\095\078\073\076",scrollBarThickness=p:get("\100\114\111\112\100\111\119\110\083\099\114\111\108\108\066\097\114\084\104\105\099\107\110\101\115\115")or"\095\078\073\076"}for p,A in pairs(A)do if A=="\095\078\073\076"then return end end local l=A.padding.Offset local G=p.instances.dropdownContainer local c=p.instances.dropdownFrame local X=p.instances.dropdownList local f=#p.dropdownIcons local o=f>A.maxIconsBeforeScroll and A.maxIconsBeforeScroll or f local m=-l local q=0 local U=A.minWidth table.sort(p.dropdownIcons,function(p,A)return p:get("\111\114\100\101\114")<A:get("\111\114\100\101\114")end)for A=1,f,1 do local G=p.dropdownIcons[A]local c,X=G:get("\105\099\111\110\083\105\122\101",nil,"\098\101\102\111\114\101\068\114\111\112\100\111\119\110")local b=X.Y.Offset+l if A<=o then q=q+b end if A==f then q=q+b/4 end m=m+b local K=X.X.Offset if K>U then U=K end local g=A==1 and p or p.dropdownIcons[A-1]local P=p.dropdownIcons[A+1]G.instances.iconButton.NextSelectionUp=g and g.instances.iconButton G.instances.iconButton.NextSelectionDown=P and P.instances.iconButton end local b=o==f and 0 or m p:set("\100\114\111\112\100\111\119\110\067\097\110\118\097\115\083\105\122\101",UDim2.new(0,0,0,b))p:set("\100\114\111\112\100\111\119\110\083\105\122\101",UDim2.new(0,(U+4)*2,0,q))local K=A.dropdownAlignment:lower()local g={left={AnchorPoint=Vector2.new(0,0);PositionXScale=0;ThicknessMultiplier=0};mid={AnchorPoint=Vector2.new(.5,0);PositionXScale=.5,ThicknessMultiplier=.5},right={AnchorPoint=Vector2.new(.5,0);PositionXScale=1;FrameAnchorPoint=Vector2.new(0,0),FramePositionXScale=0;ThicknessMultiplier=1}}local P=g[K]if not P then P=g[A.iconAlignment:lower()]end G.AnchorPoint=P.AnchorPoint G.Position=UDim2.new(P.PositionXScale,0,1,l+0)local r=A.scrollBarThickness local n=r*P.ThicknessMultiplier local V=c.VerticalScrollBarPosition==Enum.VerticalScrollBarPosition.Right and n or-n c.AnchorPoint=P.FrameAnchorPoint or P.AnchorPoint c.Position=UDim2.new(P.FramePositionXScale or P.PositionXScale,V,0,0)p._dropdownCanvasPos=Vector2.new(0,0)end function Icon._dropdownIgnoreClipping(p)p:_ignoreClipping("\100\114\111\112\100\111\119\110")end
-- Dropdowns
function Icon:setDropdown(arrayOfIcons)
	-- Reset any previous icons
	for i, otherIcon in pairs(self.dropdownIcons) do
		otherIcon:leave()
	end
	-- Apply new icons
	if type(arrayOfIcons) == "table" then
		for i, otherIcon in pairs(arrayOfIcons) do
			otherIcon:join(self, "dropdown", true)
		end
	end
	-- Update dropdown
	self:_updateDropdown()
	return self
end

function Icon:_updateDropdown()
	local values = {
		maxIconsBeforeScroll = self:get("dropdownMaxIconsBeforeScroll") or "_NIL",
		minWidth = self:get("dropdownMinWidth") or "_NIL",
		padding = self:get("dropdownListPadding") or "_NIL",
		dropdownAlignment = self:get("dropdownAlignment") or "_NIL",
		iconAlignment = self:get("alignment") or "_NIL",
		scrollBarThickness = self:get("dropdownScrollBarThickness") or "_NIL",
	}
	for k, v in pairs(values) do
		if v == "_NIL" then
			return
		end
	end

	local YPadding = values.padding.Offset
	local dropdownContainer = self.instances.dropdownContainer
	local dropdownFrame = self.instances.dropdownFrame
	local dropdownList = self.instances.dropdownList
	local totalIcons = #self.dropdownIcons

	local lastVisibleIconIndex = (totalIcons > values.maxIconsBeforeScroll and values.maxIconsBeforeScroll)
		or totalIcons
	local newCanvasSizeY = -YPadding
	local newFrameSizeY = 0
	local newMinWidth = values.minWidth
	table.sort(self.dropdownIcons, function(a, b)
		return a:get("order") < b:get("order")
	end)
	for i = 1, totalIcons do
		local otherIcon = self.dropdownIcons[i]
		local _, otherIconSize = otherIcon:get("iconSize", nil, "beforeDropdown")
		local increment = otherIconSize.Y.Offset + YPadding
		if i <= lastVisibleIconIndex then
			newFrameSizeY = newFrameSizeY + increment
		end
		if i == totalIcons then
			newFrameSizeY = newFrameSizeY + increment / 4
		end
		newCanvasSizeY = newCanvasSizeY + increment
		local otherIconWidth = otherIconSize.X.Offset --+ 4 + 100 -- the +100 is to allow for notices
		if otherIconWidth > newMinWidth then
			newMinWidth = otherIconWidth
		end
		-- This ensures the dropdown is navigated fully and correctly with a controller
		local prevIcon = (i == 1 and self) or self.dropdownIcons[i - 1]
		local nextIcon = self.dropdownIcons[i + 1]
		otherIcon.instances.iconButton.NextSelectionUp = prevIcon and prevIcon.instances.iconButton
		otherIcon.instances.iconButton.NextSelectionDown = nextIcon and nextIcon.instances.iconButton
	end

	local finalCanvasSizeY = (lastVisibleIconIndex == totalIcons and 0) or newCanvasSizeY
	self:set("dropdownCanvasSize", UDim2.new(0, 0, 0, finalCanvasSizeY))
	self:set("dropdownSize", UDim2.new(0, (newMinWidth + 4) * 2, 0, newFrameSizeY))

	-- Set alignment while considering screen bounds
	local dropdownAlignment = values.dropdownAlignment:lower()
	local alignmentDetails = {
		left = {
			AnchorPoint = Vector2.new(0, 0),
			PositionXScale = 0,
			ThicknessMultiplier = 0,
		},
		mid = {
			AnchorPoint = Vector2.new(0.5, 0),
			PositionXScale = 0.5,
			ThicknessMultiplier = 0.5,
		},
		right = {
			AnchorPoint = Vector2.new(0.5, 0),
			PositionXScale = 1,
			FrameAnchorPoint = Vector2.new(0, 0),
			FramePositionXScale = 0,
			ThicknessMultiplier = 1,
		},
	}
	local alignmentDetail = alignmentDetails[dropdownAlignment]
	if not alignmentDetail then
		alignmentDetail = alignmentDetails[values.iconAlignment:lower()]
	end
	dropdownContainer.AnchorPoint = alignmentDetail.AnchorPoint
	dropdownContainer.Position = UDim2.new(alignmentDetail.PositionXScale, 0, 1, YPadding + 0)
	local scrollbarThickness = values.scrollBarThickness
	local newThickness = scrollbarThickness * alignmentDetail.ThicknessMultiplier
	local additionalOffset = (
		dropdownFrame.VerticalScrollBarPosition == Enum.VerticalScrollBarPosition.Right and newThickness
	) or -newThickness
	dropdownFrame.AnchorPoint = alignmentDetail.FrameAnchorPoint or alignmentDetail.AnchorPoint
	dropdownFrame.Position =
		UDim2.new(alignmentDetail.FramePositionXScale or alignmentDetail.PositionXScale, additionalOffset, 0, 0)
	self._dropdownCanvasPos = Vector2.new(0, 0)
end

function Icon:_dropdownIgnoreClipping()
	self:_ignoreClipping("dropdown")
end
