Mercurial > wow > reaction
comparison classes/Overlay.lua @ 154:df67685b340e
Fixed some bar/overlay encapsulation
| author | Flick <flickerstreak@gmail.com> |
|---|---|
| date | Fri, 08 May 2009 17:30:22 +0000 |
| parents | 5c0591a31163 |
| children | 806a61b331a0 |
comparison
equal
deleted
inserted
replaced
| 153:d5e11e924053 | 154:df67685b340e |
|---|---|
| 101 local scale = min(scaleW, scaleH) | 101 local scale = min(scaleW, scaleH) |
| 102 | 102 |
| 103 SetButtonSize(bar, scale * bw, scale * bh, s) | 103 SetButtonSize(bar, scale * bw, scale * bh, s) |
| 104 end | 104 end |
| 105 | 105 |
| 106 local function ComputeBarScale(bar) | 106 local function ComputeBarScale(bar, overlay) |
| 107 local w, h = bar.controlFrame:GetWidth() - 8, bar.controlFrame:GetHeight() - 8 | 107 local w, h = overlay:GetWidth() - 8, overlay:GetHeight() - 8 |
| 108 local bw, bh = GetButtonSize(bar) | 108 local bw, bh = GetButtonSize(bar) |
| 109 local r, c, s = GetButtonGrid(bar) | 109 local r, c, s = GetButtonGrid(bar) |
| 110 | 110 |
| 111 local scaleW = w / (c*(bw+s)) | 111 local scaleW = w / (c*(bw+s)) |
| 112 local scaleH = h / (r*(bh+s)) | 112 local scaleH = h / (r*(bh+s)) |
| 441 si1:Hide() | 441 si1:Hide() |
| 442 si2:Hide() | 442 si2:Hide() |
| 443 end | 443 end |
| 444 end | 444 end |
| 445 | 445 |
| 446 local function UpdateLabelString(bar) | 446 local function UpdateLabelString(overlay) |
| 447 local label = bar.controlLabelString | 447 local label = overlay.labelString |
| 448 if label then | 448 if label then |
| 449 local name = bar.labelName | 449 local name = overlay.labelName |
| 450 if name and bar.labelSubtext then | 450 if name and overlay.labelSubtext then |
| 451 name = format("%s (%s)", name, bar.labelSubtext) | 451 name = format("%s (%s)", name, overlay.labelSubtext) |
| 452 end | 452 end |
| 453 label:SetText(name or "") | 453 label:SetText(name or "") |
| 454 end | 454 end |
| 455 end | 455 end |
| 456 | 456 |
| 497 label:SetShadowColor(0,0,0,1) | 497 label:SetShadowColor(0,0,0,1) |
| 498 label:SetShadowOffset(3,-3) | 498 label:SetShadowOffset(3,-3) |
| 499 label:SetTextColor(GetNormalTextColor()) | 499 label:SetTextColor(GetNormalTextColor()) |
| 500 label:SetText(bar:GetName()) | 500 label:SetText(bar:GetName()) |
| 501 label:Show() | 501 label:Show() |
| 502 bar.controlLabelString = label -- so that bar:SetLabel() can update it | 502 overlay.labelString = label |
| 503 overlay.labelName = bar:GetName() | |
| 503 | 504 |
| 504 local function UpdateAnchorDecoration() | 505 local function UpdateAnchorDecoration() |
| 505 local point, anchor, relPoint, x, y = f:GetPoint(1) | 506 local point, anchor, relPoint, x, y = f:GetPoint(1) |
| 506 if point then | 507 if point then |
| 507 local ofsx, ofsy = insidePointOffsetFuncs[point](x,y) | 508 local ofsx, ofsy = insidePointOffsetFuncs[point](x,y) |
| 536 local ss = GetStateScale(bar) | 537 local ss = GetStateScale(bar) |
| 537 if IsShiftKeyDown() then | 538 if IsShiftKeyDown() then |
| 538 if ss then | 539 if ss then |
| 539 f:SetMinResize( ((s+bw)*c*0.25)/ss, ((s+bh)*r*0.25)/ss ) | 540 f:SetMinResize( ((s+bw)*c*0.25)/ss, ((s+bh)*r*0.25)/ss ) |
| 540 f:SetMaxResize( ((s+bw)*c*2.5 + 1)/ss, ((s+bh)*r*2.5 + 1)/ss ) | 541 f:SetMaxResize( ((s+bw)*c*2.5 + 1)/ss, ((s+bh)*r*2.5 + 1)/ss ) |
| 541 scale = ComputeBarScale(bar) | 542 scale = ComputeBarScale(bar, overlay) |
| 542 else | 543 else |
| 543 f:SetMinResize( (s+12)*c+1, (s+12)*r+1 ) | 544 f:SetMinResize( (s+12)*c+1, (s+12)*r+1 ) |
| 544 f:SetMaxResize( (s+128)*c+1, (s+128)*r+1 ) | 545 f:SetMaxResize( (s+128)*c+1, (s+128)*r+1 ) |
| 545 RecomputeButtonSize(bar) | 546 RecomputeButtonSize(bar) |
| 546 end | 547 end |
| 590 corner:SetScript("OnMouseUp", | 591 corner:SetScript("OnMouseUp", |
| 591 function() | 592 function() |
| 592 local ss = GetStateScale(bar) | 593 local ss = GetStateScale(bar) |
| 593 if ss then | 594 if ss then |
| 594 local state = bar:GetState() | 595 local state = bar:GetState() |
| 595 SetStateScale(bar, ComputeBarScale(bar)) | 596 SetStateScale(bar, ComputeBarScale(bar, overlay)) |
| 596 end | 597 end |
| 597 StopResize() | 598 StopResize() |
| 598 end) | 599 end) |
| 599 corner:SetScript("OnEnter", | 600 corner:SetScript("OnEnter", |
| 600 function() | 601 function() |
| 727 | 728 |
| 728 if ReAction:GetKeybindMode() then | 729 if ReAction:GetKeybindMode() then |
| 729 overlay:SetFrameLevel(1) | 730 overlay:SetFrameLevel(1) |
| 730 end | 731 end |
| 731 | 732 |
| 732 bar:SetLabel(bar:GetName()) | 733 UpdateLabelString(overlay) |
| 733 UpdateLabelString(bar) | |
| 734 UpdateAnchorDecoration() | 734 UpdateAnchorDecoration() |
| 735 | 735 |
| 736 return overlay | 736 return overlay |
| 737 end | 737 end |
| 738 | 738 |
| 739 | 739 |
| 740 -- export methods to the Bar prototype | 740 -- export methods to the Bar prototype |
| 741 | 741 Bar.Overlay = { } |
| 742 function Bar:ShowControls(show) | 742 function Bar.Overlay:New( bar ) |
| 743 local f = self.controlFrame | 743 return setmetatable( {frame = CreateControls(bar)}, {__index=self} ) |
| 744 if show then | 744 end |
| 745 if not f then | 745 |
| 746 f = CreateControls(self) | 746 function Bar.Overlay:SetLabel(name) |
| 747 self.controlFrame = f | 747 self.frame.labelName = name |
| 748 end | 748 UpdateLabelString(self.frame) |
| 749 f:Show() | 749 end |
| 750 elseif f then | 750 |
| 751 f:Hide() | 751 function Bar.Overlay:SetLabelSubtext(text) |
| 752 end | 752 self.frame.labelSubtext = text |
| 753 end | 753 UpdateLabelString(self.frame) |
| 754 | 754 end |
| 755 function Bar:RefreshControls() | 755 |
| 756 if self.controlFrame and self.controlFrame:IsShown() then | 756 function Bar.Overlay:Show() |
| 757 self.controlFrame:RefreshControls() | 757 self.frame:Show() |
| 758 end | 758 end |
| 759 end | 759 |
| 760 | 760 function Bar.Overlay:Hide() |
| 761 function Bar:SetLabel(name) | 761 self.frame:Hide() |
| 762 self.labelName = name | 762 end |
| 763 UpdateLabelString(self) | |
| 764 end | |
| 765 | |
| 766 function Bar:SetLabelSubtext(text) | |
| 767 self.labelSubtext = text | |
| 768 UpdateLabelString(self) | |
| 769 end |
