From 61f126cd620038761ec00d90cbb79f7800800af2 Mon Sep 17 00:00:00 2001 From: Paul Liverman III Date: Wed, 27 Apr 2016 12:30:55 -0700 Subject: [PATCH] close #32 #33 excludeDraw / excludeMovement stuff --- demo/pop/elements/element.lua | 17 +++++++++++++++++ demo/pop/extensions/streamlined_get_set.lua | 20 ++++++++++++++++++++ lib/pop/elements/element.lua | 17 +++++++++++++++++ lib/pop/extensions/streamlined_get_set.lua | 20 ++++++++++++++++++++ src/pop/elements/element.moon | 18 ++++++++++++++++++ src/pop/extensions/streamlined_get_set.moon | 18 ++++++++++++++++++ 6 files changed, 110 insertions(+) diff --git a/demo/pop/elements/element.lua b/demo/pop/elements/element.lua index 169f88c..0532455 100644 --- a/demo/pop/elements/element.lua +++ b/demo/pop/elements/element.lua @@ -243,6 +243,20 @@ do self.parent:removeChild(self) self = nil return nil + end, + getVisibility = function(self) + return (not self.excludeDraw) + end, + setVisibility = function(self, isVisible) + self.excludeDraw = (not isVisible) + return self + end, + getStatic = function(self) + return self.excludeMovement + end, + setStatic = function(self, isStatic) + self.excludeMovement = isStatic + return self end } _base_0.__index = _base_0 @@ -262,6 +276,9 @@ do end self.horizontal = "left" self.vertical = "top" + self.excludeDraw = false + self.excludeUpdate = false + self.excludeMovement = false end, __base = _base_0, __name = "element" diff --git a/demo/pop/extensions/streamlined_get_set.lua b/demo/pop/extensions/streamlined_get_set.lua index 9efff1e..c958a9b 100644 --- a/demo/pop/extensions/streamlined_get_set.lua +++ b/demo/pop/extensions/streamlined_get_set.lua @@ -52,6 +52,26 @@ element.__base.margin = function(self, m) end end element.__base.resize = element.__base.adjustSize +element.__base.visibility = function(self, v) + if v ~= nil then + return self:setVisibility(v) + else + return self:getVisibility() + end +end +element.__base.show = function(self) + return self:setVisibility(true) +end +element.__base.hide = function(self) + return self:setVisibility(false) +end +element.__base.static = function(self, s) + if s ~= nil then + return self:setStatic(s) + else + return self:getStatic() + end +end box.__base.color = function(self, r, g, b, a) if r or g or b or a then return self:setColor(r, g, b, a) diff --git a/lib/pop/elements/element.lua b/lib/pop/elements/element.lua index 169f88c..0532455 100644 --- a/lib/pop/elements/element.lua +++ b/lib/pop/elements/element.lua @@ -243,6 +243,20 @@ do self.parent:removeChild(self) self = nil return nil + end, + getVisibility = function(self) + return (not self.excludeDraw) + end, + setVisibility = function(self, isVisible) + self.excludeDraw = (not isVisible) + return self + end, + getStatic = function(self) + return self.excludeMovement + end, + setStatic = function(self, isStatic) + self.excludeMovement = isStatic + return self end } _base_0.__index = _base_0 @@ -262,6 +276,9 @@ do end self.horizontal = "left" self.vertical = "top" + self.excludeDraw = false + self.excludeUpdate = false + self.excludeMovement = false end, __base = _base_0, __name = "element" diff --git a/lib/pop/extensions/streamlined_get_set.lua b/lib/pop/extensions/streamlined_get_set.lua index 9efff1e..c958a9b 100644 --- a/lib/pop/extensions/streamlined_get_set.lua +++ b/lib/pop/extensions/streamlined_get_set.lua @@ -52,6 +52,26 @@ element.__base.margin = function(self, m) end end element.__base.resize = element.__base.adjustSize +element.__base.visibility = function(self, v) + if v ~= nil then + return self:setVisibility(v) + else + return self:getVisibility() + end +end +element.__base.show = function(self) + return self:setVisibility(true) +end +element.__base.hide = function(self) + return self:setVisibility(false) +end +element.__base.static = function(self, s) + if s ~= nil then + return self:setStatic(s) + else + return self:getStatic() + end +end box.__base.color = function(self, r, g, b, a) if r or g or b or a then return self:setColor(r, g, b, a) diff --git a/src/pop/elements/element.moon b/src/pop/elements/element.moon index 26a606b..0dd7023 100644 --- a/src/pop/elements/element.moon +++ b/src/pop/elements/element.moon @@ -28,6 +28,10 @@ class element @horizontal = "left" @vertical = "top" + @excludeDraw = false + @excludeUpdate = false + @excludeMovement = false + debugDraw: => graphics.setLineWidth 0.5 graphics.setColor 0, 0, 0, 100 @@ -267,3 +271,17 @@ class element @parent\removeChild @ @ = nil return nil + + getVisibility: => + return (not @excludeDraw) + + setVisibility: (isVisible) => + @excludeDraw = (not isVisible) + return @ + + getStatic: => + return @excludeMovement + + setStatic: (isStatic) => + @excludeMovement = isStatic + return @ diff --git a/src/pop/extensions/streamlined_get_set.moon b/src/pop/extensions/streamlined_get_set.moon index 0593142..0e8353c 100644 --- a/src/pop/extensions/streamlined_get_set.moon +++ b/src/pop/extensions/streamlined_get_set.moon @@ -47,6 +47,24 @@ element.__base.margin = (m) => element.__base.resize = element.__base.adjustSize +element.__base.visibility = (v) => + if v != nil + return @setVisibility v + else + return @getVisibility! + +element.__base.show = => + return @setVisibility true + +element.__base.hide = => + return @setVisibility false + +element.__base.static = (s) => + if s != nil + return @setStatic s + else + return @getStatic! + -- box.__base.background -- can't be done! box.__base.color = (r, g, b, a) =>