[Sugar-devel] [PATCH] fix calculation for determining the placement of badges

Walter Bender walter.bender at gmail.com
Wed Aug 17 13:50:28 EDT 2011


On Wed, Aug 17, 2011 at 1:37 PM, Walter Bender <walter at sugarlabs.org> wrote:
> From: Walter Bender <walter.bender at gmail.com>
>
> It is my understanding the icon_info.attach_x,y are pixel offsets into the icon
> from the lower-left corner. If that is the case, then it should be added
> rather than multiplied. The other interpretation is that it is a position
> as percentage. If that is correct, then the default value should be 1.0
> instead of 0 if the badge is to be put in the lower-left. I did do an
> experiment with setting attach_x,y to 1.0 and got inconsistent results. Keeping
> it set to 0 and using it as a pixel offsets works as expected. I tested this
> patch with badges on icons on the toolbar and also the network icons in the mesh
> view and everything seems to render properly.

^left^right :P

-walter
>
> ---
>  src/sugar/graphics/icon.py |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/sugar/graphics/icon.py b/src/sugar/graphics/icon.py
> index 62a79f6..b14cb7c 100644
> --- a/src/sugar/graphics/icon.py
> +++ b/src/sugar/graphics/icon.py
> @@ -202,8 +202,8 @@ class _IconBuffer(object):
>             return info
>
>         info.size = int(_BADGE_SIZE * icon_width)
> -        info.attach_x = int(icon_info.attach_x * icon_width - info.size / 2)
> -        info.attach_y = int(icon_info.attach_y * icon_height - info.size / 2)
> +        info.attach_x = int(icon_info.attach_x + icon_width - info.size / 2)
> +        info.attach_y = int(icon_info.attach_y + icon_height - info.size / 2)
>
>         if info.attach_x < 0 or info.attach_y < 0:
>             info.icon_padding = max(-info.attach_x, -info.attach_y)
> --
> 1.7.4.4
>
>



-- 
Walter Bender
Sugar Labs
http://www.sugarlabs.org


More information about the Sugar-devel mailing list