mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
implemented moveable option for windows
This commit is contained in:
parent
b7ec6cc77f
commit
5a6891ea7d
@ -155,6 +155,9 @@ do
|
||||
if self.data.titleBar == nil then
|
||||
self.data.titleBar = true
|
||||
end
|
||||
if self.data.moveable == nil then
|
||||
self.data.moveable = true
|
||||
end
|
||||
if self.data.maximizeable == nil then
|
||||
self.data.maximizeable = false
|
||||
end
|
||||
@ -315,7 +318,7 @@ do
|
||||
return false
|
||||
end
|
||||
self.header.mousepressed = function(self, x, y, button)
|
||||
if button == pop.constants.left_mouse then
|
||||
if self.data.moveable and button == pop.constants.left_mouse then
|
||||
local grandparent = self.parent.parent
|
||||
table.insert(grandparent.child, table.remove(grandparent.child, grandparent:indexOf(self.parent)))
|
||||
selected = true
|
||||
@ -328,7 +331,9 @@ do
|
||||
self.header.mousereleased = function(self, x, y, button)
|
||||
if button == pop.constants.left_mouse then
|
||||
selected = false
|
||||
pop.focused = false
|
||||
if self == pop.focused then
|
||||
pop.focused = false
|
||||
end
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
@ -38,6 +38,7 @@ class window extends element
|
||||
|
||||
@data.maximized = false
|
||||
@data.titleBar = true if @data.titleBar == nil
|
||||
@data.moveable = true if @data.moveable == nil
|
||||
@data.maximizeable = false if @data.maximizeable == nil
|
||||
@data.minimizeable = false if @data.minimizeable == nil
|
||||
@data.closeable = false if @data.closeable == nil
|
||||
@ -86,7 +87,7 @@ class window extends element
|
||||
@window_area.data.w = @data.w - @data.padding*2
|
||||
@window_area.data.h = @data.h - @data.padding*2
|
||||
|
||||
-- window area steals mouse events to prevent propagation to elements under it
|
||||
-- window area steals mouse events to prevent propagation to elements visibily underneath it (not within its hierarchy)
|
||||
@window_area.mousepressed = (x, y, button) =>
|
||||
if button == pop.constants.left_mouse
|
||||
grandparent = @parent.parent
|
||||
@ -142,7 +143,7 @@ class window extends element
|
||||
return false
|
||||
|
||||
@header.mousepressed = (x, y, button) =>
|
||||
if button == pop.constants.left_mouse
|
||||
if @data.moveable and button == pop.constants.left_mouse
|
||||
grandparent = @parent.parent
|
||||
table.insert grandparent.child, table.remove(grandparent.child, grandparent\indexOf @parent)
|
||||
selected = true
|
||||
@ -154,7 +155,8 @@ class window extends element
|
||||
@header.mousereleased = (x, y, button) =>
|
||||
if button == pop.constants.left_mouse
|
||||
selected = false
|
||||
pop.focused = false -- maybe it should check if it is focused first?
|
||||
if @ == pop.focused
|
||||
pop.focused = false
|
||||
return true
|
||||
return false
|
||||
|
||||
|
3
main.lua
3
main.lua
@ -20,6 +20,9 @@ love.load = function()
|
||||
pop.window({
|
||||
maximizeable = true
|
||||
}, "Test Window #2"):align("center", "bottom")
|
||||
pop.window({
|
||||
moveable = false
|
||||
}, "Immoveable!")
|
||||
local centerBox = pop.box({
|
||||
w = 200,
|
||||
h = 200
|
||||
|
@ -14,6 +14,7 @@ love.load = ->
|
||||
print testWindow.window_area
|
||||
|
||||
pop.window({maximizeable: true}, "Test Window #2")\align "center", "bottom"
|
||||
pop.window({moveable: false}, "Immoveable!")
|
||||
|
||||
-- alignment testing
|
||||
centerBox = pop.box({w: 200, h: 200}, {255, 255, 0, 120})\align "center", "center"
|
||||
|
Loading…
Reference in New Issue
Block a user