Skip to content

Commit

Permalink
click control updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rbgdevx committed Dec 20, 2024
1 parent 05e974a commit df18837
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 23 deletions.
4 changes: 2 additions & 2 deletions helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ local getmetatable = getmetatable
local wipe = table.wipe
local sformat = string.format

local LSM = LibStub("LibSharedMedia-3.0")
local SharedMedia = LibStub("LibSharedMedia-3.0")

NS.Debug = function(...)
if NS.db.global.debug then
Expand Down Expand Up @@ -90,7 +90,7 @@ NS.UpdateText = function(frame, reverse)
end

NS.UpdateFont = function(frame)
frame:SetFont(LSM:Fetch("font", NS.db.global.font), NS.db.global.fontsize, "OUTLINE")
frame:SetFont(SharedMedia:Fetch("font", NS.db.global.font), NS.db.global.fontsize, "OUTLINE")
end

NS.ToggleVisibility = function(inRange, reverse)
Expand Down
44 changes: 27 additions & 17 deletions interface.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@ local AddonName, NS = ...
local CreateFrame = CreateFrame
local LibStub = LibStub

local AceConfigDialog = LibStub("AceConfigDialog-3.0")

local Interface = {}
NS.Interface = Interface

function Interface:StopMovement(frame)
function Interface:MakeUnmovable(frame)
frame:SetMovable(false)
frame:RegisterForDrag()
frame:SetScript("OnDragStart", nil)
frame:SetScript("OnDragStop", nil)
end

function Interface:MakeMoveable(frame)
frame:SetMovable(true)
frame:RegisterForDrag("LeftButton")
frame:SetScript("OnDragStart", function(f)
if NS.db.global.lock == false then
if NS.db.global.lock == false and frame:IsVisible() and frame:GetAlpha() ~= 0 then
f:StartMoving()
end
end)
frame:SetScript("OnDragStop", function(f)
if NS.db.global.lock == false then
if NS.db.global.lock == false and frame:IsVisible() and frame:GetAlpha() ~= 0 then
f:StopMovingOrSizing()
local a, _, b, c, d = f:GetPoint()
NS.db.global.position[1] = a
Expand All @@ -30,29 +35,30 @@ function Interface:MakeMoveable(frame)
end)
end

function Interface:Lock(frame)
self:StopMovement(frame)
end

function Interface:Unlock(frame)
self:MakeMoveable(frame)
function Interface:RemoveControls(frame)
frame:EnableMouse(false)
frame:SetScript("OnMouseUp", nil)
end

function Interface:AddControls(frame)
frame:EnableMouse(true)
frame:SetScript("OnMouseUp", function(_, btn)
if NS.db.global.lock == false then
if NS.db.global.lock == false and not IsInInstance() and frame:IsVisible() and frame:GetAlpha() ~= 0 then
if btn == "RightButton" then
LibStub("AceConfigDialog-3.0"):Open(AddonName)
AceConfigDialog:Open(AddonName)
end
end
end)
end

if NS.db.global.lock then
self:StopMovement(frame)
else
self:MakeMoveable(frame)
end
function Interface:Lock(frame)
self:RemoveControls(frame)
self:MakeUnmovable(frame)
end

function Interface:Unlock(frame)
self:AddControls(frame)
self:MakeMoveable(frame)
end

function Interface:CreateInterface()
Expand Down Expand Up @@ -81,7 +87,11 @@ function Interface:CreateInterface()
Interface.text = Text
Interface.textFrame = TextFrame

self:AddControls(Interface.textFrame)
if NS.db.global.lock then
self:Lock(Interface.textFrame)
else
self:Unlock(Interface.textFrame)
end

TextFrame:SetWidth(Text:GetStringWidth())
TextFrame:SetHeight(Text:GetStringHeight())
Expand Down
10 changes: 6 additions & 4 deletions options.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
local AddonName, NS = ...

local LibStub = LibStub
local CopyTable = CopyTable
local next = next
local LibStub = LibStub

local SharedMedia = LibStub("LibSharedMedia-3.0")

---@type HIR
local HIR = NS.HIR
Expand Down Expand Up @@ -93,8 +95,8 @@ NS.AceConfig = {
name = "Font Size",
width = "double",
order = 5,
min = 1,
max = 500,
min = 2,
max = 64,
step = 1,
set = function(_, val)
NS.db.global.fontsize = val
Expand All @@ -112,7 +114,7 @@ NS.AceConfig = {
width = "double",
order = 6,
dialogControl = "LSM30_Font",
values = AceGUIWidgetLSMlists.font,
values = SharedMedia:HashTable("font"),
set = function(_, val)
NS.db.global.font = val
NS.UpdateFont(NS.Interface.text)
Expand Down

0 comments on commit df18837

Please sign in to comment.