mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2025-12-20 04:40:07 +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 {
|
||||
BACKGROUND_SCALE,
|
||||
BACKGROUND_SCALE_CROP,
|
||||
BACKGROUND_SCALE_FIT,
|
||||
BACKGROUND_TILE,
|
||||
BACKGROUND_CENTERED
|
||||
};
|
||||
|
|
@ -830,7 +831,11 @@ background_draw(struct widget *widget, void *data)
|
|||
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_PAD);
|
||||
break;
|
||||
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 */
|
||||
tx = (im_w - s * allocation.width) * 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;
|
||||
} else if (strcmp(type, "scale-crop") == 0) {
|
||||
background->type = BACKGROUND_SCALE_CROP;
|
||||
} else if (strcmp(type, "scale-fit") == 0) {
|
||||
background->type = BACKGROUND_SCALE_FIT;
|
||||
} else if (strcmp(type, "tile") == 0) {
|
||||
background->type = BACKGROUND_TILE;
|
||||
} else if (strcmp(type, "centered") == 0) {
|
||||
|
|
|
|||
|
|
@ -398,7 +398,7 @@ sets the path for the background image file (string).
|
|||
.TP 7
|
||||
.BI "background-type=" tile
|
||||
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
|
||||
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.
|
||||
|
|
@ -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
|
||||
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
|
||||
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
|
||||
.BI "background-color=" 0xRRGGBB
|
||||
sets the color of the background (unsigned integer). The hexadecimal
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue