From ba7f055cfa2aefc9fa8cce4b473ce4a1b14c77f5 Mon Sep 17 00:00:00 2001 From: "James D. Callahan III" Date: Thu, 15 Jul 2010 02:14:16 -0400 Subject: [PATCH] Some code re-structuring. --- Frame.lua | 123 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 61 insertions(+), 62 deletions(-) diff --git a/Frame.lua b/Frame.lua index d564180..ebb7673 100644 --- a/Frame.lua +++ b/Frame.lua @@ -82,32 +82,31 @@ function private.InitializeFrame() ------------------------------------------------------------------------------- -- Create the MainPanel and set its values ------------------------------------------------------------------------------- - local MainPanel - do - MainPanel = CreateFrame("Frame", "ARL_MainPanel", UIParent) + local MainPanel = CreateFrame("Frame", "ARL_MainPanel", UIParent) - -- The panel width changes when contracting and expanding - store it for later use. - MainPanel.normal_width = 384 - MainPanel.expanded_width = 768 + -- The panel width changes when contracting and expanding - store it for later use. + MainPanel.normal_width = 384 + MainPanel.expanded_width = 768 - MainPanel:SetWidth(MainPanel.normal_width) - MainPanel:SetHeight(512) - MainPanel:SetFrameStrata("MEDIUM") - MainPanel:SetToplevel(true) - MainPanel:SetClampedToScreen(true) - MainPanel:SetClampRectInsets(0, -35, 0, 53) + MainPanel:SetWidth(MainPanel.normal_width) + MainPanel:SetHeight(512) + MainPanel:SetFrameStrata("MEDIUM") + MainPanel:SetToplevel(true) + MainPanel:SetClampedToScreen(true) + MainPanel:SetClampRectInsets(0, -35, 0, 53) - MainPanel:SetHitRectInsets(0, 35, 0, 53) - MainPanel:EnableMouse(true) - MainPanel:EnableKeyboard(true) - MainPanel:SetMovable(true) + MainPanel:SetHitRectInsets(0, 35, 0, 53) + MainPanel:EnableMouse(true) + MainPanel:EnableKeyboard(true) + MainPanel:SetMovable(true) - MainPanel.is_expanded = false + MainPanel.is_expanded = false - -- Let the user banish the MainPanel with the ESC key. - table.insert(UISpecialFrames, "ARL_MainPanel") - addon.Frame = MainPanel + -- Let the user banish the MainPanel with the ESC key. + table.insert(UISpecialFrames, "ARL_MainPanel") + addon.Frame = MainPanel + do local top_left = MainPanel:CreateTexture(nil, "ARTWORK") top_left:SetTexture("Interface\\QuestFrame\\UI-QuestLog-TopLeft") top_left:SetPoint("TOPLEFT", MainPanel, "TOPLEFT", 0, 0) @@ -179,60 +178,60 @@ function private.InitializeFrame() ------------------------------------------------------------------------------- -- Displays the main GUI frame. ------------------------------------------------------------------------------- - do - function MainPanel:Display(profession, is_linked) - self.is_linked = is_linked + function MainPanel:Display(profession, is_linked) + self.is_linked = is_linked - ------------------------------------------------------------------------------- - -- Set the profession. - ------------------------------------------------------------------------------- - local prev_profession = self.profession + ------------------------------------------------------------------------------- + -- Set the profession. + ------------------------------------------------------------------------------- + local prev_profession = self.profession - if profession == private.mining_name then - self.profession = 11 -- Smelting - self.prof_name = profession - else - for index, name in ipairs(ORDERED_PROFESSIONS) do - if name == profession then - self.profession = index - break - end + if profession == private.mining_name then + self.profession = 11 -- Smelting + self.prof_name = profession + else + for index, name in ipairs(ORDERED_PROFESSIONS) do + if name == profession then + self.profession = index + break end - self.prof_name = nil end + self.prof_name = nil + end - if self.profession ~= prev_profession then - self.prev_profession = self.profession - end - self.prof_button:ChangeTexture(private.profession_textures[self.profession]) - - local editbox = self.search_editbox + if self.profession ~= prev_profession then + self.prev_profession = self.profession + end + self.prof_button:ChangeTexture(private.profession_textures[self.profession]) - if self.profession ~= self.prev_profession then - editbox.prev_search = nil - end - editbox:SetText(editbox.prev_search or _G.SEARCH) + local editbox = self.search_editbox - -- If there is no current tab, this is the first time the panel has been - -- shown so things must be initialized. In this case, MainPanel.list_frame:Update() - -- will be called by the tab's OnClick handler. - if not self.current_tab then - local current_tab = self.tabs[addon.db.profile.current_tab] - local on_click = current_tab:GetScript("OnClick") + if self.profession ~= self.prev_profession then + editbox.prev_search = nil + end + editbox:SetText(editbox.prev_search or _G.SEARCH) - on_click(current_tab) + -- If there is no current tab, this is the first time the panel has been + -- shown so things must be initialized. In this case, MainPanel.list_frame:Update() + -- will be called by the tab's OnClick handler. + if not self.current_tab then + local current_tab = self.tabs[addon.db.profile.current_tab] + local on_click = current_tab:GetScript("OnClick") - self.current_tab = addon.db.profile.current_tab - else - MainPanel.list_frame:Update(nil, false) - end - self.sort_button:SetTextures() - self.filter_toggle:SetTextures() + on_click(current_tab) - self:UpdateTitle() - self:Show() + self.current_tab = addon.db.profile.current_tab + else + MainPanel.list_frame:Update(nil, false) end + self.sort_button:SetTextures() + self.filter_toggle:SetTextures() + self:UpdateTitle() + self:Show() + end + + do ------------------------------------------------------------------------------- -- Restore the panel's position on the screen. ------------------------------------------------------------------------------- -- 1.7.9.5