Mercurial > wow > reaction
comparison Overlay.lua @ 98:a44173c7a82c
- added (Hidden) to label when bar is being shown temporarily for config
- added snap-indicator (lock) icon. Displays when not dragging, if anchored, as well.
- changed bar color when anchored
| author | Flick <flickerstreak@gmail.com> |
|---|---|
| date | Fri, 24 Oct 2008 18:14:07 +0000 |
| parents | 567a885cdfad |
| children | f200bcb193d6 |
comparison
equal
deleted
inserted
replaced
| 97:5d3b7b025142 | 98:a44173c7a82c |
|---|---|
| 21 ReAction:UpdateRevision("$Revision$") | 21 ReAction:UpdateRevision("$Revision$") |
| 22 | 22 |
| 23 -- | 23 -- |
| 24 -- Bar config overlay | 24 -- Bar config overlay |
| 25 -- | 25 -- |
| 26 | |
| 27 local function GetNormalTextColor() | |
| 28 return 1.0, 1.0, 1.0, 1.0 | |
| 29 end | |
| 30 | |
| 31 local function GetAnchoredTextColor() | |
| 32 return 1.0, 1.0, 1.0, 1.0 | |
| 33 end | |
| 34 | |
| 35 local function GetNormalBgColor() | |
| 36 return 0.7, 0.7, 1.0, 0.3 | |
| 37 end | |
| 38 | |
| 39 local function GetAnchoredBgColor() | |
| 40 return 0.9, 0.2, 0.7, 0.3 | |
| 41 end | |
| 26 | 42 |
| 27 local function StoreSize(bar) | 43 local function StoreSize(bar) |
| 28 local f = bar:GetFrame() | 44 local f = bar:GetFrame() |
| 29 SetSize( bar, f:GetWidth(), f:GetHeight() ) | 45 SetSize( bar, f:GetWidth(), f:GetHeight() ) |
| 30 end | 46 end |
| 127 RIGHT = function(x, y) return -x, 0 end, | 143 RIGHT = function(x, y) return -x, 0 end, |
| 128 TOPRIGHT = function(x, y) return -x, -y end, | 144 TOPRIGHT = function(x, y) return -x, -y end, |
| 129 TOP = function(x, y) return 0, -y end, | 145 TOP = function(x, y) return 0, -y end, |
| 130 TOPLEFT = function(x, y) return x, -y end, | 146 TOPLEFT = function(x, y) return x, -y end, |
| 131 LEFT = function(x, y) return x, 0 end, | 147 LEFT = function(x, y) return x, 0 end, |
| 132 CENTER = function(x, y) return 0, 0 end, | 148 CENTER = function(x, y) return x, y end, |
| 133 } | 149 } |
| 134 local pointCoordFuncs = { | 150 local pointCoordFuncs = { |
| 135 BOTTOMLEFT = function(f) return f:GetLeft(), f:GetBottom() end, | 151 BOTTOMLEFT = function(f) return f:GetLeft(), f:GetBottom() end, |
| 136 BOTTOM = function(f) return nil, f:GetBottom() end, | 152 BOTTOM = function(f) return nil, f:GetBottom() end, |
| 137 BOTTOMRIGHT = function(f) return f:GetRight(), f:GetBottom() end, | 153 BOTTOMRIGHT = function(f) return f:GetRight(), f:GetBottom() end, |
| 316 end | 332 end |
| 317 | 333 |
| 318 local function CreateSnapIndicator() | 334 local function CreateSnapIndicator() |
| 319 local si = CreateFrame("Frame",nil,UIParent) | 335 local si = CreateFrame("Frame",nil,UIParent) |
| 320 si:SetFrameStrata("HIGH") | 336 si:SetFrameStrata("HIGH") |
| 321 si:SetHeight(8) | 337 si:SetHeight(16) |
| 322 si:SetWidth(8) | 338 si:SetWidth(16) |
| 323 local tex = si:CreateTexture() | 339 local tex = si:CreateTexture() |
| 324 tex:SetAllPoints() | 340 tex:SetAllPoints() |
| 325 tex:SetTexture(1.0, 0.82, 0, 0.8) | 341 tex:SetTexture("Interface\\AddOns\\ReAction\\img\\lock") |
| 326 tex:SetBlendMode("ADD") | 342 tex:SetBlendMode("ADD") |
| 327 tex:SetDrawLayer("OVERLAY") | 343 tex:SetDrawLayer("OVERLAY") |
| 328 return si | 344 return si |
| 329 end | 345 end |
| 330 | 346 |
| 347 if si1:IsVisible() then | 363 if si1:IsVisible() then |
| 348 si1:Hide() | 364 si1:Hide() |
| 349 si2:Hide() | 365 si2:Hide() |
| 350 end | 366 end |
| 351 end | 367 end |
| 368 return o, p | |
| 352 end | 369 end |
| 353 | 370 |
| 354 local function HideSnapIndicator() | 371 local function HideSnapIndicator() |
| 355 if si1:IsVisible() then | 372 if si1:IsVisible() then |
| 356 si1:Hide() | 373 si1:Hide() |
| 357 si2:Hide() | 374 si2:Hide() |
| 375 end | |
| 376 end | |
| 377 | |
| 378 local function UpdateLabelString(bar) | |
| 379 local label = bar.controlLabelString | |
| 380 if label then | |
| 381 local name = bar.labelName | |
| 382 if name and bar.labelSubtext then | |
| 383 name = format("%s (%s)", name, bar.labelSubtext) | |
| 384 end | |
| 385 label:SetText(name or "") | |
| 358 end | 386 end |
| 359 end | 387 end |
| 360 | 388 |
| 361 local function CreateControls(bar) | 389 local function CreateControls(bar) |
| 362 local f = bar:GetFrame() | 390 local f = bar:GetFrame() |
| 385 local hTex = overlay:CreateTexture(nil,"HIGHLIGHT") | 413 local hTex = overlay:CreateTexture(nil,"HIGHLIGHT") |
| 386 hTex:SetTexture(0.7,0.7,1.0,0.2) | 414 hTex:SetTexture(0.7,0.7,1.0,0.2) |
| 387 hTex:SetPoint("TOPLEFT",4,-4) | 415 hTex:SetPoint("TOPLEFT",4,-4) |
| 388 hTex:SetPoint("BOTTOMRIGHT",-4,4) | 416 hTex:SetPoint("BOTTOMRIGHT",-4,4) |
| 389 hTex:SetBlendMode("ADD") | 417 hTex:SetBlendMode("ADD") |
| 418 local aTex = overlay:CreateTexture(nil,"ARTWORK") | |
| 419 aTex:SetTexture("Interface\\AddOns\\ReAction\\img\\lock") | |
| 420 aTex:SetWidth(16) | |
| 421 aTex:SetHeight(16) | |
| 422 aTex:Hide() | |
| 390 | 423 |
| 391 -- label | 424 -- label |
| 392 local label = overlay:CreateFontString(nil,"OVERLAY","GameFontNormalLarge") | 425 local label = overlay:CreateFontString(nil,"OVERLAY","GameFontNormalLarge") |
| 393 label:SetAllPoints() | 426 label:SetAllPoints() |
| 394 label:SetJustifyH("CENTER") | 427 label:SetJustifyH("CENTER") |
| 395 label:SetShadowColor(0,0,0,1) | 428 label:SetShadowColor(0,0,0,1) |
| 396 label:SetShadowOffset(2,-2) | 429 label:SetShadowOffset(3,-3) |
| 397 label:SetTextColor(1,1,1,1) | 430 label:SetTextColor(GetNormalTextColor()) |
| 398 label:SetText(bar:GetName()) | 431 label:SetText(bar:GetName()) |
| 399 label:Show() | 432 label:Show() |
| 400 bar.controlLabelString = label -- so that bar:SetLabel() can update it | 433 bar.controlLabelString = label -- so that bar:SetLabel() can update it |
| 434 | |
| 435 local function UpdateAnchorDecoration() | |
| 436 local point, anchor, relPoint, x, y = f:GetPoint(1) | |
| 437 if point then | |
| 438 local ofsx, ofsy = insidePointOffsetFuncs[point](x,y) | |
| 439 if (anchor and anchor ~= UIParent) or (ofsx == 0 and ofsy == 0) then | |
| 440 bgTex:SetTexture( GetAnchoredBgColor() ) | |
| 441 hTex:SetTexture( GetAnchoredBgColor() ) | |
| 442 label:SetTextColor( GetAnchoredTextColor() ) | |
| 443 aTex:ClearAllPoints() | |
| 444 aTex:SetPoint(point) | |
| 445 aTex:Show() | |
| 446 return | |
| 447 end | |
| 448 end | |
| 449 bgTex:SetTexture( GetNormalBgColor() ) | |
| 450 hTex:SetTexture( GetNormalBgColor() ) | |
| 451 label:SetTextColor( GetNormalTextColor() ) | |
| 452 aTex:Hide() | |
| 453 end | |
| 401 | 454 |
| 402 local function StopResize() | 455 local function StopResize() |
| 403 f:StopMovingOrSizing() | 456 f:StopMovingOrSizing() |
| 404 f.isMoving = false | 457 f.isMoving = false |
| 405 f:SetScript("OnUpdate",nil) | 458 f:SetScript("OnUpdate",nil) |
| 464 local tex = corner:CreateTexture(nil,"HIGHLIGHT") | 517 local tex = corner:CreateTexture(nil,"HIGHLIGHT") |
| 465 tex:SetTexture(1.0,0.82,0,0.7) | 518 tex:SetTexture(1.0,0.82,0,0.7) |
| 466 tex:SetBlendMode("ADD") | 519 tex:SetBlendMode("ADD") |
| 467 tex:SetAllPoints() | 520 tex:SetAllPoints() |
| 468 corner:RegisterForDrag("LeftButton","RightButton") | 521 corner:RegisterForDrag("LeftButton","RightButton") |
| 469 local function updateTooltip() | 522 local function UpdateTooltip() |
| 470 local size, size2 = bar:GetButtonSize() | 523 local size, size2 = bar:GetButtonSize() |
| 471 local rows, cols, spacing = bar:GetButtonGrid() | 524 local rows, cols, spacing = bar:GetButtonGrid() |
| 472 size = (size == size2) and tostring(size) or format("%dx%d",size,size2) | 525 size = (size == size2) and tostring(size) or format("%dx%d",size,size2) |
| 473 GameTooltipTextRight4:SetText(size) | 526 GameTooltipTextRight4:SetText(size) |
| 474 GameTooltipTextRight5:SetText(tostring(spacing)) | 527 GameTooltipTextRight5:SetText(tostring(spacing)) |
| 480 if btn == "LeftButton" then -- button resize | 533 if btn == "LeftButton" then -- button resize |
| 481 f:SetMinResize( (s+12)*c+1, (s+12)*r+1 ) | 534 f:SetMinResize( (s+12)*c+1, (s+12)*r+1 ) |
| 482 f:SetScript("OnUpdate", | 535 f:SetScript("OnUpdate", |
| 483 function() | 536 function() |
| 484 RecomputeButtonSize(bar) | 537 RecomputeButtonSize(bar) |
| 485 updateTooltip() | 538 UpdateTooltip() |
| 486 end | 539 end |
| 487 ) | 540 ) |
| 488 elseif btn == "RightButton" then -- spacing resize | 541 elseif btn == "RightButton" then -- spacing resize |
| 489 f:SetMinResize( bw*c, bh*r ) | 542 f:SetMinResize( bw*c, bh*r ) |
| 490 f:SetScript("OnUpdate", | 543 f:SetScript("OnUpdate", |
| 491 function() | 544 function() |
| 492 RecomputeButtonSpacing(bar) | 545 RecomputeButtonSpacing(bar) |
| 493 updateTooltip() | 546 UpdateTooltip() |
| 494 end | 547 end |
| 495 ) | 548 ) |
| 496 end | 549 end |
| 497 f:StartSizing(point) | 550 f:StartSizing(point) |
| 498 end | 551 end |
| 528 function() | 581 function() |
| 529 f:StartMoving() | 582 f:StartMoving() |
| 530 f.isMoving = true | 583 f.isMoving = true |
| 531 local w,h = bar:GetButtonSize() | 584 local w,h = bar:GetButtonSize() |
| 532 f:ClearAllPoints() | 585 f:ClearAllPoints() |
| 586 UpdateAnchorDecoration() | |
| 533 f:SetScript("OnUpdate", function() | 587 f:SetScript("OnUpdate", function() |
| 534 if IsShiftKeyDown() then | 588 if IsShiftKeyDown() then |
| 535 DisplaySnapIndicator(f,w,h) | 589 local f, p = DisplaySnapIndicator(f,w,h) |
| 536 else | 590 else |
| 537 HideSnapIndicator() | 591 HideSnapIndicator() |
| 538 end | 592 end |
| 539 end) | 593 end) |
| 540 end | 594 end |
| 541 ) | 595 ) |
| 542 | 596 |
| 543 local function updateDragTooltip() | 597 local function UpdateDragTooltip() |
| 544 GameTooltip:SetOwner(f, "ANCHOR_TOPRIGHT") | 598 GameTooltip:SetOwner(f, "ANCHOR_TOPRIGHT") |
| 545 GameTooltip:AddLine(bar.name) | 599 GameTooltip:AddLine(bar.name) |
| 546 GameTooltip:AddLine(L["Drag to move"]) | 600 GameTooltip:AddLine(L["Drag to move"]) |
| 547 GameTooltip:AddLine(("|cff00ff00%s|r %s"):format(L["Shift-drag"],L["to anchor to nearby frames"])) | 601 GameTooltip:AddLine(("|cff00ff00%s|r %s"):format(L["Shift-drag"],L["to anchor to nearby frames"])) |
| 548 GameTooltip:AddLine(("|cff00cccc%s|r %s"):format(L["Right-click"],L["for options"])) | 602 GameTooltip:AddLine(("|cff00cccc%s|r %s"):format(L["Right-click"],L["for options"])) |
| 569 HideSnapIndicator() | 623 HideSnapIndicator() |
| 570 end | 624 end |
| 571 | 625 |
| 572 StoreExtents(bar) | 626 StoreExtents(bar) |
| 573 ReAction:RefreshOptions() | 627 ReAction:RefreshOptions() |
| 574 updateDragTooltip() | 628 UpdateDragTooltip() |
| 629 UpdateAnchorDecoration() | |
| 575 end | 630 end |
| 576 ) | 631 ) |
| 577 | 632 |
| 578 overlay:SetScript("OnEnter", | 633 overlay:SetScript("OnEnter", |
| 579 function() | 634 function() |
| 580 -- TODO: add bar type and status information to name | 635 UpdateDragTooltip() |
| 581 --[[ | |
| 582 local name = bar.name | |
| 583 for _, m in ReAction:IterateModules() do | |
| 584 local suffix = safecall(m,"GetBarNameModifier",bar) | |
| 585 if suffix then | |
| 586 name = ("%s %s"):format(name,suffix) | |
| 587 end | |
| 588 end | |
| 589 ]]-- | |
| 590 | |
| 591 updateDragTooltip() | |
| 592 end | 636 end |
| 593 ) | 637 ) |
| 594 | 638 |
| 595 overlay:SetScript("OnLeave", HideGameTooltip) | 639 overlay:SetScript("OnLeave", HideGameTooltip) |
| 596 | 640 |
| 612 KB.RegisterCallback(overlay,"LIBKEYBOUND_DISABLED") | 656 KB.RegisterCallback(overlay,"LIBKEYBOUND_DISABLED") |
| 613 | 657 |
| 614 if ReAction:GetKeybindMode() then | 658 if ReAction:GetKeybindMode() then |
| 615 overlay:SetFrameLevel(1) | 659 overlay:SetFrameLevel(1) |
| 616 end | 660 end |
| 661 | |
| 662 bar:SetLabel(bar:GetName()) | |
| 663 UpdateLabelString(bar) | |
| 664 UpdateAnchorDecoration() | |
| 617 | 665 |
| 618 return overlay | 666 return overlay |
| 619 end | 667 end |
| 620 | 668 |
| 621 | 669 |
| 633 f:Hide() | 681 f:Hide() |
| 634 end | 682 end |
| 635 end | 683 end |
| 636 | 684 |
| 637 function Bar:SetLabel(name) | 685 function Bar:SetLabel(name) |
| 638 local label = self.controlLabelString | 686 self.labelName = name |
| 639 if label then | 687 UpdateLabelString(self) |
| 640 label:SetText(self.name) | 688 end |
| 641 end | 689 |
| 642 end | 690 function Bar:SetLabelSubtext(text) |
| 691 self.labelSubtext = text | |
| 692 UpdateLabelString(self) | |
| 693 end |
