mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
fixed close buttons
This commit is contained in:
parent
16b9d28973
commit
e54fe6cb43
@ -43,7 +43,6 @@ function love.load()
|
||||
w2:setClose(false)
|
||||
local t2 = pop.text("Click here to toggle close\nbutton on this window."):setMargin(10):setColor(0,0,0)
|
||||
t2.clicked = function()
|
||||
print("CALLED") --NOTE not working!
|
||||
w2:setClose(not w2:hasClose())
|
||||
return true
|
||||
end
|
||||
@ -106,6 +105,11 @@ function love.keypressed(key)
|
||||
debugDraw = not debugDraw
|
||||
end
|
||||
|
||||
if (key == "w") and (not handled) then
|
||||
local w = pop.window()
|
||||
w.title:align("center")
|
||||
end
|
||||
|
||||
if (key == "escape") and (not handled) then
|
||||
love.event.quit()
|
||||
end
|
||||
|
@ -17,12 +17,7 @@ local path = sub(..., 1, len(...) - len("/window"))
|
||||
local element = require(tostring(path) .. "/element")
|
||||
local box = require(tostring(path) .. "/box")
|
||||
local text = require(tostring(path) .. "/text")
|
||||
local closeImage = {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
80
|
||||
}
|
||||
local closeImage = graphics.newImage(tostring(path) .. "/img/close.png")
|
||||
local left = 1
|
||||
local mousemoved_event = true
|
||||
do
|
||||
@ -196,6 +191,10 @@ do
|
||||
setClose = function(self, enabled)
|
||||
if enabled then
|
||||
self.close = box(self, closeImage)
|
||||
self.close.clicked = function()
|
||||
self:delete()
|
||||
return true
|
||||
end
|
||||
local height = self.head:getHeight()
|
||||
self.close:align("right"):setSize(height, height)
|
||||
self.head:setWidth(self.w - height)
|
||||
@ -250,7 +249,7 @@ do
|
||||
end
|
||||
_class_0.__parent.__init(self, parent)
|
||||
self.head = box(self, tBackground)
|
||||
self.title = text(self, title, tColor)
|
||||
self.title = text(self.head, title, tColor)
|
||||
self.window = box(self, wBackground)
|
||||
self.close = box(self, closeImage)
|
||||
local height = self.title:getHeight()
|
||||
@ -266,7 +265,6 @@ do
|
||||
}
|
||||
self.titleOverflow = "trunicate"
|
||||
self.close.clicked = function()
|
||||
print("CLOSE WAS CLICKED")
|
||||
self:delete()
|
||||
return true
|
||||
end
|
||||
|
@ -17,12 +17,7 @@ local path = sub(..., 1, len(...) - len("/window"))
|
||||
local element = require(tostring(path) .. "/element")
|
||||
local box = require(tostring(path) .. "/box")
|
||||
local text = require(tostring(path) .. "/text")
|
||||
local closeImage = {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
80
|
||||
}
|
||||
local closeImage = graphics.newImage(tostring(path) .. "/img/close.png")
|
||||
local left = 1
|
||||
local mousemoved_event = true
|
||||
do
|
||||
@ -196,6 +191,10 @@ do
|
||||
setClose = function(self, enabled)
|
||||
if enabled then
|
||||
self.close = box(self, closeImage)
|
||||
self.close.clicked = function()
|
||||
self:delete()
|
||||
return true
|
||||
end
|
||||
local height = self.head:getHeight()
|
||||
self.close:align("right"):setSize(height, height)
|
||||
self.head:setWidth(self.w - height)
|
||||
@ -250,7 +249,7 @@ do
|
||||
end
|
||||
_class_0.__parent.__init(self, parent)
|
||||
self.head = box(self, tBackground)
|
||||
self.title = text(self, title, tColor)
|
||||
self.title = text(self.head, title, tColor)
|
||||
self.window = box(self, wBackground)
|
||||
self.close = box(self, closeImage)
|
||||
local height = self.title:getHeight()
|
||||
@ -266,7 +265,6 @@ do
|
||||
}
|
||||
self.titleOverflow = "trunicate"
|
||||
self.close.clicked = function()
|
||||
print("CLOSE WAS CLICKED")
|
||||
self:delete()
|
||||
return true
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ element = require "#{path}/element"
|
||||
box = require "#{path}/box"
|
||||
text = require "#{path}/text"
|
||||
|
||||
closeImage = {100, 0, 0, 80} --graphics.newImage "#{path}/img/close.png"
|
||||
closeImage = graphics.newImage "#{path}/img/close.png"
|
||||
|
||||
-- version compatibility
|
||||
left = 1 -- what is the left mouse button?
|
||||
@ -34,10 +34,11 @@ class window extends element
|
||||
new: (parent, title="window", tBackground={25, 180, 230, 255}, tColor={255, 255, 255, 255}, wBackground={200, 200, 210, 255}) =>
|
||||
super parent
|
||||
|
||||
@head = box @, tBackground -- title box at top
|
||||
@title = text @, title, tColor -- text at top
|
||||
@window = box @, wBackground -- main window area
|
||||
@close = box @, closeImage -- close button
|
||||
-- NOTE @title having @head as its parent might break things horribly
|
||||
@head = box @, tBackground -- title box at top
|
||||
@title = text @head, title, tColor -- text at top
|
||||
@window = box @, wBackground -- main window area
|
||||
@close = box @, closeImage -- close button
|
||||
|
||||
-- correct placement / sizes of elements
|
||||
height = @title\getHeight!
|
||||
@ -55,7 +56,6 @@ class window extends element
|
||||
@titleOverflow = "trunicate" -- defaults to trunicating title to fit in window
|
||||
|
||||
@close.clicked = ->
|
||||
print "CLOSE WAS CLICKED"
|
||||
@delete!
|
||||
return true
|
||||
|
||||
@ -261,15 +261,18 @@ class window extends element
|
||||
setClose: (enabled) =>
|
||||
if enabled
|
||||
@close = box @, closeImage
|
||||
@close.clicked = ->
|
||||
@delete!
|
||||
return true
|
||||
height = @head\getHeight!
|
||||
@close\align("right")\setSize height, height
|
||||
@head\setWidth @w - height
|
||||
@title\align! -- new might not be working?
|
||||
@title\align!
|
||||
insert @child, @close
|
||||
else
|
||||
@close\delete!
|
||||
@head\setWidth @w
|
||||
@title\align! -- new might not be working?
|
||||
@title\align!
|
||||
@close = false
|
||||
|
||||
return @
|
||||
|
Loading…
Reference in New Issue
Block a user