Rofl .. pretty much the same as what I did
So it works at my resolution (1280x1024) now to try it with the lower setting. Erm not so pretty at 1024 x 768 but thats the 2nd image.
Code:
plugin.sizeChanged = function( scale, height, width )
local options = plugin.options;
plugin.scale = scale;
-- Grab addon information and unlock frame for movement
local MagePortsFrame = plugin.MagePorts;
nUI_Movers:lockFrame( MagePortsFrame, false, nil );
-- Resize and Reposition according to scale and size of new container
MagePortsFrame:SetWidth( width );
MagePortsFrame:SetHeight( height );
-- Center Buttons across the container
local cellCount = #MagePorts.PortalButtons;
local cellWidth = ( width / cellCount );
local btnSize = cellWidth * 0.95;
local btnGap = cellWidth * 0.05;
local verticalOffsetPortal = height / 5; -- how far up or down from center to put the button
local verticalOffsetTeleport = height / 4;
for i=1,cellCount do
MagePorts.PortalButtons[i]:SetWidth( btnSize );
MagePorts.PortalButtons[i]:SetHeight( btnSize );
MagePorts.TeleportButtons[i]:SetWidth( btnSize );
MagePorts.TeleportButtons[i]:SetHeight( btnSize );
end
local odd = ( cellCount % 2 ) == 1;
local midwayLeft = nil;
local midwayRight = nil;
if ( odd ) then
midwayLeft = math.ceil( cellCount / 2 );
else
midwayLeft = math.floor( cellCount / 2 );
midwayRight = midwayLeft + 1;
end
-- Reposition Portal Buttons and Fontstrings
if ( not midwayRight ) then
MagePorts.PortalButtons[midwayLeft]:SetPoint( "CENTER", plugin.container, "CENTER", btnGap/2, verticalOffsetPortal);
MagePorts.TeleportButtons[midwayLeft]:SetPoint( "CENTER", plugin.container, "CENTER", btnGap/2, -verticalOffsetTeleport);
else
MagePorts.PortalButtons[midwayLeft]:SetPoint( "RIGHT", plugin.container, "CENTER", -btnGap/2, verticalOffsetPortal );
MagePorts.PortalButtons[midwayRight]:SetPoint( "LEFT", plugin.container, "CENTER", btnGap/2, verticalOffsetPortal );
MagePorts.TeleportButtons[midwayLeft]:SetPoint( "RIGHT", plugin.container, "CENTER", -btnGap/2, -verticalOffsetTeleport );
MagePorts.TeleportButtons[midwayRight]:SetPoint( "LEFT", plugin.container, "CENTER", btnGap/2, -verticalOffsetTeleport );
end
for i = 1, midwayLeft - 1 do
MagePorts.PortalButtons[i]:SetPoint( "RIGHT", MagePorts.PortalButtons[i+1], "LEFT", -btnGap, 0 );
MagePorts.TeleportButtons[i]:SetPoint( "RIGHT", MagePorts.TeleportButtons[i+1], "LEFT", -btnGap, 0 );
end
for i = midwayLeft + 1, cellCount do
MagePorts.PortalButtons[i]:SetPoint( "LEFT", MagePorts.PortalButtons[i-1], "RIGHT", btnGap, 0 );
MagePorts.TeleportButtons[i]:SetPoint( "LEFT", MagePorts.TeleportButtons[i-1], "RIGHT", btnGap, 0 );
end
MagePortsFrame.PortalTitle:SetPoint( "BOTTOMLEFT", MagePorts.PortalButtons[1], "TOPLEFT", -btnGap, 0);
MagePortsFrame.PortalCount:SetPoint( "BOTTOMRIGHT", MagePorts.PortalButtons[cellCount], "TOPRIGHT", -btnGap, 0);
MagePortsFrame.TeleportTitle:SetPoint( "BOTTOMLEFT", MagePorts.TeleportButtons[1], "TOPLEFT", -btnGap, 0);
MagePortsFrame.TeleportCount:SetPoint( "BOTTOMRIGHT", MagePorts.TeleportButtons[cellCount], "TOPRIGHT", -btnGap, 0);
-- Lock addon frame for movement
nUI_Movers:lockFrame( MagePortsFrame, true, nil );
end