From 542070205f34b82c3eb57e178589d63d5be32f5b Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 26 May 2016 13:57:34 -0400 Subject: [PATCH] widget: Add proper accessors for the 'opacity' property To avoid collision with the property system and comply with the API guidelines. --- lib/wibox/hierarchy.lua | 2 +- lib/wibox/widget/base.lua | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/wibox/hierarchy.lua b/lib/wibox/hierarchy.lua index 5e6abc47..bbf961af 100644 --- a/lib/wibox/hierarchy.lua +++ b/lib/wibox/hierarchy.lua @@ -272,7 +272,7 @@ function hierarchy:draw(context, cr) -- Draw if needed if not empty_clip(cr) then - local opacity = widget.opacity + local opacity = widget:get_opacity() local function call(func, extra_arg1, extra_arg2) if not func then return end if not extra_arg2 then diff --git a/lib/wibox/widget/base.lua b/lib/wibox/widget/base.lua index a177bad4..04e16510 100644 --- a/lib/wibox/widget/base.lua +++ b/lib/wibox/widget/base.lua @@ -50,12 +50,19 @@ end -- transparent while 1 is fully opaque. -- @function set_opacity function base.widget:set_opacity(o) - if o ~= self.opacity then - self.opacity = o + if o ~= self._private.opacity then + self._private.opacity = o self:emit_signal("widget::redraw") end end +--- Get the widget opacity. +-- @treturn number The opacity (between 0 and 1) +-- @function get_opacity +function base.widget:get_opacity() + return self._private.opacity +end + --- Set the widget's width -- @tparam number|nil s The width that the widget has. `nil` means to apply the -- default mechanism of calling the `:fit` method. A number overrides the result @@ -535,7 +542,7 @@ function base.make_widget(proxy, widget_name, args) ret.visible = true -- Widget is fully opaque - ret.opacity = 1 + ret._private.opacity = 1 -- Differentiate tables from widgets rawset(ret, "is_widget", true)