struct lab_img *img;
int width;
int height;
- int padding;
};
/*
* free to destroy it.
*/
struct scaled_img_buffer *scaled_img_buffer_create(struct wlr_scene_tree *parent,
- struct lab_img *img, int width, int height, int padding);
+ struct lab_img *img, int width, int height);
-/* Update image, width, height and padding of the scaled_img_buffer */
+/* Update image, width and height of the scaled_img_buffer */
void scaled_img_buffer_update(struct scaled_img_buffer *self,
- struct lab_img *img, int width, int height, int padding);
+ struct lab_img *img, int width, int height);
/* Obtain scaled_img_buffer from wlr_scene_node */
struct scaled_img_buffer *scaled_img_buffer_from_node(struct wlr_scene_node *node);
RsvgHandle *img_svg_load(const char *filename);
struct lab_data_buffer *img_svg_render(RsvgHandle *svg, int w, int h,
- int padding, double scale);
+ double scale);
#endif /* LABWC_IMG_SVG_H */
* @img: source image
* @width: width of the created buffer
* @height: height of the created buffer
- * @padding_x: horizontal padding around the rendered image in the buffer
* @scale: scale of the created buffer
*/
struct lab_data_buffer *lab_img_render(struct lab_img *img,
- int width, int height, int padding_x, double scale);
+ int width, int height, double scale);
/**
* lab_img_destroy() - destroy lab_img
{
struct scaled_img_buffer *self = scaled_buffer->data;
struct lab_data_buffer *buffer = lab_img_render(self->img,
- self->width, self->height, self->padding, scale);
+ self->width, self->height, scale);
return buffer;
}
return lab_img_equal(a->img, b->img)
&& a->width == b->width
- && a->height == b->height
- && a->padding == b->padding;
+ && a->height == b->height;
}
static struct scaled_scene_buffer_impl impl = {
struct scaled_img_buffer *
scaled_img_buffer_create(struct wlr_scene_tree *parent, struct lab_img *img,
- int width, int height, int padding)
+ int width, int height)
{
assert(img);
struct scaled_scene_buffer *scaled_buffer = scaled_scene_buffer_create(
self->img = lab_img_copy(img);
self->width = width;
self->height = height;
- self->padding = padding;
scaled_buffer->data = self;
void
scaled_img_buffer_update(struct scaled_img_buffer *self, struct lab_img *img,
- int width, int height, int padding)
+ int width, int height)
{
assert(img);
lab_img_destroy(self->img);
self->img = lab_img_copy(img);
self->width = width;
self->height = height;
- self->padding = padding;
scaled_scene_buffer_request_update(self->scaled_buffer, width, height);
}
}
struct lab_data_buffer *
-img_svg_render(RsvgHandle *svg, int w, int h, int padding_x, double scale)
+img_svg_render(RsvgHandle *svg, int w, int h, double scale)
{
struct lab_data_buffer *buffer = buffer_create_cairo(w, h, scale);
cairo_surface_t *image = buffer->surface;
GError *err = NULL;
RsvgRectangle viewport = {
- .x = padding_x,
- .y = 0,
- .width = w - 2 * padding_x,
+ .width = w,
.height = h,
};
rsvg_handle_render_document(svg, cr, &viewport, &err);
*/
static struct lab_data_buffer *
render_cairo_surface(cairo_surface_t *surface, int width, int height,
- int padding_x, double scale)
+ double scale)
{
assert(surface);
int src_w = cairo_image_surface_get_width(surface);
cairo_t *cairo = cairo_create(buffer->surface);
struct wlr_box container = {
- .x = padding_x,
- .y = 0,
- .width = width - 2 * padding_x,
+ .width = width,
.height = height,
};
}
struct lab_data_buffer *
-lab_img_render(struct lab_img *img, int width, int height, int padding,
- double scale)
+lab_img_render(struct lab_img *img, int width, int height, double scale)
{
struct lab_data_buffer *buffer = NULL;
case LAB_IMG_XBM:
case LAB_IMG_XPM:
buffer = render_cairo_surface(img->data->buffer->surface,
- width, height, padding, scale);
+ width, height, scale);
break;
#if HAVE_RSVG
case LAB_IMG_SVG:
buffer = img_svg_render(img->data->svg, width, height,
- padding, scale);
+ scale);
break;
#endif
default:
struct ssd_part *icon_part = add_scene_part(part_list, type);
struct scaled_img_buffer *img_buffer = scaled_img_buffer_create(
parent, imgs[state_set], rc.theme->window_button_width,
- rc.theme->window_button_height, /* padding_x */ 0);
+ rc.theme->window_button_height);
assert(img_buffer);
icon_part->node = &img_buffer->scene_buffer->node;
wlr_scene_node_set_enabled(icon_part->node, false);
struct scaled_img_buffer *img_buffer =
scaled_img_buffer_from_node(node);
scaled_img_buffer_update(img_buffer, icon_img,
- theme->window_button_width,
- theme->window_button_height,
- icon_padding);
+ theme->window_button_width - 2 * icon_padding,
+ theme->window_button_height);
+ wlr_scene_node_set_position(node, icon_padding, 0);
}
}
} FOR_EACH_END