comparison Libs/DF/panel.lua @ 19:215f0dd37a6c

library update.
author Tercio
date Sat, 18 Jul 2015 17:32:30 -0300
parents 680465749fc7
children dc1c77254f80
comparison
equal deleted inserted replaced
18:680465749fc7 19:215f0dd37a6c
1328 local db = self.db 1328 local db = self.db
1329 if (db) then 1329 if (db) then
1330 db.IsLocked = db.IsLocked or false 1330 db.IsLocked = db.IsLocked or false
1331 self.IsLocked = db.IsLocked 1331 self.IsLocked = db.IsLocked
1332 db.position = db.position or {x = 0, y = 0} 1332 db.position = db.position or {x = 0, y = 0}
1333 db.position.x = db.position.x or 0
1334 db.position.y = db.position.y or 0
1333 DF:RestoreFramePosition (self) 1335 DF:RestoreFramePosition (self)
1334 end 1336 end
1335 end 1337 end
1336 1338
1337 function DF:SavePositionOnScreen (frame) 1339 function DF:SavePositionOnScreen (frame)
1338 if (frame.db and frame.db.position) then 1340 if (frame.db and frame.db.position) then
1339 local x, y = DF:GetPositionOnScreen (frame) 1341 local x, y = DF:GetPositionOnScreen (frame)
1340 --print ("saving...", x, y, frame:GetName()) 1342 --print ("saving...", x, y, frame:GetName())
1341 frame.db.position.x, frame.db.position.y = x, y 1343 if (x and y) then
1344 frame.db.position.x, frame.db.position.y = x, y
1345 end
1342 end 1346 end
1343 end 1347 end
1344 1348
1345 function DF:GetPositionOnScreen (frame) 1349 function DF:GetPositionOnScreen (frame)
1346 local xOfs, yOfs = frame:GetCenter() 1350 local xOfs, yOfs = frame:GetCenter()
1356 1360
1357 function DF:RestoreFramePosition (frame) 1361 function DF:RestoreFramePosition (frame)
1358 if (frame.db and frame.db.position) then 1362 if (frame.db and frame.db.position) then
1359 local scale, UIscale = frame:GetEffectiveScale(), UIParent:GetScale() 1363 local scale, UIscale = frame:GetEffectiveScale(), UIParent:GetScale()
1360 frame:ClearAllPoints() 1364 frame:ClearAllPoints()
1365 frame.db.position.x = frame.db.position.x or 0
1366 frame.db.position.y = frame.db.position.y or 0
1361 frame:SetPoint ("center", UIParent, "center", frame.db.position.x * UIscale / scale, frame.db.position.y * UIscale / scale) 1367 frame:SetPoint ("center", UIParent, "center", frame.db.position.x * UIscale / scale, frame.db.position.y * UIscale / scale)
1362 end 1368 end
1363 end 1369 end
1364 1370
1365 local Panel1PxHasPosition = function (self) 1371 local Panel1PxHasPosition = function (self)