diff Libs/DF/cooltip.lua @ 20:dc1c77254f80

- added close button to users panel. - framework update.
author Tercio
date Tue, 11 Aug 2015 12:46:46 -0300
parents 2f09fe4be15c
children e16b1fc13935
line wrap: on
line diff
--- a/Libs/DF/cooltip.lua	Sat Jul 18 17:32:30 2015 -0300
+++ b/Libs/DF/cooltip.lua	Tue Aug 11 12:46:46 2015 -0300
@@ -1,7 +1,10 @@
 
 local DF = _G ["DetailsFramework"]
+if (not DF or not DetailsFrameworkCanLoad) then
+	return 
+end
+
 local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
-
 local _
 --lua locals
 local _math_floor= math.floor
@@ -19,7 +22,7 @@
 local _UIParent = UIParent
 local _CreateFrame = CreateFrame
 
-local version = 1
+local version = 2
 
 function DF:CreateCoolTip()
 
@@ -51,6 +54,8 @@
 		CoolTip.WallpaperTable = {}
 		CoolTip.WallpaperTableSub = {}
 		
+		CoolTip.PopupFrameTable = {}
+		
 		CoolTip.FunctionsTableMain = {} --> menus
 		CoolTip.FunctionsTableSub = {} --> menus
 		CoolTip.ParametersTableMain = {} --> menus
@@ -254,6 +259,7 @@
 			if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then --> menu
 				CoolTip.active = true
 				CoolTip.mouseOver = true
+				CoolTip.had_interaction = true
 				self:SetScript ("OnUpdate", nil)
 				DF:Fade (self, 0)
 				--rever
@@ -270,6 +276,7 @@
 			if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
 				CoolTip.active = true
 				CoolTip.mouseOver = true
+				CoolTip.had_interaction = true
 				self:SetScript ("OnUpdate", nil)
 				DF:Fade (self, 0)
 				DF:Fade (frame1, 0)
@@ -398,6 +405,7 @@
 							if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then
 								CoolTip.active = true
 								CoolTip.mouseOver = true
+								CoolTip.had_interaction = true
 
 								frame1:SetScript ("OnUpdate", nil)
 								frame2:SetScript ("OnUpdate", nil)
@@ -410,7 +418,13 @@
 									botao.leftIcon:SetBlendMode ("BLEND")
 								end
 
-								if (CoolTip.IndexesSub [botao.index] and CoolTip.IndexesSub [botao.index] > 0) then
+								if (CoolTip.PopupFrameTable [botao.index]) then
+									local on_enter, on_leave, param1, param2 = unpack (CoolTip.PopupFrameTable [botao.index])
+									if (on_enter) then
+										xpcall (on_enter, geterrorhandler(), frame1, param1, param2)
+									end
+								
+								elseif (CoolTip.IndexesSub [botao.index] and CoolTip.IndexesSub [botao.index] > 0) then
 									if (CoolTip.OptionsTable.SubMenuIsTooltip) then
 										CoolTip:ShowSub (botao.index)
 										botao.index = i
@@ -432,6 +446,7 @@
 								end
 							else
 								CoolTip.mouseOver = true
+								CoolTip.had_interaction = true
 							end
 						end)
 						
@@ -451,6 +466,13 @@
 									botao.rightIcon:SetBlendMode ("BLEND")
 								end
 								
+								if (CoolTip.PopupFrameTable [botao.index]) then
+									local on_enter, on_leave, param1, param2 = unpack (CoolTip.PopupFrameTable [botao.index])
+									if (on_leave) then
+										xpcall (on_leave, geterrorhandler(), frame1, param1, param2)
+									end
+								end
+								
 								elapsedTime = 0
 								frame1:SetScript ("OnUpdate", OnLeaveUpdateButton)
 								--CoolTip:HideSub (i)
@@ -489,6 +511,7 @@
 							if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then
 								CoolTip.active = true
 								CoolTip.mouseOver = true
+								CoolTip.had_interaction = true
 								
 								botao.background:Show()
 								
@@ -505,6 +528,7 @@
 								DF:Fade (frame2, 0)
 							else
 								CoolTip.mouseOver = true
+								CoolTip.had_interaction = true
 							end
 						end)
 
@@ -1956,6 +1980,8 @@
 			frame2:SetBackdropBorderColor (unpack (default_backdropborder_color))
 
 			--[
+			_table_wipe (CoolTip.PopupFrameTable)
+			
 			_table_wipe (CoolTip.LeftTextTable)
 			_table_wipe (CoolTip.LeftTextTableSub)
 			_table_wipe (CoolTip.RightTextTable)
@@ -2530,6 +2556,17 @@
 		end
 	
 ----------------------------------------------------------------------
+	--> popup frame
+		function CoolTip:AddPopUpFrame (func_on_show, func_on_hide, param1, param2)
+			
+			-- act like a sub menu
+			if (CoolTip.Indexes > 0) then
+				CoolTip.PopupFrameTable [CoolTip.Indexes] = {func_on_show or false, func_on_hide or false, param1, param2}
+			end
+			
+		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]]] 
@@ -2780,11 +2817,14 @@
 	
 		--> serach key: ~start
 		function CoolTip:Show (frame, menuType, color)
+			CoolTip.had_interaction = false
 			return CoolTip:ShowCooltip (frame, menuType, color)
 		end
 		
 		function CoolTip:ShowCooltip (frame, menuType, color)
 
+			CoolTip.had_interaction = false
+		
 			if (frame) then
 				--> details framework
 				if (frame.dframework) then