widget: Add proper accessors for the 'opacity' property
To avoid collision with the property system and comply with the API guidelines.
This commit is contained in:
parent
eb79b3262d
commit
542070205f
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue