Skip to content

Commit

Permalink
✨ Added a scale limit and a reload command to reset the window
Browse files Browse the repository at this point in the history
  • Loading branch information
AssisrMatheus committed Sep 19, 2019
1 parent 11a43e8 commit e77a951
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
10 changes: 10 additions & 0 deletions chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ Chat.commands = {
Chat:Print("|cff00cc66/todo tg|r - Toggle todo window");
Chat:Print("|cff00cc66/todo add|r {message} - Adds a message from chat");
print(" ");
end,

["reload"] = function()
if(core.mainFrame) then
core.mainFrame:SetSize(200,200)
core.mainFrame:ClearAllPoints()
core.mainFrame:SetPoint("BOTTOMRIGHT", "$parent", "BOTTOMRIGHT", -120, 30)
core.mainFrame:SetScale(1)
core.mainFrame:Show()
end
end,

-- ["example"] = {
Expand Down
17 changes: 13 additions & 4 deletions components/ResponsiveFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,20 @@ function OnUpdate(self)
cx = cx / self:GetEffectiveScale() - self:GetParent():GetLeft()
cy = self:GetParent():GetHeight() - (cy / self:GetEffectiveScale() - self:GetParent():GetBottom() )



local tNewScale = cx / self:GetParent():GetWidth()
local tx, ty = self:GetParent().x / tNewScale, self:GetParent().y / tNewScale
local newScale = self:GetParent():GetScale() * tNewScale;

if (newScale > 0) then
self:GetParent():ClearAllPoints()
self:GetParent():SetScale(self:GetParent():GetScale() * tNewScale)
self:GetParent():SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", tx, ty)
self:GetParent().x, self:GetParent().y = tx, ty
local finalScale = self:GetParent():GetScale() * tNewScale;
if(finalScale > 0.5) then
self:GetParent():ClearAllPoints()
self:GetParent():SetScale(self:GetParent():GetScale() * tNewScale)
self:GetParent():SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", tx, ty)
self:GetParent().x, self:GetParent().y = tx, ty
end
end
end
end
Expand All @@ -94,6 +99,10 @@ function OnMouseDown(self, button)
self:GetParent():SetHeight(147)
end

-- Fix a bug if you click too much in the scale button
self:GetParent():StartMoving()
self:GetParent():StopMovingOrSizing()

if button == "LeftButton" then
self.isSizing = true
self:GetParent():StartSizing("BOTTOMRIGHT")
Expand Down
2 changes: 1 addition & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ function core:Init(event, name)
end


CreateFrame("Frame", "TodoChecklister", events, "TodoChecklisterTemplate");
core.mainFrame = CreateFrame("Frame", "TodoChecklister", events, "TodoChecklisterTemplate");
end
events:SetScript("OnEvent", core.Init);

0 comments on commit e77a951

Please sign in to comment.