local Prop = require("gfx.prop") local Visibility = Prop:new{ defaultState = true, uid = "VISIBILITY" } Visibility.VISIBLE = true Visibility.INVISIBLE = not Visibility.VISIBLE function Visibility:with(elementType) local propSelf = self local defaultDraw = elementType.draw local defaultHandleEvent = elementType.handleEvent function elementType:isVisible() return propSelf:getState(self) end function elementType:setVisible(visibility) return propSelf:setState(self, visibility) end function elementType:draw() if self:isVisible() then return defaultDraw(self) end return false end -- Ignore events when invisible function elementType:handleEvent(evt) if self:isVisible() then return defaultHandleEvent(self, evt) end return false end return elementType end return Visibility