Mercurial > wow > reaction
comparison Bar.lua @ 63:768be7eb22a0
Converted several ReAction APIs to event-driven model instead of 'call-method-on-all-modules' model. Cleaned up a number of other architectural issues.
| author | Flick <flickerstreak@gmail.com> |
|---|---|
| date | Thu, 22 May 2008 22:02:08 +0000 |
| parents | 20003239af0b |
| children | fcb5dad031f9 |
comparison
equal
deleted
inserted
replaced
| 62:f9cdb920470a | 63:768be7eb22a0 |
|---|---|
| 32 config.width = config.width or 480 | 32 config.width = config.width or 480 |
| 33 config.height = config.height or 40 | 33 config.height = config.height or 40 |
| 34 f:SetWidth(config.width) | 34 f:SetWidth(config.width) |
| 35 f:SetWidth(config.height) | 35 f:SetWidth(config.height) |
| 36 | 36 |
| 37 ReAction.RegisterCallback(self, "OnConfigModeChanged") | |
| 38 | |
| 37 self.frame = f | 39 self.frame = f |
| 38 self:RefreshLayout() | 40 self:RefreshLayout() |
| 39 self:ApplyAnchor() | 41 self:ApplyAnchor() |
| 40 f:Show() | 42 f:Show() |
| 41 end | 43 end |
| 44 local f = self.frame | 46 local f = self.frame |
| 45 f:UnregisterAllEvents() | 47 f:UnregisterAllEvents() |
| 46 f:Hide() | 48 f:Hide() |
| 47 f:SetParent(UIParent) | 49 f:SetParent(UIParent) |
| 48 f:ClearAllPoints() | 50 f:ClearAllPoints() |
| 51 ReAction.UnregisterAllCallbacks(self) | |
| 49 self.labelString = nil | 52 self.labelString = nil |
| 50 self.controlFrame = nil | 53 self.controlFrame = nil |
| 51 self.frame = nil | 54 self.frame = nil |
| 52 self.config = nil | 55 self.config = nil |
| 53 end | 56 end |
| 54 | 57 |
| 58 function Bar:OnConfigModeChanged(event, mode) | |
| 59 self:ShowControls(mode) | |
| 60 end | |
| 61 | |
| 55 function Bar:RefreshLayout() | 62 function Bar:RefreshLayout() |
| 56 ReAction:CallMethodOnAllModules("RefreshBar", self) | 63 ReAction:RefreshBar(self) |
| 57 end | 64 end |
| 58 | 65 |
| 59 function Bar:ApplyAnchor() | 66 function Bar:ApplyAnchor() |
| 60 local f, config = self.frame, self.config | 67 local f, config = self.frame, self.config |
| 61 f:SetWidth(config.width) | 68 f:SetWidth(config.width) |
| 184 local function StoreExtents(bar) | 191 local function StoreExtents(bar) |
| 185 local f = bar.frame | 192 local f = bar.frame |
| 186 local point, relativeTo, relativePoint, x, y = f:GetPoint(1) | 193 local point, relativeTo, relativePoint, x, y = f:GetPoint(1) |
| 187 relativeTo = relativeTo or f:GetParent() | 194 relativeTo = relativeTo or f:GetParent() |
| 188 local anchorTo | 195 local anchorTo |
| 189 for name, b in pairs(ReAction.bars) do | 196 for name, b in ReAction:IterateBars() do |
| 190 if b and b:GetFrame() == relativeTo then | 197 if b and b:GetFrame() == relativeTo then |
| 191 anchorTo = name | 198 anchorTo = name |
| 192 break | 199 break |
| 193 end | 200 end |
| 194 end | 201 end |
| 399 end | 406 end |
| 400 | 407 |
| 401 local function GetClosestVisibleEdge( f ) | 408 local function GetClosestVisibleEdge( f ) |
| 402 local r, o, e1, e2 | 409 local r, o, e1, e2 |
| 403 local a = anchorOutside | 410 local a = anchorOutside |
| 404 for _, b in pairs(ReAction.bars) do | 411 for _, b in ReAction:IterateBars() do |
| 405 local d, e, opp = GetClosestFrameEdge(f,b:GetFrame(),a) | 412 local d, e, opp = GetClosestFrameEdge(f,b:GetFrame(),a) |
| 406 if d and (not r or d < r) then | 413 if d and (not r or d < r) then |
| 407 r, o, e1, e2 = d, b:GetFrame(), e, opp | 414 r, o, e1, e2 = d, b:GetFrame(), e, opp |
| 408 end | 415 end |
| 409 end | 416 end |
| 521 si1:Hide() | 528 si1:Hide() |
| 522 si2:Hide() | 529 si2:Hide() |
| 523 end | 530 end |
| 524 end | 531 end |
| 525 | 532 |
| 526 local function RefreshBarEditor() | |
| 527 ReAction:CallModuleMethod("ConfigUI","RefreshBarEditor") | |
| 528 end | |
| 529 | |
| 530 CreateControls = function(bar) | 533 CreateControls = function(bar) |
| 531 local f = bar.frame | 534 local f = bar.frame |
| 532 | 535 |
| 533 f:SetMovable(true) | 536 f:SetMovable(true) |
| 534 f:SetResizable(true) | 537 f:SetResizable(true) |
| 582 f.isMoving = false | 585 f.isMoving = false |
| 583 f:SetScript("OnUpdate",nil) | 586 f:SetScript("OnUpdate",nil) |
| 584 StoreSize(bar) | 587 StoreSize(bar) |
| 585 ClampToButtons(bar) | 588 ClampToButtons(bar) |
| 586 ApplyAnchor(bar) | 589 ApplyAnchor(bar) |
| 587 RefreshBarEditor() | 590 ReAction:RefreshOptions() |
| 588 end | 591 end |
| 589 | 592 |
| 590 -- edge drag handles | 593 -- edge drag handles |
| 591 for _, point in pairs({"LEFT","TOP","RIGHT","BOTTOM"}) do | 594 for _, point in pairs({"LEFT","TOP","RIGHT","BOTTOM"}) do |
| 592 local edge = CreateFrame("Frame",nil,control) | 595 local edge = CreateFrame("Frame",nil,control) |
| 749 end | 752 end |
| 750 HideSnapIndicator() | 753 HideSnapIndicator() |
| 751 end | 754 end |
| 752 | 755 |
| 753 StoreExtents(bar) | 756 StoreExtents(bar) |
| 754 RefreshBarEditor() | 757 ReAction:RefreshOptions() |
| 755 updateDragTooltip() | 758 updateDragTooltip() |
| 756 end | 759 end |
| 757 ) | 760 ) |
| 758 | 761 |
| 759 control:SetScript("OnEnter", | 762 control:SetScript("OnEnter", |
| 760 function() | 763 function() |
| 761 -- add bar type and status information to name | 764 -- TODO: add bar type and status information to name |
| 765 --[[ | |
| 762 local name = bar.name | 766 local name = bar.name |
| 763 for _, m in ReAction:IterateModules() do | 767 for _, m in ReAction:IterateModules() do |
| 764 --[[ | |
| 765 local suffix = safecall(m,"GetBarNameModifier",bar) | 768 local suffix = safecall(m,"GetBarNameModifier",bar) |
| 766 if suffix then | 769 if suffix then |
| 767 name = ("%s %s"):format(name,suffix) | 770 name = ("%s %s"):format(name,suffix) |
| 768 end | 771 end |
| 769 --]] | 772 end |
| 770 end | 773 ]]-- |
| 771 | 774 |
| 772 updateDragTooltip() | 775 updateDragTooltip() |
| 773 end | 776 end |
| 774 ) | 777 ) |
| 775 | 778 |
| 823 args = { | 826 args = { |
| 824 openConfig = { | 827 openConfig = { |
| 825 type = "execute", | 828 type = "execute", |
| 826 name = L["Settings..."], | 829 name = L["Settings..."], |
| 827 desc = L["Open the editor for this bar"], | 830 desc = L["Open the editor for this bar"], |
| 828 func = function() CloseMenu(self.controlFrame); ReAction:CallModuleMethod("ConfigUI","LaunchBarEditor",self) end, | 831 func = function() CloseMenu(self.controlFrame); ReAction:ShowEditor(self) end, |
| 829 disabled = InCombatLockdown, | 832 disabled = InCombatLockdown, |
| 830 order = 1 | 833 order = 1 |
| 831 }, | 834 }, |
| 832 delete = { | 835 delete = { |
| 833 type = "execute", | 836 type = "execute", |
