From ec79e502d2befcc38c0ff86fa736fe4a6ba23240 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Wed, 05 Oct 2011 20:36:53 +0000 Subject: SpreadLayout: fix grid cell allocation The calculation of how many grid cells to assign a child element has a bug in that it rounds down instead of up. With a grid cell size of 4x4, if a child element of 9 pixels in size is added, the current code calculates that it needs 2.25 grid cells, but then rounds this down to 2. When the child gets drawn it will then draw outside of the grid cell bounds it was given. Fix this by rounding up instead of down: in the above example, 3 grid cells would be allocated. The canvas elements used already centre themselves within their allocation. In current Sugar, I can't see any notable differences from this change. However, this is a fairly obvious fix, and a necessary part of the later solution to the issue where the owner icon zoom animation does not quite match the location of the owner icon on the views. Acked-By: Sascha Silbe Signed-off-by: Daniel Drake --- diff --git a/src/jarabe/desktop/spreadlayout.py b/src/jarabe/desktop/spreadlayout.py index 9200361..b5c623e 100644 --- a/src/jarabe/desktop/spreadlayout.py +++ b/src/jarabe/desktop/spreadlayout.py @@ -14,6 +14,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +import math + import hippo import gobject import gtk @@ -78,8 +80,10 @@ class SpreadLayout(gobject.GObject, hippo.CanvasLayout): def _get_child_grid_size(self, child): min_width, width = child.get_width_request() min_height, height = child.get_height_request(width) + width = math.ceil(width / _CELL_SIZE) + height = math.ceil(height / _CELL_SIZE) - return int(width / _CELL_SIZE), int(height / _CELL_SIZE) + return int(width), int(height) def _grid_child_changed_cb(self, grid, child): child.emit_request_changed() -- cgit v0.9.1