diff options
author | Daniel Drake <dsd@laptop.org> | 2011-10-05 20:36:53 (GMT) |
---|---|---|
committer | Daniel Drake <dsd@laptop.org> | 2011-10-09 11:26:19 (GMT) |
commit | ec79e502d2befcc38c0ff86fa736fe4a6ba23240 (patch) | |
tree | c3b20c7874c0d4a439c1ac6821c61a29d6cb350e | |
parent | de97b4b345214ffe96bf7b48d925ff1a7a1318ee (diff) |
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 <silbe@activitycentral.com>
Signed-off-by: Daniel Drake <dsd@laptop.org>
-rw-r--r-- | src/jarabe/desktop/spreadlayout.py | 6 |
1 files changed, 5 insertions, 1 deletions
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() |