Skip to content
Browse files

Add tab factory

  • Loading branch information...
1 parent 60d944c commit 2a4a43921f30eb7ed7e8e5ffa50f36bc99e0df69 @tekkub committed Nov 26, 2008
Showing with 69 additions and 0 deletions.
  1. +1 −0 tekKonfig.xml
  2. +68 −0 tekKonfigTopTab.lua
View
1 tekKonfig.xml
@@ -9,4 +9,5 @@
<Script file="tekKonfigDropdown.lua"/>
<Script file="tekKonfigAboutPanel.lua"/>
<Script file="tekKonfigGroup.lua"/>
+ <Script file="tekKonfigTopTab.lua"/>
</Ui>
View
68 tekKonfigTopTab.lua
@@ -0,0 +1,68 @@
+
+local lib, oldminor = LibStub:NewLibrary("tekKonfig-TopTab", 1)
+if not lib then return end
+oldminor = oldminor or 0
+
+
+function lib:activatetab()
+ self.left:ClearAllPoints()
+ self.left:SetPoint("TOPLEFT")
+ self.left:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab")
+ self.middle:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab")
+ self.right:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab")
+ self:Disable()
+end
+
+function lib:deactivatetab()
+ self.left:ClearAllPoints()
+ self.left:SetPoint("BOTTOMLEFT", 0, 2)
+ self.left:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab")
+ self.middle:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab")
+ self.right:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab")
+ self:Enable()
+end
+
+function lib:SetTextHelper(...) self:SetWidth(40 + self:GetFontString():GetStringWidth()); return ... end
+function lib:NewSetText(...) return lib.SetTextHelper(self, self.OrigSetText(self, ...)) end
+
+function lib.new(parent, text, ...)
+ local tab = CreateFrame("Button", nil, parent)
+ tab:SetHeight(24)
+ tab:SetPoint(...)
+ tab:SetFrameLevel(tab:GetFrameLevel() + 4)
+
+ tab.left = tab:CreateTexture(nil, "BORDER")
+ tab.left:SetWidth(20) tab.left:SetHeight(24)
+ tab.left:SetTexCoord(0, 0.15625, 0, 1)
+
+ tab.right = tab:CreateTexture(nil, "BORDER")
+ tab.right:SetWidth(20) tab.right:SetHeight(24)
+ tab.right:SetPoint("TOP", tab.left)
+ tab.right:SetPoint("RIGHT", tab)
+ tab.right:SetTexCoord(0.84375, 1, 0, 1)
+
+ tab.middle = tab:CreateTexture(nil, "BORDER")
+ tab.middle:SetHeight(24)
+ tab.middle:SetPoint("LEFT", tab.left, "RIGHT")
+ tab.middle:SetPoint("RIGHT", tab.right, "Left")
+ tab.middle:SetTexCoord(0.15625, 0.84375, 0, 1)
+
+ tab:SetHighlightTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight", "ADD")
+ local hilite = tab:GetHighlightTexture()
+ hilite:ClearAllPoints()
+ hilite:SetPoint("LEFT", 10, -4)
+ hilite:SetPoint("RIGHT", -10, -4)
+
+ tab:SetDisabledFontObject(GameFontHighlightSmall)
+ tab:SetHighlightFontObject(GameFontHighlightSmall)
+ tab:SetNormalFontObject(GameFontNormalSmall)
+ tab.OrigSetText = tab.SetText
+ tab.SetText = lib.NewSetText
+ tab:SetText(text)
+
+ tab.Activate, tab.Deactivate = lib.activatetab, lib.deactivatetab
+ tab:Activate()
+
+ return tab
+end
+

0 comments on commit 2a4a439

Please sign in to comment.
Something went wrong with that request. Please try again.