-
Notifications
You must be signed in to change notification settings - Fork 609
Imagebox: add proper svg resizing #3802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,6 +182,9 @@ function imagebox:draw(ctx, cr, width, height) | |
|
||
local w, h = self._private.default.width, self._private.default.height | ||
|
||
local RsvgRect = Rsvg.Rectangle {x = 0, y = 0, width = w, height = h} | ||
local svg_surf = cairo.ImageSurface(cairo.Format.ARGB32, w, h) | ||
|
||
if self._private.resize then | ||
-- That's for the "fit" policy. | ||
local aspects = { | ||
|
@@ -233,7 +236,12 @@ 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 | ||
RsvgRect = Rsvg.Rectangle {x = 0, y = 0, width = w*aspects.w, height = h*aspects.h } | ||
svg_surf = cairo.ImageSurface(cairo.Format.ARGB32, w*aspects.w, h*aspects.h) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the stacktrace from the failed test actually pointing to this line, but anyway you got the idea :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you marked thread as resolved but test is still failing on this line: https://github.com/awesomeWM/awesome/actions/runs/6042238743/job/16477140356?pr=3802 |
||
else | ||
cr:scale(aspects.w, aspects.h) | ||
end | ||
else | ||
if self._private.halign == "center" then | ||
translate.x = math.floor((width - w)/2) | ||
|
@@ -256,7 +264,8 @@ function imagebox:draw(ctx, cr, width, height) | |
end | ||
|
||
if self._private.handle then | ||
self._private.handle:render_cairo(cr) | ||
cr:set_source_surface(svg_surf, 0, 0) | ||
Elv13 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self._private.handle:render_document(cr, RsvgRect) | ||
else | ||
cr:set_source_surface(self._private.image, 0, 0) | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.