# HG changeset patch
# User Tercio
# Date 1429558458 10800
# Node ID 2f09fe4be15c453f63ca49a9476f0fcf435e854f
# Parent f1e32be6773e2eba22df7902224f30535ef0492e
Added an Options Panel.
diff -r f1e32be6773e -r 2f09fe4be15c Hansgar_And_Franzok_Assist.lua
--- a/Hansgar_And_Franzok_Assist.lua Mon Apr 06 19:41:32 2015 -0300
+++ b/Hansgar_And_Franzok_Assist.lua Mon Apr 20 16:34:18 2015 -0300
@@ -1,3 +1,10 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF) then
+ print ("|cFFFFAA00Please restart your client to finish update some AddOns.|c")
+ return
+end
+
local floor = floor
local min = min
local UnitExists = UnitExists
@@ -6,14 +13,41 @@
local GetNumGroupMembers = GetNumGroupMembers
local abs = abs
local GetPlayerFacing = GetPlayerFacing
+local db
+local _
-local f = CreateFrame ("frame", "Hansgar_And_Franzok_Assist", UIParent)
+--local f = CreateFrame ("frame", "Hansgar_And_Franzok_Assist", UIParent)
+local f = DF:Create1PxPanel (_, 155, 166, "Hans & Franz", "Hansgar_And_Franzok_Assist", nil, "top") --
f:SetFrameStrata ("DIALOG")
-f.version = "v0.11"
+f.version = "v0.12"
+
+f.Close:SetScript ("OnClick", function (self)
+ if (f.StampersPhase) then
+ return f:StopTracking()
+ end
+ f:EndTrackPlayerPosition()
+end)
+
+f.Lock:SetScript ("OnClick", function (self)
+ if (db.FRAME_LOCK) then
+ f:SetLockState()
+ print ("|cFFFFAA00Hansgar and Franzok Assist|r frame unlocked.")
+
+ f.unlocked_frame = true
+ f.player_pos_frame:Show()
+ f.player_bar:Show()
+ f.stop_casting_frame:Show()
+ else
+ f:SetLockState()
+ print ("|cFFFFAA00Hansgar and Franzok Assist|r frame locked.")
+ f.unlocked_frame = false
+ f.stop_casting_frame:Hide()
+ end
+end)
local tframe = CreateFrame ("frame", "Hansgar_And_Franzok_Assist_PTrack", UIParent)
-f:SetSize (155, 156)
+f:SetSize (155, 159)
f:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, insets = {left = -1, right = -1, top = -1, bottom = -1},
edgeFile = "Interface\\AddOns\\Hansgar_And_Franzok_Assist\\border_2", edgeSize = 8})
f:SetPoint ("center", UIParent, "center", 300, 200)
@@ -24,10 +58,10 @@
f.all_blocks = {}
f:Hide()
-local title = f:CreateFontString (nil, "overlay", "GameFontNormal")
-title:SetText ("Hansgar & Franzok Assist")
-title:SetPoint ("center", f, "center")
-title:SetPoint ("bottom", f, "top", 0, 2)
+--local title = f:CreateFontString (nil, "overlay", "GameFontNormal")
+--title:SetText ("Hansgar & Franzok Assist")
+--title:SetPoint ("center", f, "center")
+--title:SetPoint ("bottom", f, "top", 0, 2)
--
local frame_event = CreateFrame ("frame", "Hansgar_And_Franzok_AssistEvents", f)
@@ -137,6 +171,7 @@
end
end)
player_pos_frame:Hide()
+f.player_pos_frame = player_pos_frame
--red
local t1 = player_pos_frame:CreateTexture (nil, "artwork")
@@ -240,8 +275,6 @@
end
f:RegisterComm ("HAFR", "CommReceived")
-local db
-
f.block_tracker = {}
frame_event:SetFrameStrata ("FULLSCREEN")
@@ -489,6 +522,15 @@
f:RefreshCooldownSettings()
else
+
+ if (f.StampersPhase) then
+ f:EndTrackPlayerPosition()
+ return f:StopTracking()
+ end
+
+ f:StartTracking()
+ f:StartTrackPlayerPosition()
+
print ("|cFFFFAA00Hansgar and Franzok Assist|r |cFF00FF00" .. f.version .. "|r Commands:")
print ("|cFFFFFF00/hansgar resetpos|r: reset the position of all frames.")
print ("|cFFFFFF00/hansgar lock|r: toggle lock and unlock on the frame.")
@@ -505,6 +547,185 @@
--
+local options_panel = {
+ {
+ type = "range",
+ get = function() return db.STAMPERS_DELAY end,
+ set = function (self, fixedparam, value) db.STAMPERS_DELAY = value end,
+ min = 4,
+ max = 8,
+ step = 1,
+ desc = "Time in seconds to move out from a heating up stamper.",
+ name = "Stampers Delay",
+ },
+ {
+ type = "toggle",
+ get = function() return db.FRAME_LOCK end,
+ set = function (self, fixedparam, value)
+ db.FRAME_LOCK = not value;
+ if (db.FRAME_LOCK) then
+ f:SetLockState()
+ print ("|cFFFFAA00Hansgar and Franzok Assist|r frame unlocked.")
+
+ f.unlocked_frame = true
+ f.player_pos_frame:Show()
+ f.player_bar:Show()
+ f.stop_casting_frame:Show()
+ else
+ f:SetLockState()
+ print ("|cFFFFAA00Hansgar and Franzok Assist|r frame locked.")
+ f.unlocked_frame = false
+ f.stop_casting_frame:Hide()
+ end
+ end,
+ desc = "Lock or unlock the frames.",
+ name = "Frame Locked"
+ },
+ {
+ type = "toggle",
+ get = function() return db.SHOW_DANCE end,
+ set = function (self, fixedparam, value)
+ db.SHOW_DANCE = not db.SHOW_DANCE
+ if (db.SHOW_DANCE) then
+ if (f.on_encounter) then
+ f:StartTrackPlayerPosition()
+ end
+ else
+ f:EndTrackPlayerPosition()
+ end
+ end,
+ desc = "Enable or disable the dance bar.",
+ name = "Dance Bar"
+ },
+ {
+ type = "toggle",
+ get = function() return db.CD_NUMBER end,
+ set = function (self, fixedparam, value)
+ db.CD_NUMBER = not db.CD_NUMBER
+ f:RefreshCooldownSettings()
+ end,
+ desc = "When enabled, shows the number countdown on each block.",
+ name = "Show Cooldown Number"
+ },
+ {
+ type = "toggle",
+ get = function() return db.STOP_CAST end,
+ set = function (self, fixedparam, value)
+ db.STOP_CAST = not db.STOP_CAST
+ end,
+ desc = "When enabled, shows an alert for Disrupting Roar.",
+ name = "Stop Cast Alert"
+ },
+ {
+ type = "execute",
+ func = function()
+ if (f.StampersPhase) then
+ f:EndTrackPlayerPosition()
+ return f:StopTracking()
+ end
+ f:StartTracking()
+ f:StartTrackPlayerPosition()
+ end,
+ desc = "Test the addon, run over the tracks in the room.",
+ name = "Start Test Mode"
+ },
+ {
+ type = "execute",
+ func = function()
+ f:ClearAllPoints()
+ f:SetPoint ("center", UIParent, "center")
+
+ player_bar:ClearAllPoints()
+ player_bar:SetPoint ("center", UIParent, "center")
+
+ player_pos_frame:ClearAllPoints()
+ player_pos_frame:SetPoint ("center", UIParent, "center")
+
+ if (f.StampersPhase) then
+ f:EndTrackPlayerPosition()
+ f:StopTracking()
+ end
+
+ db.FRAME_LOCK = true
+ f:SetLockState()
+
+ f.unlocked_frame = true
+
+ f:StartTracking()
+ f:StartTrackPlayerPosition()
+
+ print ("|cFFFFAA00Hansgar and Franzok Assist|r: position reseted and frames are unlocked.")
+ print ("|cFFFFAA00Hansgar and Franzok Assist|r: move between the tracks to show the other frames.")
+ end,
+ desc = "Reset the position of all frames and start the test mode.",
+ name = "Reset Position"
+ },
+ {
+ type = "execute",
+ func = function()
+ if (f.users_schedule) then
+ print ("|cFFFFAA00Hansgar and Franzok Assist|r please wait 5 seconds...")
+ elseif (IsInRaid()) then
+ f.users = {}
+ f:SendCommMessage ("HAFR", "US", "RAID")
+ f.users_schedule = f:ScheduleTimer ("ShowUsers", 5)
+ print ("|cFFFFAA00Hansgar and Franzok Assist|r please wait 5 seconds...")
+ else
+ print ("|cFFFFAA00Hansgar and Franzok Assist|r you aren't in a raid group.")
+ end
+ end,
+ desc = "Show raid members which are also using this addon.",
+ name = "Version Check"
+ },
+ {
+ type = "execute",
+ func = function()
+ f.feedback_func()
+ end,
+ desc = "Send a feedback for us on our Curse page or MMO-Champion forum Thread.",
+ name = "Send Feedback"
+ },
+}
+
+local build_options_panel = function()
+ local options_frame = DF:CreateOptionsFrame ("HansgarFranzokAssistOptions", "Hans & Franz Assist", 1)
+ options_frame:SetHeight (180)
+ DF:BuildMenu (options_frame, options_panel, 15, -60, 180)
+ options_frame:SetBackdropColor (0, 0, 0, .9)
+end
+
+f.OpenOptionsPanel = function()
+ if (not HansgarFranzokAssistOptions) then
+ build_options_panel()
+ end
+ HansgarFranzokAssistOptions:Show()
+end
+
+-- /run Hansgar_And_Franzok_Assist.OpenOptionsPanel()
+local options = DF:CreateOptionsButton (f, f.OpenOptionsPanel, "Hansgar_And_Franzok_Assist_OPButton")
+options:SetPoint ("right", f.Lock, "left", 1, 0)
+f.Options = options
+
+--
+local feedback_func = function()
+ local feedback1 = {icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\feedback_sites]], coords = DF.www_icons.mmoc, desc = "Post on our thread on MMO-Champion Forum.", link = [[http://www.mmo-champion.com/threads/1725970-Hans-gar-and-Franzok-Assist-(addon)]]}
+ local feedback2 = {icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\feedback_sites]], coords = DF.www_icons.curse, desc = "Leave a comment on our page at Curse.com.", link = [[http://www.curse.com/addons/wow/hansgar_and_franzok_assist]]}
+
+ local same1 = {name = "Details! Damage Meter", desc = "A Damage Meter with a lot of tools for raiders and leaders.", link = [[http://www.curse.com/addons/wow/details]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {0, 128/512, 0, 64/512}}
+ local same2 = {name = "Gold Token Price", desc = "Adds the slash command '/gold'. This command tells you the current price of WoW Token.", link = [[http://www.curse.com/addons/wow/gold-token-price]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {128/512, 256/512, 0, 64/512}}
+ local same3 = {name = "Salvage Yard Seller", desc = "Sells stuff gathered from salvage crates respecting item level limit.", link = [[http://www.curse.com/addons/wow/salvage-yard-seller]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {384/512, 512/512, 64/512, 128/512}}
+ local same4 = {name = "AddOns CPU Usage", desc = "Measure the CPU usage by addons. Important to get rid of FPS drops during boss encounters.", link = [[http://www.curse.com/addons/wow/addons-cpu-usage]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {384/512, 512/512, 0, 64/512}}
+ local same5 = {name = "Keep World Map Zoom", desc = "Because it's a pain having to re-zoom the world map after close and reopening in a short period of time.", link = [[http://www.curse.com/addons/wow/world-map-zoom]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {0/512, 128/512, 64/512, 128/512}}
+ local same6 = {name = "PvPScan", desc = "Show a unit frame with enemy players near you.", link = [[http://www.wowace.com/addons/pvpscan/]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {128/512, 256/512, 64/512, 128/512}}
+ local same7 = {name = "HotCorners", desc = "Show a hotcorner when poiting the mouse on the absolute top left of your screen (similar of those on Windows 8).", link = [[http://www.curse.com/addons/wow/hotcorners]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {256/512, 384/512, 64/512, 128/512}}
+
+ DF:ShowFeedbackPanel ("Hans & Franz Assist", f.version, {feedback2, feedback1}, {same1, same2, same3, same4, same5, same6, same7})
+end
+f.feedback_func = feedback_func
+local feedback_button = DF:CreateFeedbackButton (f, feedback_func, "Hansgar_And_Franzok_AssistFBButton")
+feedback_button:SetPoint ("right", f.Options, "left", 0, -1)
+--
+
local stop_casting_frame = CreateFrame ("frame", "Hansgar_And_Franzok_AssistStopCasting", UIParent)
stop_casting_frame:SetSize (200, 30)
stop_casting_frame:SetPoint ("center", UIParent, "center", 0, 75)
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/addon.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/addon.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,58 @@
+
+
+
+local DF = _G ["DetailsFramework"]
+local _
+
+function DF:CreateAddOn (name, global_saved, global_table, options_table, broker)
+
+ local addon = LibStub ("AceAddon-3.0"):NewAddon (name, "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0", "DetailsFramework-1.0")
+ _G [name] = addon
+ addon.__name = name
+
+ function addon:OnInitialize()
+
+ if (global_saved) then
+ if (broker and broker.Minimap and not global_table.Minimap) then
+ DF:Msg (name, "broker.Minimap is true but no global.Minimap declared.")
+ end
+ self.db = LibStub ("AceDB-3.0"):New (global_saved, global_table or {}, true)
+ end
+
+ if (options_table) then
+ LibStub ("AceConfig-3.0"):RegisterOptionsTable (name, options_table)
+ addon.OptionsFrame1 = LibStub ("AceConfigDialog-3.0"):AddToBlizOptions (name, name)
+
+ LibStub ("AceConfig-3.0"):RegisterOptionsTable (name .. "-Profiles", LibStub ("AceDBOptions-3.0"):GetOptionsTable (self.db))
+ addon.OptionsFrame2 = LibStub ("AceConfigDialog-3.0"):AddToBlizOptions (name .. "-Profiles", "Profiles", name)
+ end
+
+ if (broker) then
+
+ local broker_click_function = broker.OnClick
+ if (not broker_click_function and options_table) then
+ broker_click_function = function()
+ InterfaceOptionsFrame_OpenToCategory (name)
+ InterfaceOptionsFrame_OpenToCategory (name)
+ end
+ end
+
+ local databroker = LibStub ("LibDataBroker-1.1"):NewDataObject (name, {
+ type = broker.type or "launcher",
+ icon = broker.icon or [[Interface\PvPRankBadges\PvPRank15]],
+ text = broker.text or "",
+ OnTooltipShow = broker.OnTooltipShow,
+ OnClick = broker_click_function
+ })
+
+ if (databroker and broker.Minimap and global_table.Minimap) then
+ LibStub ("LibDBIcon-1.0"):Register (name, databroker, addon.db.profile.Minimap)
+ end
+
+ end
+
+ end
+
+ return addon
+
+end
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/all_addons.tga
Binary file Libs/DF/all_addons.tga has changed
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/background.tga
Binary file Libs/DF/background.tga has changed
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/border_1.tga
Binary file Libs/DF/border_1.tga has changed
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/border_2.tga
Binary file Libs/DF/border_2.tga has changed
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/border_3.tga
Binary file Libs/DF/border_3.tga has changed
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/button.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/button.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,1043 @@
+
+local DF = _G ["DetailsFramework"]
+
+local _
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+local loadstring = loadstring --> lua local
+
+local cleanfunction = function() end
+local APIButtonFunctions = false
+local ButtonMetaFunctions = {}
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ ButtonMetaFunctions.__call = function (_table, value, ...)
+ return self.func (_table.param1, _table.param2, value, ...)
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> tooltip
+ local gmember_tooltip = function (_object)
+ return _object:GetTooltip()
+ end
+ --> shown
+ local gmember_shown = function (_object)
+ return _object:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.button:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.button:GetHeight()
+ end
+ --> text
+ local gmember_text = function (_object)
+ return _object.button.text:GetText()
+ end
+ --> function
+ local gmember_function = function (_object)
+ return _rawget (_object, "func")
+ end
+ --> text color
+ local gmember_textcolor = function (_object)
+ return _object.button.text:GetTextColor()
+ end
+ --> text font
+ local gmember_textfont = function (_object)
+ local fontface = _object.button.text:GetFont()
+ return fontface
+ end
+ --> text size
+ local gmember_textsize = function (_object)
+ local _, fontsize = _object.button.text:GetFont()
+ return fontsize
+ end
+ --> texture
+ local gmember_texture = function (_object)
+ return {_object.button:GetNormalTexture(), _object.button:GetHighlightTexture(), _object.button:GetPushedTexture(), _object.button:GetDisabledTexture()}
+ end
+ --> locked
+ local gmember_locked = function (_object)
+ return _rawget (_object, "is_locked")
+ end
+
+ local get_members_function_index = {
+ ["tooltip"] = gmember_tooltip,
+ ["shown"] = gmember_shown,
+ ["width"] = gmember_width,
+ ["height"] = gmember_height,
+ ["text"] = gmember_text,
+ ["clickfunction"] = gmember_function,
+ ["texture"] = gmember_texture,
+ ["locked"] = gmember_locked,
+ ["fontcolor"] = gmember_textcolor,
+ ["fontface"] = gmember_textfont,
+ ["fontsize"] = gmember_textsize,
+ ["textcolor"] = gmember_textcolor, --alias
+ ["textfont"] = gmember_textfont, --alias
+ ["textsize"] = gmember_textsize --alias
+ }
+
+ ButtonMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = get_members_function_index [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return ButtonMetaFunctions [_member_requested]
+ end
+
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ --> tooltip
+ local smember_tooltip = function (_object, _value)
+ return _object:SetTooltip (_value)
+ end
+ --> show
+ local smember_show = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (not _value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> frame width
+ local smember_width = function (_object, _value)
+ return _object.button:SetWidth (_value)
+ end
+ --> frame height
+ local smember_height = function (_object, _value)
+ return _object.button:SetHeight (_value)
+ end
+ --> text
+ local smember_text = function (_object, _value)
+ return _object.button.text:SetText (_value)
+ end
+ --> function
+ local smember_function = function (_object, _value)
+ return _rawset (_object, "func", _value)
+ end
+ --> text color
+ local smember_textcolor = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+ return _object.button.text:SetTextColor (_value1, _value2, _value3, _value4)
+ end
+ --> text font
+ local smember_textfont = function (_object, _value)
+ return DF:SetFontFace (_object.button.text, _value)
+ end
+ --> text size
+ local smember_textsize = function (_object, _value)
+ return DF:SetFontSize (_object.button.text, _value)
+ end
+ --> texture
+ local smember_texture = function (_object, _value)
+ if (_type (_value) == "table") then
+ local _value1, _value2, _value3, _value4 = unpack (_value)
+ if (_value1) then
+ _object.button:SetNormalTexture (_value1)
+ end
+ if (_value2) then
+ _object.button:SetHighlightTexture (_value2, "ADD")
+ end
+ if (_value3) then
+ _object.button:SetPushedTexture (_value3)
+ end
+ if (_value4) then
+ _object.button:SetDisabledTexture (_value4)
+ end
+ else
+ _object.button:SetNormalTexture (_value)
+ _object.button:SetHighlightTexture (_value, "ADD")
+ _object.button:SetPushedTexture (_value)
+ _object.button:SetDisabledTexture (_value)
+ end
+ return
+ end
+ --> locked
+ local smember_locked = function (_object, _value)
+ if (_value) then
+ _object.button:SetMovable (false)
+ return _rawset (_object, "is_locked", true)
+ else
+ _object.button:SetMovable (true)
+ _rawset (_object, "is_locked", false)
+ return
+ end
+ end
+ --> text align
+ local smember_textalign = function (_object, _value)
+ if (_value == "left" or _value == "<") then
+ _object.button.text:SetPoint ("left", _object.button, "left", 2, 0)
+ _object.capsule_textalign = "left"
+ elseif (_value == "center" or _value == "|") then
+ _object.button.text:SetPoint ("center", _object.button, "center", 0, 0)
+ _object.capsule_textalign = "center"
+ elseif (_value == "right" or _value == ">") then
+ _object.button.text:SetPoint ("right", _object.button, "right", -2, 0)
+ _object.capsule_textalign = "right"
+ end
+ end
+
+ local set_members_function_index = {
+ ["tooltip"] = smember_tooltip,
+ ["show"] = smember_show,
+ ["hide"] = smember_hide,
+ ["width"] = smember_width,
+ ["height"] = smember_height,
+ ["text"] = smember_text,
+ ["clickfunction"] = smember_function,
+ ["textcolor"] = smember_textcolor,
+ ["textfont"] = smember_textfont,
+ ["textsize"] = smember_textsize,
+ ["texture"] = smember_texture,
+ ["locked"] = smember_locked,
+ ["textalign"] = smember_textalign,
+ }
+
+ ButtonMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = set_members_function_index [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+
+--> show & hide
+ function ButtonMetaFunctions:IsShown()
+ return self.button:IsShown()
+ end
+ function ButtonMetaFunctions:Show()
+ return self.button:Show()
+ end
+ function ButtonMetaFunctions:Hide()
+ return self.button:Hide()
+ end
+
+-- setpoint
+ function ButtonMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ error ("SetPoint: Invalid parameter.")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+-- sizes
+ function ButtonMetaFunctions:SetSize (w, h)
+ if (w) then
+ self.button:SetWidth (w)
+ end
+ if (h) then
+ return self.button:SetHeight (h)
+ end
+ end
+
+-- tooltip
+ function ButtonMetaFunctions:SetTooltip (tooltip)
+ if (tooltip) then
+ return _rawset (self, "have_tooltip", tooltip)
+ else
+ return _rawset (self, "have_tooltip", nil)
+ end
+ end
+ function ButtonMetaFunctions:GetTooltip()
+ return _rawget (self, "have_tooltip")
+ end
+
+-- functions
+ function ButtonMetaFunctions:SetClickFunction (func, param1, param2, clicktype)
+ if (not clicktype or string.find (string.lower (clicktype), "left")) then
+ if (func) then
+ _rawset (self, "func", func)
+ else
+ _rawset (self, "func", cleanfunction)
+ end
+
+ if (param1 ~= nil) then
+ _rawset (self, "param1", param1)
+ end
+ if (param2 ~= nil) then
+ _rawset (self, "param2", param2)
+ end
+
+ elseif (clicktype or string.find (string.lower (clicktype), "right")) then
+ if (func) then
+ _rawset (self, "funcright", func)
+ else
+ _rawset (self, "funcright", cleanfunction)
+ end
+ end
+ end
+
+-- text
+ function ButtonMetaFunctions:SetText (text)
+ if (text) then
+ self.button.text:SetText (text)
+ else
+ self.button.text:SetText (nil)
+ end
+ end
+
+-- textcolor
+ function ButtonMetaFunctions:SetTextColor (color, arg2, arg3, arg4)
+ if (arg2) then
+ return self.button.text:SetTextColor (color, arg2, arg3, arg4 or 1)
+ end
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
+ return self.button.text:SetTextColor (_value1, _value2, _value3, _value4)
+ end
+
+-- textsize
+ function ButtonMetaFunctions:SetTextSize (size)
+ return DF:SetFontSize (self.button.text, _value)
+ end
+
+-- textfont
+ function ButtonMetaFunctions:SetTextFont (font)
+ return DF:SetFontFace (_object.button.text, _value)
+ end
+
+-- textures
+ function ButtonMetaFunctions:SetTexture (normal, highlight, pressed, disabled)
+ if (normal) then
+ self.button:SetNormalTexture (normal)
+ elseif (_type (normal) ~= "boolean") then
+ self.button:SetNormalTexture (nil)
+ end
+
+ if (_type (highlight) == "boolean") then
+ if (highlight and normal and _type (normal) ~= "boolean") then
+ self.button:SetHighlightTexture (normal, "ADD")
+ end
+ elseif (highlight == nil) then
+ self.button:SetHighlightTexture (nil)
+ else
+ self.button:SetHighlightTexture (highlight, "ADD")
+ end
+
+ if (_type (pressed) == "boolean") then
+ if (pressed and normal and _type (normal) ~= "boolean") then
+ self.button:SetPushedTexture (normal)
+ end
+ elseif (pressed == nil) then
+ self.button:SetPushedTexture (nil)
+ else
+ self.button:SetPushedTexture (pressed, "ADD")
+ end
+
+ if (_type (disabled) == "boolean") then
+ if (disabled and normal and _type (normal) ~= "boolean") then
+ self.button:SetDisabledTexture (normal)
+ end
+ elseif (disabled == nil) then
+ self.button:SetDisabledTexture (nil)
+ else
+ self.button:SetDisabledTexture (disabled, "ADD")
+ end
+
+ end
+
+-- frame levels
+ function ButtonMetaFunctions:GetFrameLevel()
+ return self.button:GetFrameLevel()
+ end
+ function ButtonMetaFunctions:SetFrameLevel (level, frame)
+ if (not frame) then
+ return self.button:SetFrameLevel (level)
+ else
+ local framelevel = frame:GetFrameLevel (frame) + level
+ return self.button:SetFrameLevel (framelevel)
+ end
+ end
+
+-- icon
+ function ButtonMetaFunctions:SetIcon (texture, width, height, layout, texcoord, overlay, textdistance, leftpadding)
+ if (not self.icon) then
+ self.icon = self:CreateTexture (nil, "artwork")
+ self.icon:SetSize (self.height*0.8, self.height*0.8)
+ self.icon:SetPoint ("left", self.widget, "left", 4 + (leftpadding or 0), 0)
+ self.icon.leftpadding = leftpadding or 0
+ self.widget.text:ClearAllPoints()
+ self.widget.text:SetPoint ("left", self.icon, "right", textdistance or 2, 0)
+ end
+
+ self.icon:SetTexture (texture)
+ self.icon:SetSize (width or self.height*0.8, height or self.height*0.8)
+ self.icon:SetDrawLayer (layout or "artwork")
+ if (texcoord) then
+ self.icon:SetTexCoord (unpack (texcoord))
+ else
+ self.icon:SetTexCoord (0, 1, 0, 1)
+ end
+ if (overlay) then
+ if (type (overlay) == "string") then
+ local r, g, b, a = DF:ParseColors (overlay)
+ self.icon:SetVertexColor (r, g, b, a)
+ else
+ self.icon:SetVertexColor (unpack (overlay))
+ end
+ else
+ self.icon:SetVertexColor (1, 1, 1, 1)
+ end
+
+ local w = self.button:GetWidth()
+ local iconw = self.icon:GetWidth()
+ local text_width = self.button.text:GetStringWidth()
+ if (text_width > w-15-iconw) then
+ if (not short_method) then
+ local new_width = text_width+15+iconw
+ self.button:SetWidth (new_width)
+ elseif (short_method == 1) then
+ local loop = true
+ local textsize = 11
+ while (loop) do
+ if (text_width+15+iconw < w or textsize < 8) then
+ loop = false
+ break
+ else
+ DF:SetFontSize (self.button.text, textsize)
+ text_width = self.button.text:GetStringWidth()
+ textsize = textsize - 1
+ end
+ end
+ end
+ end
+
+ end
+
+-- frame stratas
+ function ButtonMetaFunctions:SetFrameStrata()
+ return self.button:GetFrameStrata()
+ end
+ function ButtonMetaFunctions:SetFrameStrata (strata)
+ if (_type (strata) == "table") then
+ self.button:SetFrameStrata (strata:GetFrameStrata())
+ else
+ self.button:SetFrameStrata (strata)
+ end
+ end
+
+-- enabled
+ function ButtonMetaFunctions:IsEnabled()
+ return self.button:IsEnabled()
+ end
+ function ButtonMetaFunctions:Enable()
+ return self.button:Enable()
+ end
+ function ButtonMetaFunctions:Disable()
+ return self.button:Disable()
+ end
+
+-- exec
+ function ButtonMetaFunctions:Exec()
+ return self.func (self.param1, self.param2)
+ end
+ function ButtonMetaFunctions:Click()
+ return self.func (self.param1, self.param2)
+ end
+ function ButtonMetaFunctions:RightClick()
+ return self.funcright()
+ end
+
+--> hooks
+ function ButtonMetaFunctions:SetHook (hookType, func)
+ if (func) then
+ _rawset (self, hookType.."Hook", func)
+ else
+ _rawset (self, hookType.."Hook", nil)
+ end
+ end
+
+--> custom textures
+ function ButtonMetaFunctions:InstallCustomTexture (texture, rect, coords, use_split, side_textures, side_textures2)
+
+ self.button:SetNormalTexture (nil)
+ self.button:SetPushedTexture (nil)
+ self.button:SetDisabledTexture (nil)
+ self.button:SetHighlightTexture (nil)
+
+ local button = self.button
+
+ if (use_split) then
+
+ --> 4 corners
+ button.textureTopLeft = button:CreateTexture (nil, "artwork"); button.textureTopLeft:SetSize (8, 8); button.textureTopLeft:SetPoint ("topleft", button)
+ button.textureTopRight = button:CreateTexture (nil, "artwork"); button.textureTopRight:SetSize (8, 8); button.textureTopRight:SetPoint ("topright", button)
+ button.textureBottomLeft = button:CreateTexture (nil, "artwork"); button.textureBottomLeft:SetSize (8, 8); button.textureBottomLeft:SetPoint ("bottomleft", button)
+ button.textureBottomRight = button:CreateTexture (nil, "artwork"); button.textureBottomRight:SetSize (8, 8); button.textureBottomRight:SetPoint ("bottomright", button)
+
+ button.textureLeft = button:CreateTexture (nil, "artwork"); button.textureLeft:SetWidth (4); button.textureLeft:SetPoint ("topleft", button.textureTopLeft, "bottomleft"); button.textureLeft:SetPoint ("bottomleft", button.textureBottomLeft, "topleft")
+ button.textureRight = button:CreateTexture (nil, "artwork"); button.textureRight:SetWidth (4); button.textureRight:SetPoint ("topright", button.textureTopRight, "bottomright"); button.textureRight:SetPoint ("bottomright", button.textureBottomRight, "topright")
+ button.textureTop = button:CreateTexture (nil, "artwork"); button.textureTop:SetHeight (4); button.textureTop:SetPoint ("topleft", button.textureTopLeft, "topright"); button.textureTop:SetPoint ("topright", button.textureTopRight, "topleft");
+ button.textureBottom = button:CreateTexture (nil, "artwork"); button.textureBottom:SetHeight (4); button.textureBottom:SetPoint ("bottomleft", button.textureBottomLeft, "bottomright"); button.textureBottom:SetPoint ("bottomright", button.textureBottomRight, "bottomleft");
+
+ button.textureLeft:SetTexCoord (0, 4/128, 9/128, 24/128)
+ button.textureRight:SetTexCoord (124/128, 1, 9/128, 24/128)
+ button.textureTop:SetTexCoord (9/128, 120/128, 0, 4/128)
+ button.textureBottom:SetTexCoord (9/128, 119/128, 28/128, 32/128)
+
+ button.textureTopLeft:SetTexCoord (0, 8/128, 0, 8/128)
+ button.textureTopRight:SetTexCoord (121/128, 1, 0, 8/128)
+ button.textureBottomLeft:SetTexCoord (0, 8/128, 24/128, 32/128)
+ button.textureBottomRight:SetTexCoord (120/128, 1, 24/128, 32/128)
+
+ button.textureTopLeft:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+ button.textureTopRight:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+ button.textureBottomLeft:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+ button.textureBottomRight:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+ button.textureLeft:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+ button.textureRight:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+ button.textureTop:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+ button.textureBottom:SetTexture ([[Interface\AddOns\Details\images\default_button]])
+
+ else
+ texture = texture or "Interface\\AddOns\\Details\\images\\default_button"
+ self.button.texture = self.button:CreateTexture (nil, "artwork")
+
+ if (not rect) then
+ self.button.texture:SetAllPoints (self.button)
+ else
+ self.button.texture:SetPoint ("topleft", self.button, "topleft", rect.x1, rect.y1)
+ self.button.texture:SetPoint ("bottomright", self.button, "bottomright", rect.x2, rect.y2)
+ end
+
+ if (coords) then
+ self.button.texture.coords = coords
+ self.button.texture:SetTexCoord (_unpack (coords.Normal))
+ else
+ self.button.texture:SetTexCoord (0, 1, 0, 0.24609375)
+ end
+
+ self.button.texture:SetTexture (texture)
+ end
+
+ if (side_textures) then
+ local left = self.button:CreateTexture (nil, "overlay")
+ left:SetTexture ([[Interface\TALENTFRAME\talent-main]])
+ left:SetTexCoord (0.13671875, 0.25, 0.486328125, 0.576171875)
+ left:SetPoint ("left", self.button, 0, 0)
+ left:SetWidth (10)
+ left:SetHeight (self.button:GetHeight()+2)
+ self.button.left_border = left
+
+ local right = self.button:CreateTexture (nil, "overlay")
+ right:SetTexture ([[Interface\TALENTFRAME\talent-main]])
+ right:SetTexCoord (0.01953125, 0.13671875, 0.486328125, 0.576171875)
+ right:SetPoint ("right", self.button, 0, 0)
+ right:SetWidth (10)
+ right:SetHeight (self.button:GetHeight()+2)
+ self.button.right_border = right
+
+ elseif (side_textures2) then
+
+ local left = self.button:CreateTexture (nil, "overlay")
+ left:SetTexture ([[Interface\AddOns\Details\images\icons]])
+ left:SetTexCoord (94/512, 123/512, 42/512, 87/512)
+ left:SetPoint ("left", self.button, 0, 0)
+ left:SetWidth (10)
+ left:SetHeight (self.button:GetHeight()+2)
+ self.button.left_border = left
+
+ local right = self.button:CreateTexture (nil, "overlay")
+ right:SetTexture ([[Interface\AddOns\Details\images\icons]])
+ right:SetTexCoord (65/512, 94/512, 42/512, 87/512)
+ right:SetPoint ("right", self.button, 0, 0)
+ right:SetWidth (10)
+ right:SetHeight (self.button:GetHeight()+2)
+ self.button.right_border = right
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts
+
+ local OnEnter = function (button)
+
+ if (button.textureTopLeft) then
+ button.textureLeft:SetTexCoord (0, 4/128, 40/128, 56/128)
+ button.textureRight:SetTexCoord (124/128, 1, 40/128, 56/128)
+ button.textureTop:SetTexCoord (9/128, 120/128, 33/128, 37/128)
+ button.textureBottom:SetTexCoord (9/128, 119/128, 60/128, 64/128)
+
+ button.textureTopLeft:SetTexCoord (0, 8/128, 33/128, 40/128)
+ button.textureTopRight:SetTexCoord (121/128, 1, 33/128, 40/128)
+ button.textureBottomLeft:SetTexCoord (0, 8/128, 56/128, 64/128)
+ button.textureBottomRight:SetTexCoord (120/128, 1, 56/128, 64/128)
+ end
+
+ if (button.MyObject.OnEnterHook) then
+ local interrupt = button.MyObject.OnEnterHook (button, button.MyObject)
+ if (interrupt) then
+ return
+ end
+ end
+
+ button.MyObject.is_mouse_over = true
+
+ if (button.texture) then
+ if (button.texture.coords) then
+ button.texture:SetTexCoord (_unpack (button.texture.coords.Highlight))
+ else
+ button.texture:SetTexCoord (0, 1, 0.24609375, 0.49609375)
+ end
+ end
+
+ if (button.MyObject.have_tooltip) then
+ GameCooltip2:Preset (2)
+ if (type (button.MyObject.have_tooltip) == "function") then
+ GameCooltip2:AddLine (button.MyObject.have_tooltip() or "")
+ else
+ GameCooltip2:AddLine (button.MyObject.have_tooltip)
+ end
+ GameCooltip2:ShowCooltip (button, "tooltip")
+ end
+
+ local parent = button:GetParent().MyObject
+ if (parent and parent.type == "panel") then
+ if (parent.GradientEnabled) then
+ parent:RunGradient()
+ end
+ end
+ end
+
+ local OnLeave = function (button)
+
+ if (button.textureLeft and not button.MyObject.is_mouse_down) then
+ button.textureLeft:SetTexCoord (0, 4/128, 9/128, 24/128)
+ button.textureRight:SetTexCoord (124/128, 1, 9/128, 24/128)
+ button.textureTop:SetTexCoord (9/128, 120/128, 0, 4/128)
+ button.textureBottom:SetTexCoord (9/128, 119/128, 28/128, 32/128)
+
+ button.textureTopLeft:SetTexCoord (0, 8/128, 0, 8/128)
+ button.textureTopRight:SetTexCoord (121/128, 1, 0, 8/128)
+ button.textureBottomLeft:SetTexCoord (0, 8/128, 24/128, 32/128)
+ button.textureBottomRight:SetTexCoord (120/128, 1, 24/128, 32/128)
+ end
+
+ if (button.MyObject.OnLeaveHook) then
+ local interrupt = button.MyObject.OnLeaveHook (button, button.MyObject)
+ if (interrupt) then
+ return
+ end
+ end
+
+ button.MyObject.is_mouse_over = false
+
+ if (button.texture and not button.MyObject.is_mouse_down) then
+ if (button.texture.coords) then
+ button.texture:SetTexCoord (_unpack (button.texture.coords.Normal))
+ else
+ button.texture:SetTexCoord (0, 1, 0, 0.24609375)
+ end
+ end
+
+ if (button.MyObject.have_tooltip) then
+ if (GameCooltip2:GetText (1) == button.MyObject.have_tooltip or type (button.MyObject.have_tooltip) == "function") then
+ GameCooltip2:Hide()
+ end
+ end
+
+ local parent = button:GetParent().MyObject
+ if (parent and parent.type == "panel") then
+ if (parent.GradientEnabled) then
+ parent:RunGradient (false)
+ end
+ end
+ end
+
+ local OnHide = function (button)
+ if (button.MyObject.OnHideHook) then
+ local interrupt = button.MyObject.OnHideHook (button, button.MyObject)
+ if (interrupt) then
+ return
+ end
+ end
+ end
+
+ local OnShow = function (button)
+ if (button.MyObject.OnShowHook) then
+ local interrupt = button.MyObject.OnShowHook (button, button.MyObject)
+ if (interrupt) then
+ return
+ end
+ end
+ end
+
+ local OnMouseDown = function (button, buttontype)
+ if (not button:IsEnabled()) then
+ return
+ end
+
+ if (button.textureTopLeft) then
+ button.textureLeft:SetTexCoord (0, 4/128, 72/128, 88/128)
+ button.textureRight:SetTexCoord (124/128, 1, 72/128, 88/128)
+ button.textureTop:SetTexCoord (9/128, 120/128, 65/128, 68/128)
+ button.textureBottom:SetTexCoord (9/128, 119/128, 92/128, 96/128)
+
+ button.textureTopLeft:SetTexCoord (0, 8/128, 65/128, 71/128)
+ button.textureTopRight:SetTexCoord (121/128, 1, 65/128, 71/128)
+ button.textureBottomLeft:SetTexCoord (0, 8/128, 88/128, 96/128)
+ button.textureBottomRight:SetTexCoord (120/128, 1, 88/128, 96/128)
+ end
+
+ if (button.MyObject.OnMouseDownHook) then
+ local interrupt = button.MyObject.OnMouseDownHook (button, buttontype, button.MyObject)
+ if (interrupt) then
+ return
+ end
+ end
+
+ button.MyObject.is_mouse_down = true
+
+ if (button.texture) then
+ if (button.texture.coords) then
+ button.texture:SetTexCoord (_unpack (button.texture.coords.Pushed))
+ else
+ button.texture:SetTexCoord (0, 1, 0.5078125, 0.75)
+ end
+ end
+
+ if (button.MyObject.capsule_textalign) then
+ if (button.MyObject.icon) then
+ button.MyObject.icon:SetPoint ("left", button, "left", 5 + (button.MyObject.icon.leftpadding or 0), -1)
+ elseif (button.MyObject.capsule_textalign == "left") then
+ button.text:SetPoint ("left", button, "left", 3, -1)
+ elseif (button.MyObject.capsule_textalign == "center") then
+ button.text:SetPoint ("center", button, "center", 1, -1)
+ elseif (button.MyObject.capsule_textalign == "right") then
+ button.text:SetPoint ("right", button, "right", -1, -1)
+ end
+ else
+ if (button.MyObject.icon) then
+ button.MyObject.icon:SetPoint ("left", button, "left", 7 + (button.MyObject.icon.leftpadding or 0), -2)
+ else
+ button.text:SetPoint ("center", button,"center", 1, -1)
+ end
+ end
+
+ button.mouse_down = GetTime()
+ local x, y = GetCursorPosition()
+ button.x = _math_floor (x)
+ button.y = _math_floor (y)
+
+ if (not button.MyObject.container.isLocked and button.MyObject.container:IsMovable()) then
+ if (not button.isLocked and button:IsMovable()) then
+ button.MyObject.container.isMoving = true
+ button.MyObject.container:StartMoving()
+ end
+ end
+
+ if (button.MyObject.options.OnGrab) then
+ if (_type (button.MyObject.options.OnGrab) == "string" and button.MyObject.options.OnGrab == "PassClick") then
+ if (buttontype == "LeftButton") then
+ button.MyObject.func (button.MyObject.param1, button.MyObject.param2)
+ else
+ button.MyObject.funcright (button.MyObject.param1, button.MyObject.param2)
+ end
+ end
+ end
+ end
+
+ local OnMouseUp = function (button, buttontype)
+ if (not button:IsEnabled()) then
+ return
+ end
+
+ if (button.textureLeft) then
+ if (button.MyObject.is_mouse_over) then
+ button.textureLeft:SetTexCoord (0, 4/128, 40/128, 56/128)
+ button.textureRight:SetTexCoord (124/128, 1, 40/128, 56/128)
+ button.textureTop:SetTexCoord (9/128, 120/128, 33/128, 37/128)
+ button.textureBottom:SetTexCoord (9/128, 119/128, 60/128, 64/128)
+
+ button.textureTopLeft:SetTexCoord (0, 8/128, 33/128, 40/128)
+ button.textureTopRight:SetTexCoord (121/128, 1, 33/128, 40/128)
+ button.textureBottomLeft:SetTexCoord (0, 8/128, 56/128, 64/128)
+ button.textureBottomRight:SetTexCoord (120/128, 1, 56/128, 64/128)
+ else
+ button.textureLeft:SetTexCoord (0, 4/128, 9/128, 24/128)
+ button.textureRight:SetTexCoord (124/128, 1, 9/128, 24/128)
+ button.textureTop:SetTexCoord (9/128, 120/128, 0, 4/128)
+ button.textureBottom:SetTexCoord (9/128, 119/128, 28/128, 32/128)
+
+ button.textureTopLeft:SetTexCoord (0, 8/128, 0, 8/128)
+ button.textureTopRight:SetTexCoord (121/128, 1, 0, 8/128)
+ button.textureBottomLeft:SetTexCoord (0, 8/128, 24/128, 32/128)
+ button.textureBottomRight:SetTexCoord (120/128, 1, 24/128, 32/128)
+ end
+ end
+
+ if (button.MyObject.OnMouseUpHook) then
+ local interrupt = button.MyObject.OnMouseUpHook (button, buttontype, button.MyObject)
+ if (interrupt) then
+ return
+ end
+ end
+
+ button.MyObject.is_mouse_down = false
+
+ if (button.texture) then
+ if (button.texture.coords) then
+ if (button.MyObject.is_mouse_over) then
+ button.texture:SetTexCoord (_unpack (button.texture.coords.Highlight))
+ else
+ button.texture:SetTexCoord (_unpack (coords.Normal))
+ end
+ else
+ if (button.MyObject.is_mouse_over) then
+ button.texture:SetTexCoord (0, 1, 0.24609375, 0.49609375)
+ else
+ button.texture:SetTexCoord (0, 1, 0, 0.24609375)
+ end
+ end
+ end
+
+ if (button.MyObject.capsule_textalign) then
+ if (button.MyObject.icon) then
+ button.MyObject.icon:SetPoint ("left", button, "left", 4 + (button.MyObject.icon.leftpadding or 0), 0)
+ elseif (button.MyObject.capsule_textalign == "left") then
+ button.text:SetPoint ("left", button, "left", 2, 0)
+ elseif (button.MyObject.capsule_textalign == "center") then
+ button.text:SetPoint ("center", button, "center", 0, 0)
+ elseif (button.MyObject.capsule_textalign == "right") then
+ button.text:SetPoint ("right", button, "right", -2, 0)
+ end
+ else
+ if (button.MyObject.icon) then
+ button.MyObject.icon:SetPoint ("left", button, "left", 4 + (button.MyObject.icon.leftpadding or 0), 0)
+ else
+ button.text:SetPoint ("center", button,"center", 0, 0)
+ end
+ end
+
+ if (button.MyObject.container.isMoving) then
+ button.MyObject.container:StopMovingOrSizing()
+ button.MyObject.container.isMoving = false
+ end
+
+ local x, y = GetCursorPosition()
+ x = _math_floor (x)
+ y = _math_floor (y)
+ if ((button.mouse_down+0.4 > GetTime() and (x == button.x and y == button.y)) or (x == button.x and y == button.y)) then
+ if (buttontype == "LeftButton") then
+ button.MyObject.func (button, buttontype, button.MyObject.param1, button.MyObject.param2)
+ else
+ button.MyObject.funcright (button, buttontype, button.MyObject.param1, button.MyObject.param2)
+ end
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+
+function DF:CreateButton (parent, func, w, h, text, param1, param2, texture, member, name, short_method)
+ return DF:NewButton (parent, parent, name, member, w, h, func, param1, param2, texture, text, short_method)
+end
+
+function DF:NewButton (parent, container, name, member, w, h, func, param1, param2, texture, text, short_method)
+
+ if (not name) then
+ name = "DetailsFrameworkButtonNumber" .. DF.ButtonCounter
+ DF.ButtonCounter = DF.ButtonCounter + 1
+
+ elseif (not parent) then
+ return nil
+ end
+ if (not container) then
+ container = parent
+ end
+
+ if (name:find ("$parent")) then
+ name = name:gsub ("$parent", parent:GetName())
+ end
+
+
+ local ButtonObject = {type = "button", dframework = true}
+
+ if (member) then
+ parent [member] = ButtonObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+ --> default members:
+ --> hooks
+ ButtonObject.OnEnterHook = nil
+ ButtonObject.OnLeaveHook = nil
+ ButtonObject.OnHideHook = nil
+ ButtonObject.OnShowHook = nil
+ ButtonObject.OnMouseDownHook = nil
+ ButtonObject.OnMouseUpHook = nil
+ --> misc
+ ButtonObject.is_locked = true
+ ButtonObject.container = container
+ ButtonObject.have_tooltip = nil
+ ButtonObject.options = {OnGrab = false}
+
+
+ ButtonObject.button = CreateFrame ("button", name, parent, "DetailsFrameworkButtonTemplate")
+ ButtonObject.widget = ButtonObject.button
+
+ ButtonObject.button:SetBackdrop ({bgFile = DF.folder .. "background", tileSize = 64, edgeFile = DF.folder .. "border_2", edgeSize = 10, insets = {left = 1, right = 1, top = 1, bottom = 1}})
+ ButtonObject.button:SetBackdropColor (0, 0, 0, 0.4)
+ ButtonObject.button:SetBackdropBorderColor (1, 1, 1, 1)
+
+ if (not APIButtonFunctions) then
+ APIButtonFunctions = true
+ local idx = getmetatable (ButtonObject.button).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not ButtonMetaFunctions [funcName]) then
+ ButtonMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G."..object.button:GetName()..":"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ ButtonObject.button:SetWidth (w or 100)
+ ButtonObject.button:SetHeight (h or 20)
+ ButtonObject.button.MyObject = ButtonObject
+
+ ButtonObject.text_overlay = _G [name .. "_Text"]
+ ButtonObject.disabled_overlay = _G [name .. "_TextureDisabled"]
+
+ ButtonObject.button:SetNormalTexture (texture)
+ ButtonObject.button:SetPushedTexture (texture)
+ ButtonObject.button:SetDisabledTexture (texture)
+ ButtonObject.button:SetHighlightTexture (texture, "ADD")
+
+ ButtonObject.button.text:SetText (text)
+ ButtonObject.button.text:SetPoint ("center", ButtonObject.button, "center")
+
+ local text_width = ButtonObject.button.text:GetStringWidth()
+ if (text_width > w-15 and ButtonObject.button.text:GetText() ~= "") then
+ if (not short_method) then
+ local new_width = text_width+15
+ ButtonObject.button:SetWidth (new_width)
+ elseif (short_method == 1) then
+ local loop = true
+ local textsize = 11
+ while (loop) do
+ if (text_width+15 < w or textsize < 8) then
+ loop = false
+ break
+ else
+ DF:SetFontSize (ButtonObject.button.text, textsize)
+ text_width = ButtonObject.button.text:GetStringWidth()
+ textsize = textsize - 1
+ end
+ end
+ end
+ end
+
+ ButtonObject.func = func or cleanfunction
+ ButtonObject.funcright = cleanfunction
+ ButtonObject.param1 = param1
+ ButtonObject.param2 = param2
+
+ ButtonObject.short_method = short_method
+
+ --> hooks
+ ButtonObject.button:SetScript ("OnEnter", OnEnter)
+ ButtonObject.button:SetScript ("OnLeave", OnLeave)
+ ButtonObject.button:SetScript ("OnHide", OnHide)
+ ButtonObject.button:SetScript ("OnShow", OnShow)
+ ButtonObject.button:SetScript ("OnMouseDown", OnMouseDown)
+ ButtonObject.button:SetScript ("OnMouseUp", OnMouseUp)
+
+ _setmetatable (ButtonObject, ButtonMetaFunctions)
+
+ return ButtonObject
+
+end
+
+local pickcolor_callback = function (self, r, g, b, a, button)
+ button.MyObject.color_texture:SetVertexColor (r, g, b, a)
+ button.MyObject:color_callback (r, g, b, a)
+end
+local pickcolor = function (alpha, param2, self)
+ local r, g, b, a = self.MyObject.color_texture:GetVertexColor()
+ DF:ColorPick (self, r, g, b, a, pickcolor_callback)
+end
+
+local color_button_height = 16
+local color_button_width = 16
+
+local set_colorpick_color = function (button, r, g, b, a)
+ button.color_texture:SetVertexColor (r, g, b, a)
+end
+
+local colorpick_cancel = function (self)
+ ColorPickerFrame:Hide()
+end
+
+function DF:CreateColorPickButton (parent, name, member, callback, alpha)
+ return DF:NewColorPickButton (parent, name, member, callback, alpha)
+end
+
+function DF:NewColorPickButton (parent, name, member, callback, alpha)
+
+ --button
+ local button = DF:NewButton (parent, _, name, member, color_button_width, color_button_height, pickcolor, alpha, "param2")
+ button:InstallCustomTexture()
+ button.color_callback = callback
+ button.Cancel = colorpick_cancel
+ button.SetColor = set_colorpick_color
+
+ button:SetBackdrop ({edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 6,
+ bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], insets = {left = 0, right = 0, top = 0, bottom = 0}})
+
+ --textura do fundo
+ local background = DF:NewImage (button, nil, color_button_width, color_button_height, nil, nil, nil, "$parentBck")
+ --background:SetTexture ([[Interface\AddOns\Details\images\icons]])
+ background:SetPoint ("topleft", button.widget, "topleft", 1, -2)
+ background:SetPoint ("bottomright", button.widget, "bottomright", -1, 1)
+ background:SetTexCoord (0.337890625, 0.390625, 0.625, 0.658203125)
+ background:SetDrawLayer ("background", 1)
+
+ --textura da cor
+ local img = DF:NewImage (button, nil, color_button_width, color_button_height, nil, nil, "color_texture", "$parentTex")
+ img:SetTexture (1, 1, 1)
+ img:SetPoint ("topleft", button.widget, "topleft", 1, -2)
+ img:SetPoint ("bottomright", button.widget, "bottomright", -1, 1)
+ img:SetDrawLayer ("background", 2)
+
+ return button
+
+end
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/button.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/button.xml Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,40 @@
+
+
+
+
+
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/colors.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/colors.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,150 @@
+do
+
+ local DF = _G ["DetailsFramework"]
+
+ DF.alias_text_colors = {
+ ["aliceblue"] = {0.941176, 0.972549, 1, 1},
+ ["antiquewhite"] = {0.980392, 0.921569, 0.843137, 1},
+ ["aqua"] = {0, 1, 1, 1},
+ ["aquamarine"] = {0.498039, 1, 0.831373, 1},
+ ["azure"] = {0.941176, 1, 1, 1},
+ ["beige"] = {0.960784, 0.960784, 0.862745, 1},
+ ["bisque"] = {1, 0.894118, 0.768627, 1},
+ ["black"] = {0, 0, 0, 1},
+ ["blanchedalmond"] = {1, 0.921569, 0.803922, 1},
+ ["blue"] = {0, 0, 1, 1},
+ ["blueviolet"] = {0.541176, 0.168627, 0.886275, 1},
+ ["brown"] = {0.647059, 0.164706, 0.164706, 1},
+ ["burlywood"] = {0.870588, 0.721569, 0.529412, 1},
+ ["cadetblue"] = {0.372549, 0.619608, 0.627451, 1},
+ ["chartreuse"] = {0.498039, 1, 0, 1},
+ ["chocolate"] = {0.823529, 0.411765, 0.117647, 1},
+ ["coral"] = {1, 0.498039, 0.313725, 1},
+ ["cornflowerblue"] = {0.392157, 0.584314, 0.929412, 1},
+ ["cornsilk"] = {1, 0.972549, 0.862745, 1},
+ ["crimson"] = {0.862745, 0.0784314, 0.235294, 1},
+ ["cyan"] = {0, 1, 1, 1},
+ ["darkblue"] = {0, 0, 0.545098, 1},
+ ["darkcyan"] = {0, 0.545098, 0.545098, 1},
+ ["darkgoldenrod"] = {0.721569, 0.52549, 0.0431373, 1},
+ ["darkgray"] = {0.662745, 0.662745, 0.662745, 1},
+ ["darkgreen"] = {0, 0.392157, 0, 1},
+ ["darkkhaki"] = {0.741176, 0.717647, 0.419608, 1},
+ ["darkmagenta"] = {0.545098, 0, 0.545098, 1},
+ ["darkolivegreen"] = {0.333333, 0.419608, 0.184314, 1},
+ ["darkorange"] = {1, 0.54902, 0, 1},
+ ["darkorchid"] = {0.6, 0.196078, 0.8, 1},
+ ["darkred"] = {0.545098, 0, 0, 1},
+ ["darksalmon"] = {0.913725, 0.588235, 0.478431, 1},
+ ["darkseagreen"] = {0.560784, 0.737255, 0.560784, 1},
+ ["darkslateblue"] = {0.282353, 0.239216, 0.545098, 1},
+ ["darkslategray"] = {0.184314, 0.309804, 0.309804, 1},
+ ["darkturquoise"] = {0, 0.807843, 0.819608, 1},
+ ["darkviolet"] = {0.580392, 0, 0.827451, 1},
+ ["deeppink"] = {1, 0.0784314, 0.576471, 1},
+ ["deepskyblue"] = {0, 0.74902, 1, 1},
+ ["dimgray"] = {0.411765, 0.411765, 0.411765, 1},
+ ["dimgrey"] = {0.411765, 0.411765, 0.411765, 1},
+ ["dodgerblue"] = {0.117647, 0.564706, 1, 1},
+ ["firebrick"] = {0.698039, 0.133333, 0.133333, 1},
+ ["floralwhite"] = {1, 0.980392, 0.941176, 1},
+ ["forestgreen"] = {0.133333, 0.545098, 0.133333, 1},
+ ["fuchsia"] = {1, 0, 1, 1},
+ ["gainsboro"] = {0.862745, 0.862745, 0.862745, 1},
+ ["ghostwhite"] = {0.972549, 0.972549, 1, 1},
+ ["gold"] = {1, 0.843137, 0, 1},
+ ["goldenrod"] = {0.854902, 0.647059, 0.12549, 1},
+ ["gray"] = {0.501961, 0.501961, 0.501961, 1},
+ ["green"] = {0, 0.501961, 0, 1},
+ ["greenyellow"] = {0.678431, 1, 0.184314, 1},
+ ["honeydew"] = {0.941176, 1, 0.941176, 1},
+ ["hotpink"] = {1, 0.411765, 0.705882, 1},
+ ["indianred"] = {0.803922, 0.360784, 0.360784, 1},
+ ["indigo"] = {0.294118, 0, 0.509804, 1},
+ ["ivory"] = {1, 1, 0.941176, 1},
+ ["khaki"] = {0.941176, 0.901961, 0.54902, 1},
+ ["lavender"] = {0.901961, 0.901961, 0.980392, 1},
+ ["lavenderblush"] = {1, 0.941176, 0.960784, 1},
+ ["lawngreen"] = {0.486275, 0.988235, 0, 1},
+ ["lemonchiffon"] = {1, 0.980392, 0.803922, 1},
+ ["lightblue"] = {0.678431, 0.847059, 0.901961, 1},
+ ["lightcoral"] = {0.941176, 0.501961, 0.501961, 1},
+ ["lightcyan"] = {0.878431, 1, 1, 1},
+ ["lightgoldenrodyellow"] = {0.980392, 0.980392, 0.823529, 1},
+ ["lightgray"] = {0.827451, 0.827451, 0.827451, 1},
+ ["lightgreen"] = {0.564706, 0.933333, 0.564706, 1},
+ ["lightpink"] = {1, 0.713725, 0.756863, 1},
+ ["lightsalmon"] = {1, 0.627451, 0.478431, 1},
+ ["lightseagreen"] = {0.12549, 0.698039, 0.666667, 1},
+ ["lightskyblue"] = {0.529412, 0.807843, 0.980392, 1},
+ ["lightslategray"] = {0.466667, 0.533333, 0.6, 1},
+ ["lightsteelblue"] = {0.690196, 0.768627, 0.870588, 1},
+ ["lightyellow"] = {1, 1, 0.878431, 1},
+ ["lime"] = {0, 1, 0, 1},
+ ["limegreen"] = {0.196078, 0.803922, 0.196078, 1},
+ ["linen"] = {0.980392, 0.941176, 0.901961, 1},
+ ["magenta"] = {1, 0, 1, 1},
+ ["maroon"] = {0.501961, 0, 0, 1},
+ ["mediumaquamarine"] = {0.4, 0.803922, 0.666667, 1},
+ ["mediumblue"] = {0, 0, 0.803922, 1},
+ ["mediumorchid"] = {0.729412, 0.333333, 0.827451, 1},
+ ["mediumpurple"] = {0.576471, 0.439216, 0.858824, 1},
+ ["mediumseagreen"] = {0.235294, 0.701961, 0.443137, 1},
+ ["mediumslateblue"] = {0.482353, 0.407843, 0.933333, 1},
+ ["mediumspringgreen"] = {0, 0.980392, 0.603922, 1},
+ ["mediumturquoise"] = {0.282353, 0.819608, 0.8, 1},
+ ["mediumvioletred"] = {0.780392, 0.0823529, 0.521569, 1},
+ ["midnightblue"] = {0.0980392, 0.0980392, 0.439216, 1},
+ ["mintcream"] = {0.960784, 1, 0.980392, 1},
+ ["mistyrose"] = {1, 0.894118, 0.882353, 1},
+ ["moccasin"] = {1, 0.894118, 0.709804, 1},
+ ["navajowhite"] = {1, 0.870588, 0.678431, 1},
+ ["navy"] = {0, 0, 0.501961, 1},
+ ["none"] ={0, 0, 0, 0},
+ ["oldlace"] = {0.992157, 0.960784, 0.901961, 1},
+ ["olive"] = {0.501961, 0.501961, 0, 1},
+ ["olivedrab"] = {0.419608, 0.556863, 0.137255, 1},
+ ["orange"] = {1, 0.647059, 0, 1},
+ ["orangered"] = {1, 0.270588, 0, 1},
+ ["orchid"] = {0.854902, 0.439216, 0.839216, 1},
+ ["palegoldenrod"] = {0.933333, 0.909804, 0.666667, 1},
+ ["palegreen"] = {0.596078, 0.984314, 0.596078, 1},
+ ["paleturquoise"] = {0.686275, 0.933333, 0.933333, 1},
+ ["palevioletred"] = {0.858824, 0.439216, 0.576471, 1},
+ ["papayawhip"] = {1, 0.937255, 0.835294, 1},
+ ["peachpuff"] = {1, 0.854902, 0.72549, 1},
+ ["peru"] = {0.803922, 0.521569, 0.247059, 1},
+ ["pink"] = {1, 0.752941, 0.796078, 1},
+ ["plum"] = {0.866667, 0.627451, 0.866667, 1},
+ ["powderblue"] = {0.690196, 0.878431, 0.901961, 1},
+ ["purple"] = {0.501961, 0, 0.501961, 1},
+ ["red"] = {1, 0, 0, 1},
+ ["rosybrown"] = {0.737255, 0.560784, 0.560784, 1},
+ ["royalblue"] = {0.254902, 0.411765, 0.882353, 1},
+ ["saddlebrown"] = {0.545098, 0.270588, 0.0745098, 1},
+ ["salmon"] = {0.980392, 0.501961, 0.447059, 1},
+ ["sandybrown"] = {0.956863, 0.643137, 0.376471, 1},
+ ["seagreen"] = {0.180392, 0.545098, 0.341176, 1},
+ ["seashell"] = {1, 0.960784, 0.933333, 1},
+ ["sienna"] = {0.627451, 0.321569, 0.176471, 1},
+ ["silver"] = {0.752941, 0.752941, 0.752941, 1},
+ ["skyblue"] = {0.529412, 0.807843, 0.921569, 1},
+ ["slateblue"] = {0.415686, 0.352941, 0.803922, 1},
+ ["slategray"] = {0.439216, 0.501961, 0.564706, 1},
+ ["snow"] = {1, 0.980392, 0.980392, 1},
+ ["springgreen"] = {0, 1, 0.498039, 1},
+ ["steelblue"] = {0.27451, 0.509804, 0.705882, 1},
+ ["tan"] = {0.823529, 0.705882, 0.54902, 1},
+ ["teal"] = {0, 0.501961, 0.501961, 1},
+ ["thistle"] = {0.847059, 0.74902, 0.847059, 1},
+ ["tomato"] = {1, 0.388235, 0.278431, 1},
+ ["transparent"] ={0, 0, 0, 0},
+ ["turquoise"] = {0.25098, 0.878431, 0.815686, 1},
+ ["violet"] = {0.933333, 0.509804, 0.933333, 1},
+ ["wheat"] = {0.960784, 0.870588, 0.701961, 1},
+ ["white"] = {1, 1, 1, 1},
+ ["whitesmoke"] = {0.960784, 0.960784, 0.960784, 1},
+ ["yellow"] = {1, 1, 0, 1},
+ ["yellowgreen"] = {0.603922, 0.803922, 0.196078, 1}
+ }
+end
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/cooltip.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/cooltip.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,3008 @@
+
+local DF = _G ["DetailsFramework"]
+local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
+
+local _
+--lua locals
+local _math_floor= math.floor
+local _type = type
+local _math_abs = math.abs
+local _tinsert = tinsert
+local _unpack = unpack
+local _ipairs = ipairs
+local _table_wipe = table.wipe
+local _table_insert = table.insert
+local _math_max = math.max
+--api locals
+local _GetScreenWidth = GetScreenWidth
+local _GetScreenHeight = GetScreenHeight
+local _UIParent = UIParent
+local _CreateFrame = CreateFrame
+
+local version = 1
+
+function DF:CreateCoolTip()
+
+----------------------------------------------------------------------
+ --> Cooltip Startup
+----------------------------------------------------------------------
+
+ if (_G.GameCooltip2 and _G.GameCooltip2.version >= version) then
+ return
+ end
+
+ --> Start Cooltip Table
+ local CoolTip = {version = version}
+ _G.GameCooltip2 = CoolTip
+
+ --> Containers
+ CoolTip.LeftTextTable = {}
+ CoolTip.LeftTextTableSub = {}
+ CoolTip.RightTextTable = {}
+ CoolTip.RightTextTableSub = {}
+ CoolTip.LeftIconTable = {}
+ CoolTip.LeftIconTableSub = {}
+ CoolTip.RightIconTable = {}
+ CoolTip.RightIconTableSub = {}
+ CoolTip.Banner = {false, false, false}
+ CoolTip.TopIconTableSub = {}
+ CoolTip.StatusBarTable = {}
+ CoolTip.StatusBarTableSub = {}
+ CoolTip.WallpaperTable = {}
+ CoolTip.WallpaperTableSub = {}
+
+ CoolTip.FunctionsTableMain = {} --> menus
+ CoolTip.FunctionsTableSub = {} --> menus
+ CoolTip.ParametersTableMain = {} --> menus
+ CoolTip.ParametersTableSub = {} --> menus
+
+ CoolTip.FixedValue = nil --> menus
+ CoolTip.SelectedIndexMain = nil --> menus
+ CoolTip.SelectedIndexSec = {} --> menus
+
+ --options table
+ CoolTip.OptionsList = {
+ ["IconSize"] = true,
+ ["HeightAnchorMod"] = true,
+ ["WidthAnchorMod"] = true,
+ ["MinWidth"] = true,
+ ["FixedWidth"] = true,
+ ["FixedHeight"] = true,
+ ["FixedWidthSub"] = true,
+ ["FixedHeightSub"] = true,
+ ["AlignAsBlizzTooltip"] = true,
+ ["IgnoreSubMenu"] = true,
+ ["IgnoreButtonAutoHeight"] = true,
+ ["TextHeightMod"] = true,
+ ["ButtonHeightMod"] = true,
+ ["ButtonHeightModSub"] = true,
+ ["YSpacingMod"] = true,
+ ["YSpacingModSub"] = true,
+ ["ButtonsYMod"] = true,
+ ["ButtonsYModSub"] = true,
+ ["IconHeightMod"] = true,
+ ["StatusBarHeightMod"] = true,
+ ["StatusBarTexture"] = true,
+ ["TextSize"] = true,
+ ["TextFont"] = true,
+ ["TextColor"] = true,
+ ["TextColorRight"] = true,
+ ["TextShadow"] = true,
+ ["LeftTextWidth"] = true,
+ ["RightTextWidth"] = true,
+ ["LeftTextHeight"] = true,
+ ["RightTextHeight"] = true,
+ ["NoFade"] = true,
+ ["MyAnchor"] = true,
+ ["Anchor"] = true,
+ ["RelativeAnchor"] = true,
+ ["NoLastSelectedBar"] = true,
+ ["SubMenuIsTooltip"] = true,
+ ["LeftBorderSize"] = true,
+ ["RightBorderSize"] = true,
+ ["HeighMod"] = true,
+ ["HeighModSub"] = true,
+ ["IconBlendMode"] = true,
+ ["IconBlendModeHover"] = true,
+ ["SubFollowButton"] = true,
+ ["IgnoreArrows"] = true,
+ ["SelectedTopAnchorMod"] = true,
+ ["SelectedBottomAnchorMod"] = true,
+ ["SelectedLeftAnchorMod"] = true,
+ ["SelectedRightAnchorMod"] = true,
+ }
+
+ CoolTip.OptionsTable = {}
+
+ --cprops
+ CoolTip.Indexes = 0 --> amount of lines current on shown
+ CoolTip.IndexesSub = {} --> amount of lines current on shown
+ CoolTip.HaveSubMenu = false --> amount of lines current on shown
+ CoolTip.SubIndexes = 0 --> amount of lines current on shown on sub menu
+ CoolTip.Type = 1 --> 1 tooltip 2 tooltip with bars 3 menu 4 menu + submenus
+ CoolTip.Host = nil --> frame to anchor
+ CoolTip.LastSize = 0 --> last size
+
+ CoolTip.LastIndex = 0
+
+ CoolTip.internal_x_mod = 0
+ CoolTip.internal_y_mod = 0
+ CoolTip.overlap_checked = false
+
+ --defaults
+ CoolTip.default_height = 20
+ CoolTip.default_text_size = 10.5
+ CoolTip.default_text_font = "GameFontHighlight"
+
+ CoolTip.selected_anchor = {}
+ CoolTip.selected_anchor.left = 2
+ CoolTip.selected_anchor.right = 0
+ CoolTip.selected_anchor.top = 0
+ CoolTip.selected_anchor.bottom = 0
+
+ CoolTip._default_font = SharedMedia:Fetch ("font", "Friz Quadrata TT")
+
+ --> Create Frames
+
+ --> main frame
+ local frame1
+ if (not GameCooltipFrame1) then
+ frame1 = CreateFrame ("Frame", "GameCooltipFrame1", UIParent, "DFCooltipMainFrameTemplate")
+ tinsert (UISpecialFrames, "GameCooltipFrame1")
+ DF:CreateFlashAnimation (frame1)
+ else
+ frame1 = GameCooltipFrame1
+ end
+
+ GameCooltipFrame1_FrameBackgroundCenter:SetTexture (DF.folder .. "cooltip_background")
+ GameCooltipFrame1_FrameBackgroundCenter:SetTexCoord (0.10546875, 0.89453125, 0, 1)
+ GameCooltipFrame1_FrameBackgroundLeft:SetTexture (DF.folder .. "cooltip_background")
+ GameCooltipFrame1_FrameBackgroundLeft:SetTexCoord (0, 0.103515625, 0, 1)
+ GameCooltipFrame1_FrameBackgroundRight:SetTexture (DF.folder .. "cooltip_background")
+ GameCooltipFrame1_FrameBackgroundRight:SetTexCoord (0.896484375, 1, 0, 1)
+
+ --> secondary frame
+ local frame2
+ if (not GameCooltipFrame2) then
+ frame2 = CreateFrame ("Frame", "GameCooltipFrame2", UIParent, "DFCooltipMainFrameTemplate")
+ tinsert (UISpecialFrames, "GameCooltipFrame2")
+ DF:CreateFlashAnimation (frame2)
+ frame2:SetClampedToScreen (true)
+ else
+ frame2 = GameCooltipFrame2
+ end
+
+ frame2:SetPoint ("bottomleft", frame1, "bottomright")
+
+ GameCooltipFrame2_FrameBackgroundCenter:SetTexture (DF.folder .. "cooltip_background")
+ GameCooltipFrame2_FrameBackgroundCenter:SetTexCoord (0.10546875, 0.89453125, 0, 1)
+ GameCooltipFrame2_FrameBackgroundLeft:SetTexture (DF.folder .. "cooltip_background")
+ GameCooltipFrame2_FrameBackgroundLeft:SetTexCoord (0, 0.103515625, 0, 1)
+ GameCooltipFrame2_FrameBackgroundRight:SetTexture (DF.folder .. "cooltip_background")
+ GameCooltipFrame2_FrameBackgroundRight:SetTexCoord (0.896484375, 1, 0, 1)
+
+ CoolTip.frame1 = frame1
+ CoolTip.frame2 = frame2
+ DF:Fade (frame1, 0)
+ DF:Fade (frame2, 0)
+
+ --> button containers
+ frame1.Lines = {}
+ frame2.Lines = {}
+
+----------------------------------------------------------------------
+ --> Title Function
+----------------------------------------------------------------------
+
+ function CoolTip:SetTitle (_f, text)
+ if (_f == 1) then
+ CoolTip.title1 = true
+ CoolTip.title_text = text
+ end
+ end
+
+ function CoolTip:SetTitleAnchor (_f, _anchor, ...)
+ _anchor = string.lower (_anchor)
+ if (_f == 1) then
+ self.frame1.titleIcon:ClearAllPoints()
+ self.frame1.titleText:ClearAllPoints()
+
+ if (_anchor == "left") then
+ self.frame1.titleIcon:SetPoint ("left", frame1, "left", ...)
+ self.frame1.titleText:SetPoint ("left", frame1.titleIcon, "right")
+
+ elseif (_anchor == "center") then
+ self.frame1.titleIcon:SetPoint ("center", frame1, "center")
+ self.frame1.titleIcon:SetPoint ("bottom", frame1, "top")
+ self.frame1.titleText:SetPoint ("left", frame1.titleIcon, "right")
+ self.frame1.titleText:SetText ("TESTE")
+
+ self.frame1.titleText:Show()
+ self.frame1.titleIcon:Show()
+
+ elseif (_anchor == "right") then
+ self.frame1.titleIcon:SetPoint ("right", frame1, "right", ...)
+ self.frame1.titleText:SetPoint ("right", frame1.titleIcon, "left")
+
+ end
+ elseif (_f == 2) then
+ self.frame2.titleIcon:ClearAllPoints()
+ self.frame2.titleText:ClearAllPoints()
+ if (_anchor == "left") then
+ self.frame2.titleIcon:SetPoint ("left", frame2, "left", ...)
+ self.frame2.titleText:SetPoint ("left", frame2.titleIcon, "right")
+ elseif (_anchor == "center") then
+ self.frame2.titleIcon:SetPoint ("center", frame2, "center", ...)
+ self.frame2.titleText:SetPoint ("left", frame2.titleIcon, "right")
+ elseif (_anchor == "right") then
+ self.frame2.titleIcon:SetPoint ("right", frame2, "right", ...)
+ self.frame2.titleText:SetPoint ("right", frame2.titleIcon, "left")
+ end
+ end
+ end
+
+----------------------------------------------------------------------
+ --> Button Hide and Show Functions
+----------------------------------------------------------------------
+
+ local elapsedTime = 0
+
+ CoolTip.mouseOver = false
+ CoolTip.buttonClicked = false
+
+ frame1:SetScript ("OnEnter", function (self)
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then --> menu
+ CoolTip.active = true
+ CoolTip.mouseOver = true
+ self:SetScript ("OnUpdate", nil)
+ DF:Fade (self, 0)
+ --rever
+ if (CoolTip.sub_menus) then
+ DF:Fade (frame2, 0)
+ end
+ end
+ end)
+
+ frame2:SetScript ("OnEnter", function (self)
+ if (CoolTip.OptionsTable.SubMenuIsTooltip) then
+ return CoolTip:Close()
+ end
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
+ CoolTip.active = true
+ CoolTip.mouseOver = true
+ self:SetScript ("OnUpdate", nil)
+ DF:Fade (self, 0)
+ DF:Fade (frame1, 0)
+ end
+ end)
+
+ local OnLeaveUpdateFrame1 = function (self, elapsed)
+ elapsedTime = elapsedTime+elapsed
+ if (elapsedTime > 0.7) then
+ if (not CoolTip.active and not CoolTip.buttonClicked and self == CoolTip.Host) then
+ DF:Fade (self, 1)
+ DF:Fade (frame2, 1)
+ elseif (not CoolTip.active) then
+ DF:Fade (self, 1)
+ DF:Fade (frame2, 1)
+ end
+ self:SetScript ("OnUpdate", nil)
+ frame2:SetScript ("OnUpdate", nil)
+ end
+ end
+
+ frame1:SetScript ("OnLeave", function (self)
+
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
+ CoolTip.active = false
+ CoolTip.mouseOver = false
+ elapsedTime = 0
+ self:SetScript ("OnUpdate", OnLeaveUpdateFrame1)
+ else
+ CoolTip.active = false
+ CoolTip.mouseOver = false
+ elapsedTime = 0
+ self:SetScript ("OnUpdate", OnLeaveUpdateFrame1)
+ end
+ end)
+
+ local OnLeaveUpdateFrame2 = function (self, elapsed)
+ elapsedTime = elapsedTime+elapsed
+ if (elapsedTime > 0.7) then
+ if (not CoolTip.active and not CoolTip.buttonClicked and self == CoolTip.Host) then
+ DF:Fade (self, 1)
+ DF:Fade (frame2, 1)
+ elseif (not CoolTip.active) then
+ DF:Fade (self, 1)
+ DF:Fade (frame2, 1)
+ end
+ self:SetScript ("OnUpdate", nil)
+ frame1:SetScript ("OnUpdate", nil)
+ end
+ end
+
+ frame2:SetScript ("OnLeave", function (self)
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
+ CoolTip.active = false
+ CoolTip.mouseOver = false
+ elapsedTime = 0
+ self:SetScript ("OnUpdate", OnLeaveUpdateFrame2)
+ else
+ CoolTip.active = false
+ CoolTip.mouseOver = false
+ elapsedTime = 0
+ self:SetScript ("OnUpdate", OnLeaveUpdateFrame2)
+
+ end
+ end)
+
+ frame1:SetScript ("OnHide", function (self)
+ CoolTip.active = false
+ CoolTip.buttonClicked = false
+ CoolTip.mouseOver = false
+ end)
+
+
+----------------------------------------------------------------------
+ --> Button Creation Functions
+----------------------------------------------------------------------
+
+ function GameCooltipButtonMouseDown (button)
+ local mod = CoolTip.OptionsTable.TextHeightMod or 0
+ button.leftText:SetPoint ("center", button.leftIcon, "center", 0, 0+mod)
+ button.leftText:SetPoint ("left", button.leftIcon, "right", 4, -1+mod)
+ end
+
+ function GameCooltipButtonMouseUp (button)
+ local mod = CoolTip.OptionsTable.TextHeightMod or 0
+ button.leftText:SetPoint ("center", button.leftIcon, "center", 0, 0+mod)
+ button.leftText:SetPoint ("left", button.leftIcon, "right", 3, 0+mod)
+ end
+
+ function CoolTip:CreateButton (index, frame, name)
+ local new_button = CreateFrame ("Button", name, frame, "DFCooltipButtonTemplate")
+ frame.Lines [index] = new_button
+ return new_button
+ end
+
+ local OnEnterUpdateButton = function (self, elapsed)
+ elapsedTime = elapsedTime+elapsed
+ if (elapsedTime > 0.001) then
+ --> search key: ~onenterupdatemain
+ CoolTip:ShowSub (self.index)
+ CoolTip.last_button = self.index
+ self:SetScript ("OnUpdate", nil)
+ end
+ end
+
+ local OnLeaveUpdateButton = function (self, elapsed)
+ elapsedTime = elapsedTime+elapsed
+ if (elapsedTime > 0.7) then
+ if (not CoolTip.active and not CoolTip.buttonClicked) then
+ DF:Fade (frame1, 1)
+ DF:Fade (frame2, 1)
+
+ elseif (not CoolTip.active) then
+ DF:Fade (frame1, 1)
+ DF:Fade (frame2, 1)
+ end
+ frame1:SetScript ("OnUpdate", nil)
+ end
+ end
+
+ function CoolTip:NewMainButton (i)
+ local botao = CoolTip:CreateButton (i, frame1, "GameCooltipMainButton"..i)
+
+ --> serach key: ~onenter
+ botao:SetScript ("OnEnter", function()
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then
+ CoolTip.active = true
+ CoolTip.mouseOver = true
+
+ frame1:SetScript ("OnUpdate", nil)
+ frame2:SetScript ("OnUpdate", nil)
+
+ botao.background:Show()
+
+ if (CoolTip.OptionsTable.IconBlendModeHover) then
+ botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover)
+ else
+ botao.leftIcon:SetBlendMode ("BLEND")
+ end
+
+ if (CoolTip.IndexesSub [botao.index] and CoolTip.IndexesSub [botao.index] > 0) then
+ if (CoolTip.OptionsTable.SubMenuIsTooltip) then
+ CoolTip:ShowSub (botao.index)
+ botao.index = i
+ else
+ if (CoolTip.last_button) then
+ CoolTip:ShowSub (CoolTip.last_button)
+ else
+ CoolTip:ShowSub (botao.index)
+ end
+ elapsedTime = 0
+ botao.index = i
+ botao:SetScript ("OnUpdate", OnEnterUpdateButton)
+ end
+
+ else
+ --hide second frame
+ DF:Fade (frame2, 1)
+ CoolTip.last_button = nil
+ end
+ else
+ CoolTip.mouseOver = true
+ end
+ end)
+
+ botao:SetScript ("OnLeave", function()
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then
+ CoolTip.active = false
+ CoolTip.mouseOver = false
+ botao:SetScript ("OnUpdate", nil)
+
+ botao.background:Hide()
+
+ if (CoolTip.OptionsTable.IconBlendMode) then
+ botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
+ botao.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
+ else
+ botao.leftIcon:SetBlendMode ("BLEND")
+ botao.rightIcon:SetBlendMode ("BLEND")
+ end
+
+ elapsedTime = 0
+ frame1:SetScript ("OnUpdate", OnLeaveUpdateButton)
+ --CoolTip:HideSub (i)
+ else
+ CoolTip.active = false
+ elapsedTime = 0
+ frame1:SetScript ("OnUpdate", OnLeaveUpdateButton)
+ CoolTip.mouseOver = false
+ end
+ end)
+
+ return botao
+ end
+
+ local OnLeaveUpdateButtonSec = function (self, elapsed)
+ elapsedTime = elapsedTime+elapsed
+ if (elapsedTime > 0.7) then
+ if (not CoolTip.active and not CoolTip.buttonClicked) then
+ DF:Fade (frame1, 1)
+ DF:Fade (frame2, 1)
+ elseif (not CoolTip.active) then
+ DF:Fade (frame1, 1)
+ DF:Fade (frame2, 1)
+ end
+ frame2:SetScript ("OnUpdate", nil)
+ end
+ end
+
+ function CoolTip:NewSecondaryButton (i)
+ local botao = CoolTip:CreateButton (i, frame2, "GameCooltipSecButton"..i)
+
+ botao:SetScript ("OnEnter", function()
+ if (CoolTip.OptionsTable.SubMenuIsTooltip) then
+ return CoolTip:Close()
+ end
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then
+ CoolTip.active = true
+ CoolTip.mouseOver = true
+
+ botao.background:Show()
+
+ if (CoolTip.OptionsTable.IconBlendModeHover) then
+ botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover)
+ else
+ botao.leftIcon:SetBlendMode ("BLEND")
+ end
+
+ frame1:SetScript ("OnUpdate", nil)
+ frame2:SetScript ("OnUpdate", nil)
+
+ DF:Fade (frame1, 0)
+ DF:Fade (frame2, 0)
+ else
+ CoolTip.mouseOver = true
+ end
+ end)
+
+ botao:SetScript ("OnLeave", function()
+ if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
+ CoolTip.active = false
+ CoolTip.mouseOver = false
+
+ botao.background:Hide()
+
+ if (CoolTip.OptionsTable.IconBlendMode) then
+ botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
+ botao.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
+ else
+ botao.leftIcon:SetBlendMode ("BLEND")
+ botao.rightIcon:SetBlendMode ("BLEND")
+ end
+
+ elapsedTime = 0
+ frame2:SetScript ("OnUpdate", OnLeaveUpdateButtonSec)
+ else
+ CoolTip.active = false
+ CoolTip.mouseOver = false
+ elapsedTime = 0
+ frame2:SetScript ("OnUpdate", OnLeaveUpdateButtonSec)
+ end
+ end)
+
+ return botao
+ end
+
+----------------------------------------------------------------------
+ --> Button Click Functions
+----------------------------------------------------------------------
+
+ CoolTip.selected_anchor.left = 4
+ CoolTip.selected_anchor.right = -4
+ CoolTip.selected_anchor.top = 0
+ CoolTip.selected_anchor.bottom = 0
+
+ function CoolTip:HideSelectedTexture (frame)
+ frame.selectedTop:Hide()
+ frame.selectedBottom:Hide()
+ frame.selectedMiddle:Hide()
+ end
+
+ function CoolTip:ShowSelectedTexture (frame)
+ frame.selectedTop:Show()
+ frame.selectedBottom:Show()
+ frame.selectedMiddle:Show()
+ end
+
+ function CoolTip:SetSelectedAnchor (frame, button)
+
+ local left = CoolTip.selected_anchor.left + (CoolTip.OptionsTable.SelectedLeftAnchorMod or 0)
+ local right = CoolTip.selected_anchor.right + (CoolTip.OptionsTable.SelectedRightAnchorMod or 0)
+
+ local top = CoolTip.selected_anchor.top + (CoolTip.OptionsTable.SelectedTopAnchorMod or 0)
+ local bottom = CoolTip.selected_anchor.bottom + (CoolTip.OptionsTable.SelectedBottomAnchorMod or 0)
+
+ frame.selectedTop:ClearAllPoints()
+ frame.selectedBottom:ClearAllPoints()
+
+ frame.selectedTop:SetPoint ("topleft", button, "topleft", left, top) --
+ frame.selectedTop:SetPoint ("topright", button, "topright", right, top) --
+
+ frame.selectedBottom:SetPoint ("bottomleft", button, "bottomleft", left, bottom) --
+ frame.selectedBottom:SetPoint ("bottomright", button, "bottomright", right, bottom) --
+
+ CoolTip:ShowSelectedTexture (frame)
+ end
+
+ local OnClickFunctionButtonPrincipal = function (self)
+ if (CoolTip.IndexesSub [self.index] and CoolTip.IndexesSub [self.index] > 0) then
+ CoolTip:ShowSub (self.index)
+ CoolTip.last_button = self.index
+ end
+
+ CoolTip.buttonClicked = true
+ CoolTip:SetSelectedAnchor (frame1, self)
+
+ if (not CoolTip.OptionsTable.NoLastSelectedBar) then
+ CoolTip:ShowSelectedTexture (frame1)
+
+ end
+ CoolTip.SelectedIndexMain = self.index
+
+ if (CoolTip.FunctionsTableMain [self.index]) then
+ local parameterTable = CoolTip.ParametersTableMain [self.index]
+ CoolTip.FunctionsTableMain [self.index] (_, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3])
+ end
+ end
+
+ local OnClickFunctionButtonSecundario = function (self)
+ CoolTip.buttonClicked = true
+
+ CoolTip:SetSelectedAnchor (frame2, self)
+
+ if (CoolTip.FunctionsTableSub [self.mainIndex] and CoolTip.FunctionsTableSub [self.mainIndex] [self.index]) then
+ local parameterTable = CoolTip.ParametersTableSub [self.mainIndex] [self.index]
+ CoolTip.FunctionsTableSub [self.mainIndex] [self.index] (_, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3])
+ end
+
+ local botao_p = frame1.Lines [self.mainIndex]
+ CoolTip:SetSelectedAnchor (frame1, botao_p)
+
+ if (not CoolTip.OptionsTable.NoLastSelectedBar) then
+ CoolTip:ShowSelectedTexture (frame1)
+ end
+
+ CoolTip.SelectedIndexMain = self.mainIndex
+ CoolTip.SelectedIndexSec [self.mainIndex] = self.index
+
+ end
+
+ function CoolTip:TextAndIcon (index, frame, menuButton, leftTextTable, rightTextTable, leftIconTable, rightIconTable, isSub)
+
+ --> reset width
+ menuButton.leftText:SetWidth (0)
+ menuButton.leftText:SetHeight (0)
+ menuButton.rightText:SetWidth (0)
+ menuButton.rightText:SetHeight (0)
+
+ --> set text
+ if (leftTextTable) then
+
+ menuButton.leftText:SetText (leftTextTable [1])
+
+ local r, g, b, a = leftTextTable [2], leftTextTable [3], leftTextTable [4], leftTextTable [5]
+
+ if (r == 0 and g == 0 and b == 0 and a == 0) then
+ if (CoolTip.OptionsTable.TextColor) then
+ r, g, b, a = DF:ParseColors (CoolTip.OptionsTable.TextColor)
+ menuButton.leftText:SetTextColor (r, g, b, a)
+ else
+ menuButton.leftText:SetTextColor (1, 1, 1, 1)
+ end
+ else
+ menuButton.leftText:SetTextColor (r, g, b, a)
+ end
+
+ if (CoolTip.OptionsTable.TextSize and not leftTextTable [6]) then
+ DF:SetFontSize (menuButton.leftText, CoolTip.OptionsTable.TextSize)
+ end
+
+ if (CoolTip.OptionsTable.LeftTextWidth) then
+ menuButton.leftText:SetWidth (CoolTip.OptionsTable.LeftTextWidth)
+ else
+ menuButton.leftText:SetWidth (0)
+ end
+
+ if (CoolTip.OptionsTable.LeftTextHeight) then
+ menuButton.leftText:SetHeight (CoolTip.OptionsTable.LeftTextHeight)
+ else
+ menuButton.leftText:SetHeight (0)
+ end
+
+ if (CoolTip.OptionsTable.TextFont and not leftTextTable [7]) then --font
+
+ if (_G [CoolTip.OptionsTable.TextFont]) then
+ menuButton.leftText:SetFontObject (GameFontRed or CoolTip.OptionsTable.TextFont)
+ else
+ local font = SharedMedia:Fetch ("font", CoolTip.OptionsTable.TextFont)
+ local _, size, flags = menuButton.leftText:GetFont()
+ flags = leftTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
+ size = leftTextTable [6] or CoolTip.OptionsTable.TextSize or size
+ menuButton.leftText:SetFont (font, size, flags)
+ end
+
+ elseif (leftTextTable [7]) then
+ if (_G [leftTextTable [7]]) then
+ menuButton.leftText:SetFontObject (leftTextTable [7])
+ local face, size, flags = menuButton.leftText:GetFont()
+ flags = leftTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
+ size = leftTextTable [6] or CoolTip.OptionsTable.TextSize or size
+ menuButton.leftText:SetFont (face, size, flags)
+ else
+ local font = SharedMedia:Fetch ("font", leftTextTable [7])
+ local face, size, flags = menuButton.leftText:GetFont()
+ flags = leftTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
+ size = leftTextTable [6] or CoolTip.OptionsTable.TextSize or size
+ menuButton.leftText:SetFont (face, size, flags)
+ end
+ else
+ menuButton.leftText:SetFont (CoolTip._default_font, leftTextTable [6] or CoolTip.OptionsTable.TextSize or 10, leftTextTable [8] or CoolTip.OptionsTable.TextShadow)
+ end
+
+ local height_mod = CoolTip.OptionsTable.TextHeightMod or 0
+ menuButton.leftText:SetPoint ("center", menuButton.leftIcon, "center", 0, 0+height_mod)
+ menuButton.leftText:SetPoint ("left", menuButton.leftIcon, "right", 3, 0+height_mod)
+
+ else
+ menuButton.leftText:SetText ("")
+ end
+
+ if (rightTextTable) then
+ menuButton.rightText:SetText (rightTextTable [1])
+
+ local r, g, b, a = rightTextTable [2], rightTextTable [3], rightTextTable [4], rightTextTable [5]
+
+ if (r == 0 and g == 0 and b == 0 and a == 0) then
+
+ if (CoolTip.OptionsTable.TextColorRight) then
+ r, g, b, a = DF:ParseColors (CoolTip.OptionsTable.TextColorRight)
+ menuButton.rightText:SetTextColor (r, g, b, a)
+ elseif (CoolTip.OptionsTable.TextColor) then
+ r, g, b, a = DF:ParseColors (CoolTip.OptionsTable.TextColor)
+ menuButton.rightText:SetTextColor (r, g, b, a)
+ else
+ menuButton.rightText:SetTextColor (1, 1, 1, 1)
+ end
+ else
+ menuButton.rightText:SetTextColor (r, g, b, a)
+ end
+
+ if (CoolTip.OptionsTable.TextSize and not rightTextTable [6]) then
+ DF:SetFontSize (menuButton.rightText, CoolTip.OptionsTable.TextSize)
+ end
+
+ if (CoolTip.OptionsTable.RightTextWidth) then
+ menuButton.rightText:SetWidth (CoolTip.OptionsTable.RightTextWidth)
+ else
+ menuButton.rightText:SetWidth (0)
+ end
+
+ if (CoolTip.OptionsTable.RightTextHeight) then
+ menuButton.rightText:SetHeight (CoolTip.OptionsTable.RightTextHeight)
+ else
+ menuButton.rightText:SetHeight (0)
+ end
+
+ if (CoolTip.OptionsTable.TextFont and not rightTextTable [7]) then
+ if (_G [CoolTip.OptionsTable.TextFont]) then
+ menuButton.rightText:SetFontObject (CoolTip.OptionsTable.TextFont)
+ else
+ local font = SharedMedia:Fetch ("font", CoolTip.OptionsTable.TextFont)
+ local _, size, flags = menuButton.rightText:GetFont()
+ flags = rightTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
+ size = rightTextTable [6] or CoolTip.OptionsTable.TextSize or size
+ menuButton.rightText:SetFont (font, size, flags)
+ end
+
+ elseif (rightTextTable [7]) then
+ if (_G [rightTextTable [7]]) then
+ menuButton.rightText:SetFontObject (rightTextTable [7])
+ local face, size, flags = menuButton.rightText:GetFont()
+ flags = rightTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
+ size = rightTextTable [6] or CoolTip.OptionsTable.TextSize or size
+ menuButton.rightText:SetFont (face, size, flags)
+ else
+ local font = SharedMedia:Fetch ("font", rightTextTable [7])
+ local face, size, flags = menuButton.rightText:GetFont()
+ flags = rightTextTable [8] or CoolTip.OptionsTable.TextShadow or nil
+ size = rightTextTable [6] or CoolTip.OptionsTable.TextSize or size
+ menuButton.rightText:SetFont (face, size, flags)
+ end
+
+ else
+ menuButton.rightText:SetFont (CoolTip._default_font, rightTextTable [6] or CoolTip.OptionsTable.TextSize or 10, rightTextTable [8] or CoolTip.OptionsTable.TextShadow)
+ end
+
+
+ else
+ menuButton.rightText:SetText ("")
+ end
+
+ --> left icon
+ if (leftIconTable and leftIconTable [1]) then
+ menuButton.leftIcon:SetTexture (leftIconTable [1])
+ menuButton.leftIcon:SetWidth (leftIconTable [2])
+ menuButton.leftIcon:SetHeight (leftIconTable [3])
+ menuButton.leftIcon:SetTexCoord (leftIconTable [4], leftIconTable [5], leftIconTable [6], leftIconTable [7])
+
+ local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (leftIconTable [8])
+ menuButton.leftIcon:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+
+ if (CoolTip.OptionsTable.IconBlendMode) then
+ menuButton.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
+ else
+ menuButton.leftIcon:SetBlendMode ("BLEND")
+ end
+
+ menuButton.leftIcon:SetDesaturated (leftIconTable [9])
+ else
+ menuButton.leftIcon:SetTexture (nil)
+ menuButton.leftIcon:SetWidth (1)
+ menuButton.leftIcon:SetHeight (1)
+ end
+
+ --> right icon
+ if (rightIconTable and rightIconTable [1]) then
+ menuButton.rightIcon:SetTexture (rightIconTable [1])
+ menuButton.rightIcon:SetWidth (rightIconTable [2])
+ menuButton.rightIcon:SetHeight (rightIconTable [3])
+ menuButton.rightIcon:SetTexCoord (rightIconTable [4], rightIconTable [5], rightIconTable [6], rightIconTable [7])
+
+ local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (rightIconTable [8])
+ menuButton.rightIcon:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+
+ if (CoolTip.OptionsTable.IconBlendMode) then
+ menuButton.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
+ else
+ menuButton.rightIcon:SetBlendMode ("BLEND")
+ end
+
+ menuButton.rightIcon:SetDesaturated (rightIconTable [9])
+ else
+ menuButton.rightIcon:SetTexture (nil)
+ menuButton.rightIcon:SetWidth (1)
+ menuButton.rightIcon:SetHeight (1)
+ end
+
+ --> overwrite icon size
+ if (CoolTip.OptionsTable.IconSize) then
+ menuButton.leftIcon:SetWidth (CoolTip.OptionsTable.IconSize)
+ menuButton.leftIcon:SetHeight (CoolTip.OptionsTable.IconSize)
+ menuButton.rightIcon:SetWidth (CoolTip.OptionsTable.IconSize)
+ menuButton.rightIcon:SetHeight (CoolTip.OptionsTable.IconSize)
+ end
+
+ if (CoolTip.Type == 2) then
+ CoolTip:LeftTextSpace (menuButton)
+ end
+
+ --> string length
+ if (not isSub) then --> main frame
+ if (not CoolTip.OptionsTable.FixedWidth) then
+ if (CoolTip.Type == 1 or CoolTip.Type == 2) then
+ local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth() + 10
+ if (stringWidth > frame.w) then
+ frame.w = stringWidth
+ end
+ end
+ else
+ menuButton.leftText:SetWidth (CoolTip.OptionsTable.FixedWidth - menuButton.leftIcon:GetWidth() - menuButton.rightText:GetStringWidth() - menuButton.rightIcon:GetWidth() - 30)
+ end
+ else
+ if (not CoolTip.OptionsTable.FixedWidthSub) then
+ if (CoolTip.Type == 1 or CoolTip.Type == 2) then
+ local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth()
+ if (stringWidth > frame.w) then
+ frame.w = stringWidth
+ end
+ end
+ else
+ menuButton.leftText:SetWidth (CoolTip.OptionsTable.FixedWidthSub - menuButton.leftIcon:GetWidth() - 20)
+ end
+ end
+
+ local height = _math_max ( menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight(), menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight() )
+ if (height > frame.hHeight) then
+ frame.hHeight = height
+ end
+
+ end
+
+ function CoolTip:RefreshSpark (menuButton)
+ menuButton.spark:ClearAllPoints()
+ menuButton.spark:SetPoint ("LEFT", menuButton.statusbar, "LEFT", (menuButton.statusbar:GetValue() * (menuButton.statusbar:GetWidth() / 100)) - 3, 0)
+ menuButton.spark2:ClearAllPoints()
+ menuButton.spark2:SetPoint ("left", menuButton.statusbar, "left", menuButton.statusbar:GetValue() * (menuButton.statusbar:GetWidth()/100) - 16, 0)
+ end
+
+ function CoolTip:StatusBar (menuButton, StatusBar)
+
+ if (StatusBar) then
+
+ menuButton.statusbar:SetValue (StatusBar [1])
+ menuButton.statusbar:SetStatusBarColor (StatusBar [2], StatusBar [3], StatusBar [4], StatusBar [5])
+ menuButton.statusbar:SetHeight (20 + (CoolTip.OptionsTable.StatusBarHeightMod or 0))
+
+ menuButton.spark2:Hide()
+ if (StatusBar [6]) then
+ menuButton.spark:Show()
+ --menuButton.spark:ClearAllPoints()
+ --menuButton.spark:SetPoint ("LEFT", menuButton.statusbar, "LEFT", (StatusBar [1] * (menuButton.statusbar:GetWidth() / 100)) - 3, 0)
+ else
+ menuButton.spark:Hide()
+ end
+
+ if (StatusBar [7]) then
+ menuButton.statusbar2:SetValue (StatusBar[7].value)
+ menuButton.statusbar2.texture:SetTexture (StatusBar[7].texture or [[Interface\RaidFrame\Raid-Bar-Hp-Fill]])
+ if (StatusBar[7].specialSpark) then
+ menuButton.spark2:Show()
+ end
+ if (StatusBar[7].color) then
+ local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (StatusBar[7].color)
+ menuButton.statusbar2:SetStatusBarColor (ColorR, ColorG, ColorB, ColorA)
+ else
+ menuButton.statusbar2:SetStatusBarColor (1, 1, 1, 1)
+ end
+ else
+ menuButton.statusbar2:SetValue (0)
+ menuButton.spark2:Hide()
+ end
+
+ if (CoolTip.OptionsTable.StatusBarTexture) then
+ menuButton.statusbar.texture:SetTexture (CoolTip.OptionsTable.StatusBarTexture)
+ else
+ menuButton.statusbar.texture:SetTexture ("Interface\\PaperDollInfoFrame\\UI-Character-Skills-Bar")
+ end
+
+ else
+ menuButton.statusbar:SetValue (0)
+ menuButton.statusbar2:SetValue (0)
+ menuButton.spark:Hide()
+ menuButton.spark2:Hide()
+ end
+
+ if (CoolTip.OptionsTable.LeftBorderSize) then
+ menuButton.statusbar:SetPoint ("left", menuButton, "left", 10 + CoolTip.OptionsTable.LeftBorderSize, 0)
+ else
+ menuButton.statusbar:SetPoint ("left", menuButton, "left", 10, 0)
+ end
+
+ if (CoolTip.OptionsTable.RightBorderSize) then
+ menuButton.statusbar:SetPoint ("right", menuButton, "right", CoolTip.OptionsTable.RightBorderSize + (- 10), 0)
+ else
+ menuButton.statusbar:SetPoint ("right", menuButton, "right", -10, 0)
+ end
+ end
+
+ function CoolTip:SetupMainButton (menuButton, index)
+ menuButton.index = index
+
+ --> setup texts and icons
+ CoolTip:TextAndIcon (index, frame1, menuButton, CoolTip.LeftTextTable [index], CoolTip.RightTextTable [index], CoolTip.LeftIconTable [index], CoolTip.RightIconTable [index])
+ --> setup statusbar
+ CoolTip:StatusBar (menuButton, CoolTip.StatusBarTable [index])
+
+ --> click
+ menuButton:RegisterForClicks ("LeftButtonDown")
+
+ --> string length
+ if (not CoolTip.OptionsTable.FixedWidth) then
+ local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth()
+ if (stringWidth > frame1.w) then
+ frame1.w = stringWidth
+ end
+ end
+
+ --> register click function
+ menuButton:SetScript ("OnClick", OnClickFunctionButtonPrincipal)
+ menuButton:Show()
+ end
+
+ function CoolTip:SetupSecondaryButton (menuButton, index, mainMenuIndex)
+
+ menuButton.index = index
+ menuButton.mainIndex = mainMenuIndex
+
+ --> setup texts and icons
+ CoolTip:TextAndIcon (index, frame2, menuButton, CoolTip.LeftTextTableSub [mainMenuIndex] and CoolTip.LeftTextTableSub [mainMenuIndex] [index],
+ CoolTip.RightTextTableSub [mainMenuIndex] and CoolTip.RightTextTableSub [mainMenuIndex] [index],
+ CoolTip.LeftIconTableSub [mainMenuIndex] and CoolTip.LeftIconTableSub [mainMenuIndex] [index],
+ CoolTip.RightIconTableSub [mainMenuIndex] and CoolTip.RightIconTableSub [mainMenuIndex] [index], true)
+ --> setup statusbar
+ CoolTip:StatusBar (menuButton, CoolTip.StatusBarTableSub [mainMenuIndex] and CoolTip.StatusBarTableSub [mainMenuIndex] [index])
+
+
+ --> click
+ menuButton:RegisterForClicks ("LeftButtonDown")
+
+ menuButton:ClearAllPoints()
+ menuButton:SetPoint ("center", frame2, "center")
+ menuButton:SetPoint ("top", frame2, "top", 0, (((index-1)*20)*-1)-3)
+ menuButton:SetPoint ("left", frame2, "left")
+ menuButton:SetPoint ("right", frame2, "right")
+
+ DF:Fade (menuButton, 0)
+
+ --> string length
+ local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth()
+ if (stringWidth > frame2.w) then
+ frame2.w = stringWidth
+ end
+
+ menuButton:SetScript ("OnClick", OnClickFunctionButtonSecundario)
+ menuButton:Show()
+
+ return true
+ end
+
+ -- -- --------------------------------------------------------------------------------------------------------------
+
+ function CoolTip:SetupWallpaper (wallpaperTable, wallpaper)
+ local texture = wallpaperTable [1]
+ if (DF:IsHtmlColor (texture) or type (texture) == "table") then
+ local r, g, b, a = DF:ParseColors (texture)
+ wallpaper:SetTexture (r, g, b, a)
+ else
+ wallpaper:SetTexture (texture)
+ end
+
+ wallpaper:SetTexCoord (wallpaperTable[2], wallpaperTable[3], wallpaperTable[4], wallpaperTable[5])
+
+ local color = wallpaperTable[6]
+ if (color) then
+ local r, g, b, a = DF:ParseColors (color)
+ wallpaper:SetVertexColor (r, g, b, a)
+ else
+ wallpaper:SetVertexColor (1, 1, 1, 1)
+ end
+
+ if (wallpaperTable[7]) then
+ wallpaper:SetDesaturated (true)
+ else
+ wallpaper:SetDesaturated (false)
+ end
+
+ wallpaper:Show()
+ end
+
+ -- -- --------------------------------------------------------------------------------------------------------------
+
+ function CoolTip:ShowSub (index)
+
+ if (CoolTip.OptionsTable.IgnoreSubMenu) then
+ DF:Fade (frame2, 1)
+ return
+ end
+
+ frame2:SetHeight (6)
+
+ local amtIndexes = CoolTip.IndexesSub [index]
+ if (not amtIndexes) then
+ --print ("Sub menu called but sub menu indexes is nil")
+ return
+ end
+
+ if (CoolTip.OptionsTable.FixedWidthSub) then
+ frame2:SetWidth (CoolTip.OptionsTable.FixedWidthSub)
+ end
+
+ frame2.h = CoolTip.IndexesSub [index] * 20
+ frame2.hHeight = 0
+ frame2.w = 0
+
+ --> pegar a fontsize da label principal
+ local mainButton = frame1.Lines [index]
+ local fontSize = DF:GetFontSize (mainButton.leftText)
+
+ local GotChecked = false
+
+ local IsTooltip = CoolTip.OptionsTable.SubMenuIsTooltip
+ if (IsTooltip) then
+ frame2:EnableMouse (false)
+ else
+ frame2:EnableMouse (true)
+ end
+
+ for i = 1, CoolTip.IndexesSub [index] do
+
+ local button = frame2.Lines [i]
+
+ if (not button) then
+ button = CoolTip:NewSecondaryButton (i)
+ end
+
+ local checked = CoolTip:SetupSecondaryButton (button, i, index)
+ if (checked) then
+ GotChecked = true
+ end
+
+ if (IsTooltip) then
+ button:EnableMouse (false)
+ else
+ button:EnableMouse (true)
+ end
+ end
+
+ local selected = CoolTip.SelectedIndexSec [index]
+ if (selected) then
+
+ CoolTip:SetSelectedAnchor (frame2, frame2.Lines [selected])
+
+ if (not CoolTip.OptionsTable.NoLastSelectedBar) then
+ CoolTip:ShowSelectedTexture (frame2)
+ end
+ else
+ CoolTip:HideSelectedTexture (frame2)
+ end
+
+ for i = CoolTip.IndexesSub [index] + 1, #frame2.Lines do
+ DF:Fade (frame2.Lines[i], 1)
+ end
+
+ local spacing = 0
+ if (CoolTip.OptionsTable.YSpacingModSub) then
+ spacing = CoolTip.OptionsTable.YSpacingModSub
+ end
+
+ --> normalize height of all rows
+ for i = 1, CoolTip.IndexesSub [index] do
+
+ local menuButton = frame2.Lines [i]
+
+ -- CoolTipFrame2.Lines [2].divbar
+
+ if (menuButton.leftText:GetText() == "$div") then
+
+ --> height
+ menuButton:SetHeight (4)
+
+ --> points
+ menuButton:ClearAllPoints()
+
+ menuButton:SetPoint ("center", frame2, "center")
+ menuButton:SetPoint ("left", frame2, "left")
+ menuButton:SetPoint ("right", frame2, "right")
+
+ menuButton.rightText:SetText ("")
+
+ local div_size_up = tonumber (CoolTip.RightTextTableSub [index] [i] [2])
+ if (not div_size_up) then
+ div_size_up = 0
+ end
+ local div_size_down = tonumber (CoolTip.RightTextTableSub [index] [i] [3])
+ if (not div_size_down) then
+ div_size_down = 0
+ end
+
+ menuButton:SetPoint ("top", frame2, "top", 0, ( ( (i-1) * frame2.hHeight) * -1) - 4 + (CoolTip.OptionsTable.ButtonsYModSub or 0) + spacing + (2 + (div_size_up or 0)))
+
+ if (CoolTip.OptionsTable.YSpacingModSub) then
+ spacing = spacing + CoolTip.OptionsTable.YSpacingModSub
+ end
+
+ spacing = spacing + 17 + (div_size_down or 0)
+
+ menuButton.leftText:SetText ("")
+ menuButton.isDiv = true
+
+ if (not menuButton.divbar) then
+ CoolTip:CreateDivBar (menuButton)
+ else
+ menuButton.divbar:Show()
+ end
+
+ menuButton.divbar:SetPoint ("left", menuButton, "left", frame1:GetWidth()*0.10, 0)
+ menuButton.divbar:SetPoint ("right", menuButton, "right", -frame1:GetWidth()*0.10, 0)
+
+ else
+ --> height
+ menuButton:SetHeight (frame2.hHeight + (CoolTip.OptionsTable.ButtonHeightModSub or 0))
+ --> points
+ menuButton:ClearAllPoints()
+ menuButton:SetPoint ("center", frame2, "center")
+ menuButton:SetPoint ("top", frame2, "top", 0, ( ( (i-1) * frame2.hHeight) * -1) - 4 + (CoolTip.OptionsTable.ButtonsYModSub or 0) + spacing)
+ if (CoolTip.OptionsTable.YSpacingModSub) then
+ spacing = spacing + CoolTip.OptionsTable.YSpacingModSub
+ end
+ menuButton:SetPoint ("left", frame2, "left")
+ menuButton:SetPoint ("right", frame2, "right")
+
+ if (menuButton.divbar) then
+ menuButton.divbar:Hide()
+ menuButton.isDiv = false
+ end
+ end
+
+ end
+
+ local mod = CoolTip.OptionsTable.HeighModSub or 0
+ frame2:SetHeight ( (frame2.hHeight * CoolTip.IndexesSub [index]) + 12 + (-spacing) + mod)
+
+ if (CoolTip.TopIconTableSub [index]) then
+ local upperImageTable = CoolTip.TopIconTableSub [index]
+ frame2.upperImage:SetTexture (upperImageTable [1])
+ frame2.upperImage:SetWidth (upperImageTable [2])
+ frame2.upperImage:SetHeight (upperImageTable [3])
+ frame2.upperImage:SetTexCoord (upperImageTable[4], upperImageTable[5], upperImageTable[6], upperImageTable[7])
+ frame2.upperImage:Show()
+ else
+ frame2.upperImage:Hide()
+ end
+
+ if (CoolTip.WallpaperTableSub [index]) then
+ CoolTip:SetupWallpaper (CoolTip.WallpaperTableSub [index], frame2.frameWallpaper)
+ else
+ frame2.frameWallpaper:Hide()
+ end
+
+ if (not CoolTip.OptionsTable.FixedWidthSub) then
+ frame2:SetWidth (frame2.w + 44)
+ end
+
+ DF:Fade (frame2, 0)
+
+ CoolTip:CheckOverlap()
+
+ if (CoolTip.OptionsTable.SubFollowButton and not CoolTip.frame2_leftside) then
+
+ local button = frame1.Lines [index]
+
+ frame2:ClearAllPoints()
+ frame2:SetPoint ("left", button, "right")
+
+ elseif (CoolTip.OptionsTable.SubFollowButton and CoolTip.frame2_leftside) then
+
+ local button = frame1.Lines [index]
+
+ frame2:ClearAllPoints()
+ frame2:SetPoint ("right", button, "left")
+
+ elseif (CoolTip.frame2_leftside) then
+ frame2:ClearAllPoints()
+ frame2:SetPoint ("bottomright", frame1, "bottomleft")
+ else
+ frame2:ClearAllPoints()
+ frame2:SetPoint ("bottomleft", frame1, "bottomright")
+ end
+
+ end
+
+ function CoolTip:HideSub()
+ DF:Fade (frame2, 1)
+ end
+
+
+ function CoolTip:LeftTextSpace (row)
+ row.leftText:SetWidth (row:GetWidth() - 30 - row.leftIcon:GetWidth() - row.rightIcon:GetWidth() - row.rightText:GetStringWidth())
+ row.leftText:SetHeight (10)
+ end
+
+ --> ~inicio ~start
+ function CoolTip:monta_tooltip()
+
+ --> hide sub frame
+ DF:Fade (frame2, 1)
+ --> hide select bar
+ CoolTip:HideSelectedTexture (frame1)
+
+ frame1:EnableMouse (false)
+
+ --> elevator
+ local yDown = 5
+ --> width
+ if (CoolTip.OptionsTable.FixedWidth) then
+ frame1:SetWidth (CoolTip.OptionsTable.FixedWidth)
+ end
+
+ frame1.w = CoolTip.OptionsTable.FixedWidth or 0
+ frame1.hHeight = 0
+ frame2.hHeight = 0
+
+ CoolTip.active = true
+
+ for i = 1, CoolTip.Indexes do
+
+ local button = frame1.Lines [i]
+ if (not button) then
+ button = CoolTip:NewMainButton (i)
+ end
+
+ button.index = i
+
+ --> basic stuff
+ button:Show()
+ button.background:Hide()
+ button:SetHeight (CoolTip.OptionsTable.ButtonHeightMod or CoolTip.default_height)
+ button:RegisterForClicks()
+
+ --> setup texts and icons
+ CoolTip:TextAndIcon (i, frame1, button, CoolTip.LeftTextTable [i], CoolTip.RightTextTable [i], CoolTip.LeftIconTable [i], CoolTip.RightIconTable [i])
+ --> setup statusbar
+ CoolTip:StatusBar (button, CoolTip.StatusBarTable [i])
+ end
+
+ --> hide unused lines
+ for i = CoolTip.Indexes+1, #frame1.Lines do
+ frame1.Lines[i]:Hide()
+ end
+ CoolTip.NumLines = CoolTip.Indexes
+
+ local spacing = 0
+ if (CoolTip.OptionsTable.YSpacingMod) then
+ spacing = CoolTip.OptionsTable.YSpacingMod
+ end
+
+ --> normalize height of all rows
+ local temp = -6 + spacing + (CoolTip.OptionsTable.ButtonsYMod or 0)
+ for i = 1, CoolTip.Indexes do
+ local menuButton = frame1.Lines [i]
+
+ menuButton:ClearAllPoints()
+ menuButton:SetPoint ("center", frame1, "center")
+ menuButton:SetPoint ("left", frame1, "left")
+ menuButton:SetPoint ("right", frame1, "right")
+
+ --> height
+ if (CoolTip.OptionsTable.AlignAsBlizzTooltip) then
+ local height = _math_max (8, menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight(), menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight())
+ menuButton:SetHeight (height)
+ menuButton:SetPoint ("top", frame1, "top", 0, temp)
+ temp = temp + ( height * -1)
+
+ elseif (CoolTip.OptionsTable.IgnoreButtonAutoHeight) then
+
+ local height = _math_max (menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight(), menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight())
+ menuButton:SetHeight (height)
+ menuButton:SetPoint ("top", frame1, "top", 0, temp)
+
+ temp = temp + ( height * -1) + spacing + (CoolTip.OptionsTable.ButtonsYMod or 0)
+
+ else
+ menuButton:SetHeight (frame1.hHeight + (CoolTip.OptionsTable.ButtonHeightMod or 0))
+ menuButton:SetPoint ("top", frame1, "top", 0, ( ( (i-1) * frame1.hHeight) * -1) - 6 + (CoolTip.OptionsTable.ButtonsYMod or 0) + spacing)
+ end
+
+ --> points
+
+ if (CoolTip.OptionsTable.YSpacingMod and not CoolTip.OptionsTable.IgnoreButtonAutoHeight) then
+ spacing = spacing + CoolTip.OptionsTable.YSpacingMod
+ end
+
+ menuButton:EnableMouse (false)
+ end
+
+ if (not CoolTip.OptionsTable.FixedWidth) then
+ if (CoolTip.Type == 2) then --> with bars
+ if (CoolTip.OptionsTable.MinWidth) then
+ local w = frame1.w + 34
+ frame1:SetWidth (math.max (w, CoolTip.OptionsTable.MinWidth))
+ else
+ frame1:SetWidth (frame1.w + 34)
+ end
+ else
+ --> width stability check
+ local width = frame1.w + 24
+ if (width > CoolTip.LastSize-5 and width < CoolTip.LastSize+5) then
+ width = CoolTip.LastSize
+ else
+ CoolTip.LastSize = width
+ end
+
+ if (CoolTip.OptionsTable.MinWidth) then
+ frame1:SetWidth (math.max (width, CoolTip.OptionsTable.MinWidth))
+ else
+ frame1:SetWidth (width)
+ end
+ end
+ end
+
+ if (CoolTip.OptionsTable.FixedHeight) then
+ frame1:SetHeight (CoolTip.OptionsTable.FixedHeight)
+ else
+ if (CoolTip.OptionsTable.AlignAsBlizzTooltip) then
+ frame1:SetHeight ( (temp-10) * -1)
+ elseif (CoolTip.OptionsTable.IgnoreButtonAutoHeight) then
+ frame1:SetHeight ( (temp+spacing) * -1)
+ else
+ frame1:SetHeight ( _math_max ( (frame1.hHeight * CoolTip.Indexes) + 12, 22 ))
+ end
+ end
+
+ if (CoolTip.WallpaperTable [1]) then
+ CoolTip:SetupWallpaper (CoolTip.WallpaperTable, frame1.frameWallpaper)
+ else
+ frame1.frameWallpaper:Hide()
+ end
+
+ --> unhide frame
+ DF:Fade (frame1, 0)
+ CoolTip:SetMyPoint (host)
+
+ --> fix sparks
+ for i = 1, CoolTip.Indexes do
+ local menuButton = frame1.Lines [i]
+ if (menuButton.spark:IsShown() or menuButton.spark2:IsShown()) then
+ CoolTip:RefreshSpark (menuButton)
+ end
+ end
+ end
+
+ function CoolTip:CreateDivBar (button)
+ button.divbar = button:CreateTexture (nil, "overlay")
+
+ button.divbar:SetTexture ([[Interface\QUESTFRAME\AutoQuest-Parts]])
+ button.divbar:SetTexCoord (238/512, 445/512, 0/64, 4/64)
+
+ button.divbar:SetHeight (3)
+ button.divbar:SetAlpha (0.1)
+
+ button.divbar:SetDesaturated (true)
+ end
+
+ --> ~inicio ~start
+ function CoolTip:monta_cooltip (host, instancia, options, sub_menus, icones, tamanho1, tamanho2, font, fontsize)
+
+ if (CoolTip.Indexes == 0) then
+ CoolTip:Reset()
+ CoolTip:SetType ("tooltip")
+ CoolTip:AddLine ("There is no options.")
+ CoolTip:ShowCooltip()
+ return
+ end
+
+ if (CoolTip.OptionsTable.FixedWidth) then
+ frame1:SetWidth (CoolTip.OptionsTable.FixedWidth)
+ end
+
+ frame1.w = CoolTip.OptionsTable.FixedWidth or 0
+ frame1.hHeight = 0
+ frame2.hHeight = 0
+
+ frame1:EnableMouse (true)
+
+ if (CoolTip.HaveSubMenu) then --> zera o segundo frame
+ frame2.w = 0
+ frame2:SetHeight (6)
+ if (CoolTip.SelectedIndexMain and CoolTip.IndexesSub [CoolTip.SelectedIndexMain] and CoolTip.IndexesSub [CoolTip.SelectedIndexMain] > 0) then
+ DF:Fade (frame2, 0)
+ else
+ DF:Fade (frame2, 1)
+ end
+ else
+ DF:Fade (frame2, 1)
+ end
+
+ CoolTip.active = true
+
+ for i = 1, CoolTip.Indexes do
+ local menuButton = frame1.Lines [i]
+ if (not menuButton) then
+ menuButton = CoolTip:NewMainButton (i)
+ end
+
+ CoolTip:SetupMainButton (menuButton, i)
+
+ menuButton.background:Hide()
+ end
+
+ --> selected texture
+ if (CoolTip.SelectedIndexMain) then
+ CoolTip:SetSelectedAnchor (frame1, frame1.Lines [CoolTip.SelectedIndexMain])
+
+ if (CoolTip.OptionsTable.NoLastSelectedBar) then
+ CoolTip:HideSelectedTexture (frame1)
+ else
+ CoolTip:ShowSelectedTexture (frame1)
+ end
+ else
+ CoolTip:HideSelectedTexture (frame1)
+ end
+
+ if (CoolTip.Indexes < #frame1.Lines) then
+ for i = CoolTip.Indexes+1, #frame1.Lines do
+ frame1.Lines[i]:Hide()
+ end
+ end
+
+ CoolTip.NumLines = CoolTip.Indexes
+
+ local spacing = 0
+ if (CoolTip.OptionsTable.YSpacingMod) then
+ spacing = CoolTip.OptionsTable.YSpacingMod
+ end
+
+ if (not CoolTip.OptionsTable.FixedWidth) then
+ if (CoolTip.OptionsTable.MinWidth) then
+ local w = frame1.w + 24
+ frame1:SetWidth (math.max (w, CoolTip.OptionsTable.MinWidth))
+ else
+ frame1:SetWidth (frame1.w + 24)
+ end
+ end
+
+ --> normalize height of all rows
+ for i = 1, CoolTip.Indexes do
+ local menuButton = frame1.Lines [i]
+ menuButton:EnableMouse (true)
+
+ if (menuButton.leftText:GetText() == "$div") then
+
+ --> height
+ menuButton:SetHeight (4)
+ --> points
+ menuButton:ClearAllPoints()
+ menuButton:SetPoint ("left", frame1, "left")
+ menuButton:SetPoint ("right", frame1, "right")
+ menuButton:SetPoint ("center", frame1, "center")
+
+ local div_size_up = tonumber (CoolTip.LeftTextTable [i] [2])
+ if (not div_size_up) then
+ div_size_up = 0
+ end
+ local div_size_down = tonumber (CoolTip.LeftTextTable [i] [3])
+ if (not div_size_down) then
+ div_size_down = 0
+ end
+
+ menuButton:SetPoint ("top", frame1, "top", 0, ( ( (i-1) * frame1.hHeight) * -1) - 4 + (CoolTip.OptionsTable.ButtonsYMod or 0) + spacing - 4 + div_size_up)
+ if (CoolTip.OptionsTable.YSpacingMod) then
+ spacing = spacing + CoolTip.OptionsTable.YSpacingMod
+ end
+
+ spacing = spacing + 4 + div_size_down
+
+ menuButton.leftText:SetText ("")
+ menuButton.isDiv = true
+
+ if (not menuButton.divbar) then
+ CoolTip:CreateDivBar (menuButton)
+ else
+ menuButton.divbar:Show()
+ end
+
+ menuButton.divbar:SetPoint ("left", menuButton, "left", frame1:GetWidth()*0.10, 0)
+ menuButton.divbar:SetPoint ("right", menuButton, "right", -frame1:GetWidth()*0.10, 0)
+
+ else
+
+ --> height
+ menuButton:SetHeight (frame1.hHeight + (CoolTip.OptionsTable.ButtonHeightMod or 0))
+ --> points
+ menuButton:ClearAllPoints()
+ menuButton:SetPoint ("center", frame1, "center")
+ menuButton:SetPoint ("top", frame1, "top", 0, ( ( (i-1) * frame1.hHeight) * -1) - 4 + (CoolTip.OptionsTable.ButtonsYMod or 0) + spacing)
+ if (CoolTip.OptionsTable.YSpacingMod) then
+ spacing = spacing + CoolTip.OptionsTable.YSpacingMod
+ end
+ menuButton:SetPoint ("left", frame1, "left")
+ menuButton:SetPoint ("right", frame1, "right")
+
+ if (menuButton.divbar) then
+ menuButton.divbar:Hide()
+ menuButton.isDiv = false
+ end
+ end
+
+ end
+
+ if (CoolTip.OptionsTable.FixedHeight) then
+ frame1:SetHeight (CoolTip.OptionsTable.FixedHeight)
+ else
+ local mod = CoolTip.OptionsTable.HeighMod or 0
+ frame1:SetHeight (_math_max ( (frame1.hHeight * CoolTip.Indexes) + 12 + (-spacing) + mod, 22 ))
+ end
+
+ --> sub menu arrows
+ if (CoolTip.HaveSubMenu and not CoolTip.OptionsTable.IgnoreArrows and not CoolTip.OptionsTable.SubMenuIsTooltip) then
+ for i = 1, CoolTip.Indexes do
+ if (CoolTip.IndexesSub [i] and CoolTip.IndexesSub [i] > 0) then
+ frame1.Lines [i].statusbar.subMenuArrow:Show()
+ else
+ frame1.Lines [i].statusbar.subMenuArrow:Hide()
+ end
+ end
+
+ frame1:SetWidth (frame1:GetWidth() + 16)
+ end
+
+ frame1:ClearAllPoints()
+ CoolTip:SetMyPoint (host)
+
+ if (CoolTip.title1) then
+ CoolTip.frame1.titleText:Show()
+ CoolTip.frame1.titleIcon:Show()
+ CoolTip.frame1.titleText:SetText (CoolTip.title_text)
+ CoolTip.frame1.titleIcon:SetWidth (frame1:GetWidth())
+ CoolTip.frame1.titleIcon:SetHeight (40)
+ end
+
+ if (CoolTip.WallpaperTable [1]) then
+ CoolTip:SetupWallpaper (CoolTip.WallpaperTable, frame1.frameWallpaper)
+ else
+ frame1.frameWallpaper:Hide()
+ end
+
+ DF:Fade (frame1, 0)
+
+ for i = 1, CoolTip.Indexes do
+ if (CoolTip.SelectedIndexMain and CoolTip.SelectedIndexMain == i) then
+ if (CoolTip.HaveSubMenu and CoolTip.IndexesSub [i] and CoolTip.IndexesSub [i] > 0) then
+ CoolTip:ShowSub (i)
+ end
+ end
+ end
+
+ return true
+ end
+
+ function CoolTip:SetMyPoint (host, x_mod, y_mod)
+
+ local moveX = x_mod or 0
+ local moveY = y_mod or 0
+
+ --> clear all points
+ frame1:ClearAllPoints()
+
+ local anchor = CoolTip.OptionsTable.Anchor or CoolTip.Host
+ frame1:SetPoint (CoolTip.OptionsTable.MyAnchor, anchor, CoolTip.OptionsTable.RelativeAnchor, 0 + moveX + CoolTip.OptionsTable.WidthAnchorMod, 10 + CoolTip.OptionsTable.HeightAnchorMod + moveY)
+
+ if (not x_mod) then
+ --> check if cooltip is out of screen bounds
+ local center_x = frame1:GetCenter()
+
+ if (center_x) then
+ local screen_x_res = GetScreenWidth()
+ local half_x = frame1:GetWidth() / 2
+
+ if (center_x+half_x > screen_x_res) then
+ --> out of right side
+ local move_to_left = (center_x + half_x) - screen_x_res
+ CoolTip.internal_x_mod = -move_to_left
+ return CoolTip:SetMyPoint (host, -move_to_left, 0)
+
+ elseif (center_x-half_x < 0) then
+ --> out of left side
+ local move_to_right = center_x - half_x
+ CoolTip.internal_x_mod = move_to_right*-1
+ return CoolTip:SetMyPoint (host, move_to_right*-1, 0)
+ end
+ end
+ end
+
+ if (not y_mod) then
+ --> check if cooltip is out of screen bounds
+ local _, center_y = frame1:GetCenter()
+ local screen_y_res = GetScreenHeight()
+ local half_y = frame1:GetHeight() / 2
+
+ if (center_y) then
+ if (center_y+half_y > screen_y_res) then
+ --> out of top side
+ local move_to_down = (center_y + half_y) - screen_y_res
+ CoolTip.internal_y_mod = -move_to_down
+ return CoolTip:SetMyPoint (host, 0, -move_to_down)
+
+ elseif (center_y-half_y < 0) then
+ --> out of bottom side
+ local move_to_up = center_y - half_y
+ CoolTip.internal_y_mod = move_to_up*-1
+ return CoolTip:SetMyPoint (host, 0, move_to_up*-1)
+
+ end
+ end
+ end
+
+ if (frame2:IsShown() and not CoolTip.overlap_checked) then
+
+ local frame_2_center_x = frame2:GetCenter()
+ if (frame_2_center_x) then
+ local frame_2_half_x = frame2:GetWidth() / 2
+
+ local frame_1_center_x = frame1:GetCenter()
+ if (frame_1_center_x) then
+
+ local frame_1_half_x = frame1:GetWidth() / 2
+
+ local f1_end_point = frame_1_center_x + frame_1_half_x - 3
+ local f2_start_point = frame_2_center_x - frame_2_half_x
+
+ if (f2_start_point < f1_end_point) then
+ local diff = f2_start_point - f1_end_point
+ CoolTip.overlap_checked = true
+
+ frame2:ClearAllPoints()
+ frame2:SetPoint ("bottomright", frame1, "bottomleft")
+ CoolTip.frame2_leftside = true
+ --> diff
+ return CoolTip:SetMyPoint (host, CoolTip.internal_x_mod , CoolTip.internal_y_mod)
+ end
+
+ end
+ end
+
+ end
+
+ end
+
+ function CoolTip:CheckOverlap()
+ if (frame2:IsShown()) then
+
+ local frame_2_center_x = frame2:GetCenter()
+ if (frame_2_center_x) then
+ local frame_2_half_x = frame2:GetWidth() / 2
+
+ local frame_1_center_x = frame1:GetCenter()
+ if (frame_1_center_x) then
+
+ local frame_1_half_x = frame1:GetWidth() / 2
+
+ local f1_end_point = frame_1_center_x + frame_1_half_x - 3
+ local f2_start_point = frame_2_center_x - frame_2_half_x
+
+ if (f2_start_point < f1_end_point) then
+ local diff = f2_start_point - f1_end_point
+
+ frame2:ClearAllPoints()
+ frame2:SetPoint ("bottomright", frame1, "bottomleft")
+ CoolTip.frame2_leftside = true
+ end
+
+ end
+ end
+
+ end
+ end
+
+ function CoolTip:GetText (buttonIndex)
+ local button1 = frame1.Lines [buttonIndex]
+ if (not button1) then
+ return "", ""
+ else
+ return button1.leftText:GetText() or "", button1.rightText:GetText() or ""
+ end
+ end
+
+----------------------------------------------------------------------
+ --> Get the number of lines current shown on cooltip
+
+ function CoolTip:GetNumLines()
+ return CoolTip.NumLines or 0
+ end
+
+----------------------------------------------------------------------
+ --> Remove all options actived
+ --> Set a option on current cooltip
+
+ function CoolTip:ClearAllOptions()
+ for option, _ in pairs (CoolTip.OptionsTable) do
+ CoolTip.OptionsTable [option] = nil
+ end
+
+ CoolTip:SetOption ("MyAnchor", "bottom")
+ CoolTip:SetOption ("RelativeAnchor", "top")
+ CoolTip:SetOption ("WidthAnchorMod", 0)
+ CoolTip:SetOption ("HeightAnchorMod", 0)
+ end
+
+ function CoolTip:SetOption (option, value)
+ --> check if this options exists
+ if (not CoolTip.OptionsList [option]) then
+ return --> error
+ end
+
+ --> set options
+ CoolTip.OptionsTable [option] = value
+ end
+
+----------------------------------------------------------------------
+ --> set the anchor of cooltip
+ --> parameters: frame [, cooltip anchor point, frame anchor point [, x mod, y mod]]
+ --> frame [, x mod, y mod]
+
+ --> alias
+ function CoolTip:GetOwner()
+ return CoolTip.Host
+ end
+
+ function CoolTip:SetOwner (frame, myPoint, hisPoint, x, y)
+ return CoolTip:SetHost (frame, myPoint, hisPoint, x, y)
+ end
+
+ function CoolTip:SetHost (frame, myPoint, hisPoint, x, y)
+ --> check data integrity
+ if (type (frame) ~= "table" or not frame.GetObjectType) then
+ print ("host need to be a frame")
+ return --> error
+ end
+
+ CoolTip.Host = frame
+
+ CoolTip.frame1:SetFrameLevel (frame:GetFrameLevel()+1)
+
+ --> defaults
+ myPoint = myPoint or CoolTip.OptionsTable.MyAnchor or "bottom"
+ hisPoint = hisPoint or CoolTip.OptionsTable.hisPoint or "top"
+
+ x = x or CoolTip.OptionsTable.WidthAnchorMod or 0
+ y = y or CoolTip.OptionsTable.HeightAnchorMod or 0
+
+ --> check options
+ if (type (myPoint) == "string") then
+ CoolTip:SetOption ("MyAnchor", myPoint)
+ CoolTip:SetOption ("WidthAnchorMod", x)
+ elseif (type (myPoint) == "number") then
+ CoolTip:SetOption ("HeightAnchorMod", myPoint)
+ end
+
+ if (type (hisPoint) == "string") then
+ CoolTip:SetOption ("RelativeAnchor", hisPoint)
+ CoolTip:SetOption ("HeightAnchorMod", y)
+ elseif (type (hisPoint) == "number") then
+ CoolTip:SetOption ("WidthAnchorMod", hisPoint)
+ end
+ end
+
+----------------------------------------------------------------------
+ --> set cooltip type
+ --> parameters: type (1 = tooltip | 2 = tooltip with bars | 3 = menu)
+
+ function CoolTip:IsMenu()
+ return CoolTip.frame1:IsShown() and CoolTip.Type == 3
+ end
+
+ function CoolTip:IsTooltip()
+ return CoolTip.frame1:IsShown() and (CoolTip.Type == 1 or CoolTip.Type == 2)
+ end
+
+ function CoolTip:GetType()
+ if (CoolTip.Type == 1 or CoolTip.Type == 2) then
+ return "tooltip"
+ elseif (CoolTip.Type == 3) then
+ return "menu"
+ else
+ return "none"
+ end
+ end
+
+ function CoolTip:SetType (newType)
+ if (type (newType) == "string") then
+ if (newType == "tooltip") then
+ CoolTip.Type = 1
+ elseif (newType == "tooltipbar") then
+ CoolTip.Type = 2
+ elseif (newType == "menu") then
+ CoolTip.Type = 3
+ else
+ --> error
+ end
+ elseif (type (newType) == "number") then
+ if (newType == 1) then
+ CoolTip.Type = 1
+ elseif (newType == 2) then
+ CoolTip.Type = 2
+ elseif (newType == 3) then
+ CoolTip.Type = 3
+ else
+ --> error
+ end
+ else
+ --> error
+ end
+ end
+
+ --> Set a fixed value for menu
+ function CoolTip:SetFixedParameter (value, injected)
+ if (injected ~= nil) then
+ local frame = value
+ if (frame.dframework) then
+ frame = frame.widget
+ end
+ if (frame.CoolTip) then
+ frame.CoolTip.FixedValue = injected
+ else
+ --debug
+ end
+ end
+ CoolTip.FixedValue = value
+ end
+
+ function CoolTip:SetColor (menuType, ...)
+ local ColorR, ColorG, ColorB, ColorA = DF:ParseColors (...)
+ if ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1)) then
+ frame1.framebackgroundLeft:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+ frame1.framebackgroundRight:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+ frame1.framebackgroundCenter:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+
+ elseif ((type (menuType) == "string" and menuType == "sec") or (type (menuType) == "number" and menuType == 2)) then
+ frame2.framebackgroundLeft:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+ frame2.framebackgroundRight:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+ frame2.framebackgroundCenter:SetVertexColor (ColorR, ColorG, ColorB, ColorA)
+
+ else
+ return --> error
+ end
+ end
+
+ --> Set last selected option
+ function CoolTip:SetLastSelected (menuType, index, index2)
+
+ if (CoolTip.Type == 3) then
+ if ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1)) then
+ CoolTip.SelectedIndexMain = index
+ elseif ((type (menuType) == "string" and menuType == "sec") or (type (menuType) == "number" and menuType == 2)) then
+ CoolTip.SelectedIndexSec [index] = index2
+ else
+ return --> error
+ end
+ else
+ return --> error
+ end
+ end
+
+ --> serack key: ~select
+ function CoolTip:Select (menuType, option, mainIndex)
+ if (menuType == 1) then --main menu
+ local botao = frame1.Lines [option]
+ CoolTip.buttonClicked = true
+ CoolTip:SetSelectedAnchor (frame1, botao)
+
+ --UIFrameFlash (frame1.selected, 0.05, 0.05, 0.2, true, 0, 0)
+
+ elseif (menuType == 2) then --sub menu
+ CoolTip:ShowSub (mainIndex)
+ local botao = frame2.Lines [option]
+ CoolTip.buttonClicked = true
+
+ CoolTip:SetSelectedAnchor (frame2, botao)
+ end
+ end
+
+----------------------------------------------------------------------
+ --> Reset cooltip
+
+ local default_backdrop = {bgFile=[[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile=[[Interface\Tooltips\UI-Tooltip-Border]], tile=true,
+ edgeSize=16, tileSize=16, insets = {left=3, right=3, top=4, bottom=4}}
+ local default_backdrop_color = {0.09019, 0.09019, 0.18823, 1}
+ local default_backdropborder_color = {1, 1, 1, 1}
+
+ --borda preta sem usar unpack
+
+ --> wipe all data ~reset
+ function CoolTip:Reset()
+
+ frame2:ClearAllPoints()
+ frame2:SetPoint ("bottomleft", frame1, "bottomright")
+
+ CoolTip:HideSelectedTexture (frame1)
+ CoolTip:HideSelectedTexture (frame2)
+
+ CoolTip.FixedValue = nil
+ CoolTip.HaveSubMenu = false
+
+ CoolTip.SelectedIndexMain = nil
+ _table_wipe (CoolTip.SelectedIndexSec)
+
+ CoolTip.Indexes = 0
+ CoolTip.SubIndexes = 0
+ _table_wipe (CoolTip.IndexesSub)
+
+ CoolTip.internal_x_mod = 0
+ CoolTip.internal_y_mod = 0
+ CoolTip.current_anchor = nil
+ CoolTip.overlap_checked = false
+
+ CoolTip.frame2_leftside = nil
+
+ frame1:SetBackdrop (default_backdrop)
+ frame1:SetBackdropColor (unpack (default_backdrop_color))
+ frame1:SetBackdropBorderColor (unpack (default_backdropborder_color))
+
+ frame2:SetBackdrop (default_backdrop)
+ frame2:SetBackdropColor (unpack (default_backdrop_color))
+ frame2:SetBackdropBorderColor (unpack (default_backdropborder_color))
+
+ --[
+ _table_wipe (CoolTip.LeftTextTable)
+ _table_wipe (CoolTip.LeftTextTableSub)
+ _table_wipe (CoolTip.RightTextTable)
+ _table_wipe (CoolTip.RightTextTableSub)
+
+ _table_wipe (CoolTip.LeftIconTable)
+ _table_wipe (CoolTip.LeftIconTableSub)
+ _table_wipe (CoolTip.RightIconTable)
+ _table_wipe (CoolTip.RightIconTableSub)
+
+ _table_wipe (CoolTip.StatusBarTable)
+ _table_wipe (CoolTip.StatusBarTableSub)
+
+ _table_wipe (CoolTip.FunctionsTableMain)
+ _table_wipe (CoolTip.FunctionsTableSub)
+
+ _table_wipe (CoolTip.ParametersTableMain)
+ _table_wipe (CoolTip.ParametersTableSub)
+
+ _table_wipe (CoolTip.WallpaperTable)
+ _table_wipe (CoolTip.WallpaperTableSub)
+ --]]
+
+ _table_wipe (CoolTip.TopIconTableSub)
+ CoolTip.Banner [1] = false
+ CoolTip.Banner [2] = false
+ CoolTip.Banner [3] = false
+
+ frame1.upperImage:Hide()
+ frame1.upperImage2:Hide()
+ frame1.upperImageText:Hide()
+ frame1.upperImageText2:Hide()
+
+ frame1.frameWallpaper:Hide()
+ frame2.frameWallpaper:Hide()
+
+ frame2.upperImage:Hide()
+
+ CoolTip.title1 = nil
+ CoolTip.title_text = nil
+
+ CoolTip.frame1.titleText:Hide()
+ CoolTip.frame1.titleIcon:Hide()
+
+ CoolTip:ClearAllOptions()
+ CoolTip:SetColor (1, "transparent")
+ CoolTip:SetColor (2, "transparent")
+
+ local f1Lines = frame1.Lines
+ for i = 1, #f1Lines do
+ f1Lines [i].statusbar.subMenuArrow:Hide()
+ end
+ end
+
+----------------------------------------------------------------------
+ --> Menu functions
+
+ local _default_color = {1, 1, 1}
+ local _default_point = {"center", "center", 0, -3}
+
+ function CoolTip:AddMenu (menuType, func, param1, param2, param3, leftText, leftIcon, indexUp)
+
+ if (leftText and indexUp and ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1))) then
+ CoolTip.Indexes = CoolTip.Indexes + 1
+
+ if (not CoolTip.IndexesSub [CoolTip.Indexes]) then
+ CoolTip.IndexesSub [CoolTip.Indexes] = 0
+ end
+
+ CoolTip.SubIndexes = 0
+ end
+
+ --> need a previous line
+ if (CoolTip.Indexes == 0) then
+ print ("Indexes are 0")
+ return --> return error
+ end
+
+ --> check data integrity
+ if (type (func) ~= "function") then
+ print ("No function")
+ return --> erroe
+ end
+
+ --> add
+
+ if ((type (menuType) == "string" and menuType == "main") or (type (menuType) == "number" and menuType == 1)) then
+
+ local parameterTable
+ if (CoolTip.isSpecial) then
+ parameterTable = {}
+ _table_insert (CoolTip.FunctionsTableMain, CoolTip.Indexes, func)
+ _table_insert (CoolTip.ParametersTableMain, CoolTip.Indexes, parameterTable)
+ else
+
+ CoolTip.FunctionsTableMain [CoolTip.Indexes] = func
+
+ parameterTable = CoolTip.ParametersTableMain [CoolTip.Indexes]
+ if (not parameterTable) then
+ parameterTable = {}
+ CoolTip.ParametersTableMain [CoolTip.Indexes] = parameterTable
+ end
+ end
+
+ parameterTable [1] = param1
+ parameterTable [2] = param2
+ parameterTable [3] = param3
+
+ if (leftIcon) then
+ local iconTable = CoolTip.LeftIconTable [CoolTip.Indexes]
+
+ if (not iconTable or CoolTip.isSpecial) then
+ iconTable = {}
+ CoolTip.LeftIconTable [CoolTip.Indexes] = iconTable
+ end
+
+ iconTable [1] = leftIcon
+ iconTable [2] = 16 --> default 16
+ iconTable [3] = 16 --> default 16
+ iconTable [4] = 0 --> default 0
+ iconTable [5] = 1 --> default 1
+ iconTable [6] = 0 --> default 0
+ iconTable [7] = 1 --> default 1
+ iconTable [8] = _default_color
+ end
+
+ if (leftText) then
+ local lineTable_left = CoolTip.LeftTextTable [CoolTip.Indexes]
+
+ if (not lineTable_left or CoolTip.isSpecial) then
+ lineTable_left = {}
+ CoolTip.LeftTextTable [CoolTip.Indexes] = lineTable_left
+ end
+
+ lineTable_left [1] = leftText --> line text
+ lineTable_left [2] = 0
+ lineTable_left [3] = 0
+ lineTable_left [4] = 0
+ lineTable_left [5] = 0
+ lineTable_left [6] = false
+ lineTable_left [7] = false
+ lineTable_left [8] = false
+
+ end
+
+ elseif ((type (menuType) == "string" and menuType == "sec") or (type (menuType) == "number" and menuType == 2)) then
+
+ if (CoolTip.SubIndexes == 0) then
+ if (not indexUp or not leftText) then
+ print ("not indexUp or not leftText")
+ return --> error
+ end
+ end
+
+ if (indexUp and leftText) then
+ CoolTip.SubIndexes = CoolTip.SubIndexes + 1
+ CoolTip.IndexesSub [CoolTip.Indexes] = CoolTip.IndexesSub [CoolTip.Indexes] + 1
+ elseif (indexUp and not leftText) then
+ print ("indexUp and not leftText")
+ return --> error [leftText can't be nil if indexUp are true]
+ end
+
+ --> menu container
+ local subMenuContainerParameters = CoolTip.ParametersTableSub [CoolTip.Indexes]
+ if (not subMenuContainerParameters) then
+ subMenuContainerParameters = {}
+ CoolTip.ParametersTableSub [CoolTip.Indexes] = subMenuContainerParameters
+ end
+
+ local subMenuContainerFunctions = CoolTip.FunctionsTableSub [CoolTip.Indexes]
+ if (not subMenuContainerFunctions or CoolTip.isSpecial) then
+ subMenuContainerFunctions = {}
+ CoolTip.FunctionsTableSub [CoolTip.Indexes] = subMenuContainerFunctions
+ end
+
+ --> menu table
+ local subMenuTablesParameters = subMenuContainerParameters [CoolTip.SubIndexes]
+ if (not subMenuTablesParameters or CoolTip.isSpecial) then
+ subMenuTablesParameters = {}
+ subMenuContainerParameters [CoolTip.SubIndexes] = subMenuTablesParameters
+ end
+
+ --> add
+ subMenuContainerFunctions [CoolTip.SubIndexes] = func
+
+ subMenuTablesParameters [1] = param1
+ subMenuTablesParameters [2] = param2
+ subMenuTablesParameters [3] = param3
+
+ --> text and icon
+ if (leftIcon) then
+
+ local subMenuContainerIcons = CoolTip.LeftIconTableSub [CoolTip.Indexes]
+ if (not subMenuContainerIcons) then
+ subMenuContainerIcons = {}
+ CoolTip.LeftIconTableSub [CoolTip.Indexes] = subMenuContainerIcons
+ end
+ local subMenuTablesIcons = subMenuContainerIcons [CoolTip.SubIndexes]
+ if (not subMenuTablesIcons or CoolTip.isSpecial) then
+ subMenuTablesIcons = {}
+ subMenuContainerIcons [CoolTip.SubIndexes] = subMenuTablesIcons
+ end
+
+ subMenuTablesIcons [1] = leftIcon
+ subMenuTablesIcons [2] = 16 --> default 16
+ subMenuTablesIcons [3] = 16 --> default 16
+ subMenuTablesIcons [4] = 0 --> default 0
+ subMenuTablesIcons [5] = 1 --> default 1
+ subMenuTablesIcons [6] = 0 --> default 0
+ subMenuTablesIcons [7] = 1 --> default 1
+ subMenuTablesIcons [8] = _default_color
+ end
+
+ if (leftText) then
+
+ local subMenuContainerTexts = CoolTip.LeftTextTableSub [CoolTip.Indexes]
+ if (not subMenuContainerTexts) then
+ subMenuContainerTexts = {}
+ CoolTip.LeftTextTableSub [CoolTip.Indexes] = subMenuContainerTexts
+ end
+ local subMenuTablesTexts = subMenuContainerTexts [CoolTip.SubIndexes]
+ if (not subMenuTablesTexts or CoolTip.isSpecial) then
+ subMenuTablesTexts = {}
+ subMenuContainerTexts [CoolTip.SubIndexes] = subMenuTablesTexts
+ end
+
+ subMenuTablesTexts [1] = leftText --> line text
+ subMenuTablesTexts [2] = 0
+ subMenuTablesTexts [3] = 0
+ subMenuTablesTexts [4] = 0
+ subMenuTablesTexts [5] = 0
+ subMenuTablesTexts [6] = false
+ subMenuTablesTexts [7] = false
+ subMenuTablesTexts [8] = false
+
+ end
+
+ CoolTip.HaveSubMenu = true
+
+ else
+ return --> error
+ end
+ end
+
+----------------------------------------------------------------------
+ --> adds a statusbar to the last line added.
+ --> only works with cooltip type 2 (tooltip with bars)
+ --> parameters: value [, color red, color green, color blue, color alpha [, glow]]
+ --> can also use a table or html color name in color red and send glow in color green
+
+ function CoolTip:AddStatusBar (statusbarValue, frame, ColorR, ColorG, ColorB, ColorA, statusbarGlow, backgroundBar)
+
+ --> need a previous line
+ if (CoolTip.Indexes == 0) then
+ return --> return error
+ end
+
+ --> check data integrity
+ if (type (statusbarValue) ~= "number") then
+ return --> error
+ end
+
+ if (type (ColorR) == "table" or type (ColorR) == "string") then
+ statusbarGlow, backgroundBar, ColorR, ColorG, ColorB, ColorA = ColorG, ColorB, DF:ParseColors (ColorR)
+ elseif (type (ColorR) == "boolean") then
+ backgroundBar = ColorG
+ statusbarGlow = ColorR
+ ColorR, ColorG, ColorB, ColorA = 1, 1, 1, 1
+ else
+ --> error
+ end
+
+ --> add
+ local frameTable
+ local statusbarTable
+
+ if (not frame or (type (frame) == "string" and frame == "main") or (type (frame) == "number" and frame == 1)) then
+ frameTable = CoolTip.StatusBarTable
+
+ if (CoolTip.isSpecial) then
+ statusbarTable = {}
+ _table_insert (frameTable, CoolTip.Indexes, statusbarTable)
+ else
+ statusbarTable = frameTable [CoolTip.Indexes]
+ if (not statusbarTable) then
+ statusbarTable = {}
+ _table_insert (frameTable, CoolTip.Indexes, statusbarTable)
+ --frameTable [CoolTip.Indexes] = statusbarTable
+ end
+ end
+
+ elseif ((type (frame) == "string" and frame == "sub") or (type (frame) == "number" and frame == 2)) then
+
+ frameTable = CoolTip.StatusBarTableSub
+
+ local subMenuContainerStatusBar = frameTable [CoolTip.Indexes]
+ if (not subMenuContainerStatusBar) then
+ subMenuContainerStatusBar = {}
+ frameTable [CoolTip.Indexes] = subMenuContainerStatusBar
+ end
+
+ if (CoolTip.isSpecial) then
+ statusbarTable = {}
+ _table_insert (subMenuContainerStatusBar, CoolTip.SubIndexes, statusbarTable)
+ else
+ statusbarTable = subMenuContainerStatusBar [CoolTip.SubIndexes]
+ if (not statusbarTable) then
+ statusbarTable = {}
+ _table_insert (subMenuContainerStatusBar, CoolTip.SubIndexes, statusbarTable)
+ end
+ end
+ else
+ print ("unknow frame")
+ return --> error
+ end
+
+ statusbarTable [1] = statusbarValue
+ statusbarTable [2] = ColorR
+ statusbarTable [3] = ColorG
+ statusbarTable [4] = ColorB
+ statusbarTable [5] = ColorA
+ statusbarTable [6] = statusbarGlow
+ statusbarTable [7] = backgroundBar
+
+ end
+
+ frame1.frameWallpaper:Hide()
+ frame2.frameWallpaper:Hide()
+
+ function CoolTip:SetWallpaper (index, texture, texcoord, color, desaturate)
+
+ if (CoolTip.Indexes == 0) then
+ return --> return error
+ end
+
+ local frameTable
+ local wallpaperTable
+
+ if ( (type (index) == "number" and index == 1) or (type (index) == "string" and index == "main") ) then
+ wallpaperTable = CoolTip.WallpaperTable
+
+ elseif ( (type (index) == "number" and index == 2) or (type (index) == "string" and index == "sub") ) then
+ frameTable = CoolTip.WallpaperTableSub
+
+ local subMenuContainerWallpapers = frameTable [CoolTip.Indexes]
+ if (not subMenuContainerWallpapers) then
+ subMenuContainerWallpapers = {}
+ frameTable [CoolTip.Indexes] = subMenuContainerWallpapers
+ end
+
+ wallpaperTable = subMenuContainerWallpapers
+ end
+
+ wallpaperTable [1] = texture
+ if (texcoord) then
+ wallpaperTable [2] = texcoord [1]
+ wallpaperTable [3] = texcoord [2]
+ wallpaperTable [4] = texcoord [3]
+ wallpaperTable [5] = texcoord [4]
+ else
+ wallpaperTable [2] = 0
+ wallpaperTable [3] = 1
+ wallpaperTable [4] = 0
+ wallpaperTable [5] = 1
+ end
+ wallpaperTable [6] = color
+ wallpaperTable [7] = desaturate
+ end
+
+ function CoolTip:SetBannerText (index, text, anchor, color, fontsize, fontface, fontflag)
+ local fontstring
+
+ if (index == 1) then
+ fontstring = frame1.upperImageText
+ elseif (index == 2) then
+ fontstring = frame1.upperImageText2
+ end
+
+ fontstring:SetText (text or "")
+
+ if (anchor and index == 1) then
+ local myAnchor, hisAnchor, x, y = unpack (anchor)
+ fontstring:SetPoint (myAnchor, frame1.upperImage, hisAnchor or myAnchor, x or 0, y or 0)
+ elseif (anchor and index == 2) then
+ local myAnchor, hisAnchor, x, y = unpack (anchor)
+ fontstring:SetPoint (myAnchor, frame1, hisAnchor or myAnchor, x or 0, y or 0)
+ end
+
+ if (color) then
+ local r, g, b, a = DF:ParseColors (color)
+ fontstring:SetTextColor (r, g, b, a)
+ end
+
+ local face, size, flags = fontstring:GetFont()
+ face = fontface or [[Fonts\FRIZQT__.TTF]]
+ size = fontsize or 13
+ flags = fontflag or nil
+ fontstring:SetFont (face, size, flags)
+ fontstring:Show()
+ end
+
+ function CoolTip:SetBackdrop (index, backdrop, backdropcolor, bordercolor)
+
+ local f
+ if (index == 1) then
+ f = frame1
+ elseif (index == 2) then
+ f = frame2
+ end
+
+ if (backdrop) then
+ f:SetBackdrop (backdrop)
+ end
+ if (backdropcolor) then
+ local r, g, b, a = DF:ParseColors (backdropcolor)
+ f:SetBackdropColor (r, g, b, a)
+ end
+ if (bordercolor) then
+ local r, g, b, a = DF:ParseColors (bordercolor)
+ f:SetBackdropBorderColor (r, g, b, a)
+ end
+
+ end
+
+ function CoolTip:SetBannerImage (index, texturepath, width, height, anchor, texcoord, overlay)
+
+ local texture
+
+ if (index == 1) then
+ texture = frame1.upperImage
+ elseif (index == 2) then
+ texture = frame1.upperImage2
+ end
+
+ if (texturepath) then
+ texture:SetTexture (texturepath)
+ end
+
+ if (width) then
+ texture:SetWidth (width)
+ end
+ if (height) then
+ texture:SetHeight (height)
+ end
+
+ if (anchor) then
+ if (type (anchor[1]) == "table") then
+ for _, t in _ipairs (anchor) do
+ local myAnchor, hisAnchor, x, y = unpack (t)
+ texture:SetPoint (myAnchor, frame1, hisAnchor or myAnchor, x or 0, y or 0)
+ end
+ else
+ local myAnchor, hisAnchor, x, y = unpack (anchor)
+ texture:SetPoint (myAnchor, frame1, hisAnchor or myAnchor, x or 0, y or 0)
+ end
+ end
+
+ if (texcoord) then
+ local L, R, T, B = unpack (texcoord)
+ texture:SetTexCoord (L, R, T, B)
+ end
+
+ if (overlay) then
+ texture:SetVertexColor (unpack (overlay))
+ end
+
+ CoolTip.Banner [index] = true
+ texture:Show()
+
+ end
+
+----------------------------------------------------------------------
+ --> adds a icon to the last line added.
+ --> only works with cooltip type 1 and 2 (tooltip and tooltip with bars)
+ --> parameters: icon [, width [, height [, TexCoords L R T B ]]]
+ --> texture support string path or texture object
+
+ function CoolTip:AddTexture (iconTexture, frame, side, iconWidth, iconHeight, L, R, T, B, overlayColor, point, desaturated)
+ return CoolTip:AddIcon (iconTexture, frame, side, iconWidth, iconHeight, L, R, T, B, overlayColor, point, desaturated)
+ end
+ function CoolTip:AddIcon (iconTexture, frame, side, iconWidth, iconHeight, L, R, T, B, overlayColor, point, desaturated)
+
+ --> need a previous line
+ if (CoolTip.Indexes == 0) then
+ return --> return error
+ end
+
+ --> check data integrity
+ if (type (iconTexture) ~= "string" and (type (iconTexture) ~= "table" or not iconTexture.GetObjectType or iconTexture:GetObjectType() ~= "Texture") ) then
+ return --> return error
+ end
+
+ side = side or 1
+
+ local frameTable
+ local iconTable
+
+ if (not frame or (type (frame) == "string" and frame == "main") or (type (frame) == "number" and frame == 1)) then
+
+ if (not side or (type (side) == "string" and side == "left") or (type (side) == "number" and side == 1)) then
+ frameTable = CoolTip.LeftIconTable
+
+ elseif ((type (side) == "string" and side == "right") or (type (side) == "number" and side == 2)) then
+ frameTable = CoolTip.RightIconTable
+
+ end
+
+ if (CoolTip.isSpecial) then
+ iconTable = {}
+ _table_insert (frameTable, CoolTip.Indexes, iconTable)
+ else
+ iconTable = frameTable [CoolTip.Indexes]
+ if (not iconTable) then
+ iconTable = {}
+ _table_insert (frameTable, CoolTip.Indexes, iconTable)
+ --frameTable [CoolTip.Indexes] = iconTable
+ end
+ end
+
+ elseif ((type (frame) == "string" and frame == "sub") or (type (frame) == "number" and frame == 2)) then
+
+ if ((type (side) == "string" and side == "left") or (type (side) == "number" and side == 1)) then
+ frameTable = CoolTip.LeftIconTableSub
+ elseif ((type (side) == "string" and side == "right") or (type (side) == "number" and side == 2)) then
+ frameTable = CoolTip.RightIconTableSub
+ elseif ((type (side) == "string" and side == "top") or (type (side) == "number" and side == 3)) then
+ CoolTip.TopIconTableSub [CoolTip.Indexes] = CoolTip.TopIconTableSub [CoolTip.Indexes] or {}
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [1] = iconTexture
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [2] = iconWidth or 16
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [3] = iconHeight or 16
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [4] = L or 0
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [5] = R or 1
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [6] = T or 0
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [7] = B or 1
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [8] = overlayColor or _default_color
+ CoolTip.TopIconTableSub [CoolTip.Indexes] [9] = desaturated
+ return
+ end
+
+ local subMenuContainerIcons = frameTable [CoolTip.Indexes]
+ if (not subMenuContainerIcons) then
+ subMenuContainerIcons = {}
+ frameTable [CoolTip.Indexes] = subMenuContainerIcons
+ end
+
+ if (CoolTip.isSpecial) then
+ iconTable = {}
+ subMenuContainerIcons [CoolTip.SubIndexes] = iconTable
+ else
+ iconTable = subMenuContainerIcons [CoolTip.SubIndexes]
+ if (not iconTable) then
+ iconTable = {}
+ subMenuContainerIcons [CoolTip.SubIndexes] = iconTable
+ end
+ end
+
+ else
+ return --> error
+ end
+
+ iconTable [1] = iconTexture
+ iconTable [2] = iconWidth or 16 --> default 16
+ iconTable [3] = iconHeight or 16 --> default 16
+ iconTable [4] = L or 0 --> default 0
+ iconTable [5] = R or 1 --> default 1
+ iconTable [6] = T or 0 --> default 0
+ iconTable [7] = B or 1 --> default 1
+ iconTable [8] = overlayColor or _default_color --> default 1, 1, 1
+ iconTable [9] = desaturated
+
+ return true
+ end
+
+----------------------------------------------------------------------
+ --> adds a line.
+ --> only works with cooltip type 1 and 2 (tooltip and tooltip with bars)
+ --> parameters: left text, right text [, L color R, L color G, L color B, L color A [, R color R, R color G, R color B, R color A [, wrap]]]
+
+ --> alias
+ function CoolTip:AddDoubleLine (leftText, rightText, frame, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag)
+ return CoolTip:AddLine (leftText, rightText, frame, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag)
+ end
+
+ --> adds a line for tooltips
+ function CoolTip:AddLine (leftText, rightText, frame, ColorR1, ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag)
+
+ --> check data integrity
+ local t = type (leftText)
+ if (t ~= "string") then
+ if (t == "number") then
+ leftText = tostring (leftText)
+ else
+ leftText = ""
+ end
+ end
+
+ local t = type (rightText)
+ if (t ~= "string") then
+ if (t == "number") then
+ rightText = tostring (rightText)
+ else
+ rightText = ""
+ end
+ end
+
+ if (type (ColorR1) ~= "number") then
+ ColorR2, ColorG2, ColorB2, ColorA2, fontSize, fontFace, fontFlag = ColorG1, ColorB1, ColorA1, ColorR2, ColorG2, ColorB2, ColorA2
+
+ if (type (ColorR1) == "boolean" or not ColorR1) then
+ ColorR1, ColorG1, ColorB1, ColorA1 = 0, 0, 0, 0
+ else
+ ColorR1, ColorG1, ColorB1, ColorA1 = DF:ParseColors (ColorR1)
+ end
+ end
+
+ if (type (ColorR2) ~= "number") then
+ fontSize, fontFace, fontFlag = ColorG2, ColorB2, ColorA2
+
+ if (type (ColorR2) == "boolean" or not ColorR2) then
+ ColorR2, ColorG2, ColorB2, ColorA2 = 0, 0, 0, 0
+ else
+ ColorR2, ColorG2, ColorB2, ColorA2 = DF:ParseColors (ColorR2)
+ end
+ end
+
+ local frameTableLeft
+ local frameTableRight
+ local lineTable_left
+ local lineTable_right
+
+ if (not frame or (type (frame) == "string" and frame == "main") or (type (frame) == "number" and frame == 1)) then
+
+ CoolTip.Indexes = CoolTip.Indexes + 1
+
+ if (not CoolTip.IndexesSub [CoolTip.Indexes]) then
+ CoolTip.IndexesSub [CoolTip.Indexes] = 0
+ end
+
+ CoolTip.SubIndexes = 0
+
+ frameTableLeft = CoolTip.LeftTextTable
+ frameTableRight = CoolTip.RightTextTable
+
+ if (CoolTip.isSpecial) then
+ lineTable_left = {}
+ _table_insert (frameTableLeft, CoolTip.Indexes, lineTable_left)
+ lineTable_right = {}
+ _table_insert (frameTableRight, CoolTip.Indexes, lineTable_right)
+ else
+ lineTable_left = frameTableLeft [CoolTip.Indexes]
+ lineTable_right = frameTableRight [CoolTip.Indexes]
+
+ if (not lineTable_left) then
+ lineTable_left = {}
+ _table_insert (frameTableLeft, CoolTip.Indexes, lineTable_left)
+ end
+ if (not lineTable_right) then
+ lineTable_right = {}
+ _table_insert (frameTableRight, CoolTip.Indexes, lineTable_right)
+ end
+ end
+
+ elseif ((type (frame) == "string" and frame == "sub") or (type (frame) == "number" and frame == 2)) then
+
+ CoolTip.SubIndexes = CoolTip.SubIndexes + 1
+ CoolTip.IndexesSub [CoolTip.Indexes] = CoolTip.IndexesSub [CoolTip.Indexes] + 1
+ CoolTip.HaveSubMenu = true
+
+ frameTableLeft = CoolTip.LeftTextTableSub
+ frameTableRight = CoolTip.RightTextTableSub
+
+ local subMenuContainerTexts = frameTableLeft [CoolTip.Indexes]
+ if (not subMenuContainerTexts) then
+ subMenuContainerTexts = {}
+ _table_insert (frameTableLeft, CoolTip.Indexes, subMenuContainerTexts)
+ end
+
+ if (CoolTip.isSpecial) then
+ lineTable_left = {}
+ _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_left)
+ else
+ lineTable_left = subMenuContainerTexts [CoolTip.SubIndexes]
+ if (not lineTable_left) then
+ lineTable_left = {}
+ --subMenuContainerTexts [CoolTip.SubIndexes] = lineTable_left
+ _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_left)
+ end
+ end
+
+ local subMenuContainerTexts = frameTableRight [CoolTip.Indexes]
+ if (not subMenuContainerTexts) then
+ subMenuContainerTexts = {}
+ _table_insert (frameTableRight, CoolTip.Indexes, subMenuContainerTexts)
+ --frameTableRight [CoolTip.Indexes] = subMenuContainerTexts
+ end
+
+ if (CoolTip.isSpecial) then
+ lineTable_right = {}
+ _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_right)
+ else
+ lineTable_right = subMenuContainerTexts [CoolTip.SubIndexes]
+ if (not lineTable_right) then
+ lineTable_right = {}
+ _table_insert (subMenuContainerTexts, CoolTip.SubIndexes, lineTable_right)
+ --subMenuContainerTexts [CoolTip.SubIndexes] = lineTable_right
+ end
+ end
+ else
+ return --> error
+ end
+
+ lineTable_left [1] = leftText --> line text
+ lineTable_left [2] = ColorR1
+ lineTable_left [3] = ColorG1
+ lineTable_left [4] = ColorB1
+ lineTable_left [5] = ColorA1
+ lineTable_left [6] = fontSize
+ lineTable_left [7] = fontFace
+ lineTable_left [8] = fontFlag
+
+ lineTable_right [1] = rightText --> line text
+ lineTable_right [2] = ColorR2
+ lineTable_right [3] = ColorG2
+ lineTable_right [4] = ColorB2
+ lineTable_right [5] = ColorA2
+ lineTable_right [6] = fontSize
+ lineTable_right [7] = fontFace
+ lineTable_right [8] = fontFlag
+ end
+
+ function CoolTip:AddSpecial (widgetType, index, subIndex, ...)
+
+ local currentIndex = CoolTip.Indexes
+ local currentSubIndex = CoolTip.SubIndexes
+ CoolTip.isSpecial = true
+
+ widgetType = string.lower (widgetType)
+
+ if (widgetType == "line") then
+
+ if (subIndex) then
+ CoolTip.Indexes = index
+ CoolTip.SubIndexes = subIndex-1
+ else
+ CoolTip.Indexes = index-1
+ end
+
+ CoolTip:AddLine (...)
+
+ if (subIndex) then
+ CoolTip.Indexes = currentIndex
+ CoolTip.SubIndexes = currentSubIndex+1
+ else
+ CoolTip.Indexes = currentIndex+1
+ end
+
+ elseif (widgetType == "icon") then
+
+ CoolTip.Indexes = index
+ if (subIndex) then
+ CoolTip.SubIndexes = subIndex
+ end
+
+ CoolTip:AddIcon (...)
+
+ CoolTip.Indexes = currentIndex
+ if (subIndex) then
+ CoolTip.SubIndexes = currentSubIndex
+ end
+
+ elseif (widgetType == "statusbar") then
+
+ CoolTip.Indexes = index
+ if (subIndex) then
+ CoolTip.SubIndexes = subIndex
+ end
+
+ CoolTip:AddStatusBar (...)
+
+ CoolTip.Indexes = currentIndex
+ if (subIndex) then
+ CoolTip.SubIndexes = currentSubIndex
+ end
+
+ elseif (widgetType == "menu") then
+
+ CoolTip.Indexes = index
+ if (subIndex) then
+ CoolTip.SubIndexes = subIndex
+ end
+
+ CoolTip:AddMenu (...)
+
+ CoolTip.Indexes = currentIndex
+ if (subIndex) then
+ CoolTip.SubIndexes = currentSubIndex
+ end
+
+ end
+
+ CoolTip.isSpecial = false
+
+ end
+
+ --> search key: ~fromline
+ function CoolTip:AddFromTable (_table)
+ for index, menu in _ipairs (_table) do
+ if (menu.func) then
+ CoolTip:AddMenu (menu.type or 1, menu.func, menu.param1, menu.param2, menu.param3, nil, menu.icon)
+ elseif (menu.statusbar) then
+ CoolTip:AddStatusBar (menu.value, menu.type or 1, menu.color, true)
+ elseif (menu.icon) then
+ CoolTip:AddIcon (menu.icon, menu.type or 1, menu.side or 1, menu.width, menu.height, menu.l, menu.r, menu.t, menu.b, menu.color)
+ elseif (menu.textleft or menu.textright or menu.text) then
+ CoolTip:AddLine (menu.text, "", menu.type, menu.color, menu.color)
+ end
+ end
+ end
+
+----------------------------------------------------------------------
+ --> show cooltip
+
+ --> serach key: ~start
+ function CoolTip:Show (frame, menuType, color)
+ return CoolTip:ShowCooltip (frame, menuType, color)
+ end
+
+ function CoolTip:ShowCooltip (frame, menuType, color)
+
+ if (frame) then
+ --> details framework
+ if (frame.dframework) then
+ frame = frame.widget
+ end
+ CoolTip:SetHost (frame)
+ end
+ if (menuType) then
+ CoolTip:SetType (menuType)
+ end
+ if (color) then
+ CoolTip:SetColor (1, color)
+ CoolTip:SetColor (2, color)
+ end
+
+ if (CoolTip.Type == 1 or CoolTip.Type == 2) then
+ return CoolTip:monta_tooltip()
+
+ elseif (CoolTip.Type == 3) then
+ return CoolTip:monta_cooltip()
+
+ end
+ end
+
+ local emptyOptions = {}
+
+ function CoolTip:Hide()
+ return CoolTip:Close()
+ end
+
+ function CoolTip:Close()
+ CoolTip.active = false
+ CoolTip.Host = nil
+ DF:Fade (frame1, 1)
+ DF:Fade (frame2, 1)
+
+ end
+
+ --> old function call
+ function CoolTip:ShowMe (host, arg2)
+ --> ignore if mouse is up me
+ if (CoolTip.mouseOver) then
+ return
+ end
+
+ if (not host or not arg2) then --> hideme
+ CoolTip:Close()
+ end
+ end
+
+ --> search key: ~inject
+ function CoolTip:ExecFunc (host, fromClick)
+
+ if (host.dframework) then
+ if (not host.widget.CoolTip) then
+ host.widget.CoolTip = host.CoolTip
+ end
+ host = host.widget
+ end
+
+ CoolTip:Reset()
+ CoolTip:SetType (host.CoolTip.Type)
+ CoolTip:SetFixedParameter (host.CoolTip.FixedValue)
+ CoolTip:SetColor ("main", host.CoolTip.MainColor or "transparent")
+ CoolTip:SetColor ("sec", host.CoolTip.SubColor or "transparent")
+
+ CoolTip:SetOwner (host, host.CoolTip.MyAnchor, host.CoolTip.HisAnchor, host.CoolTip.X, host.CoolTip.Y)
+
+ local options = host.CoolTip.Options
+ if (type (options) == "function") then
+ options = options()
+ end
+ if (options) then
+ for optionName, optionValue in pairs (options) do
+ CoolTip:SetOption (optionName, optionValue)
+ end
+ end
+
+ host.CoolTip.BuildFunc()
+
+ if (CoolTip.Indexes == 0) then
+ if (host.CoolTip.Default) then
+ CoolTip:SetType ("tooltip")
+ CoolTip:AddLine (host.CoolTip.Default, nil, 1, "white")
+ end
+ end
+
+ CoolTip:ShowCooltip()
+
+ if (fromClick) then
+ --UIFrameFlash (frame1, )
+ frame1:Flash (0.05, 0.05, 0.2, true, 0, 0)
+ end
+ end
+
+ local wait = 0.2
+
+ local InjectOnUpdateEnter = function (self, elapsed)
+ elapsedTime = elapsedTime+elapsed
+ if (elapsedTime > wait) then
+ self:SetScript ("OnUpdate", nil)
+ CoolTip:ExecFunc (self)
+ end
+ end
+
+ local InjectOnUpdateLeave = function (self, elapsed)
+ elapsedTime = elapsedTime+elapsed
+ if (elapsedTime > 0.2) then
+ if (not CoolTip.mouseOver and not CoolTip.buttonOver and self == CoolTip.Host) then
+ CoolTip:ShowMe (false)
+ end
+ self:SetScript ("OnUpdate", nil)
+ end
+ end
+
+ local InjectOnLeave = function (self)
+ CoolTip.buttonOver = false
+
+ if (CoolTip.active) then
+ elapsedTime = 0
+ self:SetScript ("OnUpdate", InjectOnUpdateLeave)
+ else
+ self:SetScript ("OnUpdate", nil)
+ end
+
+ if (self.CoolTip.OnLeaveFunc) then
+ self.CoolTip.OnLeaveFunc (self)
+ end
+
+ if (self.OldOnLeaveScript) then
+ self:OldOnLeaveScript()
+ end
+ end
+
+ local InjectOnEnter = function (self)
+ CoolTip.buttonOver = true
+ if (CoolTip.active) then
+ CoolTip:ExecFunc (self)
+ else
+ elapsedTime = 0
+ wait = self.CoolTip.ShowSpeed or 0.2
+ self:SetScript ("OnUpdate", InjectOnUpdateEnter)
+ end
+
+ if (self.CoolTip.OnEnterFunc) then
+ self.CoolTip.OnEnterFunc (self)
+ end
+
+ if (self.OldOnEnterScript) then
+ self:OldOnEnterScript()
+ end
+ end
+
+ function CoolTip:CoolTipInject (host, openOnClick)
+ if (host.dframework) then
+ if (not host.widget.CoolTip) then
+ host.widget.CoolTip = host.CoolTip
+ end
+ host = host.widget
+ end
+
+ local coolTable = host.CoolTip
+ if (not coolTable) then
+ print ("Host nao tem uma CoolTable.")
+ return false
+ end
+
+ host.OldOnEnterScript = host:GetScript ("OnEnter")
+ host.OldOnLeaveScript = host:GetScript ("OnLeave")
+
+ host:SetScript ("OnEnter", InjectOnEnter)
+ host:SetScript ("OnLeave", InjectOnLeave)
+
+ if (openOnClick) then
+ if (host:GetObjectType() == "Button") then
+ host:SetScript ("OnClick", function() CoolTip:ExecFunc (host, true) end)
+ end
+ end
+
+ return ture
+ end
+
+ --> all done
+ CoolTip:ClearAllOptions()
+
+ local preset2_backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], edgeFile = DF.folder .. "border_3", tile=true,
+ edgeSize = 16, tileSize = 64, insets = {left = 3, right = 3, top = 4, bottom = 4}}
+
+ local white_table = {1, 1, 1, 1}
+
+ function CoolTip:Preset (number)
+ self:Reset()
+
+ if (number == 1) then
+ self:SetOption ("TextFont", "Friz Quadrata TT")
+ self:SetOption ("TextColor", "orange")
+ self:SetOption ("TextSize", 12)
+ self:SetOption ("ButtonsYMod", -4)
+ self:SetOption ("YSpacingMod", -4)
+ self:SetOption ("IgnoreButtonAutoHeight", true)
+ self:SetColor (1, 0.5, 0.5, 0.5, 0.5)
+
+ elseif (number == 2) then
+ self:SetOption ("TextFont", "Friz Quadrata TT")
+ self:SetOption ("TextColor", "orange")
+ self:SetOption ("TextSize", 12)
+ self:SetOption ("FixedWidth", 220)
+ self:SetOption ("ButtonsYMod", -4)
+ self:SetOption ("YSpacingMod", -4)
+ self:SetOption ("IgnoreButtonAutoHeight", true)
+ self:SetColor (1, 0.5, 0.5, 0.5, 0.5)
+
+ self:SetBackdrop (1, preset2_backdrop, nil, white_table)
+ end
+ end
+
+ return CoolTip
+
+end
+
+DF:CreateCoolTip()
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/cooltip.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/cooltip.xml Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,318 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ self:SetBackdropColor (0.09019, 0.09019, 0.18823, 1)
+ self:SetBackdropBorderColor (1, 1, 1, 1)
+ self.framebackgroundLeft:SetWidth (32)
+ self.framebackgroundRight:SetWidth (32)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/cooltip_background.tga
Binary file Libs/DF/cooltip_background.tga has changed
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/dropdown.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/dropdown.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,950 @@
+
+local DF = _G ["DetailsFramework"]
+local _
+
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+local loadstring = loadstring --> lua local
+local _string_len = string.len --> lua local
+
+local cleanfunction = function() end
+local APIDropDownFunctions = false
+local DropDownMetaFunctions = {}
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ DropDownMetaFunctions.__call = function (_table, value)
+ --> unknow
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> selected value
+ local gmember_value = function (_object)
+ return _object:GetValue()
+ end
+ --> tooltip
+ local gmember_tooltip = function (_object)
+ return _object:GetTooltip()
+ end
+ --> shown
+ local gmember_shown = function (_object)
+ return _object:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.button:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.button:GetHeight()
+ end
+ --> current text
+ local gmember_text = function (_object)
+ return _object.label:GetText()
+ end
+ --> menu creation function
+ local gmember_function = function (_object)
+ return _object:GetFunction()
+ end
+ --> menu width
+ local gmember_menuwidth = function (_object)
+ return _rawget (self, "realsizeW")
+ end
+ --> menu height
+ local gmember_menuheight = function (_object)
+ return _rawget (self, "realsizeH")
+ end
+
+ local get_members_function_index = {
+ ["value"] = gmember_value,
+ ["text"] = gmember_text,
+ ["shown"] = gmember_shown,
+ ["width"] = gmember_width,
+ ["menuwidth"] = gmember_menuwidth,
+ ["height"] = gmember_height,
+ ["menuheight"] = gmember_menuheight,
+ ["tooltip"] = gmember_tooltip,
+ ["func"] = gmember_function,
+ }
+
+ DropDownMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = get_members_function_index [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return DropDownMetaFunctions [_member_requested]
+ end
+
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ --> tooltip
+ local smember_tooltip = function (_object, _value)
+ return _object:SetTooltip (_value)
+ end
+ --> show
+ local smember_show = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (not _value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> frame width
+ local smember_width = function (_object, _value)
+ return _object.dropdown:SetWidth (_value)
+ end
+ --> frame height
+ local smember_height = function (_object, _value)
+ return _object.dropdown:SetHeight (_value)
+ end
+ --> menu creation function
+ local smember_function = function (_object, _value)
+ return _object:SetFunction (_value)
+ end
+ --> menu width
+ local smember_menuwidth = function (_object, _value)
+ _object:SetMenuSize (_value, nil)
+ end
+ --> menu height
+ local smember_menuheight = function (_object, _value)
+ _object:SetMenuSize (nil, _value)
+ end
+
+ local set_members_function_index = {
+ ["tooltip"] = smember_tooltip,
+ ["show"] = smember_show,
+ ["hide"] = smember_hide,
+ ["width"] = smember_width,
+ ["menuwidth"] = smember_menuwidth,
+ ["height"] = smember_height,
+ ["menuheight"] = smember_menuheight,
+ ["func"] = smember_function,
+ }
+
+ DropDownMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = set_members_function_index [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+ function DropDownMetaFunctions:IsShown()
+ return self.dropdown:IsShown()
+ end
+ function DropDownMetaFunctions:Show()
+ return self.dropdown:Show()
+ end
+ function DropDownMetaFunctions:Hide()
+ return self.dropdown:Hide()
+ end
+
+--> menu width and height
+ function DropDownMetaFunctions:SetMenuSize (w, h)
+ if (w) then
+ return _rawset (self, "realsizeW", w)
+ end
+ if (h) then
+ return _rawset (self, "realsizeH", h)
+ end
+ end
+ function DropDownMetaFunctions:GetMenuSize()
+ return _rawget (self, "realsizeW"), _rawget (self, "realsizeH")
+ end
+
+--> function
+ function DropDownMetaFunctions:SetFunction (func)
+ return _rawset (self, "func", func)
+ end
+ function DropDownMetaFunctions:GetFunction()
+ return _rawget (self, "func")
+ end
+
+--> value
+ function DropDownMetaFunctions:GetValue()
+ return _rawget (self, "myvalue")
+ end
+ function DropDownMetaFunctions:SetValue (value)
+ return _rawset (self, "myvalue", value)
+ end
+
+--> setpoint
+ function DropDownMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+--> sizes
+ function DropDownMetaFunctions:SetSize (w, h)
+ if (w) then
+ self.dropdown:SetWidth (w)
+ end
+ if (h) then
+ return self.dropdown:SetHeight (h)
+ end
+ end
+
+--> tooltip
+ function DropDownMetaFunctions:SetTooltip (tooltip)
+ if (tooltip) then
+ return _rawset (self, "have_tooltip", tooltip)
+ else
+ return _rawset (self, "have_tooltip", nil)
+ end
+ end
+ function DropDownMetaFunctions:GetTooltip()
+ return _rawget (self, "have_tooltip")
+ end
+
+--> frame levels
+ function DropDownMetaFunctions:GetFrameLevel()
+ return self.dropdown:GetFrameLevel()
+ end
+ function DropDownMetaFunctions:SetFrameLevel (level, frame)
+ if (not frame) then
+ return self.dropdown:SetFrameLevel (level)
+ else
+ local framelevel = frame:GetFrameLevel (frame) + level
+ return self.dropdown:SetFrameLevel (framelevel)
+ end
+ end
+
+--> frame stratas
+ function DropDownMetaFunctions:GetFrameStrata()
+ return self.dropdown:GetFrameStrata()
+ end
+ function DropDownMetaFunctions:SetFrameStrata (strata)
+ if (_type (strata) == "table") then
+ self.dropdown:SetFrameStrata (strata:GetFrameStrata())
+ else
+ self.dropdown:SetFrameStrata (strata)
+ end
+ end
+
+--> enabled
+ function DropDownMetaFunctions:IsEnabled()
+ return self.dropdown:IsEnabled()
+ end
+
+ function DropDownMetaFunctions:Enable()
+
+ self:SetAlpha (1)
+ _rawset (self, "lockdown", false)
+
+ if (self.OnEnable) then
+ self.OnEnable (self)
+ end
+ --return self.dropdown:Enable()
+ end
+
+ function DropDownMetaFunctions:Disable()
+
+ self:SetAlpha (.4)
+ _rawset (self, "lockdown", true)
+
+ if (self.OnDisable) then
+ self.OnDisable (self)
+ end
+ --return self.dropdown:Disable()
+ end
+
+--> fixed value
+ function DropDownMetaFunctions:SetFixedParameter (value)
+ _rawset (self, "FixedValue", value)
+ end
+
+--> hooks
+ function DropDownMetaFunctions:SetHook (hookType, func)
+ if (func) then
+ _rawset (self, hookType.."Hook", func)
+ else
+ _rawset (self, hookType.."Hook", nil)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts
+
+local last_opened = false
+
+local function isOptionVisible (thisOption)
+ if (_type (thisOption.shown) == "boolean" or _type (thisOption.shown) == "function") then
+ if (not thisOption.shown) then
+ return false
+ elseif (not thisOption.shown()) then
+ return false
+ end
+ end
+ return true
+end
+
+function DropDownMetaFunctions:Refresh()
+ local menu = self.func()
+
+ if (#menu == 0) then
+ self:NoOption (true)
+ self.no_options = true
+ return false
+
+ elseif (self.no_options) then
+ self.no_options = false
+ self:NoOption (false)
+ self:NoOptionSelected()
+ return true
+ end
+
+ return true
+end
+
+function DropDownMetaFunctions:NoOptionSelected()
+ self.label:SetText (self.empty_text or "no option selected")
+ self.label:SetTextColor (1, 1, 1, 0.4)
+ if (self.empty_icon) then
+ self.icon:SetTexture (self.empty_icon)
+ else
+ self.icon:SetTexture ([[Interface\COMMON\UI-ModelControlPanel]])
+ self.icon:SetTexCoord (0.625, 0.78125, 0.328125, 0.390625)
+ end
+ self.icon:SetVertexColor (1, 1, 1, 0.4)
+
+ self.last_select = nil
+end
+
+function DropDownMetaFunctions:NoOption (state)
+ if (state) then
+ self:Disable()
+ self:SetAlpha (0.5)
+ self.no_options = true
+ self.label:SetText ("no options")
+ self.label:SetTextColor (1, 1, 1, 0.4)
+ self.icon:SetTexture ([[Interface\CHARACTERFRAME\UI-Player-PlayTimeUnhealthy]])
+ self.icon:SetTexCoord (0, 1, 0, 1)
+ self.icon:SetVertexColor (1, 1, 1, 0.4)
+ else
+ self.no_options = false
+ self:Enable()
+ self:SetAlpha (1)
+ end
+end
+
+function DropDownMetaFunctions:Select (optionName, byOptionNumber)
+
+ if (type (optionName) == "boolean" and not optionName) then
+ self:NoOptionSelected()
+ return false
+ end
+
+ local menu = self.func()
+
+ if (#menu == 0) then
+ self:NoOption (true)
+ return true
+ else
+ self:NoOption (false)
+ end
+
+ if (byOptionNumber and type (optionName) == "number") then
+ if (not menu [optionName]) then --> invalid index
+ self:NoOptionSelected()
+ return false
+ end
+ self:Selected (menu [optionName])
+ return true
+ end
+
+ for _, thisMenu in ipairs (menu) do
+ if ( ( thisMenu.label == optionName or thisMenu.value == optionName ) and isOptionVisible (thisMenu)) then
+ self:Selected (thisMenu)
+ return true
+ end
+ end
+
+ return false
+end
+
+function DropDownMetaFunctions:SetEmptyTextAndIcon (text, icon)
+ if (text) then
+ self.empty_text = text
+ end
+ if (icon) then
+ self.empty_icon = icon
+ end
+
+ self:Selected (self.last_select)
+end
+
+function DropDownMetaFunctions:Selected (_table)
+
+ if (not _table) then
+
+ --> there is any options?
+ if (not self:Refresh()) then
+ self.last_select = nil
+ return
+ end
+
+ --> exists options but none selected
+ self:NoOptionSelected()
+ return
+ end
+
+ self.last_select = _table
+ self:NoOption (false)
+
+ self.label:SetText (_table.label)
+ self.icon:SetTexture (_table.icon)
+
+ if (_table.icon) then
+ self.label:SetPoint ("left", self.icon, "right", 2, 0)
+ if (_table.texcoord) then
+ self.icon:SetTexCoord (unpack (_table.texcoord))
+ else
+ self.icon:SetTexCoord (0, 1, 0, 1)
+ end
+
+ if (_table.iconcolor) then
+ if (type (_table.iconcolor) == "string") then
+ self.icon:SetVertexColor (DF:ParseColors (_table.iconcolor))
+ else
+ self.icon:SetVertexColor (unpack (_table.iconcolor))
+ end
+ else
+ self.icon:SetVertexColor (1, 1, 1, 1)
+ end
+
+ else
+ self.label:SetPoint ("left", self.label:GetParent(), "left", 4, 0)
+ end
+
+ self.statusbar:SetTexture (_table.statusbar)
+
+ if (_table.color) then
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_table.color)
+ self.label:SetTextColor (_value1, _value2, _value3, _value4)
+ else
+ self.label:SetTextColor (1, 1, 1, 1)
+ end
+
+ if (_table.font) then
+ self.label:SetFont (_table.font, 10)
+ else
+ self.label:SetFont ("GameFontHighlightSmall", 10)
+ end
+
+ self:SetValue (_table.value)
+
+end
+
+function DetailsFrameworkDropDownOptionClick (button)
+
+ --> update name and icon on main frame
+ button.object:Selected (button.table)
+
+ --> close menu frame
+ button.object:Close()
+
+ --> exec function if any
+ if (button.table.onclick) then
+ button.table.onclick (button:GetParent():GetParent():GetParent().MyObject, button.object.FixedValue, button.table.value)
+ end
+
+ --> set the value of selected option in main object
+ button.object.myvalue = button.table.value
+end
+
+function DropDownMetaFunctions:Open()
+ self.dropdown.dropdownframe:Show()
+ self.dropdown.dropdownborder:Show()
+ self.dropdown.arrowTexture:SetTexture ("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Down")
+ self.opened = true
+ if (last_opened) then
+ last_opened:Close()
+ end
+ last_opened = self
+end
+
+function DropDownMetaFunctions:Close()
+ --> when menu is being close, just hide the border and the script will call back this again
+ if (self.dropdown.dropdownborder:IsShown()) then
+ self.dropdown.dropdownborder:Hide()
+ return
+ end
+ self.dropdown.dropdownframe:Hide()
+ self.dropdown.arrowTexture:SetTexture ("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Up")
+
+ local selectedTexture = _G [self:GetName() .. "_ScrollFrame_ScrollChild_SelectedTexture"]
+ selectedTexture:Hide()
+
+ self.opened = false
+ last_opened = false
+end
+
+--> close by escape key
+function DetailsFrameworkDropDownOptionsFrameOnHide (frame)
+ frame:GetParent().MyObject:Close()
+end
+
+function DetailsFrameworkDropDownOptionOnEnter (frame)
+ if (frame.table.desc) then
+ DF:CooltipPreset (2)
+ GameCooltip2:AddLine (frame.table.desc)
+ if (frame.table.descfont) then
+ GameCooltip2:SetOption ("TextFont", frame.table.descfont)
+ end
+
+ GameCooltip2:SetHost (frame, "topleft", "topright", 10, 0)
+
+ GameCooltip2:ShowCooltip (nil, "tooltip")
+ frame.tooltip = true
+ end
+ frame:GetParent().mouseover:SetPoint ("left", frame)
+ frame:GetParent().mouseover:Show()
+end
+
+function DetailsFrameworkDropDownOptionOnLeave (frame)
+ if (frame.table.desc) then
+ GameCooltip2:ShowMe (false)
+ end
+ frame:GetParent().mouseover:Hide()
+end
+
+function DetailsFrameworkDropDownOnMouseDown (button)
+
+ local object = button.MyObject
+
+ if (not object.opened and not _rawget (object, "lockdown")) then --> click to open
+
+ local menu = object:func()
+ object.builtMenu = menu
+
+ local frame_witdh = object.realsizeW
+
+ if (menu [1]) then
+ --> build menu
+
+ local scrollFrame = _G [button:GetName() .. "_ScrollFrame"]
+ local scrollChild = _G [button:GetName() .. "_ScrollFrame_ScrollChild"]
+ local scrollBorder = _G [button:GetName() .. "_Border"]
+ local selectedTexture = _G [button:GetName() .. "_ScrollFrame_ScrollChild_SelectedTexture"]
+ local mouseOverTexture = _G [button:GetName() .. "_ScrollFrame_ScrollChild_MouseOverTexture"]
+
+ local i = 1
+ local showing = 0
+ local currentText = button.text:GetText() or ""
+
+ if (object.OnMouseDownHook) then
+ local interrupt = object.OnMouseDownHook (button, buttontype, menu, scrollFrame, scrollChild, selectedTexture)
+ if (interrupt) then
+ return
+ end
+ end
+
+ for _, _table in ipairs (menu) do
+
+ local show = isOptionVisible (_table)
+
+ if (show) then
+ local _this_row = object.menus [i]
+ showing = showing + 1
+
+ if (not _this_row) then
+
+ local name = button:GetName() .. "Row" .. i
+ local parent = scrollChild
+
+ _this_row = CreateFrame ("Button", name, parent, "DetailsFrameworkDropDownOptionTemplate")
+ local anchor_i = i-1
+ _this_row:SetPoint ("topleft", parent, "topleft", 5, (-anchor_i*20)-5)
+ _this_row:SetPoint ("topright", parent, "topright", -5, (-anchor_i*20)-5)
+ _this_row.object = object
+ object.menus [i] = _this_row
+ end
+
+ _this_row.icon:SetTexture (_table.icon)
+ if (_table.icon) then
+
+ _this_row.label:SetPoint ("left", _this_row.icon, "right", 5, 0)
+
+ if (_table.texcoord) then
+ _this_row.icon:SetTexCoord (unpack (_table.texcoord))
+ else
+ _this_row.icon:SetTexCoord (0, 1, 0, 1)
+ end
+
+ if (_table.iconcolor) then
+ if (type (_table.iconcolor) == "string") then
+ _this_row.icon:SetVertexColor (DF:ParseColors (_table.iconcolor))
+ else
+ _this_row.icon:SetVertexColor (unpack (_table.iconcolor))
+ end
+ else
+ _this_row.icon:SetVertexColor (1, 1, 1, 1)
+ end
+ else
+ _this_row.label:SetPoint ("left", _this_row.statusbar, "left", 2, 0)
+ end
+
+ if (_table.iconsize) then
+ _this_row.icon:SetSize (_table.iconsize[1], _table.iconsize[2])
+ else
+ _this_row.icon:SetSize (20, 20)
+ end
+
+ if (_table.font) then
+ _this_row.label:SetFont (_table.font, 10.5)
+ else
+ _this_row.label:SetFont ("GameFontHighlightSmall", 10.5)
+ end
+
+ _this_row.statusbar:SetTexture (_table.statusbar)
+ _this_row.label:SetText (_table.label)
+
+ if (currentText and currentText == _table.label) then
+ if (_table.icon) then
+ selectedTexture:SetPoint ("left", _this_row.icon, "left", -3, 0)
+ else
+ selectedTexture:SetPoint ("left", _this_row.statusbar, "left", 0, 0)
+ end
+
+ selectedTexture:Show()
+ selectedTexture:SetVertexColor (1, 1, 1, .3);
+ currentText = nil
+ end
+
+ if (_table.color) then
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_table.color)
+ _this_row.label:SetTextColor (_value1, _value2, _value3, _value4)
+ else
+ _this_row.label:SetTextColor (1, 1, 1, 1)
+ end
+
+ _this_row.table = _table
+
+ local labelwitdh = _this_row.label:GetStringWidth()
+ if (labelwitdh+40 > frame_witdh) then
+ frame_witdh = labelwitdh+40
+ end
+ _this_row:Show()
+
+ i = i + 1
+ end
+
+ end
+
+ if (currentText) then
+ selectedTexture:Hide()
+ else
+ selectedTexture:SetWidth (frame_witdh-20)
+ end
+
+ for i = showing+1, #object.menus do
+ object.menus [i]:Hide()
+ end
+
+ local size = object.realsizeH
+
+ if (showing*20 > size) then
+ --show scrollbar and setup scroll
+ object:ShowScroll()
+ scrollFrame:EnableMouseWheel (true)
+ object.scroll:Altura (size-35)
+ object.scroll:SetMinMaxValues (0, (showing*20) - size + 20)
+ --width
+ scrollBorder:SetWidth (frame_witdh+20)
+ scrollFrame:SetWidth (frame_witdh+20)
+ scrollChild:SetWidth (frame_witdh+20)
+ --height
+ scrollBorder:SetHeight (size+20)
+ scrollFrame:SetHeight (size)
+ scrollChild:SetHeight ((showing*20)+20)
+ --mouse over texture
+ mouseOverTexture:SetWidth (frame_witdh-7)
+ --selected
+ selectedTexture:SetWidth (frame_witdh - 9)
+
+ for index, row in ipairs (object.menus) do
+ row:SetPoint ("topright", scrollChild, "topright", -22, ((-index-1)*20)-5)
+ end
+
+ else
+ --hide scrollbar and disable wheel
+ object:HideScroll()
+ scrollFrame:EnableMouseWheel (false)
+ --width
+ scrollBorder:SetWidth (frame_witdh)
+ scrollFrame:SetWidth (frame_witdh)
+ scrollChild:SetWidth (frame_witdh)
+ --height
+ scrollBorder:SetHeight ((showing*20) + 25)
+ scrollFrame:SetHeight ((showing*20) + 25)
+ --mouse over texture
+ mouseOverTexture:SetWidth (frame_witdh-10)
+ --selected
+ selectedTexture:SetWidth (frame_witdh - 9)
+
+ for index, row in ipairs (object.menus) do
+ row:SetPoint ("topright", scrollChild, "topright", -5, ((-index-1)*20)-5)
+ end
+ end
+
+ object.scroll:SetValue (0)
+ object:Open()
+
+ else
+ --> clear menu
+
+ end
+
+ else --> click to close
+
+ object:Close()
+ end
+
+end
+
+function DetailsFrameworkDropDownOnEnter (self)
+
+ if (self.MyObject.OnEnterHook) then
+ local interrupt = self.MyObject.OnEnterHook (self)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (self.MyObject.onenter_backdrop) then
+ self:SetBackdropColor (unpack (self.MyObject.onenter_backdrop))
+ else
+ self:SetBackdropColor (.2, .2, .2, .2)
+ end
+
+ self.arrowTexture2:Show()
+
+ if (self.MyObject.have_tooltip) then
+ GameCooltip2:Reset()
+ GameCooltip2:SetType ("tooltip")
+ GameCooltip2:SetColor ("main", "transparent")
+ DF:CooltipPreset (2)
+ GameCooltip2:AddLine (self.MyObject.have_tooltip)
+ GameCooltip2:SetOwner (self)
+ GameCooltip2:ShowCooltip()
+ end
+
+ local parent = self:GetParent().MyObject
+ if (parent and parent.type == "panel") then
+ if (parent.GradientEnabled) then
+ parent:RunGradient()
+ end
+ end
+
+end
+
+function DetailsFrameworkDropDownOnLeave (self)
+ if (self.MyObject.OnLeaveHook) then
+ local interrupt = self.MyObject.OnLeaveHook (self)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (self.MyObject.onleave_backdrop) then
+ self:SetBackdropColor (unpack (self.MyObject.onleave_backdrop))
+ else
+ self:SetBackdropColor (1, 1, 1, .5)
+ end
+
+ self.arrowTexture2:Hide()
+
+ if (self.MyObject.have_tooltip) then
+ GameCooltip2:ShowMe (false)
+ end
+
+ local parent = self:GetParent().MyObject
+ if (parent and parent.type == "panel") then
+ if (parent.GradientEnabled) then
+ parent:RunGradient (false)
+ end
+ end
+end
+
+function DetailsFrameworkDropDownOnSizeChanged (self, w, h)
+ self.MyObject.label:SetSize (self:GetWidth()-40, 10)
+end
+
+function DetailsFrameworkDropDownOnShow (self)
+ if (self.MyObject and self.MyObject.OnShowHook) then
+ local interrupt = self.MyObject.OnShowHook (self)
+ if (interrupt) then
+ return
+ end
+ end
+end
+
+function DetailsFrameworkDropDownOnHide (self)
+ if (self.MyObject and self.MyObject.OnHideHook) then
+ local interrupt = self.MyObject.OnHideHook (self)
+ if (interrupt) then
+ return
+ end
+ end
+
+ self.MyObject:Close()
+end
+
+
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+
+function DF:CreateDropDown (parent, func, default, w, h, member, name)
+ return DF:NewDropDown (parent, parent, name, member, w, h, func, default)
+end
+
+function DF:NewDropDown (parent, container, name, member, w, h, func, default)
+
+ if (not name) then
+ name = "DetailsFrameworkDropDownNumber" .. DF.DropDownCounter
+ DF.DropDownCounter = DF.DropDownCounter + 1
+
+ elseif (not parent) then
+ return nil
+ end
+ if (not container) then
+ container = parent
+ end
+
+ if (name:find ("$parent")) then
+ name = name:gsub ("$parent", parent:GetName())
+ end
+
+ local DropDownObject = {type = "dropdown", dframework = true}
+
+ if (member) then
+ parent [member] = DropDownObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+ if (default == nil) then
+ default = 1
+ end
+
+ --> default members:
+ --> hooks
+ DropDownObject.OnEnterHook = nil
+ DropDownObject.OnLeaveHook = nil
+ DropDownObject.OnHideHook = nil
+ DropDownObject.OnShowHook = nil
+ DropDownObject.OnMouseDownHook = nil
+ --> misc
+ DropDownObject.container = container
+ DropDownObject.have_tooltip = nil
+
+ DropDownObject.dropdown = CreateFrame ("Button", name, parent, "DetailsFrameworkDropDownTemplate")
+ DropDownObject.widget = DropDownObject.dropdown
+
+ DropDownObject.__it = {nil, nil}
+ --_G [name] = DropDownObject
+
+ if (not APIDropDownFunctions) then
+ APIDropDownFunctions = true
+ local idx = getmetatable (DropDownObject.dropdown).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not DropDownMetaFunctions [funcName]) then
+ DropDownMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G."..object.dropdown:GetName()..":"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ DropDownObject.dropdown.MyObject = DropDownObject
+
+ DropDownObject.dropdown:SetWidth (w)
+ DropDownObject.dropdown:SetHeight (h)
+
+ DropDownObject.func = func
+ DropDownObject.realsizeW = 150
+ DropDownObject.realsizeH = 150
+ DropDownObject.FixedValue = nil
+ DropDownObject.opened = false
+ DropDownObject.menus = {}
+ DropDownObject.myvalue = nil
+
+ DropDownObject.label = _G [name .. "_Text"]
+
+ DropDownObject.icon = _G [name .. "_IconTexture"]
+ DropDownObject.statusbar = _G [name .. "_StatusBarTexture"]
+ DropDownObject.select = _G [name .. "_SelectedTexture"]
+
+ local scroll = _G [DropDownObject.dropdown:GetName() .. "_ScrollFrame"]
+
+ DropDownObject.scroll = DF:NewScrollBar (scroll, _G [DropDownObject.dropdown:GetName() .. "_ScrollFrame".."_ScrollChild"], -25, -18)
+
+ function DropDownObject:HideScroll()
+ scroll.baixo:Hide()
+ scroll.cima:Hide()
+ scroll.slider:Hide()
+ end
+ function DropDownObject:ShowScroll()
+ scroll.baixo:Show()
+ scroll.cima:Show()
+ scroll.slider:Show()
+ end
+
+ --button_down_scripts (DropDownObject, scroll.slider, scroll.baixo)
+
+ DropDownObject:HideScroll()
+ DropDownObject.label:SetSize (DropDownObject.dropdown:GetWidth()-40, 10)
+
+ --> setup class
+ _setmetatable (DropDownObject, DropDownMetaFunctions)
+
+ --> initialize first menu selected
+
+ if (type (default) == "string") then
+ DropDownObject:Select (default)
+
+ elseif (type (default) == "number") then
+ if (not DropDownObject:Select (default)) then
+ DropDownObject:Select (default, true)
+ end
+ end
+
+ return DropDownObject
+
+end
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/dropdown.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/dropdown.xml Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,241 @@
+
+
+
+
+
+
+
+
+
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/feedback_sites.tga
Binary file Libs/DF/feedback_sites.tga has changed
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/fw.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/fw.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,763 @@
+
+local major, minor = "DetailsFramework-1.0", 2
+local DF, oldminor = LibStub:NewLibrary (major, minor)
+
+
+if (not DF) then
+ return
+end
+
+local _type = type
+local _unpack = unpack
+local _
+local upper = string.upper
+
+DF.LabelNameCounter = 1
+DF.PictureNameCounter = 1
+DF.BarNameCounter = 1
+DF.DropDownCounter = 1
+DF.PanelCounter = 1
+DF.ButtonCounter = 1
+DF.SliderCounter = 1
+DF.SplitBarCounter = 1
+
+do
+ local path = string.match (debugstack (1, 1, 0), "AddOns\\(.+)fw.lua")
+ if (path) then
+ DF.folder = "Interface\\AddOns\\" .. path
+ else
+ DF.folder = ""
+ end
+end
+
+DF.debug = false
+
+_G ["DetailsFramework"] = DF
+
+DF.embeds = DF.embeds or {}
+local embed_functions = {
+ "SetFontSize",
+ "SetFontFace",
+ "SetFontColor",
+ "GetFontSize",
+ "GetFontFace",
+ "trim",
+ "Msg",
+ "CreateFlashAnimation",
+ "Fade",
+ "NewColor",
+ "IsHtmlColor",
+ "ParseColors",
+ "BuildMenu",
+ "ShowTutorialAlertFrame",
+ "GetNpcIdFromGuid",
+ "ShowFeedbackPanel",
+
+ "CreateDropDown",
+ "CreateButton",
+ "CreateColorPickButton",
+ "CreateLabel",
+ "CreateBar",
+ "CreatePanel",
+ "CreateFillPanel",
+ "ColorPick",
+ "IconPick",
+ "CreateSimplePanel",
+ "CreateChartPanel",
+ "CreateImage",
+ "CreateScrollBar",
+ "CreateSwitch",
+ "CreateSlider",
+ "CreateSplitBar",
+ "CreateTextEntry",
+ "Create1PxPanel",
+ "CreateFeedbackButton",
+
+ "www_icons",
+}
+
+DF.www_icons = {
+ texture = "feedback_sites",
+ wowi = {0, 0.7890625, 0, 37/128},
+ curse = {0, 0.7890625, 38/123, 79/128},
+ mmoc = {0, 0.7890625, 80/123, 123/128},
+}
+
+function DF:Embed (target)
+ for k, v in pairs (embed_functions) do
+ target[v] = self[v]
+ end
+ self.embeds [target] = true
+ return target
+end
+
+function DF:SetFontSize (fontString, ...)
+ local fonte, _, flags = fontString:GetFont()
+ fontString:SetFont (fonte, max (...), flags)
+end
+function DF:SetFontFace (fontString, fontface)
+ local _, size, flags = fontString:GetFont()
+ fontString:SetFont (fontface, size, flags)
+end
+function DF:SetFontColor (fontString, r, g, b, a)
+ r, g, b, a = DF:ParseColors (r, g, b, a)
+ fontString:SetTextColor (r, g, b, a)
+end
+
+function DF:GetFontSize (fontString)
+ local _, size = fontString:GetFont()
+ return size
+end
+function DF:GetFontFace (fontString)
+ local fontface = fontString:GetFont()
+ return fontface
+end
+
+function DF:SetFontOutline (fontString, outline)
+ local fonte, size = fontString:GetFont()
+ if (outline) then
+ if (_type (outline) == "boolean" and outline) then
+ outline = "OUTLINE"
+ elseif (outline == 1) then
+ outline = "OUTLINE"
+ elseif (outline == 2) then
+ outline = "THICKOUTLINE"
+ end
+ end
+
+ fontString:SetFont (fonte, size, outline)
+end
+
+function DF:trim (s)
+ local from = s:match"^%s*()"
+ return from > #s and "" or s:match(".*%S", from)
+end
+
+function DF:Msg (msg)
+ print ("|cFFFFFFAA" .. self.__name .. "|r " .. msg)
+end
+
+function DF:GetNpcIdFromGuid (guid)
+ local NpcId = select ( 6, strsplit ( "-", guid ) )
+ if (NpcId) then
+ return tonumber ( NpcId )
+ end
+ return 0
+end
+
+local onFinish = function (self)
+ if (self.showWhenDone) then
+ self.frame:SetAlpha (1)
+ else
+ self.frame:SetAlpha (0)
+ self.frame:Hide()
+ end
+
+ if (self.onFinishFunc) then
+ self:onFinishFunc (self.frame)
+ end
+end
+
+local stop = function (self)
+ local FlashAnimation = self.FlashAnimation
+ FlashAnimation:Stop()
+end
+
+local flash = function (self, fadeInTime, fadeOutTime, flashDuration, showWhenDone, flashInHoldTime, flashOutHoldTime, loopType)
+
+ local FlashAnimation = self.FlashAnimation
+
+ local fadeIn = FlashAnimation.fadeIn
+ local fadeOut = FlashAnimation.fadeOut
+
+ fadeIn:Stop()
+ fadeOut:Stop()
+
+ fadeIn:SetDuration (fadeInTime or 1)
+ fadeIn:SetEndDelay (flashInHoldTime or 0)
+
+ fadeOut:SetDuration (fadeOutTime or 1)
+ fadeOut:SetEndDelay (flashOutHoldTime or 0)
+
+ FlashAnimation.duration = flashDuration
+ FlashAnimation.loopTime = FlashAnimation:GetDuration()
+ FlashAnimation.finishAt = GetTime() + flashDuration
+ FlashAnimation.showWhenDone = showWhenDone
+
+ FlashAnimation:SetLooping (loopType or "REPEAT")
+
+ self:Show()
+ self:SetAlpha (0)
+ FlashAnimation:Play()
+end
+
+function DF:CreateFlashAnimation (frame, onFinishFunc, onLoopFunc)
+ local FlashAnimation = frame:CreateAnimationGroup()
+
+ FlashAnimation.fadeOut = FlashAnimation:CreateAnimation ("Alpha") --> fade out anime
+ FlashAnimation.fadeOut:SetOrder (1)
+ FlashAnimation.fadeOut:SetChange (1)
+
+ FlashAnimation.fadeIn = FlashAnimation:CreateAnimation ("Alpha") --> fade in anime
+ FlashAnimation.fadeIn:SetOrder (2)
+ FlashAnimation.fadeIn:SetChange (-1)
+
+ frame.FlashAnimation = FlashAnimation
+ FlashAnimation.frame = frame
+ FlashAnimation.onFinishFunc = onFinishFunc
+
+ FlashAnimation:SetScript ("OnLoop", onLoopFunc)
+ FlashAnimation:SetScript ("OnFinished", onFinish)
+
+ frame.Flash = flash
+ frame.Stop = stop
+end
+
+-----------------------------------------
+
+local fade_IN_finished_func = function (frame)
+ if (frame.fading_in) then
+ frame.hidden = true
+ frame.faded = true
+ frame.fading_in = false
+ frame:Hide()
+ end
+end
+
+local fade_OUT_finished_func = function (frame)
+ if (frame:IsShown() and frame.fading_out) then
+ frame.hidden = false
+ frame.faded = false
+ frame.fading_out = false
+ else
+ frame:SetAlpha(0)
+ end
+end
+
+local just_fade_func = function (frame)
+ frame.hidden = false
+ frame.faded = true
+ frame.fading_in = false
+end
+
+local anim_OUT_alpha_func = function (frame)
+ frame.fading_out = false
+end
+
+local anim_IN_alpha_func = function (frame)
+ frame.fading_in = false
+end
+
+function DF:Fade (frame, tipo, velocidade, parametros)
+
+ if (_type (frame) == "table") then
+ if (frame.dframework) then
+ frame = frame.widget
+ end
+ end
+
+ velocidade = velocidade or 0.3
+
+ if (upper (tipo) == "IN") then
+
+ if (frame:GetAlpha() == 0 and frame.hidden and not frame.fading_out) then --> ja esta escondida
+ return
+ elseif (frame.fading_in) then --> ja esta com uma animação, se for true
+ return
+ end
+
+ if (frame.fading_out) then --> se tiver uma animação de aparecer em andamento se for true
+ frame.fading_out = false
+ end
+
+ UIFrameFadeIn (frame, velocidade, frame:GetAlpha(), 0)
+ frame.fading_in = true
+
+ frame.fadeInfo.finishedFunc = fade_IN_finished_func
+ frame.fadeInfo.finishedArg1 = frame
+
+ elseif (upper (tipo) == "OUT") then --> aparecer
+ if (frame:GetAlpha() == 1 and not frame.hidden and not frame.fading_in) then --> ja esta na tela
+ return
+ elseif (frame.fading_out) then --> já ta com fading out
+ return
+ end
+
+ if (frame.fading_in) then --> se tiver uma animação de hidar em andamento se for true
+ frame.fading_in = false
+ end
+
+ frame:Show()
+ UIFrameFadeOut (frame, velocidade, frame:GetAlpha(), 1.0)
+ frame.fading_out = true
+
+ frame.fadeInfo.finishedFunc = fade_OUT_finished_func
+ frame.fadeInfo.finishedArg1 = frame
+
+ elseif (tipo == 0) then --> força o frame a ser mostrado
+ frame.hidden = false
+ frame.faded = false
+ frame.fading_out = false
+ frame.fading_in = false
+ frame:Show()
+ frame:SetAlpha (1)
+
+ elseif (tipo == 1) then --> força o frame a ser hidado
+ frame.hidden = true
+ frame.faded = true
+ frame.fading_out = false
+ frame.fading_in = false
+ frame:SetAlpha (0)
+ frame:Hide()
+
+ elseif (tipo == -1) then --> apenas da fade sem hidar
+ if (frame:GetAlpha() == 0 and frame.hidden and not frame.fading_out) then --> ja esta escondida
+ return
+ elseif (frame.fading_in) then --> ja esta com uma animação, se for true
+ return
+ end
+
+ if (frame.fading_out) then --> se tiver uma animação de aparecer em andamento se for true
+ frame.fading_out = false
+ end
+
+ UIFrameFadeIn (frame, velocidade, frame:GetAlpha(), 0)
+ frame.fading_in = true
+ frame.fadeInfo.finishedFunc = just_fade_func
+ frame.fadeInfo.finishedArg1 = frame
+
+ elseif (upper (tipo) == "ALPHAANIM") then
+
+ local value = velocidade
+ local currentApha = frame:GetAlpha()
+ frame:Show()
+
+ if (currentApha < value) then
+ if (frame.fading_in) then --> se tiver uma animação de hidar em andamento se for true
+ frame.fading_in = false
+ frame.fadeInfo.finishedFunc = nil
+ end
+ UIFrameFadeOut (frame, 0.3, currentApha, value)
+ frame.fading_out = true
+
+ frame.fadeInfo.finishedFunc = anim_OUT_alpha_func
+ frame.fadeInfo.finishedArg1 = frame
+
+ else
+ if (frame.fading_out) then --> se tiver uma animação de hidar em andamento se for true
+ frame.fading_out = false
+ frame.fadeInfo.finishedFunc = nil
+ end
+ UIFrameFadeIn (frame, 0.3, currentApha, value)
+ frame.fading_in = true
+
+ frame.fadeInfo.finishedFunc = anim_IN_alpha_func
+ frame.fadeInfo.finishedArg1 = frame
+ end
+
+ elseif (upper (tipo) == "ALPHA") then --> setando um alpha determinado
+ if (frame.fading_in or frame.fading_out) then
+ frame.fadeInfo.finishedFunc = nil
+ UIFrameFadeIn (frame, velocidade, frame:GetAlpha(), frame:GetAlpha())
+ end
+ frame.hidden = false
+ frame.faded = false
+ frame.fading_in = false
+ frame.fading_out = false
+ frame:Show()
+ frame:SetAlpha (velocidade)
+ end
+end
+
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> points
+
+ function DF:CheckPoints (v1, v2, v3, v4, v5, object)
+
+ if (not v1 and not v2) then
+ return "topleft", object.widget:GetParent(), "topleft", 0, 0
+ end
+
+ if (_type (v1) == "string") then
+ local frameGlobal = _G [v1]
+ if (frameGlobal and frameGlobal.GetObjectType) then
+ return DF:CheckPoints (frameGlobal, v2, v3, v4, v5, object)
+ end
+
+ elseif (_type (v2) == "string") then
+ local frameGlobal = _G [v2]
+ if (frameGlobal and frameGlobal.GetObjectType) then
+ return DF:CheckPoints (v1, frameGlobal, v3, v4, v5, object)
+ end
+ end
+
+ if (_type (v1) == "string" and _type (v2) == "table") then --> :setpoint ("left", frame, _, _, _)
+ if (not v3 or _type (v3) == "number") then --> :setpoint ("left", frame, 10, 10)
+ v1, v2, v3, v4, v5 = v1, v2, v1, v3, v4
+ end
+
+ elseif (_type (v1) == "string" and _type (v2) == "number") then --> :setpoint ("topleft", x, y)
+ v1, v2, v3, v4, v5 = v1, object.widget:GetParent(), v1, v2, v3
+
+ elseif (_type (v1) == "number") then --> :setpoint (x, y)
+ v1, v2, v3, v4, v5 = "topleft", object.widget:GetParent(), "topleft", v1, v2
+
+ elseif (_type (v1) == "table") then --> :setpoint (frame, x, y)
+ v1, v2, v3, v4, v5 = "topleft", v1, "topleft", v2, v3
+
+ end
+
+ if (not v2) then
+ v2 = object.widget:GetParent()
+ elseif (v2.dframework) then
+ v2 = v2.widget
+ end
+
+ return v1 or "topleft", v2, v3 or "topleft", v4 or 0, v5 or 0
+ end
+
+
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> colors
+
+ function DF:NewColor (_colorname, _colortable, _green, _blue, _alpha)
+ assert (_type (_colorname) == "string", "NewColor: colorname must be a string.")
+ assert (not DF.alias_text_colors [_colorname], "NewColor: colorname already exists.")
+
+ if (_type (_colortable) == "table") then
+ if (_colortable[1] and _colortable[2] and _colortable[3]) then
+ _colortable[4] = _colortable[4] or 1
+ DF.alias_text_colors [_colorname] = _colortable
+ else
+ error ("invalid color table.")
+ end
+ elseif (_colortable and _green and _blue) then
+ _alpha = _alpha or 1
+ DF.alias_text_colors [_colorname] = {_colortable, _green, _blue, _alpha}
+ else
+ error ("invalid parameter.")
+ end
+
+ return true
+ end
+
+ function DF:IsHtmlColor (color)
+ return DF.alias_text_colors [color]
+ end
+
+ local tn = tonumber
+ function DF:ParseColors (_arg1, _arg2, _arg3, _arg4)
+ if (_type (_arg1) == "table") then
+ _arg1, _arg2, _arg3, _arg4 = _unpack (_arg1)
+
+ elseif (_type (_arg1) == "string") then
+
+ if (string.find (_arg1, "#")) then
+ _arg1 = _arg1:gsub ("#","")
+ if (string.len (_arg1) == 8) then --alpha
+ _arg1, _arg2, _arg3, _arg4 = tn ("0x" .. _arg1:sub (3, 4))/255, tn ("0x" .. _arg1:sub (5, 6))/255, tn ("0x" .. _arg1:sub (7, 8))/255, tn ("0x" .. _arg1:sub (1, 2))/255
+ else
+ _arg1, _arg2, _arg3, _arg4 = tn ("0x" .. _arg1:sub (1, 2))/255, tn ("0x" .. _arg1:sub (3, 4))/255, tn ("0x" .. _arg1:sub (5, 6))/255, 1
+ end
+
+ else
+ local color = DF.alias_text_colors [_arg1]
+ if (color) then
+ _arg1, _arg2, _arg3, _arg4 = _unpack (color)
+ else
+ _arg1, _arg2, _arg3, _arg4 = _unpack (DF.alias_text_colors.none)
+ end
+ end
+ end
+
+ if (not _arg1) then
+ _arg1 = 1
+ end
+ if (not _arg2) then
+ _arg2 = 1
+ end
+ if (not _arg3) then
+ _arg3 = 1
+ end
+ if (not _arg4) then
+ _arg4 = 1
+ end
+
+ return _arg1, _arg2, _arg3, _arg4
+ end
+
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> menus
+
+ function DF:BuildMenu (parent, menu, x_offset, y_offset, height)
+
+ local cur_x = x_offset
+ local cur_y = y_offset
+ local max_x = 0
+
+ height = abs ((height or parent:GetHeight()) - abs (y_offset) + 20)
+ height = height*-1
+
+ for index, widget_table in ipairs (menu) do
+
+ if (widget_table.type == "select" or widget_table.type == "dropdown") then
+ local dropdown = self:NewDropDown (parent, nil, "$parentWidget" .. index, nil, 140, 18, widget_table.values, widget_table.get())
+ dropdown.tooltip = widget_table.desc
+ local label = self:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name, "GameFontNormal", 12)
+ dropdown:SetPoint ("left", label, "right", 2)
+ label:SetPoint (cur_x, cur_y)
+
+ local size = label.widget:GetStringWidth() + 140 + 4
+ if (size > max_x) then
+ max_x = size
+ end
+
+ elseif (widget_table.type == "toggle" or widget_table.type == "switch") then
+ local switch = self:NewSwitch (parent, nil, "$parentWidget" .. index, nil, 60, 20, nil, nil, widget_table.get())
+ switch.tooltip = widget_table.desc
+ switch.OnSwitch = widget_table.set
+
+ local label = self:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name, "GameFontNormal", 12)
+ switch:SetPoint ("left", label, "right", 2)
+ label:SetPoint (cur_x, cur_y)
+
+ local size = label.widget:GetStringWidth() + 60 + 4
+ if (size > max_x) then
+ max_x = size
+ end
+
+ elseif (widget_table.type == "range" or widget_table.type == "slider") then
+ local is_decimanls = widget_table.usedecimals
+ local slider = self:NewSlider (parent, nil, "$parentWidget" .. index, nil, 140, 20, widget_table.min, widget_table.max, widget_table.step, widget_table.get(), is_decimanls)
+ slider.tooltip = widget_table.desc
+ slider:SetHook ("OnValueChange", widget_table.set)
+
+ local label = self:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name, "GameFontNormal", 12)
+ slider:SetPoint ("left", label, "right", 2)
+ label:SetPoint (cur_x, cur_y)
+
+ local size = label.widget:GetStringWidth() + 140 + 6
+ if (size > max_x) then
+ max_x = size
+ end
+
+ elseif (widget_table.type == "color" or widget_table.type == "color") then
+ local colorpick = self:NewColorPickButton (parent, "$parentWidget" .. index, nil, widget_table.set)
+ colorpick.tooltip = widget_table.desc
+
+ local default_value, g, b, a = widget_table.get()
+ if (type (default_value) == "table") then
+ colorpick:SetColor (unpack (default_value))
+ else
+ colorpick:SetColor (default_value, g, b, a)
+ end
+
+ local label = self:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name, "GameFontNormal", 12)
+ colorpick:SetPoint ("left", label, "right", 2)
+ label:SetPoint (cur_x, cur_y)
+
+ local size = label.widget:GetStringWidth() + 60 + 4
+ if (size > max_x) then
+ max_x = size
+ end
+
+ elseif (widget_table.type == "execute" or widget_table.type == "button") then
+
+ local button = self:NewButton (parent, nil, "$parentWidget", nil, 120, 18, widget_table.func, widget_table.param1, widget_table.param2, nil, widget_table.name)
+ button:InstallCustomTexture()
+ button:SetPoint (cur_x, cur_y)
+ button.tooltip = widget_table.desc
+
+ local size = button:GetWidth() + 4
+ if (size > max_x) then
+ max_x = size
+ end
+
+ end
+
+ if (widget_table.spacement) then
+ cur_y = cur_y - 30
+ else
+ cur_y = cur_y - 20
+ end
+
+ if (cur_y < height) then
+ cur_y = y_offset
+ cur_x = cur_x + max_x + 30
+
+ max_x = 0
+ end
+
+ end
+
+ end
+
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+--> tutorials
+
+ function DF:ShowTutorialAlertFrame (maintext, desctext, clickfunc)
+
+ local TutorialAlertFrame = _G.DetailsFrameworkTutorialAlertFrame
+
+ if (not TutorialAlertFrame) then
+
+ TutorialAlertFrame = CreateFrame ("ScrollFrame", "DetailsFrameworkTutorialAlertFrame", UIParent, "DetailsFrameworkTutorialAlertFrameTemplate")
+ TutorialAlertFrame.isFirst = true
+ TutorialAlertFrame:SetPoint ("left", UIParent, "left", -20, 100)
+
+ TutorialAlertFrame:SetWidth (290)
+ TutorialAlertFrame.ScrollChild:SetWidth (256)
+
+ local scrollname = TutorialAlertFrame.ScrollChild:GetName()
+ _G [scrollname .. "BorderTopLeft"]:SetVertexColor (1, 0.8, 0, 1)
+ _G [scrollname .. "BorderTopRight"]:SetVertexColor (1, 0.8, 0, 1)
+ _G [scrollname .. "BorderBotLeft"]:SetVertexColor (1, 0.8, 0, 1)
+ _G [scrollname .. "BorderBotRight"]:SetVertexColor (1, 0.8, 0, 1)
+ _G [scrollname .. "BorderLeft"]:SetVertexColor (1, 0.8, 0, 1)
+ _G [scrollname .. "BorderRight"]:SetVertexColor (1, 0.8, 0, 1)
+ _G [scrollname .. "BorderBottom"]:SetVertexColor (1, 0.8, 0, 1)
+ _G [scrollname .. "BorderTop"]:SetVertexColor (1, 0.8, 0, 1)
+
+ local iconbg = _G [scrollname .. "QuestIconBg"]
+ iconbg:SetTexture ([[Interface\MainMenuBar\UI-MainMenuBar-EndCap-Human]])
+ iconbg:SetTexCoord (0, 1, 0, 1)
+ iconbg:SetSize (100, 100)
+ iconbg:ClearAllPoints()
+ iconbg:SetPoint ("bottomleft", TutorialAlertFrame.ScrollChild, "bottomleft")
+
+ _G [scrollname .. "Exclamation"]:SetVertexColor (1, 0.8, 0, 1)
+ _G [scrollname .. "QuestionMark"]:SetVertexColor (1, 0.8, 0, 1)
+
+ _G [scrollname .. "TopText"]:SetText ("Details!") --string
+ _G [scrollname .. "QuestName"]:SetText ("") --string
+ _G [scrollname .. "BottomText"]:SetText ("") --string
+
+ TutorialAlertFrame.ScrollChild.IconShine:SetTexture ([[Interface\MainMenuBar\UI-MainMenuBar-EndCap-Human]])
+
+ TutorialAlertFrame:SetScript ("OnMouseUp", function (self)
+ if (self.clickfunc and type (self.clickfunc) == "function") then
+ self.clickfunc()
+ end
+ self:Hide()
+ end)
+ TutorialAlertFrame:Hide()
+ end
+
+ if (type (maintext) == "string") then
+ TutorialAlertFrame.ScrollChild.QuestName:SetText (maintext)
+ else
+ TutorialAlertFrame.ScrollChild.QuestName:SetText ("")
+ end
+
+ if (type (desctext) == "string") then
+ TutorialAlertFrame.ScrollChild.BottomText:SetText (desctext)
+ else
+ TutorialAlertFrame.ScrollChild.BottomText:SetText ("")
+ end
+
+ TutorialAlertFrame.clickfunc = clickfunc
+ TutorialAlertFrame:Show()
+ DetailsTutorialAlertFrame_SlideInFrame (TutorialAlertFrame, "AUTOQUEST")
+ end
+
+ function DF:CreateOptionsFrame (name, title, template)
+
+ template = template or 1
+
+ if (template == 2) then
+ local options_frame = CreateFrame ("frame", name, UIParent, "ButtonFrameTemplate")
+ tinsert (UISpecialFrames, name)
+ options_frame:SetSize (500, 200)
+
+ options_frame:SetScript ("OnMouseDown", function(self, button)
+ if (button == "RightButton") then
+ if (self.moving) then
+ self.moving = false
+ self:StopMovingOrSizing()
+ end
+ return options_frame:Hide()
+ elseif (button == "LeftButton" and not self.moving) then
+ self.moving = true
+ self:StartMoving()
+ end
+ end)
+ options_frame:SetScript ("OnMouseUp", function(self)
+ if (self.moving) then
+ self.moving = false
+ self:StopMovingOrSizing()
+ end
+ end)
+
+ options_frame:SetMovable (true)
+ options_frame:EnableMouse (true)
+ options_frame:SetFrameStrata ("DIALOG")
+ options_frame:SetToplevel (true)
+
+ options_frame:Hide()
+
+ options_frame:SetPoint ("center", UIParent, "center")
+ options_frame.TitleText:SetText (title)
+ options_frame.portrait:SetTexture ([[Interface\CHARACTERFRAME\TEMPORARYPORTRAIT-FEMALE-BLOODELF]])
+
+ return options_frame
+
+ elseif (template == 1) then
+
+ local options_frame = CreateFrame ("frame", name, UIParent)
+ tinsert (UISpecialFrames, name)
+ options_frame:SetSize (500, 200)
+
+ options_frame:SetScript ("OnMouseDown", function(self, button)
+ if (button == "RightButton") then
+ if (self.moving) then
+ self.moving = false
+ self:StopMovingOrSizing()
+ end
+ return options_frame:Hide()
+ elseif (button == "LeftButton" and not self.moving) then
+ self.moving = true
+ self:StartMoving()
+ end
+ end)
+ options_frame:SetScript ("OnMouseUp", function(self)
+ if (self.moving) then
+ self.moving = false
+ self:StopMovingOrSizing()
+ end
+ end)
+
+ options_frame:SetMovable (true)
+ options_frame:EnableMouse (true)
+ options_frame:SetFrameStrata ("DIALOG")
+ options_frame:SetToplevel (true)
+
+ options_frame:Hide()
+
+ options_frame:SetPoint ("center", UIParent, "center")
+
+ options_frame:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
+ edgeFile = [[Interface\AddOns\Details\images\border_2]], edgeSize = 32,
+ insets = {left = 1, right = 1, top = 1, bottom = 1}})
+ options_frame:SetBackdropColor (0, 0, 0, .7)
+
+ local texturetitle = options_frame:CreateTexture (nil, "artwork")
+ texturetitle:SetTexture ([[Interface\CURSOR\Interact]])
+ texturetitle:SetTexCoord (0, 1, 0, 1)
+ texturetitle:SetVertexColor (1, 1, 1, 1)
+ texturetitle:SetPoint ("topleft", options_frame, "topleft", 2, -3)
+ texturetitle:SetWidth (36)
+ texturetitle:SetHeight (36)
+
+ local title = DF:NewLabel (options_frame, nil, "$parentTitle", nil, title, nil, 20, "yellow")
+ title:SetPoint ("left", texturetitle, "right", 2, -1)
+ DF:SetFontOutline (title, true)
+
+ local c = CreateFrame ("Button", nil, options_frame, "UIPanelCloseButton")
+ c:SetWidth (32)
+ c:SetHeight (32)
+ c:SetPoint ("TOPRIGHT", options_frame, "TOPRIGHT", -3, -3)
+ c:SetFrameLevel (options_frame:GetFrameLevel()+1)
+
+ return options_frame
+ end
+ end
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/help.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/help.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,120 @@
+
+
+local DF = _G ["DetailsFramework"]
+local _
+
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+
+local APIHelpFunctions = false
+local HelpMetaFunctions = {}
+
+ local get_members_function_index = {}
+
+ HelpMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = get_members_function_index [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return HelpMetaFunctions [_member_requested]
+ end
+
+ local set_members_function_index = {}
+
+ HelpMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = set_members_function_index [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+function HelpMetaFunctions:AddHelp (width, height, x, y, buttonX, buttonY, text, anchor)
+ self.helpTable [#self.helpTable + 1] = {
+ HighLightBox = {x = x, y = y, width = width, height = height},
+ ButtonPos = { x = buttonX, y = buttonY},
+ ToolTipDir = anchor or "RIGHT",
+ ToolTipText = text
+ }
+end
+
+function HelpMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+end
+
+function HelpMetaFunctions:ShowHelp()
+ if (not HelpPlate_IsShowing (self.helpTable)) then
+ HelpPlate_Show (self.helpTable, self.frame, self.button, true)
+ else
+ HelpPlate_Hide (true)
+ end
+end
+
+local nameCounter = 1
+function DF:NewHelp (parent, width, height, x, y, buttonWidth, buttonHeight, name)
+
+ local help = {}
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+
+ local helpButton = CreateFrame ("button", name or "DetailsFrameworkHelpButton"..nameCounter, parent, "MainHelpPlateButton")
+ nameCounter = nameCounter + 1
+
+ if (not APIHelpFunctions) then
+ APIHelpFunctions = true
+ local idx = getmetatable (helpButton).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not HelpMetaFunctions [funcName]) then
+ HelpMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G."..object.button:GetName()..":"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ if (buttonWidth and buttonHeight) then
+ helpButton:SetWidth (buttonWidth)
+ helpButton:SetHeight (buttonHeight)
+ helpButton.I:SetWidth (buttonWidth*0.8)
+ helpButton.I:SetHeight (buttonHeight*0.8)
+ helpButton.Ring:SetWidth (buttonWidth)
+ helpButton.Ring:SetHeight (buttonHeight)
+ helpButton.Ring:SetPoint ("center", buttonWidth*.2, -buttonWidth*.2)
+ end
+
+ help.helpTable = {
+ FramePos = {x = x, y = y},
+ FrameSize = {width = width, height = height}
+ }
+
+ help.frame = parent
+ help.button = helpButton
+ help.widget = helpButton
+ help.I = helpButton.I
+ help.Ring = helpButton.Ring
+
+ helpButton:SetScript ("OnClick", function()
+ help:ShowHelp()
+ end)
+
+ setmetatable (help, HelpMetaFunctions)
+
+ return help
+
+end
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/icons.tga
Binary file Libs/DF/icons.tga has changed
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/label.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/label.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,296 @@
+
+
+
+local DF = _G ["DetailsFramework"]
+local _
+
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+local loadstring = loadstring --> lua local
+
+local cleanfunction = function() end
+local APILabelFunctions = false
+local LabelMetaFunctions = {}
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ LabelMetaFunctions.__call = function (_table, value)
+ return self.label:SetText (value)
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> shown
+ local gmember_shown = function (_object)
+ return _object:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.label:GetStringWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.label:GetStringHeight()
+ end
+ --> text
+ local gmember_text = function (_object)
+ return _object.label:GetText()
+ end
+ --> text color
+ local gmember_textcolor = function (_object)
+ return _object.label:GetTextColor()
+ end
+ --> text font
+ local gmember_textfont = function (_object)
+ local fontface = _object.label:GetFont()
+ return fontface
+ end
+ --> text size
+ local gmember_textsize = function (_object)
+ local _, fontsize = _object.label:GetFont()
+ return fontsize
+ end
+
+
+ local get_members_function_index = {
+ ["shown"] = gmember_shown,
+ ["width"] = gmember_width,
+ ["height"] = gmember_height,
+ ["text"] = gmember_text,
+ ["fontcolor"] = gmember_textcolor,
+ ["fontface"] = gmember_textfont,
+ ["fontsize"] = gmember_textsize,
+ ["textcolor"] = gmember_textcolor, --alias
+ ["textfont"] = gmember_textfont, --alias
+ ["textsize"] = gmember_textsize --alias
+ }
+
+ LabelMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = get_members_function_index [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return LabelMetaFunctions [_member_requested]
+ end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ --> show
+ local smember_show = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (not _value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> text
+ local smember_text = function (_object, _value)
+ return _object.label:SetText (_value)
+ end
+ --> text color
+ local smember_textcolor = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+ return _object.label:SetTextColor (_value1, _value2, _value3, _value4)
+ end
+ --> text font
+ local smember_textfont = function (_object, _value)
+ return DF:SetFontFace (_object.label, _value)
+ end
+ --> text size
+ local smember_textsize = function (_object, _value)
+ return DF:SetFontSize (_object.label, _value)
+ end
+ --> text align
+ local smember_textalign = function (_object, _value)
+ if (_value == "<") then
+ _value = "left"
+ elseif (_value == ">") then
+ _value = "right"
+ elseif (_value == "|") then
+ _value = "center"
+ end
+ return _object.label:SetJustifyH (_value)
+ end
+ --> text valign
+ local smember_textvalign = function (_object, _value)
+ if (_value == "^") then
+ _value = "top"
+ elseif (_value == "_") then
+ _value = "bottom"
+ elseif (_value == "|") then
+ _value = "middle"
+ end
+ return _object.label:SetJustifyV (_value)
+ end
+ --> field size width
+ local smember_width = function (_object, _value)
+ return _object.label:SetWidth (_value)
+ end
+ --> field size height
+ local smember_height = function (_object, _value)
+ return _object.label:SetHeight (_value)
+ end
+ --> outline (shadow)
+ local smember_outline = function (_object, _value)
+ DF:SetFontOutline (_object.label, _value)
+ end
+
+ local set_members_function_index = {
+ ["show"] = smember_show,
+ ["hide"] = smember_hide,
+ ["align"] = smember_textalign,
+ ["valign"] = smember_textvalign,
+ ["text"] = smember_text,
+ ["width"] = smember_width,
+ ["height"] = smember_height,
+ ["fontcolor"] = smember_textcolor,
+ ["color"] = smember_textcolor,--alias
+ ["fontface"] = smember_textfont,
+ ["fontsize"] = smember_textsize,
+ ["textcolor"] = smember_textcolor,--alias
+ ["textfont"] = smember_textfont,--alias
+ ["textsize"] = smember_textsize,--alias
+ ["shadow"] = smember_outline,
+ ["outline"] = smember_outline,--alias
+ }
+
+ LabelMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = set_members_function_index [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+
+--> show & hide
+ function LabelMetaFunctions:IsShown()
+ return self.label:IsShown()
+ end
+ function LabelMetaFunctions:Show()
+ return self.label:Show()
+ end
+ function LabelMetaFunctions:Hide()
+ return self.label:Hide()
+ end
+
+-- textcolor
+ function LabelMetaFunctions:SetTextColor (color, arg2, arg3, arg4)
+ if (arg2) then
+ return self.label:SetTextColor (color, arg2, arg3, arg4 or 1)
+ end
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
+ return self.label:SetTextColor (_value1, _value2, _value3, _value4)
+ end
+
+-- setpoint
+ function LabelMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+function DF:CreateLabel (parent, text, size, color, font, member, name, layer)
+ return DF:NewLabel (parent, nil, name, member, text, font, size, color, layer)
+end
+
+function DF:NewLabel (parent, container, name, member, text, font, size, color, layer)
+
+ if (not parent) then
+ return nil
+ end
+ if (not container) then
+ container = parent
+ end
+
+ if (not name) then
+ name = "DetailsFrameworkLabelNumber" .. DF.LabelNameCounter
+ DF.LabelNameCounter = DF.LabelNameCounter + 1
+ end
+
+ if (name:find ("$parent")) then
+ local pname = parent:GetName()
+ assert (pname, "label used $parent but parent has no name.")
+ name = name:gsub ("$parent", parent:GetName())
+ end
+
+ local LabelObject = {type = "label", dframework = true}
+
+ if (member) then
+ parent [member] = LabelObject
+ --container [member] = LabelObject.label
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+ font = font or "GameFontHighlightSmall"
+
+ LabelObject.label = parent:CreateFontString (name, layer or "OVERLAY", font)
+ LabelObject.widget = LabelObject.label
+
+ LabelObject.label.MyObject = LabelObject
+
+ if (not APILabelFunctions) then
+ APILabelFunctions = true
+ local idx = getmetatable (LabelObject.label).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not LabelMetaFunctions [funcName]) then
+ LabelMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G."..object.label:GetName()..":"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ LabelObject.label:SetText (text)
+
+ if (size) then
+ DF:SetFontSize (LabelObject.label, size)
+ end
+
+ if (color) then
+ local r, g, b, a = DF:ParseColors (color)
+ LabelObject.label:SetTextColor (r, g, b, a)
+ end
+
+ LabelObject.label:SetJustifyH ("LEFT")
+
+ setmetatable (LabelObject, LabelMetaFunctions)
+
+ return LabelObject
+end
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/load.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/load.xml Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/mail.tga
Binary file Libs/DF/mail.tga has changed
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/normal_bar.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/normal_bar.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,665 @@
+
+
+
+local DF = _G ["DetailsFramework"]
+local _
+
+local _rawset = rawset --> lua locals
+local _rawget = rawget --> lua locals
+local _setmetatable = setmetatable --> lua locals
+local _unpack = unpack --> lua locals
+local _type = type --> lua locals
+local _math_floor = math.floor --> lua locals
+
+local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
+
+local cleanfunction = function() end
+local BarMetaFunctions = {}
+local APIBarFunctions
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ BarMetaFunctions.__call = function (_table, value)
+ if (not value) then
+ return _table.statusbar:GetValue()
+ else
+ return _table.statusbar:SetValue (value)
+ end
+ end
+
+ BarMetaFunctions.__add = function (v1, v2)
+ if (_type (v1) == "table") then
+ local v = v1.statusbar:GetValue()
+ v = v + v2
+ v1.statusbar:SetValue (v)
+ else
+ local v = v2.statusbar:GetValue()
+ v = v + v1
+ v2.statusbar:SetValue (v)
+ end
+ end
+
+ BarMetaFunctions.__sub = function (v1, v2)
+ if (_type (v1) == "table") then
+ local v = v1.statusbar:GetValue()
+ v = v - v2
+ v1.statusbar:SetValue (v)
+ else
+ local v = v2.statusbar:GetValue()
+ v = v - v1
+ v2.statusbar:SetValue (v)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> tooltip
+ local function gmember_tooltip (_object)
+ return _object:GetTooltip()
+ end
+ --> shown
+ local gmember_shown = function (_object)
+ return _object.statusbar:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.statusbar:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.statusbar:GetHeight()
+ end
+ --> value
+ local gmember_value = function (_object)
+ return _object.statusbar:GetValue()
+ end
+ --> right text
+ local gmember_rtext = function (_object)
+ return _object.textright:GetText()
+ end
+ --> left text
+ local gmember_ltext = function (_object)
+ return _object.textleft:GetText()
+ end
+ --> left color
+ local gmember_color = function (_object)
+ return _object._texture.original_colors
+ end
+ --> icon
+ local gmember_icon = function (_object)
+ return _object._icon:GetTexture()
+ end
+ --> texture
+ local gmember_texture = function (_object)
+ return _object._texture:GetTexture()
+ end
+ --> font size
+ local gmember_textsize = function (_object)
+ local _, fontsize = _object.textleft:GetFont()
+ return fontsize
+ end
+ --> font face
+ local gmember_textfont = function (_object)
+ local fontface = _object.textleft:GetFont()
+ return fontface
+ end
+ --> font color
+ local gmember_textcolor = function (_object)
+ return _object.textleft:GetTextColor()
+ end
+
+ local get_members_function_index = {
+ ["tooltip"] = gmember_tooltip,
+ ["shown"] = gmember_shown,
+ ["width"] = gmember_width,
+ ["height"] = gmember_height,
+ ["value"] = gmember_value,
+ ["lefttext"] = gmember_ltext,
+ ["righttext"] = gmember_rtext,
+ ["color"] = gmember_color,
+ ["icon"] = gmember_icon,
+ ["texture"] = gmember_texture,
+ ["fontsize"] = gmember_textsize,
+ ["fontface"] = gmember_textfont,
+ ["fontcolor"] = gmember_textcolor,
+ ["textsize"] = gmember_textsize, --alias
+ ["textfont"] = gmember_textfont, --alias
+ ["textcolor"] = gmember_textcolor --alias
+ }
+
+ BarMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = get_members_function_index [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return BarMetaFunctions [_member_requested]
+ end
+
+
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+
+ --> tooltip
+ local smember_tooltip = function (_object, _value)
+ return _object:SetTooltip (_value)
+ end
+ --> show
+ local smember_shown = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (_value) then
+ return _object:Hide()
+ else
+ return _object:Show()
+ end
+ end
+ --> width
+ local smember_width = function (_object, _value)
+ return _object.statusbar:SetWidth (_value)
+ end
+ --> height
+ local smember_height = function (_object, _value)
+ return _object.statusbar:SetHeight (_value)
+ end
+ --> statusbar value
+ local smember_value = function (_object, _value)
+ _object.statusbar:SetValue (_value)
+ return _object.div:SetPoint ("left", _object.statusbar, "left", _value * (_object.statusbar:GetWidth()/100) - 16, 0)
+ end
+ --> right text
+ local smember_rtext = function (_object, _value)
+ return _object.textright:SetText (_value)
+ end
+ --> left text
+ local smember_ltext = function (_object, _value)
+ return _object.textleft:SetText (_value)
+ end
+ --> color
+ local smember_color = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+
+ _object.statusbar:SetStatusBarColor (_value1, _value2, _value3, _value4)
+ _object._texture.original_colors = {_value1, _value2, _value3, _value4}
+ return _object._texture:SetVertexColor (_value1, _value2, _value3, _value4)
+ end
+ --> icon
+ local smember_icon = function (_object, _value)
+ if (type (_value) == "table") then
+ local _value1, _value2 = _unpack (_value)
+ _object._icon:SetTexture (_value1)
+ if (_value2) then
+ _object._icon:SetTexCoord (_unpack (_value2))
+ end
+ else
+ _object._icon:SetTexture (_value)
+ end
+ return
+ end
+ --> texture
+ local smember_texture = function (_object, _value)
+ if (type (_value) == "table") then
+ local _value1, _value2 = _unpack (_value)
+ _object._texture:SetTexture (_value1)
+ if (_value2) then
+ _object._texture:SetTexCoord (_unpack (_value2))
+ end
+ else
+ if (_value:find ("\\")) then
+ _object._texture:SetTexture (_value)
+ else
+ local file = SharedMedia:Fetch ("statusbar", _value)
+ if (file) then
+ _object._texture:SetTexture (file)
+ else
+ _object._texture:SetTexture (_value)
+ end
+ end
+ end
+ return
+ end
+ --> font face
+ local smember_textfont = function (_object, _value)
+ DF:SetFontFace (_object.textleft, _value)
+ return DF:SetFontFace (_object.textright, _value)
+ end
+ --> font size
+ local smember_textsize = function (_object, _value)
+ DF:SetFontSize (_object.textleft, _value)
+ return DF:SetFontSize (_object.textright, _value)
+ end
+ --> font color
+ local smember_textcolor = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+ _object.textleft:SetTextColor (_value1, _value2, _value3, _value4)
+ return _object.textright:SetTextColor (_value1, _value2, _value3, _value4)
+ end
+ --> outline (shadow)
+ local smember_outline = function (_object, _value)
+ DF:SetFontOutline (_object.textleft, _value)
+ return DF:SetFontOutline (_object.textright, _value)
+ end
+
+ local set_members_function_index = {
+ ["tooltip"] = smember_tooltip,
+ ["shown"] = smember_shown,
+ ["width"] = smember_width,
+ ["height"] = smember_height,
+ ["value"] = smember_value,
+ ["righttext"] = smember_rtext,
+ ["lefttext"] = smember_ltext,
+ ["color"] = smember_color,
+ ["icon"] = smember_icon,
+ ["texture"] = smember_texture,
+ ["fontsize"] = smember_textsize,
+ ["fontface"] = smember_textfont,
+ ["fontcolor"] = smember_textcolor,
+ ["textsize"] = smember_textsize, --alias
+ ["textfont"] = smember_textfont, --alias
+ ["textcolor"] = smember_textcolor, --alias
+ ["shadow"] = smember_outline,
+ ["outline"] = smember_outline, --alias
+ }
+
+ BarMetaFunctions.__newindex = function (_table, _key, _value)
+
+ local func = set_members_function_index [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+
+--> show & hide
+ function BarMetaFunctions:Show()
+ self.statusbar:Show()
+ end
+ function BarMetaFunctions:Hide()
+ self.statusbar:Hide()
+ end
+
+--> set value (status bar)
+ function BarMetaFunctions:SetValue (value)
+ if (not value) then
+ value = 0
+ end
+ self.statusbar:SetValue (value)
+ self.div:SetPoint ("left", self.statusbar, "left", value * (self.statusbar:GetWidth()/100) - 16, 0)
+ end
+
+--> set point
+ function BarMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+--> set sizes
+ function BarMetaFunctions:SetSize (w, h)
+ if (w) then
+ self.statusbar:SetWidth (w)
+ end
+ if (h) then
+ self.statusbar:SetHeight (h)
+ end
+ end
+
+--> set texture
+ function BarMetaFunctions:SetTexture (texture)
+ self._texture:SetTexture (texture)
+ end
+
+--> set texts
+ function BarMetaFunctions:SetLeftText (text)
+ self.textleft:SetText (text)
+ end
+ function BarMetaFunctions:SetRightText (text)
+ self.textright:SetText (text)
+ end
+
+--> set color
+ function BarMetaFunctions:SetColor (r, g, b, a)
+ r, g, b, a = DF:ParseColors (r, g, b, a)
+
+ self._texture:SetVertexColor (r, g, b, a)
+ self.statusbar:SetStatusBarColor (r, g, b, a)
+ self._texture.original_colors = {r, g, b, a}
+ end
+
+--> set icons
+ function BarMetaFunctions:SetIcon (texture, ...)
+ self._icon:SetTexture (texture)
+ if (...) then
+ local L, R, U, D = _unpack (...)
+ self._icon:SetTexCoord (L, R, U, D)
+ end
+ end
+
+--> show div
+ function BarMetaFunctions:ShowDiv (bool)
+ if (bool) then
+ self.div:Show()
+ else
+ self.div:Hide()
+ end
+ end
+
+-- tooltip
+ function BarMetaFunctions:SetTooltip (tooltip)
+ if (tooltip) then
+ return _rawset (self, "have_tooltip", tooltip)
+ else
+ return _rawset (self, "have_tooltip", nil)
+ end
+ end
+ function BarMetaFunctions:GetTooltip()
+ return _rawget (self, "have_tooltip")
+ end
+
+-- frame levels
+ function BarMetaFunctions:GetFrameLevel()
+ return self.statusbar:GetFrameLevel()
+ end
+ function BarMetaFunctions:SetFrameLevel (level, frame)
+ if (not frame) then
+ return self.statusbar:SetFrameLevel (level)
+ else
+ local framelevel = frame:GetFrameLevel (frame) + level
+ return self.statusbar:SetFrameLevel (framelevel)
+ end
+ end
+
+-- frame stratas
+ function BarMetaFunctions:SetFrameStrata()
+ return self.statusbar:GetFrameStrata()
+ end
+ function BarMetaFunctions:SetFrameStrata (strata)
+ if (_type (strata) == "table") then
+ self.statusbar:SetFrameStrata (strata:GetFrameStrata())
+ else
+ self.statusbar:SetFrameStrata (strata)
+ end
+ end
+
+--> container
+ function BarMetaFunctions:SetContainer (container)
+ self.container = container
+ end
+
+--> hooks
+ function BarMetaFunctions:SetHook (hookType, func)
+ if (func) then
+ _rawset (self, hookType.."Hook", func)
+ else
+ _rawset (self, hookType.."Hook", nil)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts
+
+ local OnEnter = function (frame)
+ if (frame.MyObject.OnEnterHook) then
+ local interrupt = frame.MyObject.OnEnterHook (frame, frame.MyObject)
+ if (interrupt) then
+ return
+ end
+ end
+
+ frame.MyObject.background:Show()
+
+ if (frame.MyObject.have_tooltip) then
+ GameCooltip2:Reset()
+ GameCooltip2:AddLine (frame.MyObject.have_tooltip)
+ GameCooltip2:ShowCooltip (frame, "tooltip")
+ end
+
+ end
+
+ local OnLeave = function (frame)
+ if (frame.MyObject.OnLeaveHook) then
+ local interrupt = frame.MyObject.OnLeaveHook (frame)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (frame.MyObject.have_tooltip) then
+ GameCooltip2:ShowMe (false)
+ end
+ end
+
+ local OnHide = function (frame)
+ if (frame.MyObject.OnHideHook) then
+ local interrupt = frame.MyObject.OnHideHook (frame)
+ if (interrupt) then
+ return
+ end
+ end
+ end
+
+ local OnShow = function (frame)
+ if (frame.MyObject.OnShowHook) then
+ local interrupt = frame.MyObject.OnShowHook (frame)
+ if (interrupt) then
+ return
+ end
+ end
+ end
+
+ local OnMouseDown = function (frame, button)
+ if (frame.MyObject.OnMouseDownHook) then
+ local interrupt = frame.MyObject.OnMouseDownHook (frame, button)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (not frame.MyObject.container.isLocked and frame.MyObject.container:IsMovable()) then
+ if (not frame.isLocked and frame:IsMovable()) then
+ frame.MyObject.container.isMoving = true
+ frame.MyObject.container:StartMoving()
+ end
+ end
+ end
+
+ local OnMouseUp = function (frame, button)
+ if (frame.MyObject.OnMouseUpHook) then
+ local interrupt = frame.MyObject.OnMouseUpHook (frame, button)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (frame.MyObject.container.isMoving) then
+ frame.MyObject.container:StopMovingOrSizing()
+ frame.MyObject.container.isMoving = false
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> timer
+
+ function BarMetaFunctions:OnTimerEnd()
+ if (self.OnTimerEndHook) then
+ local interrupt = self.OnTimerEndHook()
+ if (interrupt) then
+ return
+ end
+ end
+ self.timer_texture:Hide()
+ self.div_timer:Hide()
+ self:Hide()
+ self.timer = false
+ end
+
+ local OnUpdate = function (self, elapsed)
+ local timepct = (elapsed / self.tempo) * 100
+ self.c = self.c - (timepct*self.width/100)
+ self.remaining = self.remaining - elapsed
+ self.righttext:SetText (_math_floor (self.remaining))
+ self.timertexture:SetWidth (self.c)
+ if (self.c < 1) then
+ self:SetScript ("OnUpdate", nil)
+ self.MyObject:OnTimerEnd()
+ end
+ end
+
+ function BarMetaFunctions:SetTimer (tempo)
+
+ self.statusbar.width = self.statusbar:GetWidth()
+ self.statusbar.tempo = tempo
+ self.statusbar.remaining = tempo
+ self.statusbar.c = self.statusbar.width
+
+ self.timer_texture:Show()
+ self.timer_texture:SetWidth (self.statusbar.width)
+ self.statusbar.t = self.timer_texture
+ self (1)
+
+ self.div_timer:Show()
+ self.background:Show()
+
+ self.timer = true
+
+ self.statusbar:SetScript ("OnUpdate", OnUpdate)
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+
+function DetailsFrameworkNormalBar_OnCreate (self)
+ self.texture.original_colors = {1, 1, 1, 1}
+ self.background.original_colors = {.3, .3, .3, .3}
+ self.timertexture.original_colors = {.3, .3, .3, .3}
+ return true
+end
+
+function DF:CreateBar (parent, texture, w, h, value, member, name)
+ return DF:NewBar (parent, parent, name, member, w, h, value, texture)
+end
+
+function DF:NewBar (parent, container, name, member, w, h, value, texture_name)
+
+ if (not name) then
+ name = "DetailsFrameworkBarNumber" .. DF.BarNameCounter
+ DF.BarNameCounter = DF.BarNameCounter + 1
+
+ elseif (not parent) then
+ return nil
+ elseif (not container) then
+ container = parent
+ end
+
+ if (name:find ("$parent")) then
+ name = name:gsub ("$parent", parent:GetName())
+ end
+
+ local BarObject = {type = "bar", dframework = true}
+
+ if (member) then
+ parent [member] = BarObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+ value = value or 0
+ w = w or 150
+ h = h or 14
+
+ --> default members:
+ --> hooks
+ BarObject.OnEnterHook = nil
+ BarObject.OnLeaveHook = nil
+ BarObject.OnHideHook = nil
+ BarObject.OnShowHook = nil
+ BarObject.OnMouseDownHook = nil
+ BarObject.OnMouseUpHook = nil
+ BarObject.OnTimerEndHook = nil
+ --> misc
+ BarObject.tooltip = nil
+ BarObject.locked = false
+ BarObject.have_tooltip = nil
+
+ BarObject.container = container
+
+ --> create widgets
+ BarObject.statusbar = CreateFrame ("statusbar", name, parent, "DetailsFrameworkNormalBarTemplate")
+ BarObject.widget = BarObject.statusbar
+
+ if (not APIBarFunctions) then
+ APIBarFunctions = true
+ local idx = getmetatable (BarObject.statusbar).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not BarMetaFunctions [funcName]) then
+ BarMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G."..object.statusbar:GetName()..":"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ BarObject.statusbar:SetHeight (h)
+ BarObject.statusbar:SetWidth (w)
+ BarObject.statusbar:SetFrameLevel (parent:GetFrameLevel()+1)
+ BarObject.statusbar:SetMinMaxValues (0, 100)
+ BarObject.statusbar:SetValue (value or 50)
+ BarObject.statusbar.MyObject = BarObject
+
+ BarObject.timer_texture = _G [name .. "_timerTexture"]
+ BarObject.timer_texture:SetWidth (w)
+ BarObject.timer_texture:SetHeight (h)
+
+ BarObject._texture = _G [name .. "_statusbarTexture"]
+ BarObject.background = _G [name .. "_background"]
+ BarObject._icon = _G [name .. "_icon"]
+ BarObject.textleft = _G [name .. "_TextLeft"]
+ BarObject.textright = _G [name .. "_TextRight"]
+ BarObject.div = _G [name .. "_sparkMouseover"]
+ BarObject.div_timer = _G [name .. "_sparkTimer"]
+
+ --> hooks
+ BarObject.statusbar:SetScript ("OnEnter", OnEnter)
+ BarObject.statusbar:SetScript ("OnLeave", OnLeave)
+ BarObject.statusbar:SetScript ("OnHide", OnHide)
+ BarObject.statusbar:SetScript ("OnShow", OnShow)
+ BarObject.statusbar:SetScript ("OnMouseDown", OnMouseDown)
+ BarObject.statusbar:SetScript ("OnMouseUp", OnMouseUp)
+
+ --> set class
+ _setmetatable (BarObject, BarMetaFunctions)
+
+ --> set texture
+ if (texture_name) then
+ smember_texture (BarObject, texture_name)
+ end
+
+ return BarObject
+end
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/normal_bar.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/normal_bar.xml Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ self:SetStatusBarTexture (self.texture);
+ DetailsFrameworkNormalBar_OnCreate (self);
+
+
+
+
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/panel.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/panel.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,2451 @@
+
+
+
+local DF = _G ["DetailsFramework"]
+local _
+
+--> lua locals
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+local loadstring = loadstring --> lua local
+
+local cleanfunction = function() end
+local PanelMetaFunctions = {}
+local APIFrameFunctions
+
+local simple_panel_counter = 1
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ PanelMetaFunctions.__call = function (_table, value)
+ --> nothing to do
+ return true
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> tooltip
+ local gmember_tooltip = function (_object)
+ return _object:GetTooltip()
+ end
+ --> shown
+ local gmember_shown = function (_object)
+ return _object:IsShown()
+ end
+ --> backdrop color
+ local gmember_color = function (_object)
+ return _object.frame:GetBackdropColor()
+ end
+ --> backdrop table
+ local gmember_backdrop = function (_object)
+ return _object.frame:GetBackdrop()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.frame:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.frame:GetHeight()
+ end
+ --> locked
+ local gmember_locked = function (_object)
+ return _rawget (_object, "is_locked")
+ end
+
+ local get_members_function_index = {
+ ["tooltip"] = gmember_tooltip,
+ ["shown"] = gmember_shown,
+ ["color"] = gmember_color,
+ ["backdrop"] = gmember_backdrop,
+ ["width"] = gmember_width,
+ ["height"] = gmember_height,
+ ["locked"] = gmember_locked,
+ }
+
+ PanelMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = get_members_function_index [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return PanelMetaFunctions [_member_requested]
+ end
+
+
+ --> tooltip
+ local smember_tooltip = function (_object, _value)
+ return _object:SetTooltip (_value)
+ end
+ --> show
+ local smember_show = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (not _value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> backdrop color
+ local smember_color = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+ return _object:SetBackdropColor (_value1, _value2, _value3, _value4)
+ end
+ --> frame width
+ local smember_width = function (_object, _value)
+ return _object.frame:SetWidth (_value)
+ end
+ --> frame height
+ local smember_height = function (_object, _value)
+ return _object.frame:SetHeight (_value)
+ end
+
+ --> locked
+ local smember_locked = function (_object, _value)
+ if (_value) then
+ _object.frame:SetMovable (false)
+ return _rawset (_object, "is_locked", true)
+ else
+ _object.frame:SetMovable (true)
+ _rawset (_object, "is_locked", false)
+ return
+ end
+ end
+
+ --> backdrop
+ local smember_backdrop = function (_object, _value)
+ return _object.frame:SetBackdrop (_value)
+ end
+
+ --> close with right button
+ local smember_right_close = function (_object, _value)
+ return _rawset (_object, "rightButtonClose", _value)
+ end
+
+ local set_members_function_index = {
+ ["tooltip"] = smember_tooltip,
+ ["show"] = smember_show,
+ ["hide"] = smember_hide,
+ ["color"] = smember_color,
+ ["backdrop"] = smember_backdrop,
+ ["width"] = smember_width,
+ ["height"] = smember_height,
+ ["locked"] = smember_locked,
+ ["close_with_right"] = smember_right_close,
+ }
+
+ PanelMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = set_members_function_index [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+
+--> right click to close
+ function PanelMetaFunctions:CreateRightClickLabel (textType, w, h, close_text)
+ local text
+ w = w or 20
+ h = h or 20
+
+ if (close_text) then
+ text = close_text
+ else
+ if (textType) then
+ textType = string.lower (textType)
+ if (textType == "short") then
+ text = "close window"
+ elseif (textType == "medium") then
+ text = "close window"
+ elseif (textType == "large") then
+ text = "close window"
+ end
+ else
+ text = "close window"
+ end
+ end
+
+ return DF:NewLabel (self, _, "$parentRightMouseToClose", nil, "|TInterface\\TUTORIALFRAME\\UI-TUTORIAL-FRAME:"..w..":"..h..":0:1:512:512:8:70:328:409|t " .. text)
+ end
+
+--> show & hide
+ function PanelMetaFunctions:Show()
+ self.frame:Show()
+
+ end
+ function PanelMetaFunctions:Hide()
+ self.frame:Hide()
+
+ end
+
+-- setpoint
+ function PanelMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+-- sizes
+ function PanelMetaFunctions:SetSize (w, h)
+ if (w) then
+ self.frame:SetWidth (w)
+ end
+ if (h) then
+ self.frame:SetHeight (h)
+ end
+ end
+
+-- clear
+ function PanelMetaFunctions:HideWidgets()
+ for widgetName, widgetSelf in pairs (self) do
+ if (type (widgetSelf) == "table" and widgetSelf.dframework) then
+ widgetSelf:Hide()
+ end
+ end
+ end
+
+-- backdrop
+ function PanelMetaFunctions:SetBackdrop (background, edge, tilesize, edgesize, tile, left, right, top, bottom)
+
+ if (_type (background) == "boolean" and not background) then
+ return self.frame:SetBackdrop (nil)
+
+ elseif (_type (background) == "table") then
+ self.frame:SetBackdrop (background)
+
+ else
+ local currentBackdrop = self.frame:GetBackdrop() or {edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border", bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", tile=true, tileSize=16, edgeSize=16, insets={left=1, right=0, top=0, bottom=0}}
+ currentBackdrop.bgFile = background or currentBackdrop.bgFile
+ currentBackdrop.edgeFile = edgeFile or currentBackdrop.edgeFile
+ currentBackdrop.tileSize = tilesize or currentBackdrop.tileSize
+ currentBackdrop.edgeSize = edgesize or currentBackdrop.edgeSize
+ currentBackdrop.tile = tile or currentBackdrop.tile
+ currentBackdrop.insets.left = left or currentBackdrop.insets.left
+ currentBackdrop.insets.right = left or currentBackdrop.insets.right
+ currentBackdrop.insets.top = left or currentBackdrop.insets.top
+ currentBackdrop.insets.bottom = left or currentBackdrop.insets.bottom
+ self.frame:SetBackdrop (currentBackdrop)
+ end
+ end
+
+-- backdropcolor
+ function PanelMetaFunctions:SetBackdropColor (color, arg2, arg3, arg4)
+ if (arg2) then
+ self.frame:SetBackdropColor (color, arg2, arg3, arg4 or 1)
+ self.frame.Gradient.OnLeave = {color, arg2, arg3, arg4 or 1}
+ else
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
+ self.frame:SetBackdropColor (_value1, _value2, _value3, _value4)
+ self.frame.Gradient.OnLeave = {_value1, _value2, _value3, _value4}
+ end
+ end
+
+-- border color
+ function PanelMetaFunctions:SetBackdropBorderColor (color, arg2, arg3, arg4)
+ if (arg2) then
+ return self.frame:SetBackdropBorderColor (color, arg2, arg3, arg4)
+ end
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
+ self.frame:SetBackdropBorderColor (_value1, _value2, _value3, _value4)
+ end
+
+-- gradient colors
+ function PanelMetaFunctions:SetGradient (FadeType, color)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
+ if (FadeType == "OnEnter") then
+ self.frame.Gradient.OnEnter = {_value1, _value2, _value3, _value4}
+ elseif (FadeType == "OnLeave") then
+ self.frame.Gradient.OnLeave = {_value1, _value2, _value3, _value4}
+ end
+ end
+
+-- tooltip
+ function PanelMetaFunctions:SetTooltip (tooltip)
+ if (tooltip) then
+ return _rawset (self, "have_tooltip", tooltip)
+ else
+ return _rawset (self, "have_tooltip", nil)
+ end
+ end
+ function PanelMetaFunctions:GetTooltip()
+ return _rawget (self, "have_tooltip")
+ end
+
+-- frame levels
+ function PanelMetaFunctions:GetFrameLevel()
+ return self.widget:GetFrameLevel()
+ end
+ function PanelMetaFunctions:SetFrameLevel (level, frame)
+ if (not frame) then
+ return self.widget:SetFrameLevel (level)
+ else
+ local framelevel = frame:GetFrameLevel (frame) + level
+ return self.widget:SetFrameLevel (framelevel)
+ end
+ end
+
+-- frame stratas
+ function PanelMetaFunctions:SetFrameStrata()
+ return self.widget:GetFrameStrata()
+ end
+ function PanelMetaFunctions:SetFrameStrata (strata)
+ if (_type (strata) == "table") then
+ self.widget:SetFrameStrata (strata:GetFrameStrata())
+ else
+ self.widget:SetFrameStrata (strata)
+ end
+ end
+
+-- enable and disable gradients
+ function PanelMetaFunctions:DisableGradient()
+ self.GradientEnabled = false
+ end
+ function PanelMetaFunctions:EnableGradient()
+ self.GradientEnabled = true
+ end
+
+--> hooks
+ function PanelMetaFunctions:SetHook (hookType, func)
+ if (func) then
+ _rawset (self, hookType.."Hook", func)
+ else
+ _rawset (self, hookType.."Hook", nil)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts
+
+ local OnEnter = function (frame)
+ if (frame.MyObject.OnEnterHook) then
+ local interrupt = frame.MyObject.OnEnterHook (frame, frame.MyObject)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (frame.MyObject.have_tooltip) then
+ GameCooltip2:Reset()
+ GameCooltip2:SetType ("tooltip")
+ GameCooltip2:SetColor ("main", "transparent")
+ GameCooltip2:AddLine (frame.MyObject.have_tooltip)
+ GameCooltip2:SetOwner (frame)
+ GameCooltip2:ShowCooltip()
+ end
+ end
+
+ local OnLeave = function (frame)
+ if (frame.MyObject.OnLeaveHook) then
+ local interrupt = frame.MyObject.OnLeaveHook (frame, frame.MyObject)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (frame.MyObject.have_tooltip) then
+ GameCooltip2:ShowMe (false)
+ end
+
+ end
+
+ local OnHide = function (frame)
+ if (frame.MyObject.OnHideHook) then
+ local interrupt = frame.MyObject.OnHideHook (frame, frame.MyObject)
+ if (interrupt) then
+ return
+ end
+ end
+ end
+
+ local OnShow = function (frame)
+ if (frame.MyObject.OnShowHook) then
+ local interrupt = frame.MyObject.OnShowHook (frame, frame.MyObject)
+ if (interrupt) then
+ return
+ end
+ end
+ end
+
+ local OnMouseDown = function (frame, button)
+ if (frame.MyObject.OnMouseDownHook) then
+ local interrupt = frame.MyObject.OnMouseDownHook (frame, button, frame.MyObject)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (frame.MyObject.container == UIParent) then
+ if (not frame.isLocked and frame:IsMovable()) then
+ frame.isMoving = true
+ frame:StartMoving()
+ end
+
+ elseif (not frame.MyObject.container.isLocked and frame.MyObject.container:IsMovable()) then
+ if (not frame.isLocked and frame:IsMovable()) then
+ frame.MyObject.container.isMoving = true
+ frame.MyObject.container:StartMoving()
+ end
+ end
+
+
+ end
+
+ local OnMouseUp = function (frame, button)
+ if (frame.MyObject.OnMouseUpHook) then
+ local interrupt = frame.MyObject.OnMouseUpHook (frame, button, frame.MyObject)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (button == "RightButton" and frame.MyObject.rightButtonClose) then
+ frame.MyObject:Hide()
+ end
+
+ if (frame.MyObject.container == UIParent) then
+ if (frame.isMoving) then
+ frame:StopMovingOrSizing()
+ frame.isMoving = false
+ end
+ else
+ if (frame.MyObject.container.isMoving) then
+ frame.MyObject.container:StopMovingOrSizing()
+ frame.MyObject.container.isMoving = false
+ end
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+function DF:CreatePanel (parent, w, h, backdrop, backdropcolor, bordercolor, member, name)
+ return DF:NewPanel (parent, parent, name, member, w, h, backdrop, backdropcolor, bordercolor)
+end
+
+function DF:NewPanel (parent, container, name, member, w, h, backdrop, backdropcolor, bordercolor)
+
+ if (not name) then
+ name = "DetailsFrameworkPanelNumber" .. DF.PanelCounter
+ DF.PanelCounter = DF.PanelCounter + 1
+
+ elseif (not parent) then
+ parent = UIParent
+ end
+ if (not container) then
+ container = parent
+ end
+
+ if (name:find ("$parent")) then
+ name = name:gsub ("$parent", parent:GetName())
+ end
+
+ local PanelObject = {type = "panel", dframework = true}
+
+ if (member) then
+ parent [member] = PanelObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+
+ --> default members:
+ --> hooks
+ PanelObject.OnEnterHook = nil
+ PanelObject.OnLeaveHook = nil
+ PanelObject.OnHideHook = nil
+ PanelObject.OnShowHook = nil
+ PanelObject.OnMouseDownHook = nil
+ PanelObject.OnMouseUpHook = nil
+ --> misc
+ PanelObject.is_locked = true
+ PanelObject.GradientEnabled = true
+ PanelObject.container = container
+ PanelObject.rightButtonClose = false
+
+ PanelObject.frame = CreateFrame ("frame", name, parent, "DetailsFrameworkPanelTemplate")
+ PanelObject.widget = PanelObject.frame
+
+ if (not APIFrameFunctions) then
+ APIFrameFunctions = {}
+ local idx = getmetatable (PanelObject.frame).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not PanelMetaFunctions [funcName]) then
+ PanelMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G."..object.frame:GetName()..":"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ PanelObject.frame:SetWidth (w or 100)
+ PanelObject.frame:SetHeight (h or 100)
+
+ PanelObject.frame.MyObject = PanelObject
+
+ --> hooks
+ PanelObject.frame:SetScript ("OnEnter", OnEnter)
+ PanelObject.frame:SetScript ("OnLeave", OnLeave)
+ PanelObject.frame:SetScript ("OnHide", OnHide)
+ PanelObject.frame:SetScript ("OnShow", OnShow)
+ PanelObject.frame:SetScript ("OnMouseDown", OnMouseDown)
+ PanelObject.frame:SetScript ("OnMouseUp", OnMouseUp)
+
+ _setmetatable (PanelObject, PanelMetaFunctions)
+
+ if (backdrop) then
+ PanelObject:SetBackdrop (backdrop)
+ elseif (_type (backdrop) == "boolean") then
+ PanelObject.frame:SetBackdrop (nil)
+ end
+
+ if (backdropcolor) then
+ PanelObject:SetBackdropColor (backdropcolor)
+ end
+
+ if (bordercolor) then
+ PanelObject:SetBackdropBorderColor (bordercolor)
+ end
+
+ return PanelObject
+end
+
+------------fill panel
+
+local button_on_enter = function (self)
+ self.MyObject._icon:SetBlendMode ("ADD")
+end
+local button_on_leave = function (self)
+ self.MyObject._icon:SetBlendMode ("BLEND")
+end
+
+function DF:CreateFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options)
+ return DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options)
+end
+
+function DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options)
+
+ local panel = DF:NewPanel (parent, parent, name, member, w, h)
+ panel.backdrop = nil
+
+ options = options or {rowheight = 20}
+ panel.rows = {}
+
+ for index, t in ipairs (rows) do
+ local thisrow = DF:NewPanel (panel, panel, "$parentHeader_" .. name .. index, nil, 1, 20)
+ thisrow.backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]]}
+ thisrow.color = "silver"
+ thisrow.type = t.type
+ thisrow.func = t.func
+ thisrow.name = t.name
+ thisrow.notext = t.notext
+ thisrow.icon = t.icon
+ thisrow.iconalign = t.iconalign
+
+ local text = DF:NewLabel (thisrow, nil, name .. "$parentLabel", "text")
+ text:SetPoint ("left", thisrow, "left", 2, 0)
+ text:SetText (t.name)
+
+ tinsert (panel.rows, thisrow)
+ end
+
+ local cur_width = 0
+ local row_width = w / #rows
+
+ local anchors = {}
+
+ for index, row in ipairs (panel.rows) do
+ if (autowidth) then
+ row:SetWidth (row_width)
+ row:SetPoint ("topleft", panel, "topleft", cur_width, 0)
+ tinsert (anchors, cur_width)
+ cur_width = cur_width + row_width + 1
+ else
+ row:SetPoint ("topleft", panel, "topleft", cur_width, 0)
+ row.width = rows [index].width
+ tinsert (anchors, cur_width)
+ cur_width = cur_width + rows [index].width + 1
+ end
+ end
+
+ if (autowidth) then
+ panel.rows [#panel.rows]:SetWidth (row_width - #rows + 1)
+ else
+ panel.rows [#panel.rows]:SetWidth (rows [#rows].width - #rows + 1)
+ end
+
+ local refresh_fillbox = function (self)
+ local offset = FauxScrollFrame_GetOffset (self)
+ local filled_lines = total_lines()
+
+ for index = 1, #self.lines do
+
+ local row = self.lines [index]
+ if (index <= filled_lines) then
+
+ local real_index = index + offset
+
+ local results = fill_row (real_index)
+
+ if (results [1]) then
+
+ row:Show()
+
+ for i = 1, #row.row_widgets do
+
+ row.row_widgets [i].index = real_index
+
+ if (panel.rows [i].type == "icon") then
+
+ local result = results [i]:gsub (".-%\\", "")
+ row.row_widgets [i]._icon.texture = results [i]
+
+ elseif (panel.rows [i].type == "button") then
+
+ if (type (results [i]) == "table") then
+
+ if (results [i].text) then
+ row.row_widgets [i]:SetText (results [i].text)
+ end
+
+ if (results [i].icon) then
+ row.row_widgets [i]._icon:SetTexture (results [i].icon)
+ end
+
+ if (results [i].func) then
+ row.row_widgets [i]:SetClickFunction (results [i].func, real_index, results [i].value)
+ end
+
+ else
+ row.row_widgets [i]:SetText (results [i])
+ end
+
+ else
+ --< text
+ row.row_widgets [i]:SetText (results [i])
+
+ end
+ end
+
+ else
+ row:Hide()
+ for i = 1, #row.row_widgets do
+ row.row_widgets [i]:SetText ("")
+ if (panel.rows [i].type == "icon") then
+ row.row_widgets [i]._icon.texture = ""
+ end
+ end
+ end
+ else
+ row:Hide()
+ for i = 1, #row.row_widgets do
+ row.row_widgets [i]:SetText ("")
+ if (panel.rows [i].type == "icon") then
+ row.row_widgets [i]._icon.texture = ""
+ end
+ end
+ end
+ end
+ end
+
+ function panel:Refresh()
+ local filled_lines = total_lines()
+ local scroll_total_lines = #panel.scrollframe
+ local line_height = options.rowheight
+
+ FauxScrollFrame_Update (panel.scrollframe, filled_lines, scroll_total_lines, line_height)
+ refresh_fillbox (panel.scrollframe)
+ end
+
+ local scrollframe = CreateFrame ("scrollframe", name .. "Scroll", panel.widget, "FauxScrollFrameTemplate")
+ scrollframe:SetScript ("OnVerticalScroll", function (self, offset) FauxScrollFrame_OnVerticalScroll (self, offset, 20, panel.Refresh) end)
+ scrollframe:SetPoint ("topleft", panel.widget, "topleft", 0, -21)
+ scrollframe:SetPoint ("topright", panel.widget, "topright", -23, -21)
+ scrollframe:SetPoint ("bottomleft", panel.widget, "bottomleft")
+ scrollframe:SetPoint ("bottomright", panel.widget, "bottomright", -23, 0)
+ scrollframe:SetSize (w, h)
+ panel.scrollframe = scrollframe
+ scrollframe.lines = {}
+
+ --create lines
+ local size = options.rowheight
+ local amount = math.floor (((h-21) / size))
+
+
+ for i = 1, amount do
+
+ local row = DF:NewPanel (parent, nil, "$parentRow_" .. i, nil, 1, size)
+ row.backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]]}
+ row.color = {1, 1, 1, .2}
+ row:SetPoint ("topleft", scrollframe, "topleft", 0, (i-1) * size * -1)
+ row:SetPoint ("topright", scrollframe, "topright", 0, (i-1) * size * -1)
+ tinsert (scrollframe.lines, row)
+
+ row.row_widgets = {}
+
+ for o = 1, #rows do
+
+ local _type = panel.rows [o].type
+
+ if (_type == "text") then
+
+ --> create text
+ local text = DF:NewLabel (row, nil, name .. "$parentLabel" .. o, "text" .. o)
+ text:SetPoint ("left", row, "left", anchors [o], 0)
+
+ --> insert in the table
+ tinsert (row.row_widgets, text)
+
+ elseif (_type == "entry") then
+
+ --> create editbox
+ local editbox = DF:NewTextEntry (row, nil, "$parentEntry" .. o, "entry", panel.rows [o].width, 20, panel.rows [o].func, i, o)
+ editbox.align = "left"
+ editbox:SetHook ("OnEnterPressed", function()
+ editbox.widget.focuslost = true
+ editbox:ClearFocus()
+ editbox.func (editbox.index, editbox.text)
+ return true
+ end)
+ editbox:SetPoint ("left", row, "left", anchors [o], 0)
+ editbox:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = 1})
+ editbox:SetBackdropColor (1, 1, 1, 0.1)
+ editbox:SetBackdropBorderColor (1, 1, 1, 0.1)
+ editbox.editbox.current_bordercolor = {1, 1, 1, 0.1}
+
+ --> insert in the table
+ tinsert (row.row_widgets, editbox)
+
+ elseif (_type == "button") then
+
+ --> create button
+ local button = DF:NewButton (row, nil, "$parentButton" .. o, "button", panel.rows [o].width, 20)
+
+ local func = function()
+ panel.rows [o].func (button.index, o)
+ panel:Refresh()
+ end
+ button:SetClickFunction (func)
+
+ button:SetPoint ("left", row, "left", anchors [o], 0)
+
+ --> create icon and the text
+ local icon = DF:NewImage (button, nil, 20, 20)
+ local text = DF:NewLabel (button)
+
+ button._icon = icon
+ button._text = text
+
+ button:SetHook ("OnEnter", button_on_enter)
+ button:SetHook ("OnLeave", button_on_leave)
+
+ if (panel.rows [o].icon) then
+ icon.texture = panel.rows [o].icon
+ if (panel.rows [o].iconalign) then
+ if (panel.rows [o].iconalign == "center") then
+ icon:SetPoint ("center", button, "center")
+ elseif (panel.rows [o].iconalign == "right") then
+ icon:SetPoint ("right", button, "right")
+ end
+ else
+ icon:SetPoint ("left", button, "left")
+ end
+ end
+
+ if (panel.rows [o].name and not panel.rows [o].notext) then
+ text:SetPoint ("left", icon, "right", 2, 0)
+ text.text = panel.rows [o].name
+ end
+
+ --> inser in the table
+ tinsert (row.row_widgets, button)
+
+ elseif (_type == "icon") then
+
+ --> create button and icon
+ local iconbutton = DF:NewButton (row, nil, "$parentIconButton" .. o, "iconbutton", 22, 20)
+ iconbutton:InstallCustomTexture()
+
+ iconbutton:SetHook ("OnEnter", button_on_enter)
+ iconbutton:SetHook ("OnLeave", button_on_leave)
+
+ --iconbutton:InstallCustomTexture()
+ local icon = DF:NewImage (iconbutton, nil, 20, 20, "artwork", nil, "_icon", "$parentIcon" .. o)
+ iconbutton._icon = icon
+
+ iconbutton:SetPoint ("left", row, "left", anchors [o] + ( (panel.rows [o].width - 22) / 2), 0)
+ icon:SetPoint ("center", iconbutton, "center", 0, 0)
+
+ --> set functions
+ local function iconcallback (texture)
+ iconbutton._icon.texture = texture
+ panel.rows [o].func (iconbutton.index, texture)
+ end
+
+ iconbutton:SetClickFunction (function()
+ DF:IconPick (iconcallback, true)
+ return true
+ end)
+
+ --> insert in the table
+ tinsert (row.row_widgets, iconbutton)
+
+ end
+
+ end
+ end
+
+ return panel
+end
+
+
+------------color pick
+local color_pick_func = function()
+ local r, g, b = ColorPickerFrame:GetColorRGB()
+ local a = OpacitySliderFrame:GetValue()
+ ColorPickerFrame:dcallback (r, g, b, a, ColorPickerFrame.dframe)
+end
+local color_pick_func_cancel = function()
+ ColorPickerFrame:SetColorRGB (unpack (ColorPickerFrame.previousValues))
+ local r, g, b = ColorPickerFrame:GetColorRGB()
+ local a = OpacitySliderFrame:GetValue()
+ ColorPickerFrame:dcallback (r, g, b, a, ColorPickerFrame.dframe)
+end
+
+function DF:ColorPick (frame, r, g, b, alpha, callback)
+
+ ColorPickerFrame:ClearAllPoints()
+ ColorPickerFrame:SetPoint ("bottomleft", frame, "topright", 0, 0)
+
+ ColorPickerFrame.dcallback = callback
+ ColorPickerFrame.dframe = frame
+
+ ColorPickerFrame.func = color_pick_func
+ ColorPickerFrame.opacityFunc = color_pick_func
+ ColorPickerFrame.cancelFunc = color_pick_func_cancel
+
+ ColorPickerFrame.opacity = alpha
+ ColorPickerFrame.hasOpacity = alpha and true
+
+ ColorPickerFrame.previousValues = {r, g, b}
+ ColorPickerFrame:SetParent (UIParent)
+ ColorPickerFrame:SetFrameStrata ("tooltip")
+ ColorPickerFrame:SetColorRGB (r, g, b)
+ ColorPickerFrame:Show()
+
+end
+
+------------icon pick
+function DF:IconPick (callback, close_when_select)
+
+ if (not DF.IconPickFrame) then
+
+ local string_lower = string.lower
+
+ DF.IconPickFrame = CreateFrame ("frame", "DetailsFrameworkIconPickFrame", UIParent)
+ tinsert (UISpecialFrames, "DetailsFrameworkIconPickFrame")
+ DF.IconPickFrame:SetFrameStrata ("DIALOG")
+
+ DF.IconPickFrame:SetPoint ("center", UIParent, "center")
+ DF.IconPickFrame:SetWidth (350)
+ DF.IconPickFrame:SetHeight (227)
+ DF.IconPickFrame:EnableMouse (true)
+ DF.IconPickFrame:SetMovable (true)
+ DF.IconPickFrame:SetBackdrop ({bgFile = DF.folder .. "background", edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
+ tile = true, tileSize = 32, edgeSize = 32, insets = {left = 5, right = 5, top = 5, bottom = 5}})
+
+ DF.IconPickFrame:SetBackdropBorderColor (170/255, 170/255, 170/255)
+ DF.IconPickFrame:SetBackdropColor (24/255, 24/255, 24/255, .8)
+ DF.IconPickFrame:SetFrameLevel (1)
+
+ DF.IconPickFrame.emptyFunction = function() end
+ DF.IconPickFrame.callback = DF.IconPickFrame.emptyFunction
+
+ DF.IconPickFrame.preview = CreateFrame ("frame", nil, UIParent)
+ DF.IconPickFrame.preview:SetFrameStrata ("tooltip")
+ DF.IconPickFrame.preview:SetSize (76, 76)
+ local preview_image = DF:NewImage (DF.IconPickFrame.preview, nil, 76, 76)
+ preview_image:SetAllPoints (DF.IconPickFrame.preview)
+ DF.IconPickFrame.preview.icon = preview_image
+ DF.IconPickFrame.preview:Hide()
+
+ DF.IconPickFrame.searchLabel = DF:NewLabel (DF.IconPickFrame, nil, "$parentSearchBoxLabel", nil, "search:", font, size, color)
+ DF.IconPickFrame.searchLabel:SetPoint ("topleft", DF.IconPickFrame, "topleft", 12, -20)
+ DF.IconPickFrame.search = DF:NewTextEntry (DF.IconPickFrame, nil, "$parentSearchBox", nil, 140, 20)
+ DF.IconPickFrame.search:SetPoint ("left", DF.IconPickFrame.searchLabel, "right", 2, 0)
+ DF.IconPickFrame.search:SetHook ("OnTextChanged", function()
+ DF.IconPickFrame.searching = DF.IconPickFrame.search:GetText()
+ if (DF.IconPickFrame.searching == "") then
+ DF.IconPickFrameScroll:Show()
+ DF.IconPickFrame.searching = nil
+ DF.IconPickFrame.updateFunc()
+ else
+ DF.IconPickFrameScroll:Hide()
+ FauxScrollFrame_SetOffset (DF.IconPickFrame, 1)
+ DF.IconPickFrame.last_filter_index = 1
+ DF.IconPickFrame.updateFunc()
+ end
+ end)
+
+ --> close button
+ local close_button = CreateFrame ("button", nil, DF.IconPickFrame, "UIPanelCloseButton")
+ close_button:SetWidth (32)
+ close_button:SetHeight (32)
+ close_button:SetPoint ("TOPRIGHT", DF.IconPickFrame, "TOPRIGHT", -8, -7)
+ close_button:SetFrameLevel (close_button:GetFrameLevel()+2)
+
+ local MACRO_ICON_FILENAMES = {}
+ DF.IconPickFrame:SetScript ("OnShow", function()
+
+ MACRO_ICON_FILENAMES = {};
+ MACRO_ICON_FILENAMES[1] = "INV_MISC_QUESTIONMARK";
+ local index = 2;
+
+ for i = 1, GetNumSpellTabs() do
+ local tab, tabTex, offset, numSpells, _ = GetSpellTabInfo(i);
+ offset = offset + 1;
+ local tabEnd = offset + numSpells;
+ for j = offset, tabEnd - 1 do
+ --to get spell info by slot, you have to pass in a pet argument
+ local spellType, ID = GetSpellBookItemInfo(j, "player");
+ if (spellType ~= "FUTURESPELL") then
+ local spellTexture = strupper(GetSpellBookItemTexture(j, "player"));
+ if ( not string.match( spellTexture, "INTERFACE\\BUTTONS\\") ) then
+ MACRO_ICON_FILENAMES[index] = gsub( spellTexture, "INTERFACE\\ICONS\\", "");
+ index = index + 1;
+ end
+ end
+ if (spellType == "FLYOUT") then
+ local _, _, numSlots, isKnown = GetFlyoutInfo(ID);
+ if (isKnown and numSlots > 0) then
+ for k = 1, numSlots do
+ local spellID, overrideSpellID, isKnown = GetFlyoutSlotInfo(ID, k)
+ if (isKnown) then
+ MACRO_ICON_FILENAMES[index] = gsub( strupper(GetSpellTexture(spellID)), "INTERFACE\\ICONS\\", "");
+ index = index + 1;
+ end
+ end
+ end
+ end
+ end
+ end
+
+ GetLooseMacroItemIcons (MACRO_ICON_FILENAMES)
+ GetLooseMacroIcons (MACRO_ICON_FILENAMES)
+ GetMacroIcons (MACRO_ICON_FILENAMES)
+ GetMacroItemIcons (MACRO_ICON_FILENAMES )
+
+ end)
+
+ DF.IconPickFrame:SetScript ("OnHide", function()
+ MACRO_ICON_FILENAMES = nil;
+ collectgarbage()
+ end)
+
+ DF.IconPickFrame.buttons = {}
+
+ local OnClickFunction = function (self)
+ DF.IconPickFrame.callback (self.icon:GetTexture())
+ if (DF.IconPickFrame.click_close) then
+ close_button:Click()
+ end
+ end
+
+ local onenter = function (self)
+ DF.IconPickFrame.preview:SetPoint ("bottom", self, "top", 0, 2)
+ DF.IconPickFrame.preview.icon:SetTexture (self.icon:GetTexture())
+ DF.IconPickFrame.preview:Show()
+ self.icon:SetBlendMode ("ADD")
+ end
+ local onleave = function (self)
+ DF.IconPickFrame.preview:Hide()
+ self.icon:SetBlendMode ("BLEND")
+ end
+
+ local backdrop = {bgFile = DF.folder .. "background", tile = true, tileSize = 16,
+ insets = {left = 0, right = 0, top = 0, bottom = 0}, edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]], edgeSize = 10}
+
+ for i = 0, 9 do
+ local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..(i+1), DF.IconPickFrame)
+ local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..(i+1).."Icon", "overlay")
+ newcheck.icon = image
+ image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
+ newcheck:SetSize (30, 28)
+ newcheck:SetBackdrop (backdrop)
+
+ newcheck:SetScript ("OnClick", OnClickFunction)
+ newcheck.param1 = i+1
+
+ newcheck:SetPoint ("topleft", DF.IconPickFrame, "topleft", 12 + (i*30), -40)
+ newcheck:SetID (i+1)
+ DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
+ newcheck:SetScript ("OnEnter", onenter)
+ newcheck:SetScript ("OnLeave", onleave)
+ end
+ for i = 11, 20 do
+ local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
+ local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
+ newcheck.icon = image
+ image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
+ newcheck:SetSize (30, 28)
+ newcheck:SetBackdrop (backdrop)
+
+ newcheck:SetScript ("OnClick", OnClickFunction)
+ newcheck.param1 = i
+
+ newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
+ newcheck:SetID (i)
+ DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
+ newcheck:SetScript ("OnEnter", onenter)
+ newcheck:SetScript ("OnLeave", onleave)
+ end
+ for i = 21, 30 do
+ local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
+ local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
+ newcheck.icon = image
+ image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
+ newcheck:SetSize (30, 28)
+ newcheck:SetBackdrop (backdrop)
+
+ newcheck:SetScript ("OnClick", OnClickFunction)
+ newcheck.param1 = i
+
+ newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
+ newcheck:SetID (i)
+ DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
+ newcheck:SetScript ("OnEnter", onenter)
+ newcheck:SetScript ("OnLeave", onleave)
+ end
+ for i = 31, 40 do
+ local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
+ local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
+ newcheck.icon = image
+ image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
+ newcheck:SetSize (30, 28)
+ newcheck:SetBackdrop (backdrop)
+
+ newcheck:SetScript ("OnClick", OnClickFunction)
+ newcheck.param1 = i
+
+ newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
+ newcheck:SetID (i)
+ DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
+ newcheck:SetScript ("OnEnter", onenter)
+ newcheck:SetScript ("OnLeave", onleave)
+ end
+ for i = 41, 50 do
+ local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
+ local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
+ newcheck.icon = image
+ image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
+ newcheck:SetSize (30, 28)
+ newcheck:SetBackdrop (backdrop)
+
+ newcheck:SetScript ("OnClick", OnClickFunction)
+ newcheck.param1 = i
+
+ newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
+ newcheck:SetID (i)
+ DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
+ newcheck:SetScript ("OnEnter", onenter)
+ newcheck:SetScript ("OnLeave", onleave)
+ end
+ for i = 51, 60 do
+ local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
+ local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
+ newcheck.icon = image
+ image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
+ newcheck:SetSize (30, 28)
+ newcheck:SetBackdrop (backdrop)
+
+ newcheck:SetScript ("OnClick", OnClickFunction)
+ newcheck.param1 = i
+
+ newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
+ newcheck:SetID (i)
+ DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
+ newcheck:SetScript ("OnEnter", onenter)
+ newcheck:SetScript ("OnLeave", onleave)
+ end
+
+ local scroll = CreateFrame ("ScrollFrame", "DetailsFrameworkIconPickFrameScroll", DF.IconPickFrame, "ListScrollFrameTemplate")
+
+ local ChecksFrame_Update = function (self)
+
+ local numMacroIcons = #MACRO_ICON_FILENAMES
+ local macroPopupIcon, macroPopupButton
+ local macroPopupOffset = FauxScrollFrame_GetOffset (scroll)
+ local index
+
+ local texture
+ local filter
+ if (DF.IconPickFrame.searching) then
+ filter = string_lower (DF.IconPickFrame.searching)
+ end
+
+ if (filter and filter ~= "") then
+
+ local ignored = 0
+ local tryed = 0
+ local found = 0
+ local type = type
+ local buttons = DF.IconPickFrame.buttons
+ index = 1
+
+ for i = 1, 60 do
+
+ macroPopupIcon = buttons[i].icon
+ macroPopupButton = buttons[i]
+
+ for o = index, numMacroIcons do
+
+ tryed = tryed + 1
+
+ texture = MACRO_ICON_FILENAMES [o]
+ if (type (texture) == "number") then
+ macroPopupIcon:SetToFileData (texture)
+ texture = macroPopupIcon:GetTexture()
+ macroPopupIcon:SetTexture (nil)
+ else
+ texture = "INTERFACE\\ICONS\\" .. texture
+ end
+
+ if (texture and texture:find (filter)) then
+ macroPopupIcon:SetTexture (texture)
+ macroPopupButton:Show()
+ found = found + 1
+ DF.IconPickFrame.last_filter_index = o
+ index = o+1
+ break
+ else
+ ignored = ignored + 1
+ end
+
+ end
+ end
+
+ for o = found+1, 60 do
+ macroPopupButton = _G ["DetailsFrameworkIconPickFrameButton"..o]
+ macroPopupButton:Hide()
+ end
+ else
+ for i = 1, 60 do
+ macroPopupIcon = _G ["DetailsFrameworkIconPickFrameButton"..i.."Icon"]
+ macroPopupButton = _G ["DetailsFrameworkIconPickFrameButton"..i]
+ index = (macroPopupOffset * 10) + i
+ texture = MACRO_ICON_FILENAMES [index]
+ if ( index <= numMacroIcons and texture ) then
+
+ if (type (texture) == "number") then
+ macroPopupIcon:SetToFileData (texture)
+ else
+ macroPopupIcon:SetTexture ("INTERFACE\\ICONS\\" .. texture)
+ end
+
+ macroPopupIcon:SetTexCoord (4/64, 60/64, 4/64, 60/64)
+ macroPopupButton.IconID = index
+ macroPopupButton:Show()
+ else
+ macroPopupButton:Hide()
+ end
+ end
+ end
+
+ -- Scrollbar stuff
+ FauxScrollFrame_Update (scroll, ceil (numMacroIcons / 10) , 5, 20 )
+ end
+
+ DF.IconPickFrame.updateFunc = ChecksFrame_Update
+
+ scroll:SetPoint ("topleft", DF.IconPickFrame, "topleft", -18, -37)
+ scroll:SetWidth (330)
+ scroll:SetHeight (178)
+ scroll:SetScript ("OnVerticalScroll", function (self, offset) FauxScrollFrame_OnVerticalScroll (scroll, offset, 20, ChecksFrame_Update) end)
+ scroll.update = ChecksFrame_Update
+ DF.IconPickFrameScroll = scroll
+ DF.IconPickFrame:Hide()
+
+ end
+
+ DF.IconPickFrame:Show()
+ DF.IconPickFrameScroll.update (DF.IconPickFrameScroll)
+ DF.IconPickFrame.callback = callback or DF.IconPickFrame.emptyFunction
+ DF.IconPickFrame.click_close = close_when_select
+
+end
+
+local simple_panel_counter = 1
+local simple_panel_mouse_down = function (self, button)
+ if (button == "RightButton") then
+ if (self.IsMoving) then
+ self.IsMoving = false
+ self:StopMovingOrSizing()
+ if (self.db and self.db.position) then
+ DF:SavePositionOnScreen (self)
+ end
+ end
+ self:Hide()
+ return
+ end
+ if (not self.IsMoving and not self.IsLocked) then
+ self.IsMoving = true
+ self:StartMoving()
+ end
+end
+local simple_panel_mouse_up = function (self, button)
+ if (self.IsMoving) then
+ self.IsMoving = false
+ self:StopMovingOrSizing()
+ if (self.db and self.db.position) then
+ DF:SavePositionOnScreen (self)
+ end
+ end
+end
+local simple_panel_settitle = function (self, title)
+ self.title:SetText (title)
+end
+
+function DF:CreateSimplePanel (parent, w, h, title, name)
+
+ if (not name) then
+ name = "DetailsFrameworkSimplePanel" .. simple_panel_counter
+ simple_panel_counter = simple_panel_counter + 1
+ end
+ if (not parent) then
+ parent = UIParent
+ end
+
+ local f = CreateFrame ("frame", name, UIParent)
+ f:SetSize (w or 400, h or 250)
+ f:SetPoint ("center", UIParent, "center", 0, 0)
+ f:SetFrameStrata ("FULLSCREEN")
+ f:EnableMouse()
+ f:SetMovable (true)
+ tinsert (UISpecialFrames, name)
+
+ f:SetScript ("OnMouseDown", simple_panel_mouse_down)
+ f:SetScript ("OnMouseUp", simple_panel_mouse_up)
+
+ local bg = f:CreateTexture (nil, "background")
+ bg:SetAllPoints (f)
+ bg:SetTexture (DF.folder .. "background")
+
+ local close = CreateFrame ("button", name .. "Close", f, "UIPanelCloseButton")
+ close:SetSize (32, 32)
+ close:SetPoint ("topright", f, "topright", 0, -12)
+
+ f.title = DF:CreateLabel (f, title or "", 12, nil, "GameFontNormal")
+ f.title:SetPoint ("top", f, "top", 0, -22)
+
+ f.SetTitle = simple_panel_settitle
+
+ simple_panel_counter = simple_panel_counter + 1
+
+ return f
+end
+
+local Panel1PxBackdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 64,
+edgeFile = DF.folder .. "border_3", edgeSize = 9, insets = {left = 2, right = 2, top = 3, bottom = 3}}
+
+local Panel1PxOnClickClose = function (self)
+ self:GetParent():Hide()
+end
+local Panel1PxOnToggleLock = function (self)
+ if (self.IsLocked) then
+ self.IsLocked = false
+ self:SetMovable (true)
+ self:EnableMouse (true)
+ self.Lock:GetNormalTexture():SetTexCoord (32/128, 48/128, 0, 1)
+ self.Lock:GetHighlightTexture():SetTexCoord (32/128, 48/128, 0, 1)
+ self.Lock:GetPushedTexture():SetTexCoord (32/128, 48/128, 0, 1)
+ else
+ self.IsLocked = true
+ self:SetMovable (false)
+ self:EnableMouse (false)
+ self.Lock:GetNormalTexture():SetTexCoord (16/128, 32/128, 0, 1)
+ self.Lock:GetHighlightTexture():SetTexCoord (16/128, 32/128, 0, 1)
+ self.Lock:GetPushedTexture():SetTexCoord (16/128, 32/128, 0, 1)
+ end
+end
+local Panel1PxOnClickLock = function (self)
+ local f = self:GetParent()
+ Panel1PxOnToggleLock (f)
+end
+local Panel1PxSetTitle = function (self, text)
+ self.Title:SetText (text or "")
+end
+
+local Panel1PxReadConfig = function (self)
+ local db = self.db
+ if (db) then
+ db.IsLocked = db.IsLocked or false
+ self.IsLocked = db.IsLocked
+ db.position = db.position or {x = 0, y = 0}
+ DF:RestoreFramePosition (self)
+ end
+end
+
+function DF:SavePositionOnScreen (frame)
+ if (frame.db and frame.db.position) then
+ local x, y = DF:GetPositionOnScreen (frame)
+ frame.db.position.x, frame.db.position.y = x, y
+ end
+end
+
+function DF:GetPositionOnScreen (frame)
+ local xOfs, yOfs = frame:GetCenter()
+ if (not xOfs) then
+ return
+ end
+ local scale = frame:GetEffectiveScale()
+ local UIscale = UIParent:GetScale()
+ xOfs = xOfs*scale - GetScreenWidth()*UIscale/2
+ yOfs = yOfs*scale - GetScreenHeight()*UIscale/2
+ return xOfs/UIscale, yOfs/UIscale
+end
+
+function DF:RestoreFramePosition (frame)
+ if (frame.db and frame.db.position) then
+ local scale, UIscale = frame:GetEffectiveScale(), UIParent:GetScale()
+ frame:ClearAllPoints()
+ frame:SetPoint ("center", UIParent, "center", frame.db.position.x * UIscale / scale, frame.db.position.y * UIscale / scale)
+ end
+end
+
+function DF:Create1PxPanel (parent, w, h, title, name, config, title_anchor)
+ local f = CreateFrame ("frame", name, parent or UIParent)
+ f:SetSize (w or 100, h or 75)
+ f:SetPoint ("center", UIParent, "center")
+
+ if (name) then
+ tinsert (UISpecialFrames, name)
+ end
+
+ f:SetScript ("OnMouseDown", simple_panel_mouse_down)
+ f:SetScript ("OnMouseUp", simple_panel_mouse_up)
+
+ f:SetBackdrop (Panel1PxBackdrop)
+ f:SetBackdropColor (0, 0, 0, 0.5)
+
+ f.IsLocked = false
+ f:SetMovable (true)
+ f:EnableMouse (true)
+ f:SetUserPlaced (true)
+
+ f.db = config
+ Panel1PxReadConfig (f)
+
+ local close = CreateFrame ("button", name and name .. "CloseButton", f)
+ close:SetSize (16, 16)
+ close:SetNormalTexture (DF.folder .. "icons")
+ close:SetHighlightTexture (DF.folder .. "icons")
+ close:SetPushedTexture (DF.folder .. "icons")
+ close:GetNormalTexture():SetTexCoord (0, 16/128, 0, 1)
+ close:GetHighlightTexture():SetTexCoord (0, 16/128, 0, 1)
+ close:GetPushedTexture():SetTexCoord (0, 16/128, 0, 1)
+ close:SetAlpha (0.7)
+
+ local lock = CreateFrame ("button", name and name .. "LockButton", f)
+ lock:SetSize (16, 16)
+ lock:SetNormalTexture (DF.folder .. "icons")
+ lock:SetHighlightTexture (DF.folder .. "icons")
+ lock:SetPushedTexture (DF.folder .. "icons")
+ lock:GetNormalTexture():SetTexCoord (32/128, 48/128, 0, 1)
+ lock:GetHighlightTexture():SetTexCoord (32/128, 48/128, 0, 1)
+ lock:GetPushedTexture():SetTexCoord (32/128, 48/128, 0, 1)
+ lock:SetAlpha (0.7)
+
+ close:SetPoint ("topright", f, "topright", -3, -3)
+ lock:SetPoint ("right", close, "left", 3, 0)
+
+ close:SetScript ("OnClick", Panel1PxOnClickClose)
+ lock:SetScript ("OnClick", Panel1PxOnClickLock)
+
+ local title_string = f:CreateFontString (name and name .. "Title", "overlay", "GameFontNormal")
+ title_string:SetPoint ("topleft", f, "topleft", 5, -5)
+ title_string:SetText (title or "")
+
+ if (title_anchor) then
+ if (title_anchor == "top") then
+ title_string:ClearAllPoints()
+ title_string:SetPoint ("bottomleft", f, "topleft", 0, 0)
+ close:ClearAllPoints()
+ close:SetPoint ("bottomright", f, "topright", 0, 0)
+ end
+ f.title_anchor = title_anchor
+ end
+
+ f.SetTitle = Panel1PxSetTitle
+ f.Title = title_string
+ f.Lock = lock
+ f.Close = close
+
+ return f
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------
+--> options button -- ~options
+function DF:CreateOptionsButton (parent, callback, name)
+
+ local b = CreateFrame ("button", name, parent)
+ b:SetSize (14, 14)
+ b:SetNormalTexture (DF.folder .. "icons")
+ b:SetHighlightTexture (DF.folder .. "icons")
+ b:SetPushedTexture (DF.folder .. "icons")
+ b:GetNormalTexture():SetTexCoord (48/128, 64/128, 0, 1)
+ b:GetHighlightTexture():SetTexCoord (48/128, 64/128, 0, 1)
+ b:GetPushedTexture():SetTexCoord (48/128, 64/128, 0, 1)
+ b:SetAlpha (0.7)
+
+ b:SetScript ("OnClick", callback)
+ b:SetScript ("OnEnter", function (self)
+ GameCooltip2:Reset()
+ GameCooltip2:AddLine ("Options")
+ GameCooltip2:ShowCooltip (self, "tooltip")
+ end)
+ b:SetScript ("OnLeave", function (self)
+ GameCooltip2:Hide()
+ end)
+
+ return b
+
+end
+
+------------------------------------------------------------------------------------------------------------------------------------------------
+--> feedback panel -- ~feedback
+
+function DF:CreateFeedbackButton (parent, callback, name)
+ local b = CreateFrame ("button", name, parent)
+ b:SetSize (12, 13)
+ b:SetNormalTexture (DF.folder .. "mail")
+ b:SetPushedTexture (DF.folder .. "mail")
+ b:SetHighlightTexture (DF.folder .. "mail")
+
+ b:SetScript ("OnClick", callback)
+ b:SetScript ("OnEnter", function (self)
+ GameCooltip2:Reset()
+ GameCooltip2:AddLine ("Send Feedback")
+ GameCooltip2:ShowCooltip (self, "tooltip")
+ end)
+ b:SetScript ("OnLeave", function (self)
+ GameCooltip2:Hide()
+ end)
+
+ return b
+end
+
+local backdrop_fb_line = {bgFile = DF.folder .. "background", edgeFile = DF.folder .. "border_3",
+tile = true, tileSize = 64, edgeSize = 8, insets = {left = 2, right = 2, top = 2, bottom = 2}}
+
+local on_enter_feedback = function (self)
+ self:SetBackdropColor (1, 1, 0, 0.5)
+end
+local on_leave_feedback = function (self)
+ self:SetBackdropColor (0, 0, 0, 0.3)
+end
+
+local on_click_feedback = function (self)
+
+ local feedback_link_textbox = DF.feedback_link_textbox
+
+ if (not feedback_link_textbox) then
+ local editbox = DF:CreateTextEntry (AddonFeedbackPanel, _, 275, 34)
+ editbox:SetAutoFocus (false)
+ editbox:SetHook ("OnEditFocusGained", function()
+ editbox.text = editbox.link
+ editbox:HighlightText()
+ end)
+ editbox:SetHook ("OnEditFocusLost", function()
+ editbox:Hide()
+ end)
+ editbox:SetHook ("OnChar", function()
+ editbox.text = editbox.link
+ editbox:HighlightText()
+ end)
+ editbox.text = ""
+
+ DF.feedback_link_textbox = editbox
+ feedback_link_textbox = editbox
+ end
+
+ feedback_link_textbox.link = self.link
+ feedback_link_textbox.text = self.link
+ feedback_link_textbox:Show()
+
+ feedback_link_textbox:SetPoint ("topleft", self.icon, "topright", 3, 0)
+
+ feedback_link_textbox:HighlightText()
+
+ feedback_link_textbox:SetFocus()
+ feedback_link_textbox:SetFrameLevel (self:GetFrameLevel()+2)
+end
+
+local feedback_get_fb_line = function (self)
+
+ local line = self.feedback_lines [self.next_feedback]
+ if (not line) then
+ line = CreateFrame ("frame", "AddonFeedbackPanelFB" .. self.next_feedback, self)
+ line:SetBackdrop (backdrop_fb_line)
+ line:SetBackdropColor (0, 0, 0, 0.3)
+ line:SetSize (390, 42)
+ line:SetPoint ("topleft", self.feedback_anchor, "bottomleft", 0, -5 + ((self.next_feedback-1) * 46 * -1))
+ line:SetScript ("OnEnter", on_enter_feedback)
+ line:SetScript ("OnLeave", on_leave_feedback)
+ line:SetScript ("OnMouseUp", on_click_feedback)
+
+ line.icon = line:CreateTexture (nil, "overlay")
+ line.icon:SetSize (90, 36)
+
+ line.desc = line:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
+
+ line.icon:SetPoint ("left", line, "left", 5, 0)
+ line.desc:SetPoint ("left", line.icon, "right", 5, 0)
+
+ local arrow = line:CreateTexture (nil, "overlay")
+ arrow:SetTexture ([[Interface\Buttons\JumpUpArrow]])
+ arrow:SetRotation (-1.55)
+ arrow:SetPoint ("right", line, "right", -5, 0)
+
+ self.feedback_lines [self.next_feedback] = line
+ end
+
+ self.next_feedback = self.next_feedback + 1
+
+ return line
+end
+
+local on_click_feedback = function (self)
+
+ local feedback_link_textbox = DF.feedback_link_textbox
+
+ if (not feedback_link_textbox) then
+ local editbox = DF:CreateTextEntry (AddonFeedbackPanel, _, 275, 34)
+ editbox:SetAutoFocus (false)
+ editbox:SetHook ("OnEditFocusGained", function()
+ editbox.text = editbox.link
+ editbox:HighlightText()
+ end)
+ editbox:SetHook ("OnEditFocusLost", function()
+ editbox:Hide()
+ end)
+ editbox:SetHook ("OnChar", function()
+ editbox.text = editbox.link
+ editbox:HighlightText()
+ end)
+ editbox.text = ""
+
+ DF.feedback_link_textbox = editbox
+ feedback_link_textbox = editbox
+ end
+
+ feedback_link_textbox.link = self.link
+ feedback_link_textbox.text = self.link
+ feedback_link_textbox:Show()
+
+ feedback_link_textbox:SetPoint ("topleft", self.icon, "topright", 3, 0)
+
+ feedback_link_textbox:HighlightText()
+
+ feedback_link_textbox:SetFocus()
+ feedback_link_textbox:SetFrameLevel (self:GetFrameLevel()+2)
+end
+
+local on_enter_addon = function (self)
+ if (self.tooltip) then
+ GameCooltip2:Preset (2)
+ GameCooltip2:AddLine ("|cFFFFFF00" .. self.name .. "|r")
+ GameCooltip2:AddLine ("")
+ GameCooltip2:AddLine (self.tooltip)
+ GameCooltip2:ShowCooltip (self, "tooltip")
+ end
+ self.icon:SetBlendMode ("ADD")
+end
+local on_leave_addon = function (self)
+ if (self.tooltip) then
+ GameCooltip2:Hide()
+ end
+ self.icon:SetBlendMode ("BLEND")
+end
+local on_click_addon = function (self)
+ local addon_link_textbox = DF.addon_link_textbox
+
+ if (not addon_link_textbox) then
+ local editbox = DF:CreateTextEntry (AddonFeedbackPanel, _, 128, 64)
+ editbox:SetAutoFocus (false)
+ editbox:SetHook ("OnEditFocusGained", function()
+ editbox.text = editbox.link
+ editbox:HighlightText()
+ end)
+ editbox:SetHook ("OnEditFocusLost", function()
+ editbox:Hide()
+ end)
+ editbox:SetHook ("OnChar", function()
+ editbox.text = editbox.link
+ editbox:HighlightText()
+ end)
+ editbox.text = ""
+
+ DF.addon_link_textbox = editbox
+ addon_link_textbox = editbox
+ end
+
+ addon_link_textbox.link = self.link
+ addon_link_textbox.text = self.link
+ addon_link_textbox:Show()
+
+ addon_link_textbox:SetPoint ("topleft", self.icon, "topleft", 0, 0)
+
+ addon_link_textbox:HighlightText()
+
+ addon_link_textbox:SetFocus()
+ addon_link_textbox:SetFrameLevel (self:GetFrameLevel()+2)
+end
+
+local feedback_get_addons_line = function (self)
+ local line = self.addons_lines [self.next_addons]
+ if (not line) then
+
+ line = CreateFrame ("frame", "AddonFeedbackPanelSA" .. self.next_addons, self)
+ line:SetSize (128, 64)
+
+ if (self.next_addons == 1) then
+ line:SetPoint ("topleft", self.addons_anchor, "bottomleft", 0, -5)
+ elseif (self.next_addons_line_break == self.next_addons) then
+ line:SetPoint ("topleft", self.addons_anchor, "bottomleft", 0, -5 + floor (self.next_addons_line_break/3) * 66 * -1)
+ self.next_addons_line_break = self.next_addons_line_break + 3
+ else
+ local previous = self.addons_lines [self.next_addons - 1]
+ line:SetPoint ("topleft", previous, "topright", 2, 0)
+ end
+
+ line:SetScript ("OnEnter", on_enter_addon)
+ line:SetScript ("OnLeave", on_leave_addon)
+ line:SetScript ("OnMouseUp", on_click_addon)
+
+ line.icon = line:CreateTexture (nil, "overlay")
+ line.icon:SetSize (128, 64)
+
+ line.icon:SetPoint ("topleft", line, "topleft", 0, 0)
+
+ self.addons_lines [self.next_addons] = line
+ end
+
+ self.next_addons = self.next_addons + 1
+
+ return line
+end
+
+local default_coords = {0, 1, 0, 1}
+local feedback_add_fb = function (self, table)
+ local line = self:GetFeedbackLine()
+ line.icon:SetTexture (table.icon)
+ line.icon:SetTexCoord (unpack (table.coords or default_coords))
+ line.desc:SetText (table.desc)
+ line.link = table.link
+ line:Show()
+end
+
+local feedback_add_addon = function (self, table)
+ local block = self:GetAddonsLine()
+ block.icon:SetTexture (table.icon)
+ block.icon:SetTexCoord (unpack (table.coords or default_coords))
+ block.link = table.link
+ block.tooltip = table.desc
+ block.name = table.name
+ block:Show()
+end
+
+local feedback_hide_all = function (self)
+ self.next_feedback = 1
+ self.next_addons = 1
+
+ for index, line in ipairs (self.feedback_lines) do
+ line:Hide()
+ end
+
+ for index, line in ipairs (self.addons_lines) do
+ line:Hide()
+ end
+end
+
+-- feedback_methods = { { icon = icon path, desc = description, link = url}}
+function DF:ShowFeedbackPanel (addon_name, version, feedback_methods, more_addons)
+
+ local f = _G.AddonFeedbackPanel
+
+ if (not f) then
+ f = DF:Create1PxPanel (UIParent, 400, 100, addon_name .. " Feedback", "AddonFeedbackPanel", nil)
+ f:SetFrameStrata ("FULLSCREEN")
+ f:SetPoint ("center", UIParent, "center")
+ f:SetBackdropColor (0, 0, 0, 0.8)
+ f.feedback_lines = {}
+ f.addons_lines = {}
+ f.next_feedback = 1
+ f.next_addons = 1
+ f.next_addons_line_break = 4
+
+ local feedback_anchor = f:CreateFontString (nil, "overlay", "GameFontNormal")
+ feedback_anchor:SetText ("Feedback:")
+ feedback_anchor:SetPoint ("topleft", f, "topleft", 5, -30)
+ f.feedback_anchor = feedback_anchor
+ local excla_text = f:CreateFontString (nil, "overlay", "GameFontNormal")
+ excla_text:SetText ("click and copy the link")
+ excla_text:SetPoint ("topright", f, "topright", -5, -30)
+ excla_text:SetTextColor (1, 0.8, 0.2, 0.6)
+
+ local addons_anchor = f:CreateFontString (nil, "overlay", "GameFontNormal")
+ addons_anchor:SetText ("AddOns From the Same Author:")
+ f.addons_anchor = addons_anchor
+ local excla_text2 = f:CreateFontString (nil, "overlay", "GameFontNormal")
+ excla_text2:SetText ("click and copy the link")
+ excla_text2:SetTextColor (1, 0.8, 0.2, 0.6)
+ f.excla_text2 = excla_text2
+
+ f.GetFeedbackLine = feedback_get_fb_line
+ f.GetAddonsLine = feedback_get_addons_line
+ f.AddFeedbackMethod = feedback_add_fb
+ f.AddOtherAddon = feedback_add_addon
+ f.HideAll = feedback_hide_all
+
+ DF:SetFontSize (f.Title, 14)
+
+ end
+
+ f:HideAll()
+ f:SetTitle (addon_name)
+
+ for index, feedback in ipairs (feedback_methods) do
+ f:AddFeedbackMethod (feedback)
+ end
+
+ f.addons_anchor:SetPoint ("topleft", f, "topleft", 5, f.next_feedback * 50 * -1)
+ f.excla_text2:SetPoint ("topright", f, "topright", -5, f.next_feedback * 50 * -1)
+
+ for index, addon in ipairs (more_addons) do
+ f:AddOtherAddon (addon)
+ end
+
+ f:SetHeight (80 + ((f.next_feedback-1) * 50) + (ceil ((f.next_addons-1)/3) * 66))
+
+ f:Show()
+
+ return true
+end
+
+
+------------------------------------------------------------------------------------------------------------------------------------------------
+--> chart panel -- ~chart
+
+local chart_panel_backdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
+edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 32, insets = {left = 5, right = 5, top = 5, bottom = 5}}
+
+local chart_panel_align_timelabels = function (self, elapsed_time)
+
+ self.TimeScale = elapsed_time
+
+ local linha = self.TimeLabels [17]
+ local minutos, segundos = math.floor (elapsed_time / 60), math.floor (elapsed_time % 60)
+ if (segundos < 10) then
+ segundos = "0" .. segundos
+ end
+
+ if (minutos > 0) then
+ if (minutos < 10) then
+ minutos = "0" .. minutos
+ end
+ linha:SetText (minutos .. ":" .. segundos)
+ else
+ linha:SetText ("00:" .. segundos)
+ end
+
+ local time_div = elapsed_time / 16 --786 -- 49.125
+
+ for i = 2, 16 do
+
+ local linha = self.TimeLabels [i]
+
+ local this_time = time_div * (i-1)
+ local minutos, segundos = math.floor (this_time / 60), math.floor (this_time % 60)
+
+ if (segundos < 10) then
+ segundos = "0" .. segundos
+ end
+
+ if (minutos > 0) then
+ if (minutos < 10) then
+ minutos = "0" .. minutos
+ end
+ linha:SetText (minutos .. ":" .. segundos)
+ else
+ linha:SetText ("00:" .. segundos)
+ end
+
+ end
+
+end
+
+local chart_panel_set_scale = function (self, amt, func, text)
+ if (type (amt) ~= "number") then
+ return
+ end
+
+ local piece = amt / 1000 / 8
+
+ for i = 1, 8 do
+ if (func) then
+ self ["dpsamt" .. math.abs (i-9)]:SetText ( func (piece*i) .. (text or ""))
+ else
+ if (piece*i > 1) then
+ self ["dpsamt" .. math.abs (i-9)]:SetText ( floor (piece*i) .. (text or ""))
+ else
+ self ["dpsamt" .. math.abs (i-9)]:SetText ( format ("%.3f", piece*i) .. (text or ""))
+ end
+ end
+ end
+end
+
+local chart_panel_can_move = function (self, can)
+ self.can_move = can
+end
+
+local chart_panel_overlay_reset = function (self)
+ self.OverlaysAmount = 1
+ for index, pack in ipairs (self.Overlays) do
+ for index2, texture in ipairs (pack) do
+ texture:Hide()
+ end
+ end
+end
+
+local chart_panel_reset = function (self)
+
+ self.Graphic:ResetData()
+ self.Graphic.max_value = 0
+
+ self.TimeScale = nil
+ self.BoxLabelsAmount = 1
+ table.wipe (self.GData)
+ table.wipe (self.OData)
+
+ for index, box in ipairs (self.BoxLabels) do
+ box.check:Hide()
+ box.button:Hide()
+ box.box:Hide()
+ box.text:Hide()
+ box.border:Hide()
+ box.showing = false
+ end
+
+ chart_panel_overlay_reset (self)
+end
+
+local chart_panel_enable_line = function (f, thisbox)
+
+ local index = thisbox.index
+ local type = thisbox.type
+
+ if (thisbox.enabled) then
+ --disable
+ thisbox.check:Hide()
+ thisbox.enabled = false
+ else
+ --enable
+ thisbox.check:Show()
+ thisbox.enabled = true
+ end
+
+ if (type == "graphic") then
+
+ f.Graphic:ResetData()
+ f.Graphic.max_value = 0
+
+ local max = 0
+ local max_time = 0
+
+ for index, box in ipairs (f.BoxLabels) do
+ if (box.type == type and box.showing and box.enabled) then
+ local data = f.GData [index]
+
+ f.Graphic:AddDataSeries (data[1], data[2], nil, data[3])
+
+ if (data[4] > max) then
+ max = data[4]
+ end
+ if (data [5] > max_time) then
+ max_time = data [5]
+ end
+ end
+ end
+
+ f:SetScale (max)
+ f:SetTime (max_time)
+
+ elseif (type == "overlay") then
+
+ chart_panel_overlay_reset (f)
+
+ for index, box in ipairs (f.BoxLabels) do
+ if (box.type == type and box.showing and box.enabled) then
+
+ f:AddOverlay (box.index)
+
+ end
+ end
+
+ end
+end
+
+local create_box = function (self, next_box)
+
+ local thisbox = {}
+ self.BoxLabels [next_box] = thisbox
+
+ local box = DF:NewImage (self.Graphic, nil, 16, 16, "border")
+
+ local text = DF:NewLabel (self.Graphic)
+
+ local border = DF:NewImage (self.Graphic, [[Interface\DialogFrame\UI-DialogBox-Gold-Corner]], 30, 30, "artwork")
+ border:SetPoint ("center", box, "center", -3, -4)
+ border:SetTexture ([[Interface\DialogFrame\UI-DialogBox-Gold-Corner]])
+
+ local checktexture = DF:NewImage (self.Graphic, [[Interface\Buttons\UI-CheckBox-Check]], 18, 18, "overlay")
+ checktexture:SetPoint ("center", box, "center", -1, -1)
+ checktexture:SetTexture ([[Interface\Buttons\UI-CheckBox-Check]])
+
+ thisbox.box = box
+ thisbox.text = text
+ thisbox.border = border
+ thisbox.check = checktexture
+ thisbox.enabled = true
+
+ local button = CreateFrame ("button", nil, self.Graphic)
+ button:SetSize (20, 20)
+ button:SetScript ("OnClick", function()
+ chart_panel_enable_line (self, thisbox)
+ end)
+ button:SetPoint ("center", box, "center")
+
+ thisbox.button = button
+
+ thisbox.box:SetPoint ("right", text, "left", -4, 0)
+
+ if (next_box == 1) then
+ thisbox.text:SetPoint ("topright", self, "topright", -35, -16)
+ else
+ thisbox.text:SetPoint ("right", self.BoxLabels [next_box-1].box, "left", -7, 0)
+ end
+
+ return thisbox
+
+end
+
+local realign_labels = function (self)
+
+ local width = self:GetWidth() - 108
+
+ local first_box = self.BoxLabels [1]
+ first_box.text:SetPoint ("topright", self, "topright", -35, -16)
+
+ local line_width = first_box.text:GetStringWidth() + 26
+
+ for i = 2, #self.BoxLabels do
+
+ local box = self.BoxLabels [i]
+
+ if (box.box:IsShown()) then
+
+ line_width = line_width + box.text:GetStringWidth() + 26
+
+ if (line_width > width) then
+ line_width = box.text:GetStringWidth() + 26
+ box.text:SetPoint ("topright", self, "topright", -35, -40)
+ else
+ box.text:SetPoint ("right", self.BoxLabels [i-1].box, "left", -7, 0)
+ end
+ else
+ break
+ end
+ end
+
+end
+
+local chart_panel_add_label = function (self, color, name, type, number)
+
+ local next_box = self.BoxLabelsAmount
+ local thisbox = self.BoxLabels [next_box]
+
+ if (not thisbox) then
+ thisbox = create_box (self, next_box)
+ end
+
+ self.BoxLabelsAmount = self.BoxLabelsAmount + 1
+
+ thisbox.type = type
+ thisbox.index = number
+
+ thisbox.box:SetTexture (unpack (color))
+ thisbox.text:SetText (name)
+
+ thisbox.check:Show()
+ thisbox.button:Show()
+ thisbox.border:Show()
+ thisbox.box:Show()
+ thisbox.text:Show()
+
+ thisbox.showing = true
+ thisbox.enabled = true
+
+ realign_labels (self)
+
+end
+
+local line_default_color = {1, 1, 1}
+local draw_overlay = function (self, this_overlay, overlayData, color)
+
+ local pixel = self.Graphic:GetWidth() / self.TimeScale
+ local index = 1
+ local r, g, b = unpack (color)
+
+ for i = 1, #overlayData, 2 do
+ local aura_start = overlayData [i]
+ local aura_end = overlayData [i+1]
+
+ local this_block = this_overlay [index]
+ if (not this_block) then
+ this_block = self.Graphic:CreateTexture (nil, "border")
+ tinsert (this_overlay, this_block)
+ end
+ this_block:SetHeight (self.Graphic:GetHeight())
+
+ this_block:SetPoint ("left", self.Graphic, "left", pixel * aura_start, 0)
+ if (aura_end) then
+ this_block:SetWidth ((aura_end-aura_start)*pixel)
+ else
+ --malformed table
+ this_block:SetWidth (pixel*5)
+ end
+
+ this_block:SetTexture (r, g, b, 0.25)
+ this_block:Show()
+
+ index = index + 1
+ end
+
+end
+
+local chart_panel_add_overlay = function (self, overlayData, color, name, icon)
+
+ if (not self.TimeScale) then
+ error ("Use SetTime (time) before adding an overlay.")
+ end
+
+ if (type (overlayData) == "number") then
+ local overlay_index = overlayData
+ draw_overlay (self, self.Overlays [self.OverlaysAmount], self.OData [overlay_index][1], self.OData [overlay_index][2])
+ else
+ local this_overlay = self.Overlays [self.OverlaysAmount]
+ if (not this_overlay) then
+ this_overlay = {}
+ tinsert (self.Overlays, this_overlay)
+ end
+
+ draw_overlay (self, this_overlay, overlayData, color)
+
+ tinsert (self.OData, {overlayData, color or line_default_color})
+ if (name) then
+ self:AddLabel (color or line_default_color, name, "overlay", #self.OData)
+ end
+ end
+
+ self.OverlaysAmount = self.OverlaysAmount + 1
+end
+
+local SMA_table = {}
+local SMA_max = 0
+local reset_SMA = function()
+ table.wipe (SMA_table)
+ SMA_max = 0
+end
+
+local calc_SMA
+calc_SMA = function (a, b, ...)
+ if (b) then
+ return calc_SMA (a + b, ...)
+ else
+ return a
+ end
+end
+
+local do_SMA = function (value, max_value)
+
+ if (#SMA_table == 10) then
+ tremove (SMA_table, 1)
+ end
+
+ SMA_table [#SMA_table + 1] = value
+
+ local new_value = calc_SMA (unpack (SMA_table)) / #SMA_table
+
+ if (new_value > SMA_max) then
+ SMA_max = new_value
+ return new_value, SMA_max
+ else
+ return new_value
+ end
+
+end
+
+local chart_panel_add_data = function (self, graphicData, color, name, elapsed_time, lineTexture, smoothLevel, firstIndex)
+
+ local f = self
+ self = self.Graphic
+
+ local _data = {}
+ local max_value = graphicData.max_value
+ local amount = #graphicData
+
+ local scaleW = 1/self:GetWidth()
+
+ local content = graphicData
+ tinsert (content, 1, 0)
+ tinsert (content, 1, 0)
+ tinsert (content, #content+1, 0)
+ tinsert (content, #content+1, 0)
+
+ local _i = 3
+
+ local graphMaxDps = math.max (self.max_value, max_value)
+
+ if (not smoothLevel) then
+ while (_i <= #content-2) do
+ local v = (content[_i-2]+content[_i-1]+content[_i]+content[_i+1]+content[_i+2])/5 --> normalize
+ _data [#_data+1] = {scaleW*(_i-2), v/graphMaxDps} --> x and y coords
+ _i = _i + 1
+ end
+
+ elseif (smoothLevel == "SHORT") then
+ while (_i <= #content-2) do
+ local value = (content[_i] + content[_i+1]) / 2
+ _data [#_data+1] = {scaleW*(_i-2), value}
+ _data [#_data+1] = {scaleW*(_i-2), value}
+ _i = _i + 2
+ end
+
+ elseif (smoothLevel == "SMA") then
+ reset_SMA()
+ while (_i <= #content-2) do
+ local value, is_new_max_value = do_SMA (content[_i], max_value)
+ if (is_new_max_value) then
+ max_value = is_new_max_value
+ end
+ _data [#_data+1] = {scaleW*(_i-2), value} --> x and y coords
+ _i = _i + 1
+ end
+
+ elseif (smoothLevel == -1) then
+ while (_i <= #content-2) do
+ local current = content[_i]
+
+ local minus_2 = content[_i-2] * 0.6
+ local minus_1 = content[_i-1] * 0.8
+ local plus_1 = content[_i+1] * 0.8
+ local plus_2 = content[_i+2] * 0.6
+
+ local v = (current + minus_2 + minus_1 + plus_1 + plus_2)/5 --> normalize
+ _data [#_data+1] = {scaleW*(_i-2), v/graphMaxDps} --> x and y coords
+ _i = _i + 1
+ end
+
+ elseif (smoothLevel == 1) then
+ _i = 2
+ while (_i <= #content-1) do
+ local v = (content[_i-1]+content[_i]+content[_i+1])/3 --> normalize
+ _data [#_data+1] = {scaleW*(_i-1), v/graphMaxDps} --> x and y coords
+ _i = _i + 1
+ end
+
+ elseif (smoothLevel == 2) then
+ _i = 1
+ while (_i <= #content) do
+ local v = content[_i] --> do not normalize
+ _data [#_data+1] = {scaleW*(_i), v/graphMaxDps} --> x and y coords
+ _i = _i + 1
+ end
+
+ end
+
+ tremove (content, 1)
+ tremove (content, 1)
+ tremove (content, #graphicData)
+ tremove (content, #graphicData)
+
+ if (max_value > self.max_value) then
+ --> normalize previous data
+ if (self.max_value > 0) then
+ local normalizePercent = self.max_value / max_value
+ for dataIndex, Data in ipairs (self.Data) do
+ local Points = Data.Points
+ for i = 1, #Points do
+ Points[i][2] = Points[i][2]*normalizePercent
+ end
+ end
+ end
+
+ self.max_value = max_value
+ f:SetScale (max_value)
+
+ end
+
+ tinsert (f.GData, {_data, color or line_default_color, lineTexture, max_value, elapsed_time})
+ if (name) then
+ f:AddLabel (color or line_default_color, name, "graphic", #f.GData)
+ end
+
+ if (firstIndex) then
+ if (lineTexture) then
+ if (not lineTexture:find ("\\") and not lineTexture:find ("//")) then
+ local path = string.match (debugstack (1, 1, 0), "AddOns\\(.+)LibGraph%-2%.0%.lua")
+ if path then
+ lineTexture = "Interface\\AddOns\\" .. path .. lineTexture
+ else
+ lineTexture = nil
+ end
+ end
+ end
+
+ table.insert (self.Data, 1, {Points = _data, Color = color or line_default_color, lineTexture = lineTexture, ElapsedTime = elapsed_time})
+ self.NeedsUpdate = true
+ else
+ self:AddDataSeries (_data, color or line_default_color, nil, lineTexture)
+ self.Data [#self.Data].ElapsedTime = elapsed_time
+ end
+
+ local max_time = 0
+ for _, data in ipairs (self.Data) do
+ if (data.ElapsedTime > max_time) then
+ max_time = data.ElapsedTime
+ end
+ end
+
+ f:SetTime (max_time)
+
+end
+
+local chart_panel_onresize = function (self)
+ local width, height = self:GetSize()
+ local spacement = width - 78 - 60
+ spacement = spacement / 16
+
+ for i = 1, 17 do
+ local label = self.TimeLabels [i]
+ label:SetPoint ("bottomleft", self, "bottomleft", 78 + ((i-1)*spacement), 13)
+ label.line:SetHeight (height - 45)
+ end
+
+ local spacement = (self.Graphic:GetHeight()) / 8
+ for i = 1, 8 do
+ self ["dpsamt"..i]:SetPoint ("TOPLEFT", self, "TOPLEFT", 27, -25 + (-(spacement* (i-1))) )
+ self ["dpsamt"..i].line:SetWidth (width-20)
+ end
+
+ self.Graphic:SetSize (width - 135, height - 67)
+ self.Graphic:SetPoint ("topleft", self, "topleft", 108, -35)
+end
+
+local chart_panel_vlines_on = function (self)
+ for i = 1, 17 do
+ local label = self.TimeLabels [i]
+ label.line:Show()
+ end
+end
+
+local chart_panel_vlines_off = function (self)
+ for i = 1, 17 do
+ local label = self.TimeLabels [i]
+ label.line:Hide()
+ end
+end
+
+local chart_panel_set_title = function (self, title)
+ self.chart_title.text = title
+end
+
+local chart_panel_mousedown = function (self, button)
+ if (button == "LeftButton" and self.can_move) then
+ if (not self.isMoving) then
+ self:StartMoving()
+ self.isMoving = true
+ end
+ elseif (button == "RightButton" and not self.no_right_click_close) then
+ if (not self.isMoving) then
+ self:Hide()
+ end
+ end
+end
+local chart_panel_mouseup = function (self, button)
+ if (button == "LeftButton" and self.isMoving) then
+ self:StopMovingOrSizing()
+ self.isMoving = nil
+ end
+end
+
+local chart_panel_hide_close_button = function (self)
+ self.CloseButton:Hide()
+end
+
+local chart_panel_right_click_close = function (self, value)
+ if (type (value) == "boolean") then
+ if (value) then
+ self.no_right_click_close = nil
+ else
+ self.no_right_click_close = true
+ end
+ end
+end
+
+function DF:CreateChartPanel (parent, w, h, name)
+
+ if (not name) then
+ name = "DFPanel" .. DF.PanelCounter
+ DF.PanelCounter = DF.PanelCounter + 1
+ end
+
+ parent = parent or UIParent
+ w = w or 800
+ h = h or 500
+
+ local f = CreateFrame ("frame", name, parent)
+ f:SetSize (w or 500, h or 400)
+ f:EnableMouse (true)
+ f:SetMovable (true)
+
+ f:SetScript ("OnMouseDown", chart_panel_mousedown)
+ f:SetScript ("OnMouseUp", chart_panel_mouseup)
+
+ f:SetBackdrop (chart_panel_backdrop)
+ f:SetBackdropColor (.3, .3, .3, .3)
+
+ local c = CreateFrame ("Button", nil, f, "UIPanelCloseButton")
+ c:SetWidth (32)
+ c:SetHeight (32)
+ c:SetPoint ("TOPRIGHT", f, "TOPRIGHT", -3, -7)
+ c:SetFrameLevel (f:GetFrameLevel()+1)
+ c:SetAlpha (0.9)
+ f.CloseButton = c
+
+ local title = DF:NewLabel (f, nil, "$parentTitle", "chart_title", "Chart!", nil, 20, {1, 1, 0})
+ title:SetPoint ("topleft", f, "topleft", 110, -13)
+
+ local bottom_texture = DF:NewImage (f, nil, 702, 25, "background", nil, nil, "$parentBottomTexture")
+ bottom_texture:SetTexture (0, 0, 0, .6)
+ bottom_texture:SetPoint ("bottomleft", f, "bottomleft", 8, 7)
+ bottom_texture:SetPoint ("bottomright", f, "bottomright", -8, 7)
+
+ f.Overlays = {}
+ f.OverlaysAmount = 1
+
+ f.BoxLabels = {}
+ f.BoxLabelsAmount = 1
+
+ f.TimeLabels = {}
+ for i = 1, 17 do
+ local time = f:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
+ time:SetText ("00:00")
+ time:SetPoint ("bottomleft", f, "bottomleft", 78 + ((i-1)*36), 13)
+ f.TimeLabels [i] = time
+
+ local line = f:CreateTexture (nil, "border")
+ line:SetSize (1, h-45)
+ line:SetTexture (1, 1, 1, .1)
+ line:SetPoint ("bottomleft", time, "topright", 0, -10)
+ line:Hide()
+ time.line = line
+ end
+
+ --graphic
+ local g = LibStub:GetLibrary("LibGraph-2.0"):CreateGraphLine (name .. "Graphic", f, "topleft","topleft", 108, -35, w - 120, h - 67)
+ g:SetXAxis (-1,1)
+ g:SetYAxis (-1,1)
+ g:SetGridSpacing (false, false)
+ g:SetGridColor ({0.5,0.5,0.5,0.3})
+ g:SetAxisDrawing (false,false)
+ g:SetAxisColor({1.0,1.0,1.0,1.0})
+ g:SetAutoScale (true)
+ g:SetLineTexture ("smallline")
+ g:SetBorderSize ("right", 0.001)
+ g:SetBorderSize ("left", 0.000)
+ g:SetBorderSize ("top", 0.002)
+ g:SetBorderSize ("bottom", 0.001)
+ g.VerticalLines = {}
+ g.max_value = 0
+
+ g:SetLineTexture ("line")
+
+ f.Graphic = g
+ f.GData = {}
+ f.OData = {}
+
+ --div lines
+ for i = 1, 8, 1 do
+ local line = g:CreateTexture (nil, "overlay")
+ line:SetTexture (1, 1, 1, .2)
+ line:SetWidth (670)
+ line:SetHeight (1.1)
+
+ local s = f:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
+ f ["dpsamt"..i] = s
+ s:SetText ("100k")
+ s:SetPoint ("topleft", f, "topleft", 27, -61 + (-(24.6*i)))
+
+ line:SetPoint ("topleft", s, "bottom", -27, 0)
+ s.line = line
+ end
+
+ f.SetTime = chart_panel_align_timelabels
+ f.EnableVerticalLines = chart_panel_vlines_on
+ f.DisableVerticalLines = chart_panel_vlines_off
+ f.SetTitle = chart_panel_set_title
+ f.SetScale = chart_panel_set_scale
+ f.Reset = chart_panel_reset
+ f.AddLine = chart_panel_add_data
+ f.CanMove = chart_panel_can_move
+ f.AddLabel = chart_panel_add_label
+ f.AddOverlay = chart_panel_add_overlay
+ f.HideCloseButton = chart_panel_hide_close_button
+ f.RightClickClose = chart_panel_right_click_close
+
+ f:SetScript ("OnSizeChanged", chart_panel_onresize)
+ chart_panel_onresize (f)
+
+ return f
+end
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/panel.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/panel.xml Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ self.Gradient = {
+ ["OnEnter"] = {0.3, 0.3, 0.3, 0.5},
+ ["OnLeave"] = {0.9, 0.7, 0.7, 1}
+ }
+
+
+
+
+
+
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/picture.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/picture.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,284 @@
+
+
+
+local DF = _G ["DetailsFramework"]
+local _
+
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+local loadstring = loadstring --> lua local
+
+local cleanfunction = function() end
+local APIImageFunctions = false
+local ImageMetaFunctions = {}
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ ImageMetaFunctions.__call = function (_table, value)
+ return self.image:SetTexture (value)
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> shown
+ local gmember_shown = function (_object)
+ return _object:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.image:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.image:GetHeight()
+ end
+ --> texture
+ local gmember_texture = function (_object)
+ return _object.image:GetTexture()
+ end
+ --> alpha
+ local gmember_alpha = function (_object)
+ return _object.image:GetAlpha()
+ end
+
+ local get_members_function_index = {
+ ["shown"] = gmember_shown,
+ ["alpha"] = gmember_alpha,
+ ["width"] = gmember_width,
+ ["height"] = gmember_height,
+ ["texture"] = gmember_texture,
+ }
+
+ ImageMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = get_members_function_index [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return ImageMetaFunctions [_member_requested]
+ end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ --> show
+ local smember_show = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (not _value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> texture
+ local smember_texture = function (_object, _value)
+ if (type (_value) == "table") then
+ local r, g, b, a = DF:ParseColors (_value)
+ _object.image:SetTexture (r, g, b, a or 1)
+ else
+ if (DF:IsHtmlColor (_value)) then
+ local r, g, b, a = DF:ParseColors (_value)
+ _object.image:SetTexture (r, g, b, a or 1)
+ else
+ _object.image:SetTexture (_value)
+ end
+ end
+ end
+ --> width
+ local smember_width = function (_object, _value)
+ return _object.image:SetWidth (_value)
+ end
+ --> height
+ local smember_height = function (_object, _value)
+ return _object.image:SetHeight (_value)
+ end
+ --> alpha
+ local smember_alpha = function (_object, _value)
+ return _object.image:SetAlpha (_value)
+ end
+ --> color
+ local smember_color = function (_object, _value)
+ if (type (_value) == "table") then
+ local r, g, b, a = DF:ParseColors (_value)
+ _object.image:SetTexture (r,g,b, a or 1)
+ else
+ if (DF:IsHtmlColor (_value)) then
+ local r, g, b, a = DF:ParseColors (_value)
+ _object.image:SetTexture (r, g, b, a or 1)
+ else
+ _object.image:SetTexture (_value)
+ end
+ end
+ end
+ --> desaturated
+ local smember_desaturated = function (_object, _value)
+ if (_value) then
+ _object:SetDesaturated (true)
+ else
+ _object:SetDesaturated (false)
+ end
+ end
+ --> texcoords
+ local smember_texcoord = function (_object, _value)
+ if (_value) then
+ _object:SetTexCoord (unpack (_value))
+ else
+ _object:SetTexCoord (0, 1, 0, 1)
+ end
+ end
+
+ local set_members_function_index = {
+ ["show"] = smember_show,
+ ["hide"] = smember_hide,
+ ["alpha"] = smember_alpha,
+ ["width"] = smember_width,
+ ["height"] = smember_height,
+ ["texture"] = smember_texture,
+ ["texcoord"] = smember_texcoord,
+ ["color"] = smember_color,
+ ["blackwhite"] = smember_desaturated,
+ }
+
+ ImageMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = set_members_function_index [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+--> show & hide
+ function ImageMetaFunctions:IsShown()
+ return self.image:IsShown()
+ end
+ function ImageMetaFunctions:Show()
+ return self.image:Show()
+ end
+ function ImageMetaFunctions:Hide()
+ return self.image:Hide()
+ end
+
+-- setpoint
+ function ImageMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+-- sizes
+ function ImageMetaFunctions:SetSize (w, h)
+ if (w) then
+ self.image:SetWidth (w)
+ end
+ if (h) then
+ return self.image:SetHeight (h)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+
+function DF:CreateImage (parent, texture, w, h, layer, coords, member, name)
+ return DF:NewImage (parent, texture, w, h, layer, coords, member, name)
+end
+
+function DF:NewImage (parent, texture, w, h, layer, coords, member, name)
+
+ if (not parent) then
+ return nil
+ end
+
+ if (not name) then
+ name = "DetailsFrameworkPictureNumber" .. DF.PictureNameCounter
+ DF.PictureNameCounter = DF.PictureNameCounter + 1
+ end
+
+ if (name:find ("$parent")) then
+ name = name:gsub ("$parent", parent:GetName())
+ end
+
+ local ImageObject = {type = "image", dframework = true}
+
+ if (member) then
+ parent [member] = ImageObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+
+ texture = texture or ""
+
+ ImageObject.image = parent:CreateTexture (name, layer or "OVERLAY")
+ ImageObject.widget = ImageObject.image
+
+ if (not APIImageFunctions) then
+ APIImageFunctions = true
+ local idx = getmetatable (ImageObject.image).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not ImageMetaFunctions [funcName]) then
+ ImageMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G."..object.image:GetName()..":"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ ImageObject.image.MyObject = ImageObject
+
+ if (w) then
+ ImageObject.image:SetWidth (w)
+ end
+ if (h) then
+ ImageObject.image:SetHeight (h)
+ end
+ if (texture) then
+ if (type (texture) == "table") then
+ local r, g, b = DF:ParseColors (texture)
+ ImageObject.image:SetTexture (r,g,b)
+ else
+ if (DF:IsHtmlColor (texture)) then
+ local r, g, b = DF:ParseColors (texture)
+ ImageObject.image:SetTexture (r, g, b)
+ else
+ ImageObject.image:SetTexture (texture)
+ end
+ end
+ end
+
+ if (coords and type (coords) == "table" and coords [4]) then
+ ImageObject.image:SetTexCoord (unpack (coords))
+ end
+
+ setmetatable (ImageObject, ImageMetaFunctions)
+
+ return ImageObject
+end
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/pictureedit.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/pictureedit.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,510 @@
+
+
+
+local DF = _G ["DetailsFramework"]
+local _
+
+ local window = DF:NewPanel (UIParent, nil, "DetailsFrameworkImageEdit", nil, 100, 100, false)
+ window:SetPoint ("center", UIParent, "center")
+ window:SetResizable (true)
+ window:SetMovable (true)
+ tinsert (UISpecialFrames, "DetailsFrameworkImageEdit")
+ window:SetFrameStrata ("TOOLTIP")
+
+ window:SetMaxResize (266, 226)
+
+ window.hooks = {}
+
+ local background = DF:NewImage (window, nil, nil, nil, "background", nil, nil, "$parentBackground")
+ background:SetAllPoints()
+ background:SetTexture (0, 0, 0, .8)
+
+ local edit_texture = DF:NewImage (window, nil, 300, 250, "artwork", nil, nil, "$parentImage")
+ edit_texture:SetAllPoints()
+
+ local background_frame = CreateFrame ("frame", "DetailsFrameworkImageEditBackground", DetailsFrameworkImageEdit)
+ background_frame:SetPoint ("topleft", DetailsFrameworkImageEdit, "topleft", -10, 12)
+ background_frame:SetFrameStrata ("DIALOG")
+ background_frame:SetSize (400, 252)
+
+ background_frame:SetResizable (true)
+ background_frame:SetMovable (true)
+
+ background_frame:SetScript ("OnMouseDown", function()
+ window:StartMoving()
+ end)
+ background_frame:SetScript ("OnMouseUp", function()
+ window:StopMovingOrSizing()
+ end)
+
+ local background_frame_image = background_frame:CreateTexture (nil, "background")
+ background_frame_image:SetAllPoints (background_frame)
+ background_frame_image:SetTexture ([[Interface\AddOns\Details\images\welcome]])
+
+ local haveHFlip = false
+ local haveVFlip = false
+
+--> Top Slider
+
+ local topCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageTopCoord")
+ topCoordTexture:SetPoint ("topleft", window, "topleft")
+ topCoordTexture:SetPoint ("topright", window, "topright")
+ topCoordTexture.color = "red"
+ topCoordTexture.height = 1
+ topCoordTexture.alpha = .2
+
+ local topSlider = DF:NewSlider (window, nil, "$parentTopSlider", "topSlider", 100, 100, 0.1, 100, 0.1, 0)
+ topSlider:SetAllPoints (window.widget)
+ topSlider:SetOrientation ("VERTICAL")
+ topSlider.backdrop = nil
+ topSlider.fractional = true
+ topSlider:SetHook ("OnEnter", function() return true end)
+ topSlider:SetHook ("OnLeave", function() return true end)
+
+ local topSliderThumpTexture = topSlider:CreateTexture (nil, "overlay")
+ topSliderThumpTexture:SetTexture (1, 1, 1)
+ topSliderThumpTexture:SetWidth (512)
+ topSliderThumpTexture:SetHeight (3)
+ topSlider:SetThumbTexture (topSliderThumpTexture)
+
+ topSlider:SetHook ("OnValueChange", function (_, _, value)
+ topCoordTexture.image:SetHeight (window.frame:GetHeight()/100*value)
+ if (window.callback_func) then
+ window.accept (true)
+ end
+ end)
+
+ topSlider:Hide()
+
+--> Bottom Slider
+
+ local bottomCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageBottomCoord")
+ bottomCoordTexture:SetPoint ("bottomleft", window, "bottomleft", 0, 0)
+ bottomCoordTexture:SetPoint ("bottomright", window, "bottomright", 0, 0)
+ bottomCoordTexture.color = "red"
+ bottomCoordTexture.height = 1
+ bottomCoordTexture.alpha = .2
+
+ local bottomSlider= DF:NewSlider (window, nil, "$parentBottomSlider", "bottomSlider", 100, 100, 0.1, 100, 0.1, 100)
+ bottomSlider:SetAllPoints (window.widget)
+ bottomSlider:SetOrientation ("VERTICAL")
+ bottomSlider.backdrop = nil
+ bottomSlider.fractional = true
+ bottomSlider:SetHook ("OnEnter", function() return true end)
+ bottomSlider:SetHook ("OnLeave", function() return true end)
+
+ local bottomSliderThumpTexture = bottomSlider:CreateTexture (nil, "overlay")
+ bottomSliderThumpTexture:SetTexture (1, 1, 1)
+ bottomSliderThumpTexture:SetWidth (512)
+ bottomSliderThumpTexture:SetHeight (3)
+ bottomSlider:SetThumbTexture (bottomSliderThumpTexture)
+
+ bottomSlider:SetHook ("OnValueChange", function (_, _, value)
+ value = math.abs (value-100)
+ bottomCoordTexture.image:SetHeight (math.max (window.frame:GetHeight()/100*value, 1))
+ if (window.callback_func) then
+ window.accept (true)
+ end
+ end)
+
+ bottomSlider:Hide()
+
+--> Left Slider
+
+ local leftCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageLeftCoord")
+ leftCoordTexture:SetPoint ("topleft", window, "topleft", 0, 0)
+ leftCoordTexture:SetPoint ("bottomleft", window, "bottomleft", 0, 0)
+ leftCoordTexture.color = "red"
+ leftCoordTexture.width = 1
+ leftCoordTexture.alpha = .2
+
+ local leftSlider = DF:NewSlider (window, nil, "$parentLeftSlider", "leftSlider", 100, 100, 0.1, 100, 0.1, 0.1)
+ leftSlider:SetAllPoints (window.widget)
+ leftSlider.backdrop = nil
+ leftSlider.fractional = true
+ leftSlider:SetHook ("OnEnter", function() return true end)
+ leftSlider:SetHook ("OnLeave", function() return true end)
+
+ local leftSliderThumpTexture = leftSlider:CreateTexture (nil, "overlay")
+ leftSliderThumpTexture:SetTexture (1, 1, 1)
+ leftSliderThumpTexture:SetWidth (3)
+ leftSliderThumpTexture:SetHeight (512)
+ leftSlider:SetThumbTexture (leftSliderThumpTexture)
+
+ leftSlider:SetHook ("OnValueChange", function (_, _, value)
+ leftCoordTexture.image:SetWidth (window.frame:GetWidth()/100*value)
+ if (window.callback_func) then
+ window.accept (true)
+ end
+ end)
+
+ leftSlider:Hide()
+
+--> Right Slider
+
+ local rightCoordTexture = DF:NewImage (window, nil, nil, nil, "overlay", nil, nil, "$parentImageRightCoord")
+ rightCoordTexture:SetPoint ("topright", window, "topright", 0, 0)
+ rightCoordTexture:SetPoint ("bottomright", window, "bottomright", 0, 0)
+ rightCoordTexture.color = "red"
+ rightCoordTexture.width = 1
+ rightCoordTexture.alpha = .2
+
+ local rightSlider = DF:NewSlider (window, nil, "$parentRightSlider", "rightSlider", 100, 100, 0.1, 100, 0.1, 100)
+ rightSlider:SetAllPoints (window.widget)
+ rightSlider.backdrop = nil
+ rightSlider.fractional = true
+ rightSlider:SetHook ("OnEnter", function() return true end)
+ rightSlider:SetHook ("OnLeave", function() return true end)
+ --[
+ local rightSliderThumpTexture = rightSlider:CreateTexture (nil, "overlay")
+ rightSliderThumpTexture:SetTexture (1, 1, 1)
+ rightSliderThumpTexture:SetWidth (3)
+ rightSliderThumpTexture:SetHeight (512)
+ rightSlider:SetThumbTexture (rightSliderThumpTexture)
+ --]]
+ rightSlider:SetHook ("OnValueChange", function (_, _, value)
+ value = math.abs (value-100)
+ rightCoordTexture.image:SetWidth (math.max (window.frame:GetWidth()/100*value, 1))
+ if (window.callback_func) then
+ window.accept (true)
+ end
+ end)
+
+ rightSlider:Hide()
+
+--> Edit Buttons
+
+ local buttonsBackground = DF:NewPanel (UIParent, nil, "DetailsFrameworkImageEditButtonsBg", nil, 115, 230)
+ --buttonsBackground:SetPoint ("topleft", window, "topright", 2, 0)
+ buttonsBackground:SetPoint ("topright", background_frame, "topright", -8, -10)
+ buttonsBackground:Hide()
+ --buttonsBackground:SetMovable (true)
+ tinsert (UISpecialFrames, "DetailsFrameworkImageEditButtonsBg")
+ buttonsBackground:SetFrameStrata ("TOOLTIP")
+
+ local alphaFrameShown = false
+
+ local editingSide = nil
+ local lastButton = nil
+ local alphaFrame
+ local originalColor = {0.9999, 0.8196, 0}
+
+ local enableTexEdit = function (side, _, button)
+
+ if (alphaFrameShown) then
+ alphaFrame:Hide()
+ alphaFrameShown = false
+ button.text:SetTextColor (unpack (originalColor))
+ end
+
+ if (ColorPickerFrame:IsShown()) then
+ ColorPickerFrame:Hide()
+ end
+
+ if (lastButton) then
+ lastButton.text:SetTextColor (unpack (originalColor))
+ end
+
+ if (editingSide == side) then
+ window [editingSide.."Slider"]:Hide()
+ editingSide = nil
+ return
+
+ elseif (editingSide) then
+ window [editingSide.."Slider"]:Hide()
+ end
+
+ editingSide = side
+ button.text:SetTextColor (1, 1, 1)
+ lastButton = button
+
+ window [side.."Slider"]:Show()
+ end
+
+ local leftTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentLeftTexButton", nil, 100, 20, enableTexEdit, "left", nil, nil, "Crop Left", 1)
+ leftTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -10)
+ local rightTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentRightTexButton", nil, 100, 20, enableTexEdit, "right", nil, nil, "Crop Right", 1)
+ rightTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -30)
+ local topTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentTopTexButton", nil, 100, 20, enableTexEdit, "top", nil, nil, "Crop Top", 1)
+ topTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -50)
+ local bottomTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentBottomTexButton", nil, 100, 20, enableTexEdit, "bottom", nil, nil, "Crop Bottom", 1)
+ bottomTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -70)
+ leftTexCoordButton:InstallCustomTexture()
+ rightTexCoordButton:InstallCustomTexture()
+ topTexCoordButton:InstallCustomTexture()
+ bottomTexCoordButton:InstallCustomTexture()
+
+ local Alpha = DF:NewButton (buttonsBackground, nil, "$parentBottomAlphaButton", nil, 100, 20, alpha, nil, nil, nil, "Alpha", 1)
+ Alpha:SetPoint ("topright", buttonsBackground, "topright", -8, -115)
+ Alpha:InstallCustomTexture()
+
+ --> overlay color
+ local selectedColor = function (default)
+ if (default) then
+ edit_texture:SetVertexColor (unpack (default))
+ if (window.callback_func) then
+ window.accept (true)
+ end
+ else
+ edit_texture:SetVertexColor (ColorPickerFrame:GetColorRGB())
+ if (window.callback_func) then
+ window.accept (true)
+ end
+ end
+ end
+
+ local changeColor = function()
+
+ ColorPickerFrame.func = nil
+ ColorPickerFrame.opacityFunc = nil
+ ColorPickerFrame.cancelFunc = nil
+ ColorPickerFrame.previousValues = nil
+
+ local r, g, b = edit_texture:GetVertexColor()
+ ColorPickerFrame:SetColorRGB (r, g, b)
+ ColorPickerFrame:SetParent (buttonsBackground.widget)
+ ColorPickerFrame.hasOpacity = false
+ ColorPickerFrame.previousValues = {r, g, b}
+ ColorPickerFrame.func = selectedColor
+ ColorPickerFrame.cancelFunc = selectedColor
+ ColorPickerFrame:ClearAllPoints()
+ ColorPickerFrame:SetPoint ("left", buttonsBackground.widget, "right")
+ ColorPickerFrame:Show()
+
+ if (alphaFrameShown) then
+ alphaFrame:Hide()
+ alphaFrameShown = false
+ Alpha.button.text:SetTextColor (unpack (originalColor))
+ end
+
+ if (lastButton) then
+ lastButton.text:SetTextColor (unpack (originalColor))
+ if (editingSide) then
+ window [editingSide.."Slider"]:Hide()
+ end
+ end
+ end
+
+ local changeColorButton = DF:NewButton (buttonsBackground, nil, "$parentOverlayColorButton", nil, 100, 20, changeColor, nil, nil, nil, "Color", 1)
+ changeColorButton:SetPoint ("topright", buttonsBackground, "topright", -8, -95)
+ changeColorButton:InstallCustomTexture()
+
+ alphaFrame = DF:NewPanel (buttonsBackground, nil, "DetailsFrameworkImageEditAlphaBg", nil, 40, 225)
+ alphaFrame:SetPoint ("topleft", buttonsBackground, "topright", 2, 0)
+ alphaFrame:Hide()
+ local alphaSlider = DF:NewSlider (alphaFrame, nil, "$parentAlphaSlider", "alphaSlider", 30, 220, 1, 100, 1, edit_texture:GetAlpha()*100)
+ alphaSlider:SetPoint ("top", alphaFrame, "top", 0, -5)
+ alphaSlider:SetOrientation ("VERTICAL")
+ alphaSlider.thumb:SetSize (40, 30)
+ --leftSlider.backdrop = nil
+ --leftSlider.fractional = true
+
+ local alpha = function(_, _, button)
+
+ if (ColorPickerFrame:IsShown()) then
+ ColorPickerFrame:Hide()
+ end
+
+ if (lastButton) then
+ lastButton.text:SetTextColor (unpack (originalColor))
+ if (editingSide) then
+ window [editingSide.."Slider"]:Hide()
+ end
+ end
+
+ if (not alphaFrameShown) then
+ alphaFrame:Show()
+ alphaSlider:SetValue (edit_texture:GetAlpha()*100)
+ alphaFrameShown = true
+ button.text:SetTextColor (1, 1, 1)
+ else
+ alphaFrame:Hide()
+ alphaFrameShown = false
+ button.text:SetTextColor (unpack (originalColor))
+ end
+ end
+
+ Alpha.clickfunction = alpha
+
+ alphaSlider:SetHook ("OnValueChange", function (_, _, value)
+ edit_texture:SetAlpha (value/100)
+ if (window.callback_func) then
+ window.accept (true)
+ end
+ end)
+
+ local resizer = CreateFrame ("Button", nil, window.widget)
+ resizer:SetNormalTexture ([[Interface\AddOns\Details\images\skins\default_skin]])
+ resizer:SetHighlightTexture ([[Interface\AddOns\Details\images\skins\default_skin]])
+ resizer:GetNormalTexture():SetTexCoord (0.00146484375, 0.01513671875, 0.24560546875, 0.25927734375)
+ resizer:GetHighlightTexture():SetTexCoord (0.00146484375, 0.01513671875, 0.24560546875, 0.25927734375)
+ resizer:SetWidth (16)
+ resizer:SetHeight (16)
+ resizer:SetPoint ("BOTTOMRIGHT", window.widget, "BOTTOMRIGHT", 0, 0)
+ resizer:EnableMouse (true)
+ resizer:SetFrameLevel (window.widget:GetFrameLevel() + 2)
+
+ resizer:SetScript ("OnMouseDown", function (self, button)
+ window.widget:StartSizing ("BOTTOMRIGHT")
+ end)
+
+ resizer:SetScript ("OnMouseUp", function (self, button)
+ window.widget:StopMovingOrSizing()
+ end)
+
+ window.widget:SetScript ("OnMouseDown", function()
+ window.widget:StartMoving()
+ end)
+ window.widget:SetScript ("OnMouseUp", function()
+ window.widget:StopMovingOrSizing()
+ end)
+
+ window.widget:SetScript ("OnSizeChanged", function()
+ edit_texture.width = window.width
+ edit_texture.height = window.height
+ leftSliderThumpTexture:SetHeight (window.height)
+ rightSliderThumpTexture:SetHeight (window.height)
+ topSliderThumpTexture:SetWidth (window.width)
+ bottomSliderThumpTexture:SetWidth (window.width)
+
+ rightCoordTexture.image:SetWidth (math.max ( (window.frame:GetWidth() / 100 * math.abs (rightSlider:GetValue()-100)), 1))
+ leftCoordTexture.image:SetWidth (window.frame:GetWidth()/100*leftSlider:GetValue())
+ bottomCoordTexture:SetHeight (math.max ( (window.frame:GetHeight() / 100 * math.abs (bottomSlider:GetValue()-100)), 1))
+ topCoordTexture:SetHeight (window.frame:GetHeight()/100*topSlider:GetValue())
+
+ if (window.callback_func) then
+ window.accept (true)
+ end
+ end)
+
+
+
+ --> flip
+ local flip = function (side)
+ if (side == 1) then
+ haveHFlip = not haveHFlip
+ if (window.callback_func) then
+ window.accept (true)
+ end
+ elseif (side == 2) then
+ haveVFlip = not haveVFlip
+ if (window.callback_func) then
+ window.accept (true)
+ end
+ end
+ end
+
+ local flipButtonH = DF:NewButton (buttonsBackground, nil, "$parentFlipButton", nil, 100, 20, flip, 1, nil, nil, "Flip H", 1)
+ flipButtonH:SetPoint ("topright", buttonsBackground, "topright", -8, -140)
+ flipButtonH:InstallCustomTexture()
+ --
+ local flipButtonV = DF:NewButton (buttonsBackground, nil, "$parentFlipButton2", nil, 100, 20, flip, 2, nil, nil, "Flip V", 1)
+ flipButtonV:SetPoint ("topright", buttonsBackground, "topright", -8, -160)
+ flipButtonV:InstallCustomTexture()
+
+ --> accept
+ window.accept = function (keep_editing)
+
+ if (not keep_editing) then
+ buttonsBackground:Hide()
+ window:Hide()
+ alphaFrame:Hide()
+ ColorPickerFrame:Hide()
+ end
+
+ local coords = {}
+ local l, r, t, b = leftSlider.value/100, rightSlider.value/100, topSlider.value/100, bottomSlider.value/100
+
+ if (haveHFlip) then
+ coords [1] = r
+ coords [2] = l
+ else
+ coords [1] = l
+ coords [2] = r
+ end
+
+ if (haveVFlip) then
+ coords [3] = b
+ coords [4] = t
+ else
+ coords [3] = t
+ coords [4] = b
+ end
+
+ return window.callback_func (edit_texture.width, edit_texture.height, {edit_texture:GetVertexColor()}, edit_texture:GetAlpha(), coords, window.extra_param)
+ end
+
+ local acceptButton = DF:NewButton (buttonsBackground, nil, "$parentAcceptButton", nil, 100, 20, window.accept, nil, nil, nil, "Done", 1)
+ acceptButton:SetPoint ("topright", buttonsBackground, "topright", -8, -200)
+ acceptButton:InstallCustomTexture()
+
+
+
+window:Hide()
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ local ttexcoord
+ function DF:ImageEditor (callback, texture, texcoord, colors, width, height, extraParam, alpha, maximize)
+
+ texcoord = texcoord or {0, 1, 0, 1}
+ ttexcoord = texcoord
+
+ colors = colors or {1, 1, 1, 1}
+
+ alpha = alpha or 1
+
+ edit_texture:SetTexture (texture)
+ edit_texture.width = width
+ edit_texture.height = height
+ edit_texture.maximize = maximize
+
+ edit_texture:SetVertexColor (colors [1], colors [2], colors [3])
+
+ edit_texture:SetAlpha (alpha)
+
+ DF:ScheduleTimer ("RefreshImageEditor", 0.2)
+
+ window:Show()
+ window.callback_func = callback
+ window.extra_param = extraParam
+ buttonsBackground:Show()
+
+ table.wipe (window.hooks)
+ end
+
+ function DF:RefreshImageEditor()
+
+ if (edit_texture.maximize) then
+ DetailsFrameworkImageEdit:SetSize (266, 226)
+ else
+ DetailsFrameworkImageEdit:SetSize (edit_texture.width, edit_texture.height)
+ end
+
+ local l, r, t, b = unpack (ttexcoord)
+
+ if (l > r) then
+ haveHFlip = true
+ leftSlider:SetValue (r * 100)
+ rightSlider:SetValue (l * 100)
+ else
+ haveHFlip = false
+ leftSlider:SetValue (l * 100)
+ rightSlider:SetValue (r * 100)
+ end
+
+ if (t > b) then
+ haveVFlip = true
+ topSlider:SetValue (b * 100)
+ bottomSlider:SetValue (t * 100)
+ else
+ haveVFlip = false
+ topSlider:SetValue (t * 100)
+ bottomSlider:SetValue (b * 100)
+ end
+
+ if (window.callback_func) then
+ window.accept (true)
+ end
+
+ end
+
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/scrollbar.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/scrollbar.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,232 @@
+
+local DF = _G ["DetailsFramework"]
+
+function DF:CreateScrollBar (master, slave, x, y)
+ return DF:NewScrollBar (master, slave, x, y)
+end
+
+function DF:NewScrollBar (master, slave, x, y)
+
+ local new_slider = CreateFrame ("Slider", nil, master)
+ new_slider.scrollMax = 560 --default - tamanho da janela de fundo
+
+ -- ///// SLIDER /////
+ new_slider:SetPoint ("TOPLEFT", master, "TOPRIGHT", x, y)
+ new_slider.ativo = true
+
+ new_slider.bg = new_slider:CreateTexture (nil, "BACKGROUND")
+ new_slider.bg:SetAllPoints (true)
+ new_slider.bg:SetTexture (0, 0, 0, 0)
+ --coisinha do meio
+ new_slider.thumb = new_slider:CreateTexture (nil, "OVERLAY")
+ new_slider.thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob")
+ new_slider.thumb:SetSize (29, 30)
+ new_slider:SetThumbTexture (new_slider.thumb)
+
+ new_slider:SetOrientation ("VERTICAL")
+ new_slider:SetSize(16, 100)
+ new_slider:SetMinMaxValues(0, new_slider.scrollMax)
+ new_slider:SetValue(0)
+ new_slider.ultimo = 0
+
+ local botao_cima = CreateFrame ("Button", nil, master)
+
+ botao_cima:SetPoint ("BOTTOM", new_slider, "TOP", 0, -12)
+ botao_cima.x = 0
+ botao_cima.y = -12
+
+ botao_cima:SetWidth (29)
+ botao_cima:SetHeight (32)
+ botao_cima:SetNormalTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Up")
+ botao_cima:SetPushedTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Down")
+ botao_cima:SetDisabledTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Disabled")
+ botao_cima:Show()
+ botao_cima:Disable()
+
+ local botao_baixo = CreateFrame ("Button", nil, master)
+ botao_baixo:SetPoint ("TOP", new_slider, "BOTTOM", 0, 12)
+ botao_baixo.x = 0
+ botao_baixo.y = 12
+
+ botao_baixo:SetWidth (29)
+ botao_baixo:SetHeight (32)
+ botao_baixo:SetNormalTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Up")
+ botao_baixo:SetPushedTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Down")
+ botao_baixo:SetDisabledTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Disabled")
+ botao_baixo:Show()
+ botao_baixo:Disable()
+
+ master.baixo = botao_baixo
+ master.cima = botao_cima
+ master.slider = new_slider
+
+ botao_baixo:SetScript ("OnMouseDown", function(self)
+ if (not new_slider:IsEnabled()) then
+ return
+ end
+
+ local current = new_slider:GetValue()
+ local minValue, maxValue = new_slider:GetMinMaxValues()
+ if (current+5 < maxValue) then
+ new_slider:SetValue (current+5)
+ else
+ new_slider:SetValue (maxValue)
+ end
+ self.precionado = true
+ self.last_up = -0.3
+ self:SetScript ("OnUpdate", function(self, elapsed)
+ self.last_up = self.last_up + elapsed
+ if (self.last_up > 0.03) then
+ self.last_up = 0
+ local current = new_slider:GetValue()
+ local minValue, maxValue = new_slider:GetMinMaxValues()
+ if (current+2 < maxValue) then
+ new_slider:SetValue (current+2)
+ else
+ new_slider:SetValue (maxValue)
+ end
+ end
+ end)
+ end)
+ botao_baixo:SetScript ("OnMouseUp", function(self)
+ self.precionado = false
+ self:SetScript ("OnUpdate", nil)
+ end)
+
+ botao_cima:SetScript ("OnMouseDown", function(self)
+ if (not new_slider:IsEnabled()) then
+ return
+ end
+
+ local current = new_slider:GetValue()
+ if (current-5 > 0) then
+ new_slider:SetValue (current-5)
+ else
+ new_slider:SetValue (0)
+ end
+ self.precionado = true
+ self.last_up = -0.3
+ self:SetScript ("OnUpdate", function(self, elapsed)
+ self.last_up = self.last_up + elapsed
+ if (self.last_up > 0.03) then
+ self.last_up = 0
+ local current = new_slider:GetValue()
+ if (current-2 > 0) then
+ new_slider:SetValue (current-2)
+ else
+ new_slider:SetValue (0)
+ end
+ end
+ end)
+ end)
+ botao_cima:SetScript ("OnMouseUp", function(self)
+ self.precionado = false
+ self:SetScript ("OnUpdate", nil)
+ end)
+ --> isso aqui pra quando o slider ativar, o scroll fica na posição zero
+ botao_cima:SetScript ("OnEnable", function (self)
+ local current = new_slider:GetValue()
+ if (current == 0) then
+ botao_cima:Disable()
+ end
+ end)
+
+ new_slider:SetScript ("OnValueChanged", function (self)
+ local current = self:GetValue()
+ master:SetVerticalScroll (current)
+
+ local minValue, maxValue = new_slider:GetMinMaxValues()
+
+ if (current == minValue) then
+ botao_cima:Disable()
+ elseif (not botao_cima:IsEnabled()) then
+ botao_cima:Enable()
+ end
+
+ if (current == maxValue) then
+ botao_baixo:Disable()
+ elseif (not botao_baixo:IsEnabled()) then
+ botao_baixo:Enable()
+ end
+
+ end)
+
+ new_slider:SetScript ("OnShow", function (self)
+ botao_cima:Show()
+ botao_baixo:Show()
+ end)
+
+ new_slider:SetScript ("OnDisable", function (self)
+ botao_cima:Disable()
+ botao_baixo:Disable()
+ end)
+
+ new_slider:SetScript ("OnEnable", function (self)
+ botao_cima:Enable()
+ botao_baixo:Enable()
+ end)
+
+ master:SetScript ("OnMouseWheel", function (self, delta)
+ if (not new_slider:IsEnabled()) then
+ return
+ end
+
+ local current = new_slider:GetValue()
+ if (delta < 0) then
+ --baixo
+ local minValue, maxValue = new_slider:GetMinMaxValues()
+ if (current + (master.wheel_jump or 20) < maxValue) then
+ new_slider:SetValue (current + (master.wheel_jump or 20))
+ else
+ new_slider:SetValue (maxValue)
+ end
+ elseif (delta > 0) then
+ --cima
+ if (current + (master.wheel_jump or 20) > 0) then
+ new_slider:SetValue (current - (master.wheel_jump or 20))
+ else
+ new_slider:SetValue (0)
+ end
+ end
+ end)
+
+ function new_slider:Altura (h)
+ self:SetHeight (h)
+ end
+
+ function new_slider:Update (desativar)
+
+ if (desativar) then
+ new_slider:Disable()
+ new_slider:SetValue(0)
+ new_slider.ativo = false
+ master:EnableMouseWheel (false)
+ return
+ end
+
+ self.scrollMax = slave:GetHeight()-master:GetHeight()
+ if (self.scrollMax > 0) then
+ new_slider:SetMinMaxValues (0, self.scrollMax)
+ if (not new_slider.ativo) then
+ new_slider:Enable()
+ new_slider.ativo = true
+ master:EnableMouseWheel (true)
+ end
+ else
+ new_slider:Disable()
+ new_slider:SetValue(0)
+ new_slider.ativo = false
+ master:EnableMouseWheel (false)
+ end
+ end
+
+ function new_slider:cimaPoint (x, y)
+ botao_cima:SetPoint ("BOTTOM", new_slider, "TOP", x, (y)-12)
+ end
+
+ function new_slider:baixoPoint (x, y)
+ botao_baixo:SetPoint ("TOP", new_slider, "BOTTOM", x, (y)+12)
+ end
+
+ return new_slider
+end
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/slider.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/slider.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,1034 @@
+
+
+
+local DF = _G ["DetailsFramework"]
+local _
+
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+local loadstring = loadstring --> lua local
+
+local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
+
+local cleanfunction = function() end
+local APISliderFunctions = false
+local SliderMetaFunctions = {}
+local NameLessSlider = 1
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ SliderMetaFunctions.__call = function (_table, value)
+ if (not value) then
+ if (_table.isSwitch) then
+
+ if (type (value) == "boolean") then --> false
+ return _table.slider:SetValue (1)
+ end
+
+ if (_table.slider:GetValue() == 1) then
+ return false
+ else
+ return true
+ end
+ end
+ return _table.slider:GetValue()
+ else
+ if (_table.isSwitch) then
+ if (type (value) == "boolean") then
+ if (value) then
+ _table.slider:SetValue (2)
+ else
+ _table.slider:SetValue (1)
+ end
+ else
+ _table.slider:SetValue (value)
+ end
+ return
+ end
+
+ return _table.slider:SetValue (value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> tooltip
+ local gmember_tooltip = function (_object)
+ return _object:GetTooltip()
+ end
+ --> shown
+ local gmember_shown = function (_object)
+ return _object:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.slider:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.slider:GetHeight()
+ end
+ --> locked
+ local gmember_locked = function (_object)
+ return _rawget (_object, "lockdown")
+ end
+ --> fractional
+ local gmember_fractional = function (_object)
+ return _rawget (_object, "useDecimals")
+ end
+ --> value
+ local gmember_value = function (_object)
+ return _object()
+ end
+
+ local get_members_function_index = {
+ ["tooltip"] = gmember_tooltip,
+ ["shown"] = gmember_shown,
+ ["width"] = gmember_width,
+ ["height"] = gmember_height,
+ ["locked"] = gmember_locked,
+ ["fractional"] = gmember_fractional,
+ ["value"] = gmember_value,
+ }
+
+ SliderMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = get_members_function_index [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return SliderMetaFunctions [_member_requested]
+ end
+
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ --> tooltip
+ local smember_tooltip = function (_object, _value)
+ return _object:SetTooltip (_value)
+ end
+ --> show
+ local smember_show = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (not _value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> frame width
+ local smember_width = function (_object, _value)
+ return _object.slider:SetWidth (_value)
+ end
+ --> frame height
+ local smember_height = function (_object, _value)
+ return _object.slider:SetHeight (_value)
+ end
+ --> locked
+ local smember_locked = function (_object, _value)
+ if (_value) then
+ return self:Disable()
+ else
+ return self:Enable()
+ end
+ end
+ --> backdrop
+ local smember_backdrop = function (_object, _value)
+ return _object.slider:SetBackdrop (_value)
+ end
+ --> fractional
+ local smember_fractional = function (_object, _value)
+ return _rawset (_object, "useDecimals", _value)
+ end
+ --> value
+ local smember_value = function (_object, _value)
+ _object (_value)
+ end
+
+ local set_members_function_index = {
+ ["tooltip"] = smember_tooltip,
+ ["show"] = smember_show,
+ ["hide"] = smember_hide,
+ ["backdrop"] = smember_backdrop,
+ ["width"] = smember_width,
+ ["height"] = smember_height,
+ ["locked"] = smember_locked,
+ ["fractional"] = smember_fractional,
+ ["value"] = smember_value,
+ }
+
+ SliderMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = set_members_function_index [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+
+--> show & hide
+ function SliderMetaFunctions:IsShown()
+ return self.slider:IsShown()
+ end
+ function SliderMetaFunctions:Show()
+ return self.slider:Show()
+ end
+ function SliderMetaFunctions:Hide()
+ return self.slider:Hide()
+ end
+
+--> fixed value
+ function SliderMetaFunctions:SetFixedParameter (value)
+ _rawset (self, "FixedValue", value)
+ end
+
+--> set value
+ function SliderMetaFunctions:SetValue (value)
+ return self (value)
+ end
+
+-- thumb size
+ function SliderMetaFunctions:SetThumbSize (w, h)
+ if (not w) then
+ w = self.thumb:GetWidth()
+ end
+ if (not h) then
+ h = self.thumb:GetHeight()
+ end
+ return self.thumb:SetSize (w, h)
+ end
+
+
+-- setpoint
+ function SliderMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+-- sizes
+ function SliderMetaFunctions:SetSize (w, h)
+ if (w) then
+ self.slider:SetWidth (w)
+ end
+ if (h) then
+ return self.slider:SetHeight (h)
+ end
+ end
+
+-- tooltip
+ function SliderMetaFunctions:SetTooltip (tooltip)
+ if (tooltip) then
+ return _rawset (self, "have_tooltip", tooltip)
+ else
+ return _rawset (self, "have_tooltip", nil)
+ end
+ end
+ function SliderMetaFunctions:GetTooltip()
+ return _rawget (self, "have_tooltip")
+ end
+
+-- frame levels
+ function SliderMetaFunctions:GetFrameLevel()
+ return self.slider:GetFrameLevel()
+ end
+ function SliderMetaFunctions:SetFrameLevel (level, frame)
+ if (not frame) then
+ return self.slider:SetFrameLevel (level)
+ else
+ local framelevel = frame:GetFrameLevel (frame) + level
+ return self.slider:SetFrameLevel (framelevel)
+ end
+ end
+
+-- frame stratas
+ function SliderMetaFunctions:SetFrameStrata()
+ return self.slider:GetFrameStrata()
+ end
+ function SliderMetaFunctions:SetFrameStrata (strata)
+ if (_type (strata) == "table") then
+ self.slider:SetFrameStrata (strata:GetFrameStrata())
+ else
+ self.slider:SetFrameStrata (strata)
+ end
+ end
+
+-- enabled
+ function SliderMetaFunctions:IsEnabled()
+ return not _rawget (self, "lockdown")
+ end
+ function SliderMetaFunctions:Enable()
+ self.slider:Enable()
+ if (not self.lock_texture) then
+ DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture")
+ self.lock_texture:SetDesaturated (true)
+ self.lock_texture:SetPoint ("center", self.amt, "center")
+ end
+ self.lock_texture:Hide()
+ self.slider.amt:Show()
+ self:SetAlpha (1)
+ return _rawset (self, "lockdown", false)
+ end
+
+ function SliderMetaFunctions:Disable()
+
+ self.slider:Disable()
+ self.slider.amt:Hide()
+ self:SetAlpha (.4)
+
+ if (not self.lock_texture) then
+ DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture")
+ self.lock_texture:SetDesaturated (true)
+ self.lock_texture:SetPoint ("center", self.amt, "center")
+ end
+ self.lock_texture:Show()
+
+ return _rawset (self, "lockdown", true)
+ end
+
+--> hooks
+ function SliderMetaFunctions:SetHook (hookType, func)
+ if (func) then
+ _rawset (self, hookType.."Hook", func)
+ else
+ _rawset (self, hookType.."Hook", nil)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts
+
+ local OnEnter = function (slider)
+
+ if (_rawget (slider.MyObject, "lockdown")) then
+ return
+ end
+
+ DetailsFrameworkSliderButtons1:ShowMe (slider)
+
+ if (slider.MyObject.OnEnterHook) then
+ local interrupt = slider.MyObject.OnEnterHook (slider)
+ if (interrupt) then
+ return
+ end
+ end
+
+ slider.thumb:SetAlpha (1)
+
+ if (slider.MyObject.have_tooltip and slider.MyObject.have_tooltip ~= "Right Click to Type the Value") then
+ GameCooltip2:Preset (2)
+ GameCooltip2:AddLine (slider.MyObject.have_tooltip)
+ GameCooltip2:ShowCooltip (slider, "tooltip")
+ else
+ GameCooltip2:Preset (1)
+ GameCooltip2:AddLine ("Right Click to Type the Value")
+ GameCooltip2:AddIcon ([[Interface\TUTORIALFRAME\UI-TUTORIAL-FRAME]], 1, 1, 16, 16, 0.015625, 0.15671875, 0.640625, 0.798828125)
+ GameCooltip2:ShowCooltip (slider, "tooltip")
+ end
+
+ local parent = slider:GetParent().MyObject
+ if (parent and parent.type == "panel") then
+ if (parent.GradientEnabled) then
+ parent:RunGradient()
+ end
+ end
+
+ end
+
+ local OnLeave = function (slider)
+
+ if (_rawget (slider.MyObject, "lockdown")) then
+ return
+ end
+
+ DetailsFrameworkSliderButtons1:PrepareToHide()
+
+ if (slider.MyObject.OnLeaveHook) then
+ local interrupt = slider.MyObject.OnLeaveHook (slider)
+ if (interrupt) then
+ return
+ end
+ end
+
+ slider.thumb:SetAlpha (.7)
+
+ if (slider.MyObject.have_tooltip) then
+ GameCooltip2:ShowMe (false)
+ end
+
+ local parent = slider:GetParent().MyObject
+ if (parent and parent.type == "panel") then
+ if (parent.GradientEnabled) then
+ parent:RunGradient (false)
+ end
+ end
+
+ end
+
+
+ local f = CreateFrame ("frame", "DetailsFrameworkSliderButtons1", UIParent)
+ f:Hide()
+ --f:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], tile = true, tileSize = 5})
+ f:SetHeight (18)
+
+ local t = 0
+ f.is_going_hide = false
+ local going_hide = function (self, elapsed)
+ t = t + elapsed
+ if (t > 0.3) then
+ f:Hide()
+ f:SetScript ("OnUpdate", nil)
+ f.is_going_hide = false
+ end
+ end
+
+ function f:ShowMe (host)
+ f:SetPoint ("bottomleft", host, "topleft", -3, -5)
+ f:SetPoint ("bottomright", host, "topright", 3, -5)
+ f:SetFrameStrata (host:GetFrameStrata())
+ f:SetFrameLevel (host:GetFrameLevel())
+ f:Show()
+ if (f.is_going_hide) then
+ f:SetScript ("OnUpdate", nil)
+ f.is_going_hide = false
+ end
+
+ f.host = host.MyObject
+ end
+
+ function f:PrepareToHide()
+ f.is_going_hide = true
+ t = 0
+ f:SetScript ("OnUpdate", going_hide)
+ end
+
+ local button_plus = CreateFrame ("button", "DetailsFrameworkSliderButtonsPlusButton", f)
+ local button_minor = CreateFrame ("button", "DetailsFrameworkSliderButtonsMinorButton", f)
+
+ button_plus:SetScript ("OnEnter", function (self)
+ if (f.is_going_hide) then
+ f:SetScript ("OnUpdate", nil)
+ f.is_going_hide = false
+ end
+ end)
+ button_minor:SetScript ("OnEnter", function (self)
+ if (f.is_going_hide) then
+ f:SetScript ("OnUpdate", nil)
+ f.is_going_hide = false
+ end
+ end)
+
+ button_plus:SetScript ("OnLeave", function (self)
+ f:PrepareToHide()
+ end)
+ button_minor:SetScript ("OnLeave", function (self)
+ f:PrepareToHide()
+ end)
+
+ button_plus:SetNormalTexture ([[Interface\Buttons\UI-PlusButton-Up]])
+ button_minor:SetNormalTexture ([[Interface\Buttons\UI-MinusButton-Up]])
+
+ button_plus:SetPushedTexture ([[Interface\Buttons\UI-PlusButton-Down]])
+ button_minor:SetPushedTexture ([[Interface\Buttons\UI-MinusButton-Down]])
+
+ button_plus:SetDisabledTexture ([[Interface\Buttons\UI-PlusButton-Disabled]])
+ button_minor:SetDisabledTexture ([[Interface\Buttons\UI-MinusButton-Disabled]])
+
+ button_plus:SetHighlightTexture ([[Interface\Buttons\UI-PlusButton-Hilight]])
+ button_minor:SetHighlightTexture ([[Interface\Buttons\UI-PlusButton-Hilight]])
+
+ --button_minor:SetPoint ("bottomleft", f, "bottomleft", -6, -13)
+ --button_plus:SetPoint ("bottomright", f, "bottomright", 6, -13)
+
+ button_minor:SetPoint ("bottomright", f, "bottomright", 13, -13)
+ button_plus:SetPoint ("left", button_minor, "right", -2, 0)
+
+ button_plus:SetSize (16, 16)
+ button_minor:SetSize (16, 16)
+
+ local timer = 0
+ local change_timer = 0
+
+ -- -- --
+
+ local plus_button_script = function()
+
+ local current = f.host.value
+ local editbox = SliderMetaFunctions.editbox_typevalue
+
+ if (f.host.fine_tuning) then
+ f.host:SetValue (current + f.host.fine_tuning)
+ if (editbox and SliderMetaFunctions.editbox_typevalue:IsShown()) then
+ SliderMetaFunctions.editbox_typevalue:SetText (tostring (string.format ("%.2f", current + f.host.fine_tuning)))
+ end
+ else
+ if (f.host.useDecimals) then
+ f.host:SetValue (current + 0.1)
+ if (editbox and SliderMetaFunctions.editbox_typevalue:IsShown()) then
+ SliderMetaFunctions.editbox_typevalue:SetText (string.format ("%.2f", current + 0.1))
+ end
+ else
+ f.host:SetValue (current + 1)
+ if (editbox and SliderMetaFunctions.editbox_typevalue:IsShown()) then
+ SliderMetaFunctions.editbox_typevalue:SetText (tostring (math.floor (current + 1)))
+ end
+ end
+ end
+
+ end
+
+ button_plus:SetScript ("OnMouseUp", function (self)
+ if (not button_plus.got_click) then
+ plus_button_script()
+ end
+ button_plus.got_click = false
+ self:SetScript ("OnUpdate", nil)
+ end)
+
+ local on_update = function (self, elapsed)
+ timer = timer + elapsed
+ if (timer > 0.4) then
+ change_timer = change_timer + elapsed
+ if (change_timer > 0.1) then
+ change_timer = 0
+ plus_button_script()
+ button_plus.got_click = true
+ end
+ end
+ end
+ button_plus:SetScript ("OnMouseDown", function (self)
+ timer = 0
+ change_timer = 0
+ self:SetScript ("OnUpdate", on_update)
+ end)
+
+ -- -- --
+
+ local minor_button_script = function()
+ local current = f.host.value
+ local editbox = SliderMetaFunctions.editbox_typevalue
+
+ if (f.host.fine_tuning) then
+ f.host:SetValue (current - f.host.fine_tuning)
+ if (editbox and SliderMetaFunctions.editbox_typevalue:IsShown()) then
+ SliderMetaFunctions.editbox_typevalue:SetText (tostring (string.format ("%.2f", current - f.host.fine_tuning)))
+ end
+ else
+ if (f.host.useDecimals) then
+ f.host:SetValue (current - 0.1)
+ if (editbox and SliderMetaFunctions.editbox_typevalue:IsShown()) then
+ SliderMetaFunctions.editbox_typevalue:SetText (string.format ("%.2f", current - 0.1))
+ end
+ else
+ f.host:SetValue (current - 1)
+ if (editbox and SliderMetaFunctions.editbox_typevalue:IsShown()) then
+ SliderMetaFunctions.editbox_typevalue:SetText (tostring (math.floor (current - 1)))
+ end
+ end
+ end
+ end
+
+ button_minor:SetScript ("OnMouseUp", function (self)
+ if (not button_minor.got_click) then
+ minor_button_script()
+ end
+ button_minor.got_click = false
+ self:SetScript ("OnUpdate", nil)
+ end)
+
+ local on_update = function (self, elapsed)
+ timer = timer + elapsed
+ if (timer > 0.4) then
+ change_timer = change_timer + elapsed
+ if (change_timer > 0.1) then
+ change_timer = 0
+ minor_button_script()
+ button_minor.got_click = true
+ end
+ end
+ end
+ button_minor:SetScript ("OnMouseDown", function (self)
+ timer = 0
+ change_timer = 0
+ self:SetScript ("OnUpdate", on_update)
+ end)
+
+ function SliderMetaFunctions:TypeValue()
+ if (not self.isSwitch) then
+
+ if (not SliderMetaFunctions.editbox_typevalue) then
+
+ local editbox = CreateFrame ("EditBox", "DetailsFrameworkSliderEditBox", UIParent)
+
+ editbox:SetSize (40, 20)
+ editbox:SetJustifyH ("center")
+ editbox:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]],
+ edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", --edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
+ tile = true, edgeSize = 8, tileSize = 5})
+ editbox:SetFontObject ("GameFontHighlightSmall")
+
+ editbox:SetScript ("OnEnterPressed", function()
+ editbox:ClearFocus()
+ editbox:Hide()
+ editbox:GetParent().MyObject.typing_value = false
+ editbox:GetParent().MyObject.value = tonumber (editbox:GetText())
+ end)
+
+ editbox:SetScript ("OnEscapePressed", function()
+ editbox:ClearFocus()
+ editbox:Hide()
+ editbox:GetParent().MyObject.typing_value = false
+ editbox:GetParent().MyObject.value = tonumber (self.typing_value_started)
+ end)
+
+ editbox:SetScript ("OnTextChanged", function()
+ editbox:GetParent().MyObject.typing_can_change = true
+ editbox:GetParent().MyObject.value = tonumber (editbox:GetText())
+ editbox:GetParent().MyObject.typing_can_change = false
+
+ -- esse self fica como o primeiro a ser alterado
+ --print ("text changed", self:GetName())
+ --print ()
+ end)
+
+ SliderMetaFunctions.editbox_typevalue = editbox
+ end
+
+ local pvalue = self.previous_value [2]
+ self:SetValue (pvalue)
+
+ self.typing_value = true
+ self.typing_value_started = pvalue
+
+ SliderMetaFunctions.editbox_typevalue:SetSize (self.width, self.height)
+ SliderMetaFunctions.editbox_typevalue:SetPoint ("center", self.widget, "center")
+ SliderMetaFunctions.editbox_typevalue:SetFocus()
+ SliderMetaFunctions.editbox_typevalue:SetParent (self.widget)
+ SliderMetaFunctions.editbox_typevalue:SetFrameLevel (self.widget:GetFrameLevel()+1)
+
+ if (self.useDecimals) then
+ SliderMetaFunctions.editbox_typevalue:SetText (tostring (string.format ("%.1f", self.value)))
+ else
+ SliderMetaFunctions.editbox_typevalue:SetText (tostring (math.floor (self.value)))
+ end
+
+ SliderMetaFunctions.editbox_typevalue:HighlightText()
+
+ SliderMetaFunctions.editbox_typevalue:Show()
+ end
+ end
+
+ local OnMouseDown = function (slider, button)
+ if (button == "RightButton") then
+ slider.MyObject:TypeValue()
+ end
+ end
+
+ local OnMouseUp = function (slider, button)
+ --if (button == "RightButton") then
+ -- if (slider.MyObject.typing_value) then
+ -- slider.MyObject:SetValue (slider.MyObject.previous_value [2])
+ -- end
+ --end
+ end
+
+ local OnHide = function (slider)
+ if (slider.MyObject.OnHideHook) then
+ local interrupt = slider.MyObject.OnHideHook (slider)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (slider.MyObject.typing_value) then
+ SliderMetaFunctions.editbox_typevalue:ClearFocus()
+ SliderMetaFunctions.editbox_typevalue:SetText ("")
+ slider.MyObject.typing_valu = false
+ end
+ end
+
+ local OnShow = function (slider)
+ if (slider.MyObject.OnShowHook) then
+ local interrupt = slider.MyObject.OnShowHook (slider)
+ if (interrupt) then
+ return
+ end
+ end
+ end
+
+ local table_insert = table.insert
+ local table_remove = table.remove
+
+ local OnValueChanged = function (slider)
+
+ local amt = slider:GetValue()
+
+ if (slider.MyObject.typing_value and not slider.MyObject.typing_can_change) then
+ slider.MyObject:SetValue (slider.MyObject.typing_value_started)
+ return
+ end
+
+ table_insert (slider.MyObject.previous_value, 1, amt)
+ table_remove (slider.MyObject.previous_value, 4)
+
+ if (slider.MyObject.OnValueChangeHook) then
+ local interrupt = slider.MyObject.OnValueChangeHook (slider, slider.MyObject.FixedValue, amt)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (slider.MyObject.OnValueChanged) then
+ slider.MyObject.OnValueChanged (slider, slider.MyObject.FixedValue, amt)
+ end
+
+ if (amt < 10 and amt >= 1) then
+ amt = "0"..amt
+ end
+
+ if (slider.MyObject.useDecimals) then
+ slider.amt:SetText (string.format ("%.2f", amt))
+ else
+ slider.amt:SetText (math.floor (amt))
+ end
+ slider.MyObject.ivalue = amt
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+
+local SwitchOnClick = function (self, button, forced_value, value)
+
+ local slider = self.MyObject
+
+ if (_rawget (slider, "lockdown")) then
+ return
+ end
+
+ if (forced_value) then
+ _rawset (slider, "value", not value)
+ end
+
+ if (_rawget (slider, "value")) then --actived
+
+ _rawset (slider, "value", false)
+ slider._text:SetText (slider._ltext)
+ slider._thumb:ClearAllPoints()
+
+ slider:SetBackdropColor (1, 0, 0, 0.4)
+ slider._thumb:SetPoint ("left", slider.widget, "left")
+
+ else
+
+ _rawset (slider, "value", true)
+ slider._text:SetText (slider._rtext)
+ slider._thumb:ClearAllPoints()
+
+ slider:SetBackdropColor (0, 0, 1, 0.4)
+ slider._thumb:SetPoint ("right", slider.widget, "right")
+
+ end
+
+ if (slider.OnSwitch and not forced_value) then
+ local value = _rawget (slider, "value")
+ if (slider.return_func) then
+ value = slider:return_func (value)
+ end
+ slider.OnSwitch (slider, slider.FixedValue, value)
+ end
+
+end
+
+local default_switch_func = function (self, passed_value)
+ if (self.value) then
+ return false
+ else
+ return true
+ end
+end
+
+local switch_get_value = function (self)
+ return self.value
+end
+
+local switch_set_value = function (self, value)
+ if (self.switch_func) then
+ value = self:switch_func (value)
+ end
+
+ SwitchOnClick (self.widget, nil, true, value)
+end
+
+local switch_set_fixparameter = function (self, value)
+ _rawset (self, "FixedValue", value)
+end
+
+local switch_disable = function (self)
+ if (not self.lock_texture) then
+ DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture")
+ self.lock_texture:SetDesaturated (true)
+ self.lock_texture:SetPoint ("center", self._thumb, "center")
+ end
+
+ self.lock_texture:Show()
+ self._text:Hide()
+ self:SetAlpha (.4)
+ _rawset (self, "lockdown", true)
+end
+local switch_enable = function (self)
+ if (not self.lock_texture) then
+ DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture")
+ self.lock_texture:SetDesaturated (true)
+ self.lock_texture:SetPoint ("center", self._thumb, "center")
+ end
+
+ self.lock_texture:Hide()
+ self._text:Show()
+ self:SetAlpha (1)
+ return _rawset (self, "lockdown", false)
+end
+
+function DF:CreateSwitch (parent, on_switch, default_value, w, h, ltext, rtext, member, name, color_inverted, switch_func, return_func, with_label)
+ local switch, label = DF:NewSwitch (parent, parent, name, member, w or 60, h or 20, ltext, rtext, default_value, color_inverted, switch_func, return_func, with_label)
+ if (on_switch) then
+ switch.OnSwitch = on_switch
+ end
+ return switch, label
+end
+
+function DF:NewSwitch (parent, container, name, member, w, h, ltext, rtext, default_value, color_inverted, switch_func, return_func, with_label)
+
+--> early checks
+ if (not name) then
+ name = "DetailsFrameWorkSlider" .. NameLessSlider
+ NameLessSlider = NameLessSlider + 1
+ elseif (not parent) then
+ return nil
+ end
+ if (not container) then
+ container = parent
+ end
+
+--> defaults
+ ltext = ltext or "OFF"
+ rtext = rtext or "ON"
+
+--> build frames
+
+ w = w or 60
+ h = h or 20
+
+ local slider = DF:NewButton (parent, container, name, member, w, h)
+
+ slider.switch_func = switch_func
+ slider.return_func = return_func
+ slider.SetValue = switch_set_value
+ slider.GetValue = switch_get_value
+ slider.SetFixedParameter = switch_set_fixparameter
+ slider.Disable = switch_disable
+ slider.Enable = switch_enable
+
+ if (member) then
+ parent [member] = slider
+ end
+
+ slider:SetBackdrop ({edgeFile = [[Interface\Buttons\UI-SliderBar-Border]], edgeSize = 8,
+ bgFile = [[Interface\AddOns\Details\images\background]], insets = {left = 3, right = 3, top = 5, bottom = 5}})
+
+ local thumb = slider:CreateTexture (nil, "artwork")
+ thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob")
+ thumb:SetSize (34+(h*0.2), h*1.2)
+ thumb:SetAlpha (0.7)
+ thumb:SetPoint ("left", slider.widget, "left")
+
+ local text = slider:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
+ text:SetTextColor (.8, .8, .8, 1)
+ text:SetPoint ("center", thumb, "center")
+
+ slider._text = text
+ slider._thumb = thumb
+ slider._ltext = ltext
+ slider._rtext = rtext
+ slider.thumb = thumb
+
+ slider.invert_colors = color_inverted
+
+ slider:SetScript ("OnClick", SwitchOnClick)
+
+ slider:SetValue (default_value)
+
+ slider.isSwitch = true
+
+ if (with_label) then
+ local label = DF:CreateLabel (slider.widget, with_label, nil, nil, nil, "label", nil, "overlay")
+ label.text = with_label
+ slider.widget:SetPoint ("left", label.widget, "right", 2, 0)
+ with_label = label
+ end
+
+ return slider, with_label
+end
+
+function DF:CreateSlider (parent, w, h, min, max, step, defaultv, isDecemal, member, name, with_label)
+ local slider, label = DF:NewSlider (parent, parent, name, member, w, h, min, max, step, defaultv, isDecemal, false, with_label)
+ return slider, label
+end
+
+function DF:NewSlider (parent, container, name, member, w, h, min, max, step, defaultv, isDecemal, isSwitch, with_label)
+
+--> early checks
+ if (not name) then
+ name = "DetailsFrameworkSlider" .. DF.SliderCounter
+ DF.SliderCounter = DF.SliderCounter + 1
+ end
+ if (not parent) then
+ return nil
+ end
+ if (not container) then
+ container = parent
+ end
+
+ if (name:find ("$parent")) then
+ name = name:gsub ("$parent", parent:GetName())
+ end
+
+ local SliderObject = {type = "slider", dframework = true}
+
+ if (member) then
+ parent [member] = SliderObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+--> defaults
+ min = min or 1
+ max = max or 2
+ step = step or 1
+ defaultv = defaultv or min
+
+ w = w or 130
+ h = h or 19
+
+ --> default members:
+ --> hooks
+ SliderObject.OnEnterHook = nil
+ SliderObject.OnLeaveHook = nil
+ SliderObject.OnHideHook = nil
+ SliderObject.OnShowHook = nil
+ SliderObject.OnValueChangeHook = nil
+ --> misc
+ SliderObject.lockdown = false
+ SliderObject.container = container
+ SliderObject.have_tooltip = nil
+ SliderObject.FixedValue = nil
+ SliderObject.useDecimals = isDecemal or false
+
+ SliderObject.slider = CreateFrame ("slider", name, parent)
+ SliderObject.widget = SliderObject.slider
+
+ if (not APISliderFunctions) then
+ APISliderFunctions = true
+ local idx = getmetatable (SliderObject.slider).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not SliderMetaFunctions [funcName]) then
+ SliderMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G."..object.slider:GetName()..":"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ SliderObject.slider.MyObject = SliderObject
+ SliderObject.slider:SetWidth (w)
+ SliderObject.slider:SetHeight (h)
+ SliderObject.slider:SetOrientation ("horizontal")
+ SliderObject.slider:SetMinMaxValues (min, max)
+ SliderObject.slider:SetValueStep (step)
+ SliderObject.slider:SetValue (defaultv)
+ SliderObject.ivalue = defaultv
+
+ SliderObject.slider:SetBackdrop ({edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", edgeSize = 8})
+ SliderObject.slider:SetBackdropColor (0.9, 0.7, 0.7, 1.0)
+
+ SliderObject.thumb = SliderObject.slider:CreateTexture (nil, "artwork")
+ SliderObject.thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob")
+ SliderObject.thumb:SetSize (30+(h*0.2), h*1.2)
+ SliderObject.thumb:SetAlpha (0.7)
+ SliderObject.slider:SetThumbTexture (SliderObject.thumb)
+ SliderObject.slider.thumb = SliderObject.thumb
+
+ if (not isSwitch) then
+ SliderObject.have_tooltip = "Right Click to Type the Value"
+ end
+
+ SliderObject.amt = SliderObject.slider:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
+
+ local amt = defaultv
+ if (amt < 10 and amt >= 1) then
+ amt = "0"..amt
+ end
+
+ if (SliderObject.useDecimals) then
+ SliderObject.amt:SetText (string.format ("%.2f", amt))
+ else
+ SliderObject.amt:SetText (math.floor (amt))
+ end
+
+ SliderObject.amt:SetTextColor (.8, .8, .8, 1)
+ SliderObject.amt:SetPoint ("center", SliderObject.thumb, "center")
+ SliderObject.slider.amt = SliderObject.amt
+
+ SliderObject.previous_value = {defaultv or 0, 0, 0}
+
+ --> hooks
+ SliderObject.slider:SetScript ("OnEnter", OnEnter)
+ SliderObject.slider:SetScript ("OnLeave", OnLeave)
+ SliderObject.slider:SetScript ("OnHide", OnHide)
+ SliderObject.slider:SetScript ("OnShow", OnShow)
+ SliderObject.slider:SetScript ("OnValueChanged", OnValueChanged)
+ SliderObject.slider:SetScript ("OnMouseDown", OnMouseDown)
+ SliderObject.slider:SetScript ("OnMouseUp", OnMouseUp)
+
+
+ _setmetatable (SliderObject, SliderMetaFunctions)
+
+ if (with_label) then
+ local label = DF:CreateLabel (SliderObject.slider, with_label, nil, nil, nil, "label", nil, "overlay")
+ label.text = with_label
+ SliderObject.slider:SetPoint ("left", label.widget, "right", 2, 0)
+ with_label = label
+ end
+
+ return SliderObject, with_label
+
+end
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/split_bar.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/split_bar.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,644 @@
+
+
+
+local DF = _G ["DetailsFramework"]
+local _
+
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+
+local cleanfunction = function() end
+local SplitBarMetaFunctions = {}
+local APISplitBarFunctions
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ SplitBarMetaFunctions.__call = function (_table, value)
+ if (not value) then
+ return _table.statusbar:GetValue()
+ else
+ _table.div:SetPoint ("left", _table.statusbar, "left", value * (_table.statusbar:GetWidth()/100) - 18, 0)
+ return _table.statusbar:SetValue (value)
+ end
+ end
+
+ SplitBarMetaFunctions.__add = function (v1, v2)
+ if (_type (v1) == "table") then
+ local v = v1.statusbar:GetValue()
+ v = v + v2
+ v1.div:SetPoint ("left", v1.statusbar, "left", value * (v1.statusbar:GetWidth()/100) - 18, 0)
+ v1.statusbar:SetValue (v)
+ else
+ local v = v2.statusbar:GetValue()
+ v = v + v1
+ v2.div:SetPoint ("left", v2.statusbar, "left", value * (v2.statusbar:GetWidth()/100) - 18, 0)
+ v2.statusbar:SetValue (v)
+ end
+ end
+
+ SplitBarMetaFunctions.__sub = function (v1, v2)
+ if (_type (v1) == "table") then
+ local v = v1.statusbar:GetValue()
+ v = v - v2
+ v1.div:SetPoint ("left", v1.statusbar, "left", value * (v1.statusbar:GetWidth()/100) - 18, 0)
+ v1.statusbar:SetValue (v)
+ else
+ local v = v2.statusbar:GetValue()
+ v = v - v1
+ v2.div:SetPoint ("left", v2.statusbar, "left", value * (v2.statusbar:GetWidth()/100) - 18, 0)
+ v2.statusbar:SetValue (v)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> tooltip
+ local function gmember_tooltip (_object)
+ return _object:GetTooltip()
+ end
+ --> shown
+ local gmember_shown = function (_object)
+ return _object.statusbar:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.statusbar:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.statusbar:GetHeight()
+ end
+ --> value
+ local gmember_value = function (_object)
+ return _object.statusbar:GetValue()
+ end
+ --> right text
+ local gmember_rtext = function (_object)
+ return _object.textright:GetText()
+ end
+ --> left text
+ local gmember_ltext = function (_object)
+ return _object.textleft:GetText()
+ end
+ --> right color
+ local gmember_rcolor = function (_object)
+ return _object.background.original_colors
+ end
+ --> left color
+ local gmember_lcolor = function (_object)
+ return _object.texture.original_colors
+ end
+ --> right icon
+ local gmember_ricon = function (_object)
+ return _object.iconright:GetTexture()
+ end
+ --> left icon
+ local gmember_licon = function (_object)
+ return _object.iconleft:GetTexture()
+ end
+ --> texture
+ local gmember_texture = function (_object)
+ return _object.texture:GetTexture()
+ end
+ --> font size
+ local gmember_textsize = function (_object)
+ local _, fontsize = _object.textleft:GetFont()
+ return fontsize
+ end
+ --> font face
+ local gmember_textfont = function (_object)
+ local fontface = _object.textleft:GetFont()
+ return fontface
+ end
+ --> font color
+ local gmember_textcolor = function (_object)
+ return _object.textleft:GetTextColor()
+ end
+
+ local get_members_function_index = {
+ ["tooltip"] = gmember_tooltip,
+ ["shown"] = gmember_shown,
+ ["width"] = gmember_width,
+ ["height"] = gmember_height,
+ ["value"] = gmember_value,
+ ["righttext"] = gmember_rtext,
+ ["lefttext"] = gmember_ltext,
+ ["rightcolor"] = gmember_rcolor,
+ ["leftcolor"] = gmember_lcolor,
+ ["righticon"] = gmember_ricon,
+ ["lefticon"] = gmember_licon,
+ ["texture"] = gmember_texture,
+ ["fontsize"] = gmember_textsize,
+ ["fontface"] = gmember_textfont,
+ ["fontcolor"] = gmember_textcolor,
+ ["textsize"] = gmember_textsize, --alias
+ ["textfont"] = gmember_textfont, --alias
+ ["textcolor"] = gmember_textcolor --alias
+ }
+
+ SplitBarMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = get_members_function_index [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return SplitBarMetaFunctions [_member_requested]
+ end
+
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ --> tooltip
+ local smember_tooltip = function (_object, _value)
+ return _object:SetTooltip (_value)
+ end
+ --> show
+ local smember_shown = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (_value) then
+ return _object:Hide()
+ else
+ return _object:Show()
+ end
+ end
+ --> width
+ local smember_width = function (_object, _value)
+ return _object.statusbar:SetWidth (_value)
+ end
+ --> height
+ local smember_height = function (_object, _value)
+ return _object.statusbar:SetHeight (_value)
+ end
+ --> statusbar value
+ local smember_value = function (_object, _value)
+ _object.statusbar:SetValue (_value)
+ return _object.div:SetPoint ("left", _object.statusbar, "left", _value * (_object.statusbar:GetWidth()/100) - 18, 0)
+ end
+ --> right text
+ local smember_rtext = function (_object, _value)
+ return _object.textright:SetText (_value)
+ end
+ --> left text
+ local smember_ltext = function (_object, _value)
+ return _object.textleft:SetText (_value)
+ end
+ --> right color
+ local smember_rcolor = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+ _object.background.original_colors = {_value1, _value2, _value3, _value4}
+ return _object.background:SetVertexColor (_value1, _value2, _value3, _value4)
+ end
+ --> left color
+ local smember_lcolor = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+
+ _object.statusbar:SetStatusBarColor (_value1, _value2, _value3, _value4)
+ _object.texture.original_colors = {_value1, _value2, _value3, _value4}
+ return _object.texture:SetVertexColor (_value1, _value2, _value3, _value4)
+ end
+ --> right icon
+ local smember_ricon = function (_object, _value)
+ if (type (_value) == "table") then
+ local _value1, _value2 = _unpack (_value)
+ _object.iconright:SetTexture (_value1)
+ if (_value2) then
+ _object.iconright:SetTexCoord (_unpack (_value2))
+ end
+ else
+ _object.iconright:SetTexture (_value)
+ end
+ return
+ end
+ --> left icon
+ local smember_licon = function (_object, _value)
+ if (type (_value) == "table") then
+ local _value1, _value2 = _unpack (_value)
+ _object.iconleft:SetTexture (_value1)
+ if (_value2) then
+ _object.iconleft:SetTexCoord (_unpack (_value2))
+ end
+ else
+ _object.iconleft:SetTexture (_value)
+ end
+ return
+ end
+ --> texture
+ local smember_texture = function (_object, _value)
+ if (type (_value) == "table") then
+ local _value1, _value2 = _unpack (_value)
+ _object.texture:SetTexture (_value1)
+ _object.background:SetTexture (_value1)
+ if (_value2) then
+ _object.texture:SetTexCoord (_unpack (_value2))
+ _object.background:SetTexCoord (_unpack (_value2))
+ end
+ else
+ _object.texture:SetTexture (_value)
+ _object.background:SetTexture (_value)
+ end
+ return
+ end
+ --> font face
+ local smember_textfont = function (_object, _value)
+ DF:SetFontFace (_object.textleft, _value)
+ return DF:SetFontFace (_object.textright, _value)
+ end
+ --> font size
+ local smember_textsize = function (_object, _value)
+ DF:SetFontSize (_object.textleft, _value)
+ return DF:SetFontSize (_object.textright, _value)
+ end
+ --> font color
+ local smember_textcolor = function (_object, _value)
+ local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
+ _object.textleft:SetTextColor (_value1, _value2, _value3, _value4)
+ return _object.textright:SetTextColor (_value1, _value2, _value3, _value4)
+ end
+
+ local set_members_function_index = {
+ ["tooltip"] = smember_tooltip,
+ ["shown"] = smember_shown,
+ ["width"] = smember_width,
+ ["height"] = smember_height,
+ ["value"] = smember_value,
+ ["righttext"] = smember_rtext,
+ ["lefttext"] = smember_ltext,
+ ["rightcolor"] = smember_rcolor,
+ ["leftcolor"] = smember_lcolor,
+ ["righticon"] = smember_ricon,
+ ["lefticon"] = smember_licon,
+ ["texture"] = smember_texture,
+ ["fontsize"] = smember_textsize,
+ ["fontface"] = smember_textfont,
+ ["fontcolor"] = smember_textcolor,
+ ["textsize"] = smember_textsize, --alias
+ ["textfont"] = smember_textfont, --alias
+ ["textcolor"] = smember_textcolor --alias
+ }
+
+ SplitBarMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = set_members_function_index [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+
+--> show & hide
+ function SplitBarMetaFunctions:Show()
+ return self.statusbar:Show()
+ end
+ function SplitBarMetaFunctions:Hide()
+ return self.statusbar:Hide()
+ end
+
+-- set split
+ function SplitBarMetaFunctions:SetSplit (value)
+ if (not value) then
+ value = self.statusbar:GetValue()
+ elseif (value < 0 or value > 100) then
+ return
+ end
+ self.statusbar:SetValue (value)
+ self.div:SetPoint ("left", self.statusbar, "left", value * (self.statusbar:GetWidth()/100) - 18, 0)
+ end
+
+-- setpoint
+ function SplitBarMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
+ v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
+ if (not v1) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+ return self.widget:SetPoint (v1, v2, v3, v4, v5)
+ end
+
+-- sizes
+ function SplitBarMetaFunctions:SetSize (w, h)
+ if (w) then
+ self.statusbar:SetWidth (w)
+ end
+ if (h) then
+ self.statusbar:SetHeight (h)
+ end
+ end
+
+-- texture
+ function SplitBarMetaFunctions:SetTexture (texture)
+ self.background:SetTexture (texture)
+ self.texture:SetTexture (texture)
+ end
+
+-- texts
+ function SplitBarMetaFunctions:SetLeftText (text)
+ self.textleft:SetText (text)
+ end
+ function SplitBarMetaFunctions:SetRightText (text)
+ self.textright:SetText (text)
+ end
+
+-- colors
+ function SplitBarMetaFunctions:SetLeftColor (r, g, b, a)
+ r, g, b, a = DF:ParseColors (r, g, b, a)
+ self.texture:SetVertexColor (r, g, b, a)
+ self.texture.original_colors = {r, g, b, a}
+ end
+ function SplitBarMetaFunctions:SetRightColor (r, g, b, a)
+ r, g, b, a = DF:ParseColors (r, g, b, a)
+ self.background:SetVertexColor (r, g, b, a)
+ self.background.original_colors = {r, g, b, a}
+ end
+
+-- icons
+ function SplitBarMetaFunctions:SetLeftIcon (texture, ...)
+ self.iconleft:SetTexture (texture)
+ if (...) then
+ local L, R, U, D = unpack (...)
+ self.iconleft:SetTexCoord (L, R, U, D)
+ end
+ end
+ function SplitBarMetaFunctions:SetRightIcon (texture, ...)
+ self.iconright:SetTexture (texture)
+ if (...) then
+ local L, R, U, D = unpack (...)
+ self.iconright:SetTexCoord (L, R, U, D)
+ end
+ end
+
+-- tooltip
+ function SplitBarMetaFunctions:SetTooltip (tooltip)
+ if (tooltip) then
+ return _rawset (self, "have_tooltip", tooltip)
+ else
+ return _rawset (self, "have_tooltip", nil)
+ end
+ end
+ function SplitBarMetaFunctions:GetTooltip()
+ return _rawget (self, "have_tooltip")
+ end
+
+-- frame levels
+ function SplitBarMetaFunctions:GetFrameLevel()
+ return self.statusbar:GetFrameLevel()
+ end
+ function SplitBarMetaFunctions:SetFrameLevel (level, frame)
+ if (not frame) then
+ return self.statusbar:SetFrameLevel (level)
+ else
+ local framelevel = frame:GetFrameLevel (frame) + level
+ return self.statusbar:SetFrameLevel (framelevel)
+ end
+ end
+
+-- frame stratas
+ function SplitBarMetaFunctions:SetFrameStrata()
+ return self.statusbar:GetFrameStrata()
+ end
+ function SplitBarMetaFunctions:SetFrameStrata (strata)
+ if (_type (strata) == "table") then
+ self.statusbar:SetFrameStrata (strata:GetFrameStrata())
+ else
+ self.statusbar:SetFrameStrata (strata)
+ end
+ end
+
+--> hooks
+ function SplitBarMetaFunctions:SetHook (hookType, func)
+ if (func) then
+ _rawset (self, hookType.."Hook", func)
+ else
+ _rawset (self, hookType.."Hook", nil)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts
+ local OnEnter = function (frame)
+ if (frame.MyObject.OnEnterHook) then
+ local interrupt = frame.MyObject.OnEnterHook (frame)
+ if (interrupt) then
+ return
+ end
+ end
+
+ local oc = frame.MyObject.texture.original_colors --original colors
+ DF:GradientEffect ( frame.MyObject.texture, "texture", oc[1], oc[2], oc[3], oc[4], oc[1]+0.2, oc[2]+0.2, oc[3]+0.2, oc[4], .2)
+ frame.MyObject.div:SetPoint ("left", frame, "left", frame:GetValue() * (frame:GetWidth()/100) - 18, 0)
+
+ if (frame.MyObject.have_tooltip) then
+ GameCooltip2:Reset()
+ GameCooltip2:AddLine (frame.MyObject.have_tooltip)
+ GameCooltip2:ShowCooltip (frame, "tooltip")
+ end
+
+ local parent = frame:GetParent().MyObject
+ if (parent and parent.type == "panel") then
+ if (parent.GradientEnabled) then
+ parent:RunGradient()
+ end
+ end
+ end
+
+ local OnLeave = function (frame)
+ if (frame.MyObject.OnLeaveHook) then
+ local interrupt = frame.MyObject.OnLeaveHook (frame)
+ if (interrupt) then
+ return
+ end
+ end
+
+ local oc = frame.MyObject.texture.original_colors --original colors
+ local r, g, b, a = frame.MyObject.texture:GetVertexColor()
+ DF:GradientEffect ( frame.MyObject.texture, "texture", r, g, b, a, oc[1], oc[2], oc[3], oc[4], .2)
+
+ if (frame.MyObject.have_tooltip) then
+ DF.popup:ShowMe (false)
+ end
+
+ local parent = frame:GetParent().MyObject
+ if (parent and parent.type == "panel") then
+ if (parent.GradientEnabled) then
+ parent:RunGradient (false)
+ end
+ end
+ end
+
+ local OnHide = function (frame)
+ if (frame.MyObject.OnHideHook) then
+ local interrupt = frame.MyObject.OnHideHook (frame)
+ if (interrupt) then
+ return
+ end
+ end
+ end
+
+ local OnShow = function (frame)
+ if (frame.MyObject.OnShowHook) then
+ local interrupt = frame.MyObject.OnShowHook (frame)
+ if (interrupt) then
+ return
+ end
+ end
+ end
+
+ local OnMouseDown = function (frame, button)
+ if (frame.MyObject.OnMouseDownHook) then
+ local interrupt = frame.MyObject.OnMouseDownHook (frame, button)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (not frame.MyObject.container.isLocked and frame.MyObject.container:IsMovable()) then
+ if (not frame.isLocked and frame:IsMovable()) then
+ frame.MyObject.container.isMoving = true
+ frame.MyObject.container:StartMoving()
+ end
+ end
+ end
+
+ local OnMouseUp = function (frame, button)
+ if (frame.MyObject.OnMouseUpHook) then
+ local interrupt = frame.MyObject.OnMouseUpHook (frame, button)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (frame.MyObject.container.isMoving) then
+ frame.MyObject.container:StopMovingOrSizing()
+ frame.MyObject.container.isMoving = false
+ end
+ end
+
+ local OnSizeChanged = function (statusbar)
+ statusbar.MyObject.div:SetPoint ("left", statusbar, "left", statusbar:GetValue() * (statusbar:GetWidth()/100) - 18, 0)
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+
+function DetailsFrameworkSplitlBar_OnCreate (self)
+ self.texture.original_colors = {1, 1, 1, 1}
+ self.background.original_colors = {.5, .5, .5, 1}
+ self.spark:SetPoint ("left", self, "left", self:GetValue() * (self:GetWidth()/100) - 18, 0)
+ return true
+end
+
+function DF:CreateSplitBar (parent, parent, w, h, member, name)
+ return DF:NewSplitBar (parent, container, name, member, w, h)
+end
+
+function DF:NewSplitBar (parent, container, name, member, w, h)
+
+ if (not name) then
+ name = "DetailsFrameworkSplitbar" .. DF.SplitBarCounter
+ DF.SplitBarCounter = DF.SplitBarCounter + 1
+ end
+ if (not parent) then
+ return nil
+ end
+ if (not container) then
+ container = parent
+ end
+
+ if (name:find ("$parent")) then
+ name = name:gsub ("$parent", parent:GetName())
+ end
+
+ local SplitBarObject = {type = "barsplit", dframework = true}
+
+ if (member) then
+ parent [member] = SplitBarObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+ --> default members:
+ --> hooks
+ SplitBarObject.OnEnterHook = nil
+ SplitBarObject.OnLeaveHook = nil
+ SplitBarObject.OnHideHook = nil
+ SplitBarObject.OnShowHook = nil
+ SplitBarObject.OnMouseDownHook = nil
+ SplitBarObject.OnMouseUpHook = nil
+ --> misc
+ SplitBarObject.tooltip = nil
+ SplitBarObject.locked = false
+ SplitBarObject.have_tooltip = nil
+ SplitBarObject.container = container
+
+ --> create widgets
+ SplitBarObject.statusbar = CreateFrame ("statusbar", name, parent, "DetailsFrameworkSplitBarTemplate")
+ SplitBarObject.widget = SplitBarObject.statusbar
+
+ if (not APISplitBarFunctions) then
+ APISplitBarFunctions = true
+ local idx = getmetatable (SplitBarObject.statusbar).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not SplitBarMetaFunctions [funcName]) then
+ SplitBarMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G."..object.statusbar:GetName()..":"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ SplitBarObject.statusbar:SetHeight (h or 200)
+ SplitBarObject.statusbar:SetWidth (w or 14)
+
+ SplitBarObject.statusbar.MyObject = SplitBarObject
+
+ SplitBarObject.textleft = _G [name .. "_TextLeft"]
+ SplitBarObject.textright = _G [name .. "_TextRight"]
+
+ SplitBarObject.iconleft = _G [name .. "_IconLeft"]
+ SplitBarObject.iconright = _G [name .. "_IconRight"]
+
+ SplitBarObject.background = _G [name .. "_StatusBarBackground"]
+ SplitBarObject.texture = _G [name .. "_StatusBarTexture"]
+
+ SplitBarObject.div = _G [name .. "_Spark"]
+
+
+ --> hooks
+ SplitBarObject.statusbar:SetScript ("OnEnter", OnEnter)
+ SplitBarObject.statusbar:SetScript ("OnLeave", OnLeave)
+ SplitBarObject.statusbar:SetScript ("OnHide", OnHide)
+ SplitBarObject.statusbar:SetScript ("OnShow", OnShow)
+ SplitBarObject.statusbar:SetScript ("OnMouseDown", OnMouseDown)
+ SplitBarObject.statusbar:SetScript ("OnMouseUp", OnMouseUp)
+ SplitBarObject.statusbar:SetScript ("OnSizeChanged", OnSizeChanged)
+
+ _setmetatable (SplitBarObject, SplitBarMetaFunctions)
+
+ return SplitBarObject
+end
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/split_bar.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/split_bar.xml Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ self:SetStatusBarTexture (self.texture);
+ self:SetMinMaxValues (1, 100);
+ self:SetValue (50);
+ DetailsFrameworkSplitlBar_OnCreate (self);
+
+
+
+
+
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/textentry.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/textentry.lua Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,664 @@
+
+
+
+local DF = _G ["DetailsFramework"]
+local _
+
+local _rawset = rawset --> lua local
+local _rawget = rawget --> lua local
+local _setmetatable = setmetatable --> lua local
+local _unpack = unpack --> lua local
+local _type = type --> lua local
+local _math_floor = math.floor --> lua local
+local loadstring = loadstring --> lua local
+local _string_len = string.len --> lua local
+
+local cleanfunction = function() end
+local APITextEntryFunctions = false
+local TextEntryMetaFunctions = {}
+
+DF.TextEntryCounter = 1
+
+------------------------------------------------------------------------------------------------------------
+--> metatables
+
+ TextEntryMetaFunctions.__call = function (_table, value)
+ --> unknow
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> members
+
+ --> tooltip
+ local gmember_tooltip = function (_object)
+ return _object:GetTooltip()
+ end
+ --> shown
+ local gmember_shown = function (_object)
+ return _object:IsShown()
+ end
+ --> frame width
+ local gmember_width = function (_object)
+ return _object.editbox:GetWidth()
+ end
+ --> frame height
+ local gmember_height = function (_object)
+ return _object.editbox:GetHeight()
+ end
+ --> get text
+ local gmember_text = function (_object)
+ return _object.editbox:GetText()
+ end
+
+ local get_members_function_index = {
+ ["tooltip"] = gmember_tooltip,
+ ["shown"] = gmember_shown,
+ ["width"] = gmember_width,
+ ["height"] = gmember_height,
+ ["text"] = gmember_text,
+ }
+
+ TextEntryMetaFunctions.__index = function (_table, _member_requested)
+
+ local func = get_members_function_index [_member_requested]
+ if (func) then
+ return func (_table, _member_requested)
+ end
+
+ local fromMe = _rawget (_table, _member_requested)
+ if (fromMe) then
+ return fromMe
+ end
+
+ return TextEntryMetaFunctions [_member_requested]
+ end
+
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ --> tooltip
+ local smember_tooltip = function (_object, _value)
+ return _object:SetTooltip (_value)
+ end
+ --> show
+ local smember_show = function (_object, _value)
+ if (_value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> hide
+ local smember_hide = function (_object, _value)
+ if (not _value) then
+ return _object:Show()
+ else
+ return _object:Hide()
+ end
+ end
+ --> frame width
+ local smember_width = function (_object, _value)
+ return _object.editbox:SetWidth (_value)
+ end
+ --> frame height
+ local smember_height = function (_object, _value)
+ return _object.editbox:SetHeight (_value)
+ end
+ --> set text
+ local smember_text = function (_object, _value)
+ return _object.editbox:SetText (_value)
+ end
+ --> set multiline
+ local smember_multiline = function (_object, _value)
+ if (_value) then
+ return _object.editbox:SetMultiLine (true)
+ else
+ return _object.editbox:SetMultiLine (false)
+ end
+ end
+ --> text horizontal pos
+ local smember_horizontalpos = function (_object, _value)
+ return _object.editbox:SetJustifyH (string.lower (_value))
+ end
+
+ local set_members_function_index = {
+ ["tooltip"] = smember_tooltip,
+ ["show"] = smember_show,
+ ["hide"] = smember_hide,
+ ["width"] = smember_width,
+ ["height"] = smember_height,
+ ["text"] = smember_text,
+ ["multiline"] = smember_multiline,
+ ["align"] = smember_horizontalpos,
+ }
+
+ TextEntryMetaFunctions.__newindex = function (_table, _key, _value)
+ local func = set_members_function_index [_key]
+ if (func) then
+ return func (_table, _value)
+ else
+ return _rawset (_table, _key, _value)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> methods
+
+--> set point
+ function TextEntryMetaFunctions:SetPoint (MyAnchor, SnapTo, HisAnchor, x, y, Width)
+
+ if (type (MyAnchor) == "boolean" and MyAnchor and self.space) then
+ local textWidth = self.label:GetStringWidth()+2
+ self.editbox:SetWidth (self.space - textWidth - 15)
+ return
+
+ elseif (type (MyAnchor) == "boolean" and MyAnchor and not self.space) then
+ self.space = self.label:GetStringWidth()+2 + self.editbox:GetWidth()
+ end
+
+ if (Width) then
+ self.space = Width
+ end
+
+ MyAnchor, SnapTo, HisAnchor, x, y = DF:CheckPoints (MyAnchor, SnapTo, HisAnchor, x, y, self)
+ if (not MyAnchor) then
+ print ("Invalid parameter for SetPoint")
+ return
+ end
+
+ if (self.space) then
+ self.label:ClearAllPoints()
+ self.editbox:ClearAllPoints()
+
+ self.label:SetPoint (MyAnchor, SnapTo, HisAnchor, x, y)
+ self.editbox:SetPoint ("left", self.label, "right", 2, 0)
+
+ local textWidth = self.label:GetStringWidth()+2
+ self.editbox:SetWidth (self.space - textWidth - 15)
+ else
+ self.label:ClearAllPoints()
+ self.editbox:ClearAllPoints()
+ self.editbox:SetPoint (MyAnchor, SnapTo, HisAnchor, x, y)
+ end
+
+ end
+
+--> frame levels
+ function TextEntryMetaFunctions:GetFrameLevel()
+ return self.editbox:GetFrameLevel()
+ end
+ function TextEntryMetaFunctions:SetFrameLevel (level, frame)
+ if (not frame) then
+ return self.editbox:SetFrameLevel (level)
+ else
+ local framelevel = frame:GetFrameLevel (frame) + level
+ return self.editbox:SetFrameLevel (framelevel)
+ end
+ end
+
+--> select all text
+ function TextEntryMetaFunctions:SelectAll()
+ self.editbox:HighlightText()
+ end
+
+--> set labal description
+ function TextEntryMetaFunctions:SetLabelText (text)
+ if (text) then
+ self.label:SetText (text)
+ else
+ self.label:SetText ("")
+ end
+ self:SetPoint (true) --> refresh
+ end
+
+--> set tab order
+ function TextEntryMetaFunctions:SetNext (nextbox)
+ self.next = nextbox
+ end
+
+--> blink
+ function TextEntryMetaFunctions:Blink()
+ self.label:SetTextColor (1, .2, .2, 1)
+ end
+
+--> show & hide
+ function TextEntryMetaFunctions:IsShown()
+ return self.editbox:IsShown()
+ end
+ function TextEntryMetaFunctions:Show()
+ return self.editbox:Show()
+ end
+ function TextEntryMetaFunctions:Hide()
+ return self.editbox:Hide()
+ end
+
+-- tooltip
+ function TextEntryMetaFunctions:SetTooltip (tooltip)
+ if (tooltip) then
+ return _rawset (self, "have_tooltip", tooltip)
+ else
+ return _rawset (self, "have_tooltip", nil)
+ end
+ end
+ function TextEntryMetaFunctions:GetTooltip()
+ return _rawget (self, "have_tooltip")
+ end
+
+--> hooks
+ function TextEntryMetaFunctions:SetHook (hookType, func)
+ if (func) then
+ _rawset (self, hookType.."Hook", func)
+ else
+ _rawset (self, hookType.."Hook", nil)
+ end
+ end
+
+ function TextEntryMetaFunctions:Enable()
+ if (not self.editbox:IsEnabled()) then
+ self.editbox:Enable()
+ self.editbox:SetBackdropBorderColor (unpack (self.enabled_border_color))
+ self.editbox:SetBackdropColor (unpack (self.enabled_backdrop_color))
+ self.editbox:SetTextColor (unpack (self.enabled_text_color))
+ end
+ end
+
+ function TextEntryMetaFunctions:Disable()
+ if (self.editbox:IsEnabled()) then
+ self.enabled_border_color = {self.editbox:GetBackdropBorderColor()}
+ self.enabled_backdrop_color = {self.editbox:GetBackdropColor()}
+ self.enabled_text_color = {self.editbox:GetTextColor()}
+
+ self.editbox:Disable()
+
+ self.editbox:SetBackdropBorderColor (.5, .5, .5, .5)
+ self.editbox:SetBackdropColor (.5, .5, .5, .5)
+ self.editbox:SetTextColor (.5, .5, .5, .5)
+ end
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> scripts
+ local OnEnter = function (textentry)
+
+ if (textentry.MyObject.OnEnterHook) then
+ local interrupt = textentry.MyObject.OnEnterHook (textentry)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (textentry.MyObject.have_tooltip) then
+ GameCooltip2:Preset (2)
+ GameCooltip2:AddLine (textentry.MyObject.have_tooltip)
+ GameCooltip2:ShowCooltip (textentry, "tooltip")
+ end
+
+ textentry.mouse_over = true
+
+ if (textentry:IsEnabled()) then
+ textentry.current_bordercolor = textentry.current_bordercolor or {textentry:GetBackdropBorderColor()}
+ textentry:SetBackdropBorderColor (1, 1, 1, 1)
+ end
+
+ local parent = textentry:GetParent().MyObject
+ if (parent and parent.type == "panel") then
+ if (parent.GradientEnabled) then
+ parent:RunGradient()
+ end
+ end
+
+ end
+
+ local OnLeave = function (textentry)
+ if (textentry.MyObject.OnLeaveHook) then
+ local interrupt = textentry.MyObject.OnLeaveHook (textentry)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (textentry.MyObject.have_tooltip) then
+ GameCooltip2:ShowMe (false)
+ end
+
+ textentry.mouse_over = false
+
+ if (textentry:IsEnabled()) then
+ textentry:SetBackdropBorderColor (unpack (textentry.current_bordercolor))
+ end
+
+ local parent = textentry:GetParent().MyObject
+ if (parent and parent.type == "panel") then
+ if (parent.GradientEnabled) then
+ parent:RunGradient (false)
+ end
+ end
+ end
+
+ local OnHide = function (textentry)
+ if (textentry.MyObject.OnHideHook) then
+ local interrupt = textentry.MyObject.OnHideHook (textentry)
+ if (interrupt) then
+ return
+ end
+ end
+ end
+
+ local OnShow = function (textentry)
+ if (textentry.MyObject.OnShowHook) then
+ local interrupt = textentry.MyObject.OnShowHook (textentry)
+ if (interrupt) then
+ return
+ end
+ end
+ end
+
+ local OnEnterPressed = function (textentry, byScript)
+
+ if (textentry.MyObject.OnEnterPressedHook) then
+ local interrupt = textentry.MyObject.OnEnterPressedHook (textentry)
+ if (interrupt) then
+ return
+ end
+ end
+
+ local texto = DF:trim (textentry:GetText())
+ if (_string_len (texto) > 0) then
+ textentry.text = texto
+ if (textentry.MyObject.func) then
+ textentry.MyObject.func (textentry.MyObject.param1, textentry.MyObject.param2, texto, textentry, byScript or textentry)
+ end
+ else
+ textentry:SetText ("")
+ textentry.MyObject.currenttext = ""
+ end
+ textentry.focuslost = true --> perdeu_focus isso aqui pra quando estiver editando e clicar em outra caixa
+ textentry:ClearFocus()
+
+ if (textentry.MyObject.tab_on_enter and textentry.MyObject.next) then
+ textentry.MyObject.next:SetFocus()
+ end
+ end
+
+ local OnEscapePressed = function (textentry)
+
+ if (textentry.MyObject.OnEscapePressedHook) then
+ local interrupt = textentry.MyObject.OnEscapePressedHook (textentry)
+ if (interrupt) then
+ return
+ end
+ end
+
+ --textentry:SetText("")
+ --textentry.MyObject.currenttext = ""
+ textentry.focuslost = true
+ textentry:ClearFocus()
+ end
+
+ local OnEditFocusLost = function (textentry)
+
+ if (textentry:IsShown()) then
+
+ if (textentry.MyObject.OnEditFocusLostHook) then
+ local interrupt = textentry.MyObject.OnEditFocusLostHook (textentry)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (not textentry.focuslost) then
+ local texto = DF:trim (textentry:GetText())
+ if (_string_len (texto) > 0) then
+ textentry.MyObject.currenttext = texto
+ if (textentry.MyObject.func) then
+ textentry.MyObject.func (textentry.MyObject.param1, textentry.MyObject.param2, texto, textentry, nil)
+ end
+ else
+ textentry:SetText ("")
+ textentry.MyObject.currenttext = ""
+ end
+ else
+ textentry.focuslost = false
+ end
+
+ textentry.MyObject.label:SetTextColor (.8, .8, .8, 1)
+
+ end
+ end
+
+ local OnEditFocusGained = function (textentry)
+ if (textentry.MyObject.OnEditFocusGainedHook) then
+ local interrupt = textentry.MyObject.OnEditFocusGainedHook (textentry)
+ if (interrupt) then
+ return
+ end
+ end
+ textentry.MyObject.label:SetTextColor (1, 1, 1, 1)
+ end
+
+ local OnChar = function (textentry, text)
+ if (textentry.MyObject.OnCharHook) then
+ local interrupt = textentry.MyObject.OnCharHook (textentry, text)
+ if (interrupt) then
+ return
+ end
+ end
+ end
+
+ local OnTextChanged = function (textentry, byUser)
+ if (textentry.MyObject.OnTextChangedHook) then
+ local interrupt = textentry.MyObject.OnTextChangedHook (textentry, byUser)
+ if (interrupt) then
+ return
+ end
+ end
+ end
+
+ local OnTabPressed = function (textentry)
+ if (textentry.MyObject.OnTabPressedHook) then
+ local interrupt = textentry.MyObject.OnTabPressedHook (textentry, byUser)
+ if (interrupt) then
+ return
+ end
+ end
+
+ if (textentry.MyObject.next) then
+ OnEnterPressed (textentry, false)
+ textentry.MyObject.next:SetFocus()
+ end
+ end
+
+ function TextEntryMetaFunctions:PressEnter (byScript)
+ OnEnterPressed (self.editbox, byScript)
+ end
+
+------------------------------------------------------------------------------------------------------------
+--> object constructor
+
+function DF:CreateTextEntry (parent, func, w, h, member, name)
+ return DF:NewTextEntry (parent, parent, name, member, w, h, func)
+end
+
+function DF:NewTextEntry (parent, container, name, member, w, h, func, param1, param2, space)
+
+ if (not name) then
+ name = "DetailsFrameworkTextEntryNumber" .. DF.TextEntryCounter
+ DF.TextEntryCounter = DF.TextEntryCounter + 1
+
+ elseif (not parent) then
+ return nil
+ end
+
+ if (not container) then
+ container = parent
+ end
+
+ if (name:find ("$parent")) then
+ name = name:gsub ("$parent", parent:GetName())
+ end
+
+ local TextEntryObject = {type = "textentry", dframework = true}
+
+ if (member) then
+ parent [member] = TextEntryObject
+ end
+
+ if (parent.dframework) then
+ parent = parent.widget
+ end
+ if (container.dframework) then
+ container = container.widget
+ end
+
+ --> default members:
+ --> hooks
+ TextEntryObject.OnEnterHook = nil
+ TextEntryObject.OnLeaveHook = nil
+ TextEntryObject.OnHideHook = nil
+ TextEntryObject.OnShowHook = nil
+ TextEntryObject.OnEnterPressedHook = nil
+ TextEntryObject.OnEscapePressedHook = nil
+ TextEntryObject.OnEditFocusGainedHook = nil
+ TextEntryObject.OnEditFocusLostHook = nil
+ TextEntryObject.OnCharHook = nil
+ TextEntryObject.OnTextChangedHook = nil
+ TextEntryObject.OnTabPressedHook = nil
+
+ --> misc
+ TextEntryObject.container = container
+ TextEntryObject.have_tooltip = nil
+
+ TextEntryObject.editbox = CreateFrame ("EditBox", name, parent, "DetailsFrameworkEditBoxTemplate2")
+ TextEntryObject.widget = TextEntryObject.editbox
+
+ TextEntryObject.editbox:SetTextInsets (3, 0, 0, -3)
+
+ if (not APITextEntryFunctions) then
+ APITextEntryFunctions = true
+ local idx = getmetatable (TextEntryObject.editbox).__index
+ for funcName, funcAddress in pairs (idx) do
+ if (not TextEntryMetaFunctions [funcName]) then
+ TextEntryMetaFunctions [funcName] = function (object, ...)
+ local x = loadstring ( "return _G."..object.editbox:GetName()..":"..funcName.."(...)")
+ return x (...)
+ end
+ end
+ end
+ end
+
+ TextEntryObject.editbox.MyObject = TextEntryObject
+
+ if (not w and space) then
+ w = space
+ elseif (w and space) then
+ if (DF.debug) then
+ print ("warning: you are using width and space, try use only space for better results.")
+ end
+ end
+
+ TextEntryObject.editbox:SetWidth (w)
+ TextEntryObject.editbox:SetHeight (h)
+
+ TextEntryObject.editbox:SetJustifyH ("center")
+ TextEntryObject.editbox:EnableMouse (true)
+ TextEntryObject.editbox:SetText ("")
+
+ TextEntryObject.editbox:SetAutoFocus (false)
+ TextEntryObject.editbox:SetFontObject ("GameFontHighlightSmall")
+
+ TextEntryObject.editbox.current_bordercolor = {1, 1, 1, 0.7}
+ TextEntryObject.editbox:SetBackdropBorderColor (1, 1, 1, 0.7)
+ TextEntryObject.enabled_border_color = {TextEntryObject.editbox:GetBackdropBorderColor()}
+ TextEntryObject.enabled_backdrop_color = {TextEntryObject.editbox:GetBackdropColor()}
+ TextEntryObject.enabled_text_color = {TextEntryObject.editbox:GetTextColor()}
+
+ TextEntryObject.func = func
+ TextEntryObject.param1 = param1
+ TextEntryObject.param2 = param2
+ TextEntryObject.next = nil
+ TextEntryObject.space = space
+ TextEntryObject.tab_on_enter = false
+
+ TextEntryObject.label = _G [name .. "_Desc"]
+
+ TextEntryObject.editbox:SetBackdrop ({bgFile = DF.folder .. "background", tileSize = 64, edgeFile = DF.folder .. "border_2", edgeSize = 10, insets = {left = 1, right = 1, top = 1, bottom = 1}})
+
+ --> hooks
+ TextEntryObject.editbox:SetScript ("OnEnter", OnEnter)
+ TextEntryObject.editbox:SetScript ("OnLeave", OnLeave)
+ TextEntryObject.editbox:SetScript ("OnHide", OnHide)
+ TextEntryObject.editbox:SetScript ("OnShow", OnShow)
+
+ TextEntryObject.editbox:SetScript ("OnEnterPressed", OnEnterPressed)
+ TextEntryObject.editbox:SetScript ("OnEscapePressed", OnEscapePressed)
+ TextEntryObject.editbox:SetScript ("OnEditFocusLost", OnEditFocusLost)
+ TextEntryObject.editbox:SetScript ("OnEditFocusGained", OnEditFocusGained)
+ TextEntryObject.editbox:SetScript ("OnChar", OnChar)
+ TextEntryObject.editbox:SetScript ("OnTextChanged", OnTextChanged)
+ TextEntryObject.editbox:SetScript ("OnTabPressed", OnTabPressed)
+
+ _setmetatable (TextEntryObject, TextEntryMetaFunctions)
+
+ return TextEntryObject
+
+end
+
+local function_gettext = function (self)
+ return self.editbox:GetText()
+end
+local function_settext = function (self, text)
+ return self.editbox:SetText (text)
+end
+local function_clearfocus = function (self)
+ return self.editbox:ClearFocus()
+end
+local function_setfocus = function (self)
+ return self.editbox:SetFocus (true)
+end
+
+function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent)
+
+ if (name:find ("$parent")) then
+ name = name:gsub ("$parent", parent:GetName())
+ end
+
+ local borderframe = CreateFrame ("Frame", name, parent)
+ borderframe:SetSize (w, h)
+
+ if (member) then
+ parent [member] = borderframe
+ end
+
+ local scrollframe = CreateFrame ("ScrollFrame", name, borderframe, "DetailsFrameworkEditBoxMultiLineTemplate")
+
+ scrollframe:SetScript ("OnSizeChanged", function (self)
+ scrollframe.editbox:SetSize (self:GetSize())
+ end)
+
+ scrollframe:SetPoint ("topleft", borderframe, "topleft", 10, -10)
+ scrollframe:SetPoint ("bottomright", borderframe, "bottomright", -30, 10)
+
+ scrollframe.editbox:SetMultiLine (true)
+ scrollframe.editbox:SetJustifyH ("left")
+ scrollframe.editbox:SetJustifyV ("top")
+ scrollframe.editbox:SetMaxBytes (1024000)
+ scrollframe.editbox:SetMaxLetters (128000)
+
+ borderframe.GetText = function_gettext
+ borderframe.SetText = function_settext
+ borderframe.ClearFocus = function_clearfocus
+ borderframe.SetFocus = function_setfocus
+
+ if (not nointent) then
+ IndentationLib.enable (scrollframe.editbox, nil, 4)
+ end
+
+ borderframe:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
+ tile = 1, tileSize = 16, edgeSize = 16, insets = {left = 5, right = 5, top = 5, bottom = 5}})
+ borderframe:SetBackdropColor (0.090195, 0.090195, 0.188234, 1)
+ borderframe:SetBackdropBorderColor (1, 1, 1, 1)
+
+ borderframe.scroll = scrollframe
+ borderframe.editbox = scrollframe.editbox
+
+ return borderframe
+end
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/textentry.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/textentry.xml Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/DF/tutorial_alert.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DF/tutorial_alert.xml Mon Apr 20 16:34:18 2015 -0300
@@ -0,0 +1,247 @@
+
+
+
+
+
+
+
+
+ self:SetHorizontalScroll(-28.5);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ self:GetParent():Hide();
+
+
+ self:GetParent():Hide();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ self:GetParent():Hide();
+
+
+ self:GetParent():Hide();
+ --if (self:GetParent():GetParent():GetParent().type=="COMPLETED") then
+ --self:GetParent():GetParent().Flash:Show();
+ --end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ self.IconFlash:SetVertexColor(1, 0, 0);
+
+
+ UIFrameFlash(self, 0.75, 0.75, -1, nil);
+
+
+ UIFrameFlashStop(self);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r f1e32be6773e -r 2f09fe4be15c Libs/libs.xml
--- a/Libs/libs.xml Mon Apr 06 19:41:32 2015 -0300
+++ b/Libs/libs.xml Mon Apr 20 16:34:18 2015 -0300
@@ -3,4 +3,6 @@
+
+
\ No newline at end of file