widget: Move 'visible' into _private

This commit is contained in:
Emmanuel Lepage Vallee 2016-05-26 14:25:07 -04:00
parent afa17fd8f9
commit c0eabf9d8f
5 changed files with 18 additions and 11 deletions

View file

@ -249,7 +249,7 @@ function menu:exec(num, opts)
self.active_child:hide() self.active_child:hide()
end end
self.active_child = self.child[num] self.active_child = self.child[num]
if not self.active_child.visible then if not self.active_child:get_visible() then
self.active_child:show() self.active_child:show()
end end
elseif type(cmd) == "string" then elseif type(cmd) == "string" then
@ -431,7 +431,7 @@ function menu:delete(num)
local item = self.items[num] local item = self.items[num]
if not item then return end if not item then return end
item.widget:disconnect_signal("mouse::enter", item._mouse) item.widget:disconnect_signal("mouse::enter", item._mouse)
item.widget.visible = false item.widget:set_visible(false)
table.remove(self.items, num) table.remove(self.items, num)
if self.sel == num then if self.sel == num then
self:item_leave(self.sel) self:item_leave(self.sel)

View file

@ -22,7 +22,7 @@ local background = { mt = {} }
-- Draw this widget -- Draw this widget
function background:draw(context, cr, width, height) function background:draw(context, cr, width, height)
if not self._private.widget or not self._private.widget.visible then if not self._private.widget or not self._private.widget:get_visible() then
return return
end end
@ -167,7 +167,7 @@ function background:get_fg()
return self._private.foreground return self._private.foreground
end end
--- The background shape. --- The background shap e.
-- --
-- Use `set_shape` to set additional shape paramaters. -- Use `set_shape` to set additional shape paramaters.
-- --

View file

@ -29,7 +29,7 @@ end
-- Layout this layout -- Layout this layout
function rotate:layout(_, width, height) function rotate:layout(_, width, height)
if not self.widget or not self.widget.visible then if not self.widget or not self.widget._private.visible then
return return
end end

View file

@ -259,7 +259,7 @@ end
-- @param cr The cairo context that is used for drawing. -- @param cr The cairo context that is used for drawing.
function hierarchy:draw(context, cr) function hierarchy:draw(context, cr)
local widget = self:get_widget() local widget = self:get_widget()
if not widget.visible then if not widget._private.visible then
return return
end end

View file

@ -37,14 +37,21 @@ end
-- @tparam boolean b Wether the widget is visible at all -- @tparam boolean b Wether the widget is visible at all
-- @function set_visible -- @function set_visible
function base.widget:set_visible(b) function base.widget:set_visible(b)
if b ~= self.visible then if b ~= self._private.visible then
self.visible = b self._private.visible = b
self:emit_signal("widget::layout_changed") self:emit_signal("widget::layout_changed")
-- In case something ignored fit and drew the widget anyway -- In case something ignored fit and drew the widget anyway
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
end end
end end
--- Get if the widget is visible.
-- @treturn boolean If the widget is visible
-- @function get_visible
function base.widget:get_visible()
return self._private.visible or false
end
--- Set a widget's opacity --- Set a widget's opacity
-- @tparam number o The opacity to use (a number from 0 to 1). 0 is fully -- @tparam number o The opacity to use (a number from 0 to 1). 0 is fully
-- transparent while 1 is fully opaque. -- transparent while 1 is fully opaque.
@ -221,7 +228,7 @@ end
function base.fit_widget(parent, context, widget, width, height) function base.fit_widget(parent, context, widget, width, height)
record_dependency(parent, widget) record_dependency(parent, widget)
if not widget.visible then if not widget._private.visible then
return 0, 0 return 0, 0
end end
@ -266,7 +273,7 @@ end
function base.layout_widget(parent, context, widget, width, height) function base.layout_widget(parent, context, widget, width, height)
record_dependency(parent, widget) record_dependency(parent, widget)
if not widget.visible then if not widget._private.visible then
return return
end end
@ -539,7 +546,7 @@ function base.make_widget(proxy, widget_name, args)
ret._private.widget_buttons = {} ret._private.widget_buttons = {}
-- Widget is visible -- Widget is visible
ret.visible = true ret._private.visible = true
-- Widget is fully opaque -- Widget is fully opaque
ret._private.opacity = 1 ret._private.opacity = 1