mirror of
https://github.com/labwc/labwc.git
synced 2025-11-14 06:59:54 -05:00
img: remove padding_x from lab_img_render()
padding_x in lab_img_render() was just to make sure window icons in the titlebar doesn't get too close to adjacent buttons and it didn't felt clean. To remove it from lab_img, this commit changes the size of window icon buffers from (window.button.width)x(window.button.height) to (window.button.width * 0.8)x(window.button.height) and horizontally slide it by (window.button.width * 0.1) to keep the horizontal padding. Note that the size of the hitbox for a window icon is kept the same and nothing is changed from user's perspective.
This commit is contained in:
parent
a0cf6bb068
commit
45f73b58a1
8 changed files with 20 additions and 30 deletions
|
|
@ -36,7 +36,7 @@ img_svg_load(const char *filename)
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
@ -44,9 +44,7 @@ img_svg_render(RsvgHandle *svg, int w, int h, int padding_x, double scale)
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ lab_img_add_modifier(struct lab_img *img, lab_img_modifier_func_t modifier)
|
|||
*/
|
||||
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);
|
||||
|
|
@ -130,9 +130,7 @@ render_cairo_surface(cairo_surface_t *surface, int width, int height,
|
|||
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,
|
||||
};
|
||||
|
||||
|
|
@ -151,8 +149,7 @@ render_cairo_surface(cairo_surface_t *surface, int width, int 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;
|
||||
|
||||
|
|
@ -162,12 +159,12 @@ lab_img_render(struct lab_img *img, int width, int height, int padding,
|
|||
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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue