Quantcast

Change window opening so it works on high-ui-scale screens

James Whitehead II [10-13-10 - 13:46]
Change window opening so it works on high-ui-scale screens
Filename
BindConfig.lua
Clique.lua
Clique.xml
diff --git a/BindConfig.lua b/BindConfig.lua
index 91a90ab..701c41b 100755
--- a/BindConfig.lua
+++ b/BindConfig.lua
@@ -3,6 +3,13 @@ local L = addon.L

 local MAX_ROWS = 12

+function CliqueConfig:ShowWithSpellBook()
+    self:ClearAllPoints()
+    self:SetParent(SpellBookFrame)
+    self:SetPoint("LEFT", SpellBookFrame, "RIGHT", 55, 0)
+    self:Show()
+end
+
 function CliqueConfig:OnShow()
     if not self.initialized then
         self:SetupGUI()
@@ -16,6 +23,9 @@ function CliqueConfig:OnShow()
 end

 function CliqueConfig:OnHide()
+    self:ClearAllPoints()
+    self:SetParent(UIParent)
+    self:Hide()
     CliqueSpellTab:SetChecked(false)
 end

@@ -92,14 +102,17 @@ function CliqueConfig:HijackSpellbook()
         self.spellbookButtons[idx] = button
     end

-    local function showHideHandler(frame)
+    SpellBookFrame:HookScript("OnShow", function(frame)
         self:EnableSpellbookButtons()
-    end
-    SpellBookFrame:HookScript("OnShow", showHideHandler)
-    SpellBookFrame:HookScript("OnHide", showHideHandler)
+    end)
+    SpellBookFrame:HookScript("OnHide", function(frame)
+        self:EnableSpellbookButtons()
+    end)

     -- TODO: This isn't a great way to do this, but for now
-    hooksecurefunc("SpellBookSkillLineTab_OnClick", showHideHandler)
+    hooksecurefunc("SpellBookSkillLineTab_OnClick", function()
+        self:EnableSpellbookButtons()
+    end)
     self:EnableSpellbookButtons()
 end

@@ -162,9 +175,8 @@ end
 function CliqueConfig:Button_OnClick(button)
     -- Click handler for "Bind spell" button
     if button == self.page1.button_spell then
-        if SpellBookFrame and not SpellBookFrame:IsVisible() then
-            ShowUIPanel(SpellBookFrame)
-        end
+        ShowUIPanel(SpellBookFrame)
+        CliqueConfig:ShowWithSpellBook()

     -- Click handler for "Bind other" button
     elseif button == self.page1.button_other then
@@ -496,3 +508,12 @@ function CliqueConfig:Row_OnClick(frame, button)
     EasyMenu(menu, self.dropdown, "cursor", 0, 0, nil, nil)
 end

+function CliqueConfig:SpellTab_OnClick(frame)
+    if self:IsVisible() then
+        HideUIPanel(CliqueConfig)
+    elseif SpellBookFrame:IsVisible() then
+        self:ShowWithSpellBook()
+    else
+        ShowUIPanel(CliqueConfig)
+    end
+end
diff --git a/Clique.lua b/Clique.lua
index b268764..2d5b234 100755
--- a/Clique.lua
+++ b/Clique.lua
@@ -551,5 +551,9 @@ end

 SLASH_CLIQUE1 = "/clique"
 SlashCmdList["CLIQUE"] = function(msg, editbox)
-    ShowUIPanel(CliqueConfig)
+    if SpellBookFrame:IsVisible() then
+        CliqueConfig:ShowWithSpellBook()
+    else
+        ShowUIPanel(CliqueConfig)
+    end
 end
diff --git a/Clique.xml b/Clique.xml
index 3c31ee0..59c0f33 100755
--- a/Clique.xml
+++ b/Clique.xml
@@ -125,11 +125,7 @@
     <CheckButton name="CliqueSpellTab" inherits="SpellBookSkillLineTabTemplate" parent="SpellBookFrame" hidden="false">
         <Scripts>
             <OnClick>
-                if CliqueConfig:IsVisible() then
-                    HideUIPanel(CliqueConfig)
-                else
-                    ShowUIPanel(CliqueConfig)
-                end
+                CliqueConfig:SpellTab_OnClick()
             </OnClick>
             <OnShow>
                 if CliqueConfig:IsVisible() then