Moved intersect checkers to the widget libraries.
Scott Sibley [09-18-10 - 00:44]
Moved intersect checkers to the widget libraries.
diff --git a/Modules/Bars.lua b/Modules/Bars.lua
index a71c6dd..2cdf0d5 100644
--- a/Modules/Bars.lua
+++ b/Modules/Bars.lua
@@ -146,24 +146,10 @@ local optionsDefaults = {
local intersectTimer
local intersectUpdate = function()
- local frame = GetMouseFocus()
- if frame and frame ~= UIParent and frame ~= WorldFrame then
- for k, widget in pairs(mod.bars or {}) do
- if widget.config.intersect then
- if environment.Intersect(frame, widget.bar, widget.config.intersectxPad1 or widget.config.intersectPad or 0, widget.config.intersectyPad1 or widget.config.intersectPad or 0, widget.config.intersectxPad2 or widget.config.intersectPad or 0, widget.config.intersectyPad2 or widget.config.intersectPad or 0) then
- widget.hidden = true
- bar:Hide()
- widget:Stop()
- elseif not environment.Intersect(frame, widget.bar, widget.config.intersectxPad1 or widget.config.intersectPad or 0, widget.config.intersectyPad1 or widget.config.intersectPad or 0, widget.config.intersectxPad2 or widget.config.intersectPad or 0, widget.config.intersectyPad2 or widget.config.intersectPad or 0) and widget.hidden then
- widget.hidden = false
- bar:Show()
- widget:Start()
- end
- end
- end
- end
+ WidgetBar.IntersectUpdate(mod.bars)
end
+
function updateBar(widget, bar)
bar:SetValue(widget.val1 * 100)
@@ -262,6 +248,7 @@ local function createBars()
widget.bar1 = true
widget.bar = bar
mod.bars[v] = widget
+ v.bar = bar
if v.expression2 then
bar = new()
diff --git a/Modules/Histograms.lua b/Modules/Histograms.lua
index 5b7c829..a66e809 100644
--- a/Modules/Histograms.lua
+++ b/Modules/Histograms.lua
@@ -200,25 +200,9 @@ local optionsDefaults = {
},
}
-local insersectTimer
+local intersectTimer
local intersectUpdate = function()
- local frame = GetMouseFocus()
- if frame and frame ~= UIParent and frame ~= WorldFrame then
- for k, widget in pairs(mod.histograms) do
- for i, bar in ipairs(widget.bars or {}) do
- if widget.config.intersect then
- if environment.Intersect(bar, frame, widget.config.intersectxPad1 or widget.config.itnersectPad or 0, widget.config.intersectyPad1 or widget.config.intersectPad or 0, widget.config.intersectxPad2 or widget.config.intersectPad or 0, widget.config.intersectyPad2 or widget.config.intersectPad or 0) then
- widget.hidden = true
- bar:Hide()
- widget.frame:Hide()
- elseif not environment.Intersect(bar, frame, widget.config.intersectxPad1 or widget.config.itnersectPad or 0, widget.config.intersectyPad1 or widget.config.intersectPad or 0, widget.config.intersectxPad2 or widget.config.intersectPad or 0, widget.config.intersectyPad2 or widget.config.intersectPad or 0) and widget.hidden then
- widget.hidden = false
- bar:Show()
- end
- end
- end
- end
- end
+ WidgetHistogram.IntersectUpdate(mod.histograms)
end
function updateHistogram(widget)
diff --git a/Modules/Text.lua b/Modules/Text.lua
index 84d693a..d2bd2be 100644
--- a/Modules/Text.lua
+++ b/Modules/Text.lua
@@ -19,6 +19,7 @@ local LibCore = LibStub("StarLibCore-1.0")
local LibQTip = LibStub("LibQTip-1.0")
local PluginUtils = LibStub("StarLibPluginUtils-1.0")
local LibTimer = LibStub("StarLibTimer-1.0")
+local Widget = LibStub("StarLibWidget-1.0")
local environment = {}
@@ -277,20 +278,7 @@ local optionsDefaults = {
local intersectTimer
local intersectUpdate = function()
- local frame = GetMouseFocus()
- if frame and frame ~= UIParent and frame ~= WorldFrame then
- for k, widget in pairs(mod.texts) do
- if widget.config.intersect then
- if environment.Intersect(frame, widget.frame, widget.config.intersectxPad1 or widget.config.intersectPad or 0, widget.config.intersectyPad1 or widget.config.intersectPad or 0, widget.config.intersectxPad2 or widget.config.intersectPad or 0, widget.config.intersectyPad2 or widget.config.intersectPad or 0) then
- widget.hidden = true
- widget.frame:Hide()
- elseif not environment.Intersect(frame, widget.frame, widget.config.intersectxPad1 or widget.config.intersectPad or 0, widget.config.intersectyPad1 or widget.config.intersectPad or 0, widget.config.intersectxPad2 or widget.config.intersectPad or 0, widget.config.intersectyPad2 or widget.config.intersectPad or 0) and widget.hidden then
- widget.hidden = false
- widget.frame:Show()
- end
- end
- end
- end
+ WidgetText.IntersectUpdate(mod.texts)
end
function updateText(widget)