Skip to content

Commit

Permalink
[Window] Added showing of maximize button when window is minimized. I…
Browse files Browse the repository at this point in the history
…mproves #100
  • Loading branch information
flamendless committed Sep 27, 2021
1 parent d0b2175 commit b538e3d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Internal/UI/Window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ local function NewInstance(Id)
Instance.IsAppearing = false
Instance.IsOpen = true
Instance.IsContentOpen = true
Instance.IsMinimized = false
Instance.NoSavedSettings = false
return Instance
end
Expand Down Expand Up @@ -376,8 +377,10 @@ end
local function DrawButton(Type, ActiveInstance, Options, Radius, OffsetX, OffsetY, HoverColor, Color)
local IsClicked = false
local MouseX, MouseY = Mouse.Position()
local IsObstructed = Window.IsObstructed(MouseX, MouseY, true)
if Type == "Minimize" then
local IsObstructed
if Type == "Close" then
IsObstructed = Window.IsObstructed(MouseX, MouseY, true)
elseif Type == "Minimize" then
IsObstructed = false
end
local Size = Radius * 0.5
Expand All @@ -399,7 +402,11 @@ local function DrawButton(Type, ActiveInstance, Options, Radius, OffsetX, Offset
if Type == "Close" then
DrawCommands.Cross(X, Y, Size, Color)
elseif Type == "Minimize" then
DrawCommands.Line(X - Size, Y, X + Size, Y, Size, Color)
if ActiveInstance.IsMinimized then
DrawCommands.Rectangle("line", X - Size, Y - Size, Size * 2, Size * 2, Color)
else
DrawCommands.Line(X - Size, Y, X + Size, Y, Size, Color)
end
end

return IsClicked
Expand Down Expand Up @@ -718,6 +725,7 @@ function Window.Begin(Id, Options)
if IsClicked then
ActiveInstance.IsContentOpen = not ActiveInstance.IsContentOpen
ActiveInstance.IsMoving = false
ActiveInstance.IsMinimized = not ActiveInstance.IsMinimized
end
end

Expand Down

0 comments on commit b538e3d

Please sign in to comment.