Fix snowflake layout
This commit is contained in:
parent
8aa31a6095
commit
bf1aea368f
1
NEWS
1
NEWS
@ -1,3 +1,4 @@
|
|||||||
|
* #3053: Fix the distance between the clustered xos and the activity. (marco)
|
||||||
* Make the sizes of mesh icons match Eben spec. (marco)
|
* Make the sizes of mesh icons match Eben spec. (marco)
|
||||||
* #3364: When joining an activity, pick up its sharing scope, so we don't
|
* #3364: When joining an activity, pick up its sharing scope, so we don't
|
||||||
try to re-share already shared activities in order to invite someone (smcv)
|
try to re-share already shared activities in order to invite someone (smcv)
|
||||||
|
@ -22,8 +22,8 @@ import hippo
|
|||||||
|
|
||||||
from sugar.graphics import style
|
from sugar.graphics import style
|
||||||
|
|
||||||
_BASE_RADIUS = style.zoom(25)
|
_BASE_DISTANCE = style.zoom(15)
|
||||||
_CHILDREN_FACTOR = 1
|
_CHILDREN_FACTOR = style.zoom(3)
|
||||||
|
|
||||||
class SnowflakeLayout(gobject.GObject,hippo.CanvasLayout):
|
class SnowflakeLayout(gobject.GObject,hippo.CanvasLayout):
|
||||||
__gtype_name__ = 'SugarSnowflakeLayout'
|
__gtype_name__ = 'SugarSnowflakeLayout'
|
||||||
@ -52,7 +52,7 @@ class SnowflakeLayout(gobject.GObject,hippo.CanvasLayout):
|
|||||||
return (size, size)
|
return (size, size)
|
||||||
|
|
||||||
def do_get_width_request(self):
|
def do_get_width_request(self):
|
||||||
size = self._calculate_size()
|
size = self._calculate_size()
|
||||||
return (size, size)
|
return (size, size)
|
||||||
|
|
||||||
def do_allocate(self, x, y, width, height,
|
def do_allocate(self, x, y, width, height,
|
||||||
@ -86,19 +86,20 @@ class SnowflakeLayout(gobject.GObject,hippo.CanvasLayout):
|
|||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
def _get_radius(self):
|
def _get_radius(self):
|
||||||
return int(_BASE_RADIUS + _CHILDREN_FACTOR * self._nflakes)
|
radius = int(_BASE_DISTANCE + _CHILDREN_FACTOR * self._nflakes)
|
||||||
|
for child in self._box.get_layout_children():
|
||||||
|
if child.is_center:
|
||||||
|
[min_w, child_w] = child.get_width_request()
|
||||||
|
[min_h, child_h] = child.get_height_request(child_w)
|
||||||
|
radius += max(child_w, child_h) / 2
|
||||||
|
|
||||||
|
return radius
|
||||||
|
|
||||||
def _calculate_size(self):
|
def _calculate_size(self):
|
||||||
size = 0
|
thickness = 0
|
||||||
for child in self._box.get_layout_children():
|
for child in self._box.get_layout_children():
|
||||||
[min_width, child_width] = child.get_width_request()
|
[min_width, child_width] = child.get_width_request()
|
||||||
[min_height, child_height] = child.get_height_request(child_width)
|
[min_height, child_height] = child.get_height_request(child_width)
|
||||||
|
thickness = max(thickness, max(child_width, child_height))
|
||||||
|
|
||||||
new_size = max(child_width, child_height)
|
return self._get_radius() * 2 + thickness
|
||||||
if not child.is_center:
|
|
||||||
new_size += self._get_radius() * 2
|
|
||||||
|
|
||||||
if new_size > size:
|
|
||||||
size = new_size
|
|
||||||
|
|
||||||
return size
|
|
||||||
|
Loading…
Reference in New Issue
Block a user