Mercurial > wow > reaction
comparison Overlay.lua @ 92:5f1d7a81317c
- Various bugfixes
- Switched action bar paging/mc fully to the _childupdate method
| author | Flick <flickerstreak@gmail.com> |
|---|---|
| date | Fri, 17 Oct 2008 22:43:57 +0000 |
| parents | 7cabc8ac6c16 |
| children | 567a885cdfad |
comparison
equal
deleted
inserted
replaced
| 91:c2504a8b996c | 92:5f1d7a81317c |
|---|---|
| 14 local SetAnchor = Bar.SetAnchor | 14 local SetAnchor = Bar.SetAnchor |
| 15 local SetButtonSize = Bar.SetButtonSize | 15 local SetButtonSize = Bar.SetButtonSize |
| 16 local SetButtonGrid = Bar.SetButtonGrid | 16 local SetButtonGrid = Bar.SetButtonGrid |
| 17 local ApplyAnchor = Bar.ApplyAnchor | 17 local ApplyAnchor = Bar.ApplyAnchor |
| 18 | 18 |
| 19 local KB = LibStub("LibKeyBound-1.0") | |
| 20 | |
| 19 ReAction:UpdateRevision("$Revision$") | 21 ReAction:UpdateRevision("$Revision$") |
| 20 | 22 |
| 21 -- | 23 -- |
| 22 -- Bar config overlay | 24 -- Bar config overlay |
| 23 -- | 25 -- |
| 27 SetSize( bar, f:GetWidth(), f:GetHeight() ) | 29 SetSize( bar, f:GetWidth(), f:GetHeight() ) |
| 28 end | 30 end |
| 29 | 31 |
| 30 local function StoreExtents(bar) | 32 local function StoreExtents(bar) |
| 31 local f = bar:GetFrame() | 33 local f = bar:GetFrame() |
| 32 SetAnchor( bar, f:GetPoint(1) ) | 34 local p, fr, rp, x, y = f:GetPoint(1) |
| 35 fr = fr or UIParent | |
| 36 SetAnchor( bar, p, fr, rp, x, y ) | |
| 33 SetSize( bar, f:GetWidth(), f:GetHeight() ) | 37 SetSize( bar, f:GetWidth(), f:GetHeight() ) |
| 34 end | 38 end |
| 35 | 39 |
| 36 local function RecomputeButtonSize(bar) | 40 local function RecomputeButtonSize(bar) |
| 37 local w, h = GetSize(bar) | 41 local w, h = GetSize(bar) |
| 265 end | 269 end |
| 266 | 270 |
| 267 local function GetClosestPointSnapped(f1, rx, ry, xOff, yOff) | 271 local function GetClosestPointSnapped(f1, rx, ry, xOff, yOff) |
| 268 local o, p, rp, x, y = GetClosestVisiblePoint(f1) | 272 local o, p, rp, x, y = GetClosestVisiblePoint(f1) |
| 269 local s = false | 273 local s = false |
| 274 | |
| 275 local insideOffsetFunc = p and insidePointOffsetFuncs[p] | |
| 276 local coordFunc = p and pointCoordFuncs[p] | |
| 277 if not insideOffsetFunc or not coordFunc then | |
| 278 return | |
| 279 end | |
| 270 | 280 |
| 271 local sx, sy = insidePointOffsetFuncs[p](xOff or 0, yOff or 0) | 281 local sx, sy = insidePointOffsetFuncs[p](xOff or 0, yOff or 0) |
| 272 local xx, yy = pointCoordFuncs[p](f1) | 282 local xx, yy = pointCoordFuncs[p](f1) |
| 273 if xx and yy then | 283 if xx and yy then |
| 274 if math.abs(x) <= rx then | 284 if math.abs(x) <= rx then |
| 351 local function CreateControls(bar) | 361 local function CreateControls(bar) |
| 352 local f = bar:GetFrame() | 362 local f = bar:GetFrame() |
| 353 | 363 |
| 354 f:SetMovable(true) | 364 f:SetMovable(true) |
| 355 f:SetResizable(true) | 365 f:SetResizable(true) |
| 356 f:SetClampedToScreen(true) | 366 |
| 357 | 367 local overlay = CreateFrame("Button", nil, f) |
| 358 local control = CreateFrame("Button", nil, f) | 368 overlay:EnableMouse(true) |
| 359 control:EnableMouse(true) | 369 overlay:SetFrameLevel(3) -- set it above the buttons |
| 360 control:SetToplevel(true) | 370 overlay:SetPoint("TOPLEFT", -4, 4) |
| 361 control:SetPoint("TOPLEFT", -4, 4) | 371 overlay:SetPoint("BOTTOMRIGHT", 4, -4) |
| 362 control:SetPoint("BOTTOMRIGHT", 4, -4) | 372 overlay:SetBackdrop({ |
| 363 control:SetBackdrop({ | |
| 364 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", | 373 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
| 365 tile = true, | 374 tile = true, |
| 366 tileSize = 16, | 375 tileSize = 16, |
| 367 edgeSize = 16, | 376 edgeSize = 16, |
| 368 insets = { left = 0, right = 0, top = 0, bottom = 0 }, | 377 insets = { left = 0, right = 0, top = 0, bottom = 0 }, |
| 369 }) | 378 }) |
| 370 control:SetClampedToScreen(true) | |
| 371 | 379 |
| 372 -- textures | 380 -- textures |
| 373 local bgTex = control:CreateTexture(nil,"BACKGROUND") | 381 local bgTex = overlay:CreateTexture(nil,"BACKGROUND") |
| 374 bgTex:SetTexture(0.7,0.7,1.0,0.2) | 382 bgTex:SetTexture(0.7,0.7,1.0,0.2) |
| 375 bgTex:SetPoint("TOPLEFT",4,-4) | 383 bgTex:SetPoint("TOPLEFT",4,-4) |
| 376 bgTex:SetPoint("BOTTOMRIGHT",-4,4) | 384 bgTex:SetPoint("BOTTOMRIGHT",-4,4) |
| 377 local hTex = control:CreateTexture(nil,"HIGHLIGHT") | 385 local hTex = overlay:CreateTexture(nil,"HIGHLIGHT") |
| 378 hTex:SetTexture(0.7,0.7,1.0,0.2) | 386 hTex:SetTexture(0.7,0.7,1.0,0.2) |
| 379 hTex:SetPoint("TOPLEFT",4,-4) | 387 hTex:SetPoint("TOPLEFT",4,-4) |
| 380 hTex:SetPoint("BOTTOMRIGHT",-4,4) | 388 hTex:SetPoint("BOTTOMRIGHT",-4,4) |
| 381 hTex:SetBlendMode("ADD") | 389 hTex:SetBlendMode("ADD") |
| 382 | 390 |
| 383 -- label | 391 -- label |
| 384 local label = control:CreateFontString(nil,"OVERLAY","GameFontNormalLarge") | 392 local label = overlay:CreateFontString(nil,"OVERLAY","GameFontNormalLarge") |
| 385 label:SetAllPoints() | 393 label:SetAllPoints() |
| 386 label:SetJustifyH("CENTER") | 394 label:SetJustifyH("CENTER") |
| 387 label:SetShadowColor(0,0,0,1) | 395 label:SetShadowColor(0,0,0,1) |
| 388 label:SetShadowOffset(2,-2) | 396 label:SetShadowOffset(2,-2) |
| 389 label:SetTextColor(1,1,1,1) | 397 label:SetTextColor(1,1,1,1) |
| 401 ReAction:RefreshOptions() | 409 ReAction:RefreshOptions() |
| 402 end | 410 end |
| 403 | 411 |
| 404 -- edge drag handles | 412 -- edge drag handles |
| 405 for _, point in pairs({"LEFT","TOP","RIGHT","BOTTOM"}) do | 413 for _, point in pairs({"LEFT","TOP","RIGHT","BOTTOM"}) do |
| 406 local edge = CreateFrame("Frame",nil,control) | 414 local edge = CreateFrame("Frame",nil,overlay) |
| 407 edge:EnableMouse(true) | 415 edge:EnableMouse(true) |
| 408 edge:SetWidth(8) | 416 edge:SetWidth(8) |
| 409 edge:SetHeight(8) | 417 edge:SetHeight(8) |
| 410 if point == "TOP" or point == "BOTTOM" then | 418 if point == "TOP" or point == "BOTTOM" then |
| 411 edge:SetPoint(point.."LEFT") | 419 edge:SetPoint(point.."LEFT") |
| 443 edge:SetScript("OnLeave", HideGameTooltip) | 451 edge:SetScript("OnLeave", HideGameTooltip) |
| 444 edge:Show() | 452 edge:Show() |
| 445 end | 453 end |
| 446 | 454 |
| 447 -- corner drag handles, nested in an anonymous frame so that they are on top | 455 -- corner drag handles, nested in an anonymous frame so that they are on top |
| 448 local foo = CreateFrame("Frame",nil,control) | 456 local foo = CreateFrame("Frame",nil,overlay) |
| 449 foo:SetAllPoints(true) | 457 foo:SetAllPoints(true) |
| 450 for _, point in pairs({"BOTTOMLEFT","TOPLEFT","BOTTOMRIGHT","TOPRIGHT"}) do | 458 for _, point in pairs({"BOTTOMLEFT","TOPLEFT","BOTTOMRIGHT","TOPRIGHT"}) do |
| 451 local corner = CreateFrame("Frame",nil,foo) | 459 local corner = CreateFrame("Frame",nil,foo) |
| 452 corner:EnableMouse(true) | 460 corner:EnableMouse(true) |
| 453 corner:SetWidth(12) | 461 corner:SetWidth(12) |
| 511 end | 519 end |
| 512 ) | 520 ) |
| 513 | 521 |
| 514 end | 522 end |
| 515 | 523 |
| 516 control:RegisterForDrag("LeftButton") | 524 overlay:RegisterForDrag("LeftButton") |
| 517 control:RegisterForClicks("RightButtonUp") | 525 overlay:RegisterForClicks("RightButtonUp") |
| 518 | 526 |
| 519 control:SetScript("OnDragStart", | 527 overlay:SetScript("OnDragStart", |
| 520 function() | 528 function() |
| 521 f:StartMoving() | 529 f:StartMoving() |
| 522 f.isMoving = true | 530 f.isMoving = true |
| 523 local w,h = bar:GetButtonSize() | 531 local w,h = bar:GetButtonSize() |
| 524 f:ClearAllPoints() | 532 f:ClearAllPoints() |
| 543 GameTooltip:AddLine(L["Currently anchored to <%s>"]:format(a)) | 551 GameTooltip:AddLine(L["Currently anchored to <%s>"]:format(a)) |
| 544 end | 552 end |
| 545 GameTooltip:Show() | 553 GameTooltip:Show() |
| 546 end | 554 end |
| 547 | 555 |
| 548 control:SetScript("OnDragStop", | 556 overlay:SetScript("OnDragStop", |
| 549 function() | 557 function() |
| 550 f:StopMovingOrSizing() | 558 f:StopMovingOrSizing() |
| 551 f.isMoving = false | 559 f.isMoving = false |
| 552 f:SetScript("OnUpdate",nil) | 560 f:SetScript("OnUpdate",nil) |
| 553 | 561 |
| 565 ReAction:RefreshOptions() | 573 ReAction:RefreshOptions() |
| 566 updateDragTooltip() | 574 updateDragTooltip() |
| 567 end | 575 end |
| 568 ) | 576 ) |
| 569 | 577 |
| 570 control:SetScript("OnEnter", | 578 overlay:SetScript("OnEnter", |
| 571 function() | 579 function() |
| 572 -- TODO: add bar type and status information to name | 580 -- TODO: add bar type and status information to name |
| 573 --[[ | 581 --[[ |
| 574 local name = bar.name | 582 local name = bar.name |
| 575 for _, m in ReAction:IterateModules() do | 583 for _, m in ReAction:IterateModules() do |
| 582 | 590 |
| 583 updateDragTooltip() | 591 updateDragTooltip() |
| 584 end | 592 end |
| 585 ) | 593 ) |
| 586 | 594 |
| 587 control:SetScript("OnLeave", HideGameTooltip) | 595 overlay:SetScript("OnLeave", HideGameTooltip) |
| 588 | 596 |
| 589 control:SetScript("OnClick", | 597 overlay:SetScript("OnClick", |
| 590 function() | 598 function() |
| 591 ReAction:ShowEditor(bar) | 599 ReAction:ShowEditor(bar) |
| 592 end | 600 end |
| 593 ) | 601 ) |
| 594 | 602 |
| 595 control:Raise() | 603 function overlay:LIBKEYBOUND_ENABLED(evt) |
| 596 | 604 self:SetFrameLevel(1) |
| 597 return control | 605 end |
| 606 | |
| 607 function overlay:LIBKEYBOUND_DISABLED(evt) | |
| 608 self:SetFrameLevel(3) | |
| 609 end | |
| 610 | |
| 611 KB.RegisterCallback(overlay,"LIBKEYBOUND_ENABLED") | |
| 612 KB.RegisterCallback(overlay,"LIBKEYBOUND_DISABLED") | |
| 613 | |
| 614 if ReAction:GetKeybindMode() then | |
| 615 self:SetFrameLevel(1) | |
| 616 end | |
| 617 | |
| 618 return overlay | |
| 598 end | 619 end |
| 599 | 620 |
| 600 | 621 |
| 601 -- export methods to the Bar prototype | 622 -- export methods to the Bar prototype |
| 602 | 623 |
| 603 function Bar:ShowControls(show) | 624 function Bar:ShowControls(show) |
| 625 local f = self.controlFrame | |
| 604 if show then | 626 if show then |
| 605 if not self.controlFrame then | 627 if not f then |
| 606 self.controlFrame = CreateControls(self) | 628 f = CreateControls(self) |
| 607 end | 629 self.controlFrame = f |
| 608 self.controlFrame:Show() | 630 end |
| 609 self.controlFrame:Raise() | 631 f:Show() |
| 610 elseif self.controlFrame then | 632 elseif f then |
| 611 self.controlFrame:Hide() | 633 f:Hide() |
| 612 end | 634 end |
| 613 end | 635 end |
| 614 | 636 |
| 615 function Bar:SetLabel(name) | 637 function Bar:SetLabel(name) |
| 616 if self.controlLabelString then | 638 local label = self.controlLabelString |
| 617 self.controlLabelString:SetText(self.name) | 639 if label then |
| 618 end | 640 label:SetText(self.name) |
| 619 end | 641 end |
| 642 end |
