Mercurial > wow > reaction
comparison classes/Overlay.lua @ 155:806a61b331a0
Pushed the state implementation into Bar
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Fri, 15 May 2009 22:38:19 +0000 |
parents | df67685b340e |
children | 8cc187143acd |
comparison
equal
deleted
inserted
replaced
154:df67685b340e | 155:806a61b331a0 |
---|---|
25 | 25 |
26 -- | 26 -- |
27 -- Wrap some of the bar manipulators to make them state-aware | 27 -- Wrap some of the bar manipulators to make them state-aware |
28 -- | 28 -- |
29 local function SetAnchor( bar, point, frame, relPoint, x, y ) | 29 local function SetAnchor( bar, point, frame, relPoint, x, y ) |
30 local state = bar:GetState() | 30 local state = bar:GetSecureState() |
31 if state then | 31 if state then |
32 local anchorstate = bar:GetStateProperty(state, "anchorEnable") | 32 local anchorstate = bar:GetStateProperty(state, "anchorEnable") |
33 if anchorstate then | 33 if anchorstate then |
34 bar:SetStateProperty(state, "anchorFrame", frame) | 34 bar:SetStateProperty(state, "anchorFrame", frame) |
35 bar:SetStateProperty(state, "anchorPoint", point) | 35 bar:SetStateProperty(state, "anchorPoint", point) |
42 end | 42 end |
43 bar:SetAnchor(point, frame, relPoint, x, y) | 43 bar:SetAnchor(point, frame, relPoint, x, y) |
44 end | 44 end |
45 | 45 |
46 local function GetStateScale( bar ) | 46 local function GetStateScale( bar ) |
47 local state = bar:GetState() | 47 local state = bar:GetSecureState() |
48 if state and bar:GetStateProperty(state, "enableScale") then | 48 if state and bar:GetStateProperty(state, "enableScale") then |
49 return bar:GetStateProperty(state, "scale") | 49 return bar:GetStateProperty(state, "scale") |
50 end | 50 end |
51 end | 51 end |
52 | 52 |
53 local function SetStateScale( bar, scale ) | 53 local function SetStateScale( bar, scale ) |
54 local state = bar:GetState() | 54 local state = bar:GetSecureState() |
55 if state and bar:GetStateProperty(state, "enableScale") then | 55 if state and bar:GetStateProperty(state, "enableScale") then |
56 bar:SetStateProperty(state, "scale", scale) | 56 bar:SetStateProperty(state, "scale", scale) |
57 end | 57 end |
58 end | 58 end |
59 | 59 |
555 RecomputeGrid(bar) | 555 RecomputeGrid(bar) |
556 end | 556 end |
557 GameTooltipTextRight2:SetText(format("%d x %d",r,c)) | 557 GameTooltipTextRight2:SetText(format("%d x %d",r,c)) |
558 | 558 |
559 local ss = GetStateScale(bar) | 559 local ss = GetStateScale(bar) |
560 local state = bar:GetState() | |
561 if ss then | 560 if ss then |
562 GameTooltipTextRight4:SetText(format("%d%%", scale*100)) | 561 GameTooltipTextRight4:SetText(format("%d%%", scale*100)) |
563 else | 562 else |
564 local size = (bw == bh) and tostring(bw) or format("%d x %d",bw,bh) | 563 local size = (bw == bh) and tostring(bw) or format("%d x %d",bw,bh) |
565 GameTooltipTextRight3:SetText(size) | 564 GameTooltipTextRight3:SetText(size) |
590 ) | 589 ) |
591 corner:SetScript("OnMouseUp", | 590 corner:SetScript("OnMouseUp", |
592 function() | 591 function() |
593 local ss = GetStateScale(bar) | 592 local ss = GetStateScale(bar) |
594 if ss then | 593 if ss then |
595 local state = bar:GetState() | |
596 SetStateScale(bar, ComputeBarScale(bar, overlay)) | 594 SetStateScale(bar, ComputeBarScale(bar, overlay)) |
597 end | 595 end |
598 StopResize() | 596 StopResize() |
599 end) | 597 end) |
600 corner:SetScript("OnEnter", | 598 corner:SetScript("OnEnter", |
601 function() | 599 function() |
602 local bw, bh = GetButtonSize(bar) | 600 local bw, bh = GetButtonSize(bar) |
603 local r, c, s = bar:GetButtonGrid() | 601 local r, c, s = bar:GetButtonGrid() |
604 local size = (bw == bh) and tostring(bw) or format("%d x %d",bw,bh) | 602 local size = (bw == bh) and tostring(bw) or format("%d x %d",bw,bh) |
605 local ss = GetStateScale(bar) | 603 local ss = GetStateScale(bar) |
606 local state = bar:GetState() | 604 local state = bar:GetSecureState() |
607 GameTooltip:SetOwner(f, "ANCHOR_"..point) | 605 GameTooltip:SetOwner(f, "ANCHOR_"..point) |
608 if ss then | 606 if ss then |
609 GameTooltip:AddLine(format("%s (%s: %s)", bar:GetName(), L["State"], state)) | 607 GameTooltip:AddLine(format("%s (%s: %s)", bar:GetName(), L["State"], state)) |
610 else | 608 else |
611 GameTooltip:AddLine(bar:GetName()) | 609 GameTooltip:AddLine(bar:GetName()) |
650 ) | 648 ) |
651 | 649 |
652 local function UpdateDragTooltip() | 650 local function UpdateDragTooltip() |
653 GameTooltip:SetOwner(f, "ANCHOR_TOPRIGHT") | 651 GameTooltip:SetOwner(f, "ANCHOR_TOPRIGHT") |
654 local ss = GetStateScale(bar) | 652 local ss = GetStateScale(bar) |
655 local state = bar:GetState() | 653 local state = bar:GetSecureState() |
656 if ss then | 654 if ss then |
657 GameTooltip:AddLine(format("%s (%s: %s)", bar:GetName(), L["State"], state)) | 655 GameTooltip:AddLine(format("%s (%s: %s)", bar:GetName(), L["State"], state)) |
658 else | 656 else |
659 GameTooltip:AddLine(bar:GetName()) | 657 GameTooltip:AddLine(bar:GetName()) |
660 end | 658 end |
758 end | 756 end |
759 | 757 |
760 function Bar.Overlay:Hide() | 758 function Bar.Overlay:Hide() |
761 self.frame:Hide() | 759 self.frame:Hide() |
762 end | 760 end |
761 | |
762 function Bar.Overlay:IsShown() | |
763 return self.frame:IsShown() | |
764 end | |
765 | |
766 function Bar.Overlay:RefreshControls() | |
767 self.frame:RefreshControls() | |
768 end |