From c0eabf9d8f85e90fca9c5657e34e05f63c514319 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 26 May 2016 14:25:07 -0400 Subject: [PATCH] widget: Move 'visible' into _private --- lib/awful/menu.lua | 4 ++-- lib/wibox/container/background.lua | 4 ++-- lib/wibox/container/rotate.lua | 2 +- lib/wibox/hierarchy.lua | 2 +- lib/wibox/widget/base.lua | 17 ++++++++++++----- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/awful/menu.lua b/lib/awful/menu.lua index 663b7704..4fff3df9 100644 --- a/lib/awful/menu.lua +++ b/lib/awful/menu.lua @@ -249,7 +249,7 @@ function menu:exec(num, opts) self.active_child:hide() end 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() end elseif type(cmd) == "string" then @@ -431,7 +431,7 @@ function menu:delete(num) local item = self.items[num] if not item then return end item.widget:disconnect_signal("mouse::enter", item._mouse) - item.widget.visible = false + item.widget:set_visible(false) table.remove(self.items, num) if self.sel == num then self:item_leave(self.sel) diff --git a/lib/wibox/container/background.lua b/lib/wibox/container/background.lua index da1d64f6..d16c7c31 100644 --- a/lib/wibox/container/background.lua +++ b/lib/wibox/container/background.lua @@ -22,7 +22,7 @@ local background = { mt = {} } -- Draw this widget 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 end @@ -167,7 +167,7 @@ function background:get_fg() return self._private.foreground end ---- The background shape. +--- The background shap e. -- -- Use `set_shape` to set additional shape paramaters. -- diff --git a/lib/wibox/container/rotate.lua b/lib/wibox/container/rotate.lua index 48e2a980..08d42e04 100644 --- a/lib/wibox/container/rotate.lua +++ b/lib/wibox/container/rotate.lua @@ -29,7 +29,7 @@ end -- Layout this layout 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 end diff --git a/lib/wibox/hierarchy.lua b/lib/wibox/hierarchy.lua index bbf961af..6ef800af 100644 --- a/lib/wibox/hierarchy.lua +++ b/lib/wibox/hierarchy.lua @@ -259,7 +259,7 @@ end -- @param cr The cairo context that is used for drawing. function hierarchy:draw(context, cr) local widget = self:get_widget() - if not widget.visible then + if not widget._private.visible then return end diff --git a/lib/wibox/widget/base.lua b/lib/wibox/widget/base.lua index 887bfd6d..ae023191 100644 --- a/lib/wibox/widget/base.lua +++ b/lib/wibox/widget/base.lua @@ -37,14 +37,21 @@ end -- @tparam boolean b Wether the widget is visible at all -- @function set_visible function base.widget:set_visible(b) - if b ~= self.visible then - self.visible = b + if b ~= self._private.visible then + self._private.visible = b self:emit_signal("widget::layout_changed") -- In case something ignored fit and drew the widget anyway self:emit_signal("widget::redraw_needed") 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 -- @tparam number o The opacity to use (a number from 0 to 1). 0 is fully -- transparent while 1 is fully opaque. @@ -221,7 +228,7 @@ end function base.fit_widget(parent, context, widget, width, height) record_dependency(parent, widget) - if not widget.visible then + if not widget._private.visible then return 0, 0 end @@ -266,7 +273,7 @@ end function base.layout_widget(parent, context, widget, width, height) record_dependency(parent, widget) - if not widget.visible then + if not widget._private.visible then return end @@ -539,7 +546,7 @@ function base.make_widget(proxy, widget_name, args) ret._private.widget_buttons = {} -- Widget is visible - ret.visible = true + ret._private.visible = true -- Widget is fully opaque ret._private.opacity = 1