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:
parent
ab121e9ac0
commit
e23940cc6a
|
@ -362,6 +362,28 @@ end
|
||||||
-- @tparam[opt=nil] image|nil image
|
-- @tparam[opt=nil] image|nil image
|
||||||
-- @propemits false false
|
-- @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.
|
--- Set the `imagebox` image.
|
||||||
--
|
--
|
||||||
-- The image can be a file, a cairo image surface, or an rsvg handle object
|
-- 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
|
return true
|
||||||
end
|
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.
|
--- Set a clip shape for this imagebox.
|
||||||
--
|
--
|
||||||
-- A clip shape defines an area and dimension to which the content should be
|
-- A clip shape defines an area and dimension to which the content should be
|
||||||
|
|
Loading…
Reference in New Issue