imagebox: Expose the "optimal size" properties.

The `textbox` already has the equivalent. This will soon be used
by the new `wibox.container.border` widget.
This commit is contained in:
Emmanuel Lepage Vallee 2022-01-05 11:40:28 -08:00
parent ab121e9ac0
commit e23940cc6a
1 changed files with 30 additions and 0 deletions

View File

@ -362,6 +362,28 @@ end
-- @tparam[opt=nil] image|nil image
-- @propemits false false
--- Return the source image width.
--
-- For SVG images, this may be affected by the DPI and might not
-- reflect the size the images will be rendered at. For PNG or
-- JPG images, this will return the file resolution.
--
-- @property source_width
-- @tparam number source_width
-- @see image
-- @see source_height
--- Return the source image height.
--
-- For SVG images, this may be affected by the DPI and might not
-- reflect the size the images will be rendered at. For PNG or
-- JPG images, this will return the file resolution.
--
-- @property source_height
-- @tparam number source_height
-- @see image
-- @see source_width
--- Set the `imagebox` image.
--
-- The image can be a file, a cairo image surface, or an rsvg handle object
@ -417,6 +439,14 @@ function imagebox:set_image(image)
return true
end
for _, dim in ipairs { "width", "height" } do
imagebox["get_source_"..dim] = function(self)
if not self._private.default then return nil end
return self._private.default[dim]
end
end
--- Set a clip shape for this imagebox.
--
-- A clip shape defines an area and dimension to which the content should be