Skip to content

Commit

Permalink
Allow partial offscreen frame dragging (#1143)
Browse files Browse the repository at this point in the history
Sometimes it's convenient to have our main window open alongside an
existing game panel, like when you have this dark urge to update your CO
field while scanning the auction house.

Unfortunately with the size of our window and the fact that it clamps to
the screen, we make this a bit tricky - depending upon the panels and
other junk you've got shown, you can't actually move our window out of
the way enough because it clamps at the edges of the screen.

To resolve this, we now allow the user to drag the window *partially*
off-screen, clamping only if the position of the window would fall
within ~around 300 units of it being completely off-screen. That way you
can move about 70% of the window completely out of the way if you want
to look at that Draenei's transmog or whatever.
  • Loading branch information
Meorawr authored Oct 22, 2024
1 parent 4f6462c commit 26c6974
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions totalRP3/UI/Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function TRP3_MainFrameMixin:OnShow()
end

function TRP3_MainFrameMixin:OnSizeChanged()
self:UpdateClampRectInsets();
TRP3_Addon:TriggerEvent(TRP3_Addon.Events.NAVIGATION_RESIZED, TRP3_MainFramePageContainer:GetSize());
end

Expand Down Expand Up @@ -103,6 +104,19 @@ function TRP3_MainFrameMixin:UpdateWindowStateButtons()
self.Maximize:SetShown(state == WindowState.Normal and ShouldShowWindowStateButtons());
end

function TRP3_MainFrameMixin:UpdateClampRectInsets()
local width, height = self:GetSize();
local ratio = width / height;
local padding = 300;

local left = width - padding;
local right = -left;
local bottom = height - (padding / ratio);
local top = -bottom;

self:SetClampRectInsets(left, right, top, bottom);
end

TRP3_MainFrameLayoutMixin = CreateFromMixins(TRP3_MainFrameMixin);

function TRP3_MainFrameLayoutMixin:OnLoad()
Expand Down

0 comments on commit 26c6974

Please sign in to comment.