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

Simon Schampijer simon at schampijer.de
Thu Aug 18 04:13:40 EDT 2011


On 08/17/2011 07:37 PM, Walter Bender 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.

So 0,0 is at the left upper corner. You can see this easily by just 
setting info.attach_x and info.attach_y to 0.

An example is:

badge-x = int(icon-x=0.97 * icon-width=55 - badge-size=24 / 2)
badge-y = int(icon-y=0.84 * icon-width=55 - badge-size=24 / 2)

badge-x will be 41 and badge-y 34 in this case (now.png).

The simplest I came up with would be:

badge-x = int(icon-x=0.97 + icon-width=55 - badge-size=24)
badge-y = int(icon-y=0.84 + icon-width=55 - badge-size=24)

badge-x will be 31 and badge-y 31, too (simple.png).

Your proposal would be:

badge-x = int(icon-x=0.97 + icon-width=55 - badge-size=24 / 2)
badge-y = int(icon-y=0.84 + icon-width=55 - badge-size=24 / 2)

badge-x will be 43 and badge-y 43, too (walter.png).

So I think our current approach is the most sophisticated one because it 
weights in x and y. I think we are good with what we have.

Can you describe the exact issue you are seeing and maybe paste a simple 
example?

Regards,
    Simon


-------------- next part --------------
A non-text attachment was scrubbed...
Name: now.png
Type: image/png
Size: 6253 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20110818/562f3103/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: simple.png
Type: image/png
Size: 7293 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20110818/562f3103/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: walter.png
Type: image/png
Size: 4071 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20110818/562f3103/attachment-0005.png>


More information about the Sugar-devel mailing list