Skip to content

Commit

Permalink
Sync with UILibDropDownMenu from latest retail build 55818
Browse files Browse the repository at this point in the history
  • Loading branch information
hizuro committed Jul 24, 2024
1 parent df5dbd7 commit d7f00c1
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions LibDropDownMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function UIDropDownMenuButton_OnEnter(self)
if ( self.tooltipTitle and not self.noTooltipWhileEnabled and not UIDropDownMenuButton_ShouldShowIconTooltip(self) ) then
if ( self.tooltipOnButton ) then
local tooltip = GetAppropriateTooltip();
tooltip:SetOwner(self, "ANCHOR_RIGHT");
tooltip:SetOwner(self, self.tooltipAnchor or "ANCHOR_RIGHT");
GameTooltip_SetTitle(tooltip, self.tooltipTitle);
if self.tooltipInstruction then
GameTooltip_AddInstructionLine(tooltip, self.tooltipInstruction);
Expand Down Expand Up @@ -317,7 +317,7 @@ end

function UIDropDownMenuButton_ShouldShowIconTooltip(self)
if self.Icon and (self.iconTooltipTitle or self.iconTooltipText) and (self.icon or self.mouseOverIcon) then
return GetMouseFocus() == self.Icon;
return self.Icon:IsMouseMotionFocus();
end
return false;
end
Expand Down Expand Up @@ -400,6 +400,7 @@ info.tooltipWarning = [nil, STRING] -- Warning-style text of the tooltip shown o
info.tooltipInstruction = [nil, STRING] -- Instruction-style text of the tooltip shown on mouseover
info.tooltipOnButton = [nil, 1] -- Show the tooltip attached to the button instead of as a Newbie tooltip.
info.tooltipBackdropStyle = [nil, TABLE] -- Optional Backdrop style of the tooltip shown on mouseover
info.tooltipAnchor = [nil, STRING] -- Pass a custom tooltip anchor (Default is "ANCHOR_RIGHT")
info.justifyH = [nil, "CENTER"] -- Justify button text
info.arg1 = [ANYTHING] -- This is the first argument used by info.func
info.arg2 = [ANYTHING] -- This is the second argument used by info.func
Expand Down Expand Up @@ -494,6 +495,11 @@ function UIDropDownMenu_AddSpace(level)
UIDropDownMenu_AddButton(spaceInfo, level);
end

local function UIDropDownMenu_IsDisplayModeMenu()
local frame = UIDROPDOWNMENU_OPEN_MENU;
return frame and frame.displayMode == "MENU";
end

function UIDropDownMenu_AddButton(info, level)
--[[
Might to uncomment this if there are performance issues
Expand Down Expand Up @@ -641,6 +647,7 @@ function UIDropDownMenu_AddButton(info, level)
button.tooltipInstruction = info.tooltipInstruction;
button.tooltipWarning = info.tooltipWarning;
button.tooltipBackdropStyle = info.tooltipBackdropStyle;
button.tooltipAnchor = info.tooltipAnchor;
button.arg1 = info.arg1;
button.arg2 = info.arg2;
button.hasArrow = info.hasArrow;
Expand Down Expand Up @@ -700,15 +707,12 @@ function UIDropDownMenu_AddButton(info, level)
end

-- Adjust offset if displayMode is menu
local frame = UIDROPDOWNMENU_OPEN_MENU;
if ( frame and frame.displayMode == "MENU" ) then
if ( not info.notCheckable ) then
xPos = xPos - 6;
end
if (not info.notCheckable) and UIDropDownMenu_IsDisplayModeMenu() then
xPos = xPos - 6;
end

-- If no open frame then set the frame to the currently initialized frame
frame = frame or UIDROPDOWNMENU_INIT_MENU;
local frame = frame or UIDROPDOWNMENU_INIT_MENU;

if ( info.leftPadding ) then
xPos = xPos + info.leftPadding;
Expand Down Expand Up @@ -1056,17 +1060,23 @@ function UIDropDownMenu_GetSelectedID(frame)
if ( frame.selectedID ) then
return frame.selectedID;
else
local selectedName = UIDropDownMenu_GetSelectedName(frame);
local selectedValue = UIDropDownMenu_GetSelectedValue(frame);
if ( not selectedName and not selectedValue ) then
return nil;
end

-- If no explicit selectedID then try to send the id of a selected value or name
local listFrame = _G["LibDropDownMenu_List"..UIDROPDOWNMENU_MENU_LEVEL];
for i=1, listFrame.numButtons do
local button = _G["LibDropDownMenu_List"..UIDROPDOWNMENU_MENU_LEVEL.."Button"..i];
-- See if checked or not
if ( UIDropDownMenu_GetSelectedName(frame) ) then
if ( button:GetText() == UIDropDownMenu_GetSelectedName(frame) ) then
if ( selectedName ) then
if ( button:GetText() == selectedName ) then
return i;
end
elseif ( UIDropDownMenu_GetSelectedValue(frame) ) then
if ( button.value == UIDropDownMenu_GetSelectedValue(frame) ) then
elseif ( selectedValue ) then
if ( button.value == selectedValue ) then
return i;
end
end
Expand Down Expand Up @@ -1150,6 +1160,7 @@ function ToggleDropDownMenu(level, value, dropDownFrame, anchorName, xOffset, yO
end
if ( listFrame:IsShown() and (UIDROPDOWNMENU_OPEN_MENU == tempFrame) ) then
listFrame:Hide();
return false;
else
-- Set the dropdownframe scale
local uiScale;
Expand Down Expand Up @@ -1274,7 +1285,7 @@ function ToggleDropDownMenu(level, value, dropDownFrame, anchorName, xOffset, yO
UIDropDownMenu_Initialize(dropDownFrame, dropDownFrame.initialize, nil, level, menuList);
-- If no items in the drop down don't show it
if ( listFrame.numButtons == 0 ) then
return;
return false;
end

listFrame.onShow = dropDownFrame.listFrameOnShow;
Expand All @@ -1286,7 +1297,7 @@ function ToggleDropDownMenu(level, value, dropDownFrame, anchorName, xOffset, yO
-- Hack will fix this in next revision of dropdowns
if ( not x or not y ) then
listFrame:Hide();
return;
return false;
end

listFrame.onHide = dropDownFrame.onHide;
Expand Down Expand Up @@ -1359,6 +1370,7 @@ function ToggleDropDownMenu(level, value, dropDownFrame, anchorName, xOffset, yO
listFrame.parentID = anchorFrame:GetID();
listFrame:SetPoint(point, anchorFrame, relativePoint, xOffset, yOffset);
end
return true;
end
end

Expand Down

0 comments on commit d7f00c1

Please sign in to comment.