Opened 15 years ago

Closed 14 years ago

#4720 closed enhancement (fixed)

Wallpapers should be able to fill & keep proper aspect ratio (easy)

Reported by: olaf Owned by: nobody
Priority: normal Milestone: R1
Component: Preferences/Backgrounds Version: R1/Development
Keywords: gsoc2010 Cc:
Blocked By: Blocking:
Platform: All

Description

The wallpapers configuration window should allow users to use a smaller or larger wallpaper and stretch it properly. Properly, as in, keep the aspect ratio in tact while filling the screen (cropping some of either the width or height to compensate).

Additionally, but not necessary, allow it to be repositioned as well after being fit to the screen.

Attachments (2)

wallpaper-fix.diff (2.2 KB ) - added by engleek 15 years ago.
Replacement for previous fix, with ratio comparing and obeying 80 chars style rule.
wallpaper-fix.2.diff (4.0 KB ) - added by engleek 15 years ago.
Third version, with three extra private methods to apply the 80 chars style rule in a nicer way and improve modularity. Hopefully this won't have too much of a negative impact on performance.

Download all attachments as: .zip

Change History (12)

comment:1 by korli, 15 years ago

Owner: changed from korli to nobody

comment:2 by stippi, 15 years ago

This patch is almost perfect. I think you need to compare aspect ratio of screen and bitmap in order to decide where to overlap. A bitmap may have to overlap at top/bottom OR left/right, depending on whether the aspect ratio is smaller or greater than the view aspect ratio, even though in both cases, the width may be greater than the height.

Other than that, the patch just needs to honor the 80 chars/line limit. :-)

by engleek, 15 years ago

Attachment: wallpaper-fix.diff added

Replacement for previous fix, with ratio comparing and obeying 80 chars style rule.

comment:3 by engleek, 15 years ago

I'm not entirely happy with what I did with the 80 chars style rule. I did my best to make it still kind of understandable, but it's a bit tricky. Any guidelines for this rule?

in reply to:  3 comment:4 by anevilyak, 15 years ago

Replying to engleek:

I'm not entirely happy with what I did with the 80 chars style rule. I did my best to make it still kind of understandable, but it's a bit tricky. Any guidelines for this rule?

In this instance it might make sense to break those calculations into their own functions, and call those from the switch cases, since they wouldn't be nested quite as heavily. Otherwise it might be prudent to just do the calculations in multiple steps instead of one giant statement as now.

by engleek, 15 years ago

Attachment: wallpaper-fix.2.diff added

Third version, with three extra private methods to apply the 80 chars style rule in a nicer way and improve modularity. Hopefully this won't have too much of a negative impact on performance.

comment:5 by mmadia, 15 years ago

Keywords: gsoc2010 added

comment:6 by stippi, 15 years ago

I've tested the patch, Christopher, but there may be some problems. I have a wallpaper here which exactly fits the screen. But when I switch to the "Scale to fit" mode, the image gets suddenly stretched horizontally somewhat. Have not looked into why this might be.

in reply to:  6 comment:7 by devheart, 14 years ago

Replying to stippi:

In BRectHorizontalOverlap() and BRectVerticalOverlap(), it looks like engleek swapped the last hostRect.Width/Height in each equation.

In BRectHorizontalOverlap(), it should be

    return (((hostRect.Height() / resizedRect.Height()) 
            * resizedRect.Width()) - hostRect.Width()) / 2;

and BRectVertialOverlap() should be

    return (((hostRect.Width() / resizedRect.Width()) 
            * resizedRect.Height()) - hostRect.Height()) / 2;
Version 0, edited 14 years ago by devheart (next)

comment:8 by korli, 14 years ago

Stephan, let me know if you have time to check again with info provided by devheart.

comment:9 by stippi, 14 years ago

Unfortunately, I don't have much time at all. Would be glad if someone else could review, thanks!

comment:10 by korli, 14 years ago

Resolution: fixed
Status: newclosed

OK I applied the patch with the devheart fix in hrev40144. I removed some braces which were unneeded. Tested OK.

Note: See TracTickets for help on using tickets.