@@ -4,7 +4,11 @@ local MR = ns.MR
44local FONT_HEADERS = ns .FONT_HEADERS
55local FONT_ROWS = ns .FONT_ROWS
66local StyledFrame = ns .StyledFrame
7- local RestoreFramePos = ns .RestoreFramePos
7+ local RestoreManagedFramePos = ns .RestoreManagedFramePos
8+ local SaveManagedFramePos = ns .SaveManagedFramePos
9+ local SyncManagedFramePos = ns .SyncManagedFramePos
10+ local AnimateManagedFrameHeight = ns .AnimateManagedFrameHeight
11+ local IsManagedHeaderBottom = ns .IsManagedHeaderBottom
812local LeftAccent = ns .LeftAccent
913local TopAccent = ns .TopAccent
1014local TitleBar = ns .TitleBar
@@ -437,42 +441,20 @@ local function BuildGatheringLocationsFrame(isRetry)
437441 local width = db .gatheringWidth or DEFAULT_W
438442 local height = db .gatheringHeight or DEFAULT_H
439443 local minimized = db .gatheringMinimized or false
440- local headerBottom = MR . GetManagedHeaderPosition and MR : GetManagedHeaderPosition () == " bottom "
444+ local headerBottom = IsManagedHeaderBottom ()
441445 gatheringMinimized = minimized
442446
443447 local function ApplyFrameHeight (frame , targetHeight )
444- if not (MR .IsManagedAnimatedMinimizeEnabled and MR :IsManagedAnimatedMinimizeEnabled ()) then
445- frame :SetHeight (targetHeight )
446- return
447- end
448-
449- local startHeight = frame :GetHeight () or targetHeight
450- local delta = targetHeight - startHeight
451- if math.abs (delta ) < 1 then
452- frame :SetHeight (targetHeight )
453- return
454- end
455-
456- frame ._mrAnimTick = 0
457- frame :SetScript (" OnUpdate" , function (self , dt )
458- self ._mrAnimTick = (self ._mrAnimTick or 0 ) + (dt or 0 )
459- local duration = math.min (0.18 , math.max (0.06 , math.abs (delta ) / 1600 ))
460- local progress = math.min (self ._mrAnimTick / duration , 1 )
461- local eased = 1 - ((1 - progress ) * (1 - progress ) * (1 - progress ))
462- self :SetHeight (startHeight + (delta * eased ))
463- if progress >= 1 then
464- self :SetHeight (targetHeight )
465- self ._mrAnimTick = nil
466- self :SetScript (" OnUpdate" , nil )
467- end
448+ AnimateManagedFrameHeight (frame , targetHeight , function (self )
449+ self :SetScript (" OnUpdate" , nil )
468450 end )
469451 end
470452
471453 local frame = StyledFrame (UIParent , nil , " MEDIUM" , 10 )
472454 frame :SetSize (width , minimized and TITLE_H or height )
473455 frame :SetBackdropColor (0.03 , 0.05 , 0.08 , 0.97 * alpha )
474456 frame :SetBackdropBorderColor (0.22 , 0.18 , 0.28 , alpha )
475- RestoreFramePos (frame , " gatheringLocPos" , 860 , 0 )
457+ RestoreManagedFramePos (frame , " gatheringLocPos" , 860 , 0 )
476458 frame .leftAccent = nil
477459 frame .topAccent = TopAccent (frame , 0.80 , 0.53 , 0.20 )
478460 if frame .leftAccent then frame .leftAccent :SetAlpha (alpha ) end
@@ -492,26 +474,7 @@ local function BuildGatheringLocationsFrame(isRetry)
492474 titleBar :SetScript (" OnDragStart" , function () if not db .gatheringLocked then frame :StartMoving () end end )
493475 titleBar :SetScript (" OnDragStop" , function ()
494476 frame :StopMovingOrSizing ()
495- if headerBottom then
496- local left = frame :GetLeft ()
497- local bottom = frame :GetBottom ()
498- if left and bottom and MR .db then
499- MR :SetWindowLayoutValue (" gatheringLocPos" , { point = " BOTTOMLEFT" , relPoint = " BOTTOMLEFT" , x = left , y = bottom })
500- return
501- end
502- else
503- local left = frame :GetLeft ()
504- local top = frame :GetTop ()
505- if left and top and MR .db then
506- MR :SetWindowLayoutValue (" gatheringLocPos" , { point = " TOPLEFT" , relPoint = " BOTTOMLEFT" , x = left , y = top })
507- return
508- end
509- end
510-
511- local point , _ , relPoint , x , y = frame :GetPoint ()
512- if MR .db then
513- MR :SetWindowLayoutValue (" gatheringLocPos" , { point = point , relPoint = relPoint , x = x , y = y })
514- end
477+ SaveManagedFramePos (frame , " gatheringLocPos" , headerBottom and " bottom" or " top" )
515478 end )
516479 if MR .ApplyPanelHeaderAutoHide then MR :ApplyPanelHeaderAutoHide (frame , titleBar ) end
517480
@@ -858,40 +821,13 @@ local function BuildGatheringLocationsFrame(isRetry)
858821 if minBtn .RefreshLabel then minBtn :RefreshLabel () end
859822
860823 if gatheringMinimized then
861- if headerBottom then
862- local left = frame :GetLeft ()
863- local bottom = frame :GetBottom ()
864- if left and bottom then
865- frame :ClearAllPoints ()
866- frame :SetPoint (" BOTTOMLEFT" , UIParent , " BOTTOMLEFT" , left , bottom )
867- if MR .db then
868- MR :SetWindowLayoutValue (" gatheringLocPos" , { point = " BOTTOMLEFT" , relPoint = " BOTTOMLEFT" , x = left , y = bottom })
869- end
870- end
871- else
872- local left = frame :GetLeft ()
873- local top = frame :GetTop ()
874- if left and top then
875- frame :ClearAllPoints ()
876- frame :SetPoint (" TOPLEFT" , UIParent , " BOTTOMLEFT" , left , top )
877- if MR .db then
878- MR :SetWindowLayoutValue (" gatheringLocPos" , { point = " TOPLEFT" , relPoint = " BOTTOMLEFT" , x = left , y = top })
879- end
880- end
881- end
824+ SyncManagedFramePos (frame , " gatheringLocPos" , headerBottom and " bottom" or " top" )
882825 if frame ._scroll then frame ._scroll :Hide () end
883826 if frame ._scrollTrack then frame ._scrollTrack :Hide () end
884827 if frame ._dragger then frame ._dragger :Hide () end
885828 ApplyFrameHeight (frame , TITLE_H )
886829 else
887- if headerBottom then
888- local left = frame :GetLeft ()
889- local bottom = frame :GetBottom ()
890- if left and bottom then
891- frame :ClearAllPoints ()
892- frame :SetPoint (" BOTTOMLEFT" , UIParent , " BOTTOMLEFT" , left , bottom )
893- end
894- end
830+ SyncManagedFramePos (frame , " gatheringLocPos" , headerBottom and " bottom" or " top" )
895831 if frame ._scroll then frame ._scroll :Show () end
896832 if frame ._scrollTrack then frame ._scrollTrack :Show () end
897833 if frame ._dragger then frame ._dragger :Show () end
0 commit comments