Skip to content

Commit

Permalink
Imagebox: add proper svg resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
Rene Kievits authored and Elv13 committed Dec 31, 2023
1 parent cb72c0a commit a44bd32
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lib/wibox/widget/imagebox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,16 @@ function imagebox:draw(ctx, cr, width, height)
cr:clip(self._private.clip_shape(cr, w*aspects.w, h*aspects.h, unpack(self._private.clip_args)))
end

cr:scale(aspects.w, aspects.h)
if self._private.handle then
self._private.handle:render_document(cr, Rsvg.Rectangle {
x = 0,
y = 0,
width = w * aspects.w,
height = h * aspects.h
})
else
cr:scale(aspects.w, aspects.h)
end
else
if self._private.halign == "center" then
translate.x = math.floor((width - w)/2)
Expand All @@ -253,11 +262,13 @@ function imagebox:draw(ctx, cr, width, height)
if self._private.clip_shape then
cr:clip(self._private.clip_shape(cr, w, h, unpack(self._private.clip_args)))
end

if self._private.handle then
self._private.handle:render_document(cr, Rsvg.Rectangle {x = 0, y = 0, width = w, height = h})
end
end

if self._private.handle then
self._private.handle:render_cairo(cr)
else
if not self._private.handle then
cr:set_source_surface(self._private.image, 0, 0)

local filter = self._private.scaling_quality
Expand Down

0 comments on commit a44bd32

Please sign in to comment.