From 78b8f349d4664a29d71f10f955afc5a7a9cf9bdf Mon Sep 17 00:00:00 2001 From: shagu Date: Fri, 8 Nov 2024 21:20:56 +0100 Subject: [PATCH] config: adjust window size to available screen space --- config.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/config.lua b/config.lua index 7c6055d..6366b92 100644 --- a/config.lua +++ b/config.lua @@ -18,8 +18,6 @@ end) settings:SetPoint("CENTER", UIParent, "CENTER", 0, 0) settings:SetWidth(max_width) -settings:SetHeight(max_height) - settings:SetMovable(true) settings:EnableMouse(true) settings:RegisterForDrag("LeftButton") @@ -34,15 +32,11 @@ settings:SetBackdrop({ }) settings.scrollframe = CreateFrame('ScrollFrame', 'AdvancedSettingsGUIScrollframe', settings, 'UIPanelScrollFrameTemplate') -settings.scrollframe:SetHeight(max_height - 80) settings.scrollframe:SetWidth(max_width - 50) settings.scrollframe:SetPoint('CENTER', settings, -16, 15) settings.scrollframe:Hide() settings.container = CreateFrame("Frame", "AdvancedSettingsGUIContainer", settings) -settings.container:SetPoint("CENTER", settings, 0, 20) -settings.container:SetHeight(max_height - 30) -settings.container:SetWidth(max_width - 20) settings.title = CreateFrame("Frame", "AdvancedSettingsGUITtitle", settings) settings.title:SetPoint("TOP", settings, "TOP", 0, 12) @@ -102,6 +96,14 @@ settings.defaults:SetScript("OnClick", function() end) settings.load = function(self) + -- never use more than 3/4 of the screen size + max_height = math.min(UIParent:GetHeight()/UIParent:GetScale()*0.75, 680) + + -- update window sizing according to screen + settings:SetHeight(max_height) + settings.scrollframe:SetHeight(max_height - 80) + settings.container:SetHeight(max_height - 30) + settings.entries = settings.entries or {} local expansion = ShaguTweaks:GetExpansion() @@ -196,6 +198,12 @@ settings.load = function(self) if yoff < max_height then -- reduce base frame if possible settings:SetHeight(yoff + 60) + settings.container:SetParent(settings) + settings.container:ClearAllPoints() + settings.container:SetPoint("CENTER", settings, 0, 20) + settings.container:SetWidth(max_width - 20) + + settings.scrollframe:Hide() elseif yoff > max_height then -- set up scrollframe when needed settings.container:SetParent(settings.scrollframe)