In spread layout always get width/height request to not
confuse hippo. Eventually we will have to deal with size changes in a better way. Fix flakes count in SnowflakeLayout. Fix #5904
This commit is contained in:
parent
93533e69f2
commit
aaaaa92f98
@ -267,7 +267,7 @@ class ActivityView(hippo.CanvasBox):
|
|||||||
self.set_layout(self._layout)
|
self.set_layout(self._layout)
|
||||||
|
|
||||||
self._icon = self._create_icon()
|
self._icon = self._create_icon()
|
||||||
self._layout.add_center(self._icon)
|
self._layout.add(self._icon, center=True)
|
||||||
|
|
||||||
self._update_palette()
|
self._update_palette()
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ class ActivityView(hippo.CanvasBox):
|
|||||||
def _color_changed_cb(self, activity, pspec):
|
def _color_changed_cb(self, activity, pspec):
|
||||||
self._layout.remove(self._icon)
|
self._layout.remove(self._icon)
|
||||||
self._icon = self._create_icon()
|
self._icon = self._create_icon()
|
||||||
self._layout.add_center(self._icon)
|
self._layout.add(self._icon, center=True)
|
||||||
self._icon.set_palette(self._palette)
|
self._icon.set_palette(self._palette)
|
||||||
|
|
||||||
def _private_changed_cb(self, activity, pspec):
|
def _private_changed_cb(self, activity, pspec):
|
||||||
|
@ -31,18 +31,21 @@ class SnowflakeLayout(gobject.GObject,hippo.CanvasLayout):
|
|||||||
gobject.GObject.__init__(self)
|
gobject.GObject.__init__(self)
|
||||||
self._nflakes = 0
|
self._nflakes = 0
|
||||||
|
|
||||||
def add(self, child):
|
def add(self, child, center=False):
|
||||||
self._box.append(child)
|
if not center:
|
||||||
|
|
||||||
box_child = self._box.find_box_child(child)
|
|
||||||
box_child.is_center = False
|
|
||||||
|
|
||||||
self._nflakes += 1
|
self._nflakes += 1
|
||||||
|
|
||||||
def add_center(self, child):
|
|
||||||
self._box.append(child)
|
self._box.append(child)
|
||||||
|
|
||||||
box_child = self._box.find_box_child(child)
|
box_child = self._box.find_box_child(child)
|
||||||
box_child.is_center = True
|
box_child.is_center = center
|
||||||
|
|
||||||
|
def remove(self, child):
|
||||||
|
box_child = self._box.find_box_child(child)
|
||||||
|
if not box_child.is_center:
|
||||||
|
self._nflakes -= 1
|
||||||
|
|
||||||
|
self._box.remove(child)
|
||||||
|
|
||||||
def do_set_box(self, box):
|
def do_set_box(self, box):
|
||||||
self._box = box
|
self._box = box
|
||||||
|
@ -218,6 +218,10 @@ class SpreadLayout(gobject.GObject, hippo.CanvasLayout):
|
|||||||
def do_allocate(self, x, y, width, height,
|
def do_allocate(self, x, y, width, height,
|
||||||
req_width, req_height, origin_changed):
|
req_width, req_height, origin_changed):
|
||||||
for child in self._box.get_layout_children():
|
for child in self._box.get_layout_children():
|
||||||
|
# We need to always get requests to not confuse hippo
|
||||||
|
min_w, child_width = child.get_width_request()
|
||||||
|
min_h, child_height = child.get_height_request(child_width)
|
||||||
|
|
||||||
rect = child.grid_rect
|
rect = child.grid_rect
|
||||||
if child.grid_rect:
|
if child.grid_rect:
|
||||||
child.allocate(rect.x * _CELL_SIZE,
|
child.allocate(rect.x * _CELL_SIZE,
|
||||||
@ -227,8 +231,6 @@ class SpreadLayout(gobject.GObject, hippo.CanvasLayout):
|
|||||||
origin_changed)
|
origin_changed)
|
||||||
else:
|
else:
|
||||||
vertical_offset = child.vertical_offset
|
vertical_offset = child.vertical_offset
|
||||||
min_w, child_width = child.get_width_request()
|
|
||||||
min_h, child_height = child.get_height_request(child_width)
|
|
||||||
child_x = x + (width - child_width) / 2
|
child_x = x + (width - child_width) / 2
|
||||||
child_y = y + (height - child_height + vertical_offset) / 2
|
child_y = y + (height - child_height + vertical_offset) / 2
|
||||||
child.allocate(child_x, child_y, child_width, child_height,
|
child.allocate(child_x, child_y, child_width, child_height,
|
||||||
|
Loading…
Reference in New Issue
Block a user