mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-01-04 14:30:21 +01:00
desktop-shell: Add scale-fit background type
It is similar to scale-crop but fits to the output so that the image does not get cropped. Signed-off-by: Jaeyoon Jung <jaeyoon.jung@lge.com>
This commit is contained in:
parent
683eabb61e
commit
e91252a943
2 changed files with 11 additions and 3 deletions
|
|
@ -777,6 +777,7 @@ panel_add_launcher(struct panel *panel, const char *icon, const char *path, cons
|
||||||
enum {
|
enum {
|
||||||
BACKGROUND_SCALE,
|
BACKGROUND_SCALE,
|
||||||
BACKGROUND_SCALE_CROP,
|
BACKGROUND_SCALE_CROP,
|
||||||
|
BACKGROUND_SCALE_FIT,
|
||||||
BACKGROUND_TILE,
|
BACKGROUND_TILE,
|
||||||
BACKGROUND_CENTERED
|
BACKGROUND_CENTERED
|
||||||
};
|
};
|
||||||
|
|
@ -830,7 +831,11 @@ background_draw(struct widget *widget, void *data)
|
||||||
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_PAD);
|
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_PAD);
|
||||||
break;
|
break;
|
||||||
case BACKGROUND_SCALE_CROP:
|
case BACKGROUND_SCALE_CROP:
|
||||||
s = (sx < sy) ? sx : sy;
|
case BACKGROUND_SCALE_FIT:
|
||||||
|
if (background->type == BACKGROUND_SCALE_CROP)
|
||||||
|
s = (sx < sy) ? sx : sy;
|
||||||
|
else
|
||||||
|
s = (sx > sy) ? sx : sy;
|
||||||
/* align center */
|
/* align center */
|
||||||
tx = (im_w - s * allocation.width) * 0.5;
|
tx = (im_w - s * allocation.width) * 0.5;
|
||||||
ty = (im_h - s * allocation.height) * 0.5;
|
ty = (im_h - s * allocation.height) * 0.5;
|
||||||
|
|
@ -1206,6 +1211,8 @@ background_create(struct desktop *desktop, struct output *output)
|
||||||
background->type = BACKGROUND_SCALE;
|
background->type = BACKGROUND_SCALE;
|
||||||
} else if (strcmp(type, "scale-crop") == 0) {
|
} else if (strcmp(type, "scale-crop") == 0) {
|
||||||
background->type = BACKGROUND_SCALE_CROP;
|
background->type = BACKGROUND_SCALE_CROP;
|
||||||
|
} else if (strcmp(type, "scale-fit") == 0) {
|
||||||
|
background->type = BACKGROUND_SCALE_FIT;
|
||||||
} else if (strcmp(type, "tile") == 0) {
|
} else if (strcmp(type, "tile") == 0) {
|
||||||
background->type = BACKGROUND_TILE;
|
background->type = BACKGROUND_TILE;
|
||||||
} else if (strcmp(type, "centered") == 0) {
|
} else if (strcmp(type, "centered") == 0) {
|
||||||
|
|
|
||||||
|
|
@ -398,7 +398,7 @@ sets the path for the background image file (string).
|
||||||
.TP 7
|
.TP 7
|
||||||
.BI "background-type=" tile
|
.BI "background-type=" tile
|
||||||
determines how the background image is drawn (string). Can be
|
determines how the background image is drawn (string). Can be
|
||||||
.BR centered ", " scale ", " scale-crop " or " tile " (default)."
|
.BR centered ", " scale ", " scale-crop ", " scale-fit " or " tile " (default)."
|
||||||
Centered shows the image once centered. If the image is smaller than the
|
Centered shows the image once centered. If the image is smaller than the
|
||||||
output, the rest of the surface will be in background color. If the image
|
output, the rest of the surface will be in background color. If the image
|
||||||
size does fit the output it will be cropped left and right, or top and bottom.
|
size does fit the output it will be cropped left and right, or top and bottom.
|
||||||
|
|
@ -406,7 +406,8 @@ Scale means scaled to fit the output precisely, not preserving aspect ratio.
|
||||||
Scale-crop preserves aspect ratio, scales the background image just big
|
Scale-crop preserves aspect ratio, scales the background image just big
|
||||||
enough to cover the output, and centers it. The image ends up cropped from
|
enough to cover the output, and centers it. The image ends up cropped from
|
||||||
left and right, or top and bottom, if the aspect ratio does not match the
|
left and right, or top and bottom, if the aspect ratio does not match the
|
||||||
output. Tile repeats the background image to fill the output.
|
output. Scale-fit is similar to scale-crop but it fits to the output so the
|
||||||
|
image does not get cropped. Tile repeats the background image to fill the output.
|
||||||
.TP 7
|
.TP 7
|
||||||
.BI "background-color=" 0xRRGGBB
|
.BI "background-color=" 0xRRGGBB
|
||||||
sets the color of the background (unsigned integer). The hexadecimal
|
sets the color of the background (unsigned integer). The hexadecimal
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue