Skip to content

Commit

Permalink
fix keyboard positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuller committed Jun 9, 2024
1 parent 0997777 commit 5ce78b5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
41 changes: 30 additions & 11 deletions Dominos_Config/overlay/dragFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -502,18 +502,37 @@ end

-- position
function DragFrame:NudgeFrame(dx, dy)
local ox, oy, ow, oh = self.owner:GetRect()
local _, _, pw, ph = self.owner:GetParent():GetRect()
local x = Clamp(Round(ox + dx), 0, pw - ow)
local y = Clamp(Round(oy + dy), 0, ph - oh)
local f = self.owner

self.owner:ClearSavedAnchor()
self.owner:ClearAllPoints()
self.owner:SetPoint("BOTTOMLEFT", x, y)
self.owner:SaveRelativePostiion()
self.owner:RestorePosition()
-- grab all the coordinates we need
-- frame
local fl, fb, fw, fh = f:GetScaledRect()
local fs = f:GetEffectiveScale()

self:ShowTemporaryText(0.5, "(%d, %d)", self.owner:GetRect())
-- parent (effectively UIParent)
local _, _, pw, ph = f:GetParent():GetScaledRect()

-- screen position (for pixel precision)
local _, sh = GetPhysicalScreenSize()

-- adjust increments so that they're always in terms of screen pixels
dx = dx * (ph / sh)
dy = dy * (ph / sh)

-- calculate the new coordinates. Ensure that they're within the screen
local x = Clamp(fl + dx, 0, pw - fw)
local y = Clamp(fb + dy, 0, ph - fh)

-- reposition the frame, and save our position again (so that it is)
-- stored relative to the nearest screen corner
f:ClearSavedAnchor()
f:ClearAllPoints()
f:SetPoint("BOTTOMLEFT", x / fs, y / fs)
f:SaveRelativePostiion()
f:RestorePosition()

-- report in terms of screen pixels
self:ShowTemporaryText(0.5, "(%d, %d)", x * (sh / ph), y * (sh / ph))
end

-- preview
Expand Down Expand Up @@ -596,4 +615,4 @@ end

Addon.DragFrameLabelFont = DragFrameLabelFont
Addon.DragFrameLabelHighlightFont = DragFrameLabelHighlightFont
Addon.DragFrame = DragFrame
Addon.DragFrame = DragFrame
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Dominos Changelog

## 10.2.32

* Keyboard nudge increments are now in terms of your screen's resolution
* Fixed issues with using keyboard positioning on scaled frames

## 10.2.31

* (Cata) Fix encounter bar positioning
Expand Down

0 comments on commit 5ce78b5

Please sign in to comment.