Skip to content

Commit

Permalink
scaling functions
Browse files Browse the repository at this point in the history
  • Loading branch information
blooblahguy committed Jul 7, 2019
1 parent 44ae13d commit ad9a3f3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
32 changes: 32 additions & 0 deletions core/media_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,38 @@ function bdCore:RGBPercToHex(r, g, b)
return string.format("%02x%02x%02x", r*255, g*255, b*255)
end

-- borders / spacing
function bdCore:get_border(frame)
local borderSize = c.persistent.bdAddons.border
local screenheight = select(2, GetPhysicalScreenSize())
local scale = 768 / screenheight
local frame_scale = frame:GetEffectiveScale()
local pixel = scale / frame_scale
local border = pixel * borderSize

return border
end

function bdCore:set_border(frame, type)
local border = bdNameplates:get_border(frame)

if (not frame.background) then
frame.background = frame:CreateTexture(nil, "BACKGROUND", nil, -7)
frame.background:SetTexture(bdCore.media.flat)
frame.background:SetVertexColor(unpack(bdCore.media.backdrop))
frame.background.SetFrameLevel = bdCore.noop
frame.border = frame:CreateTexture(nil, "BACKGROUND", nil, -8)
frame.border:SetTexture(bdCore.media.flat)
frame.border:SetVertexColor(unpack(bdCore.media.border))
frame.border.SetFrameLevel = bdCore.noop
end

frame.border:SetPoint("TOPLEFT", frame, "TOPLEFT", -border, border)
frame.border:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", border, -border)
frame.background:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0)
frame.background:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, 0)
end

-- make it purdy
function bdCore:setBackdrop(frame, resize, padding)
if (frame.background) then return end
Expand Down
7 changes: 4 additions & 3 deletions core/moving_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ function bdCore:makeMovable(frame, resize, rename)
end

frame:ClearAllPoints()
frame:SetPoint("TOPRIGHT", Mover, "TOPRIGHT", -border, -border)
frame:SetPoint("CENTER", Mover, "CENTER", 0, 0)

bdCore.moveFrames[#bdCore.moveFrames+1] = Mover

Expand Down Expand Up @@ -436,8 +436,9 @@ function bdCore:toggleLock()
frame:EnableMouse(true)
frame:SetMovable(true)
frame:SetUserPlaced(false)
frame:RegisterForDrag("LeftButton","RightButton")
frame:SetScript("OnDragStart", function(self) self:StartMoving(); if (self.controls) then self.controls:Hide() end end)
frame:RegisterForDrag("LeftButton")
-- frame:SetScript("OnDragStart", function(self) self:StartMoving(); if (self.controls) then self.controls:Hide() end end)
frame:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame:SetScript("OnDragStop", function(self) self:dragStop(self) end)
frame:SetFrameStrata("TOOLTIP")

Expand Down

0 comments on commit ad9a3f3

Please sign in to comment.