Skip to content

Commit a44bd32

Browse files
Rene KievitsElv13
authored andcommitted
Imagebox: add proper svg resizing
1 parent cb72c0a commit a44bd32

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lib/wibox/widget/imagebox.lua

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,16 @@ function imagebox:draw(ctx, cr, width, height)
233233
cr:clip(self._private.clip_shape(cr, w*aspects.w, h*aspects.h, unpack(self._private.clip_args)))
234234
end
235235

236-
cr:scale(aspects.w, aspects.h)
236+
if self._private.handle then
237+
self._private.handle:render_document(cr, Rsvg.Rectangle {
238+
x = 0,
239+
y = 0,
240+
width = w * aspects.w,
241+
height = h * aspects.h
242+
})
243+
else
244+
cr:scale(aspects.w, aspects.h)
245+
end
237246
else
238247
if self._private.halign == "center" then
239248
translate.x = math.floor((width - w)/2)
@@ -253,11 +262,13 @@ function imagebox:draw(ctx, cr, width, height)
253262
if self._private.clip_shape then
254263
cr:clip(self._private.clip_shape(cr, w, h, unpack(self._private.clip_args)))
255264
end
265+
266+
if self._private.handle then
267+
self._private.handle:render_document(cr, Rsvg.Rectangle {x = 0, y = 0, width = w, height = h})
268+
end
256269
end
257270

258-
if self._private.handle then
259-
self._private.handle:render_cairo(cr)
260-
else
271+
if not self._private.handle then
261272
cr:set_source_surface(self._private.image, 0, 0)
262273

263274
local filter = self._private.scaling_quality

0 commit comments

Comments
 (0)