Mercurial > libervia-desktop-kivy
comparison cagou/core/widgets_handler.py @ 170:f4522b7c3318
widgets handler: use widget's top and right
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 29 Apr 2018 12:23:52 +0200 |
parents | ef09dce878c7 |
children | 27b4ceb977c7 |
comparison
equal
deleted
inserted
replaced
169:6a288d4a493f | 170:f4522b7c3318 |
---|---|
398 @property | 398 @property |
399 def default_widget(self): | 399 def default_widget(self): |
400 return G.host.default_wid['factory'](G.host.default_wid, None, None) | 400 return G.host.default_wid['factory'](G.host.default_wid, None, None) |
401 | 401 |
402 def do_layout(self, *args): | 402 def do_layout(self, *args): |
403 x, y = self.pos | |
404 width, height = self.width, self.height | |
405 end_x, end_y = x + width, y + height | |
406 for child in self.children: | 403 for child in self.children: |
407 # XXX: left must be calculated before right and bottom before top | 404 # XXX: left must be calculated before right and bottom before top |
408 # because they are the pos, and are used to caculate size (right and top) | 405 # because they are the pos, and are used to caculate size (right and top) |
409 # left | 406 # left |
410 left = child._left_wid | 407 left = child._left_wid |
411 left_end_x = x-1 if left is None else left.x + left.width | 408 left_end_x = self.x-1 if left is None else left.right |
412 if child.x != left_end_x + 1 and child._split == "None": | 409 if child.x != left_end_x + 1 and child._split == "None": |
413 child.x = left_end_x + 1 | 410 child.x = left_end_x + 1 |
414 # right | 411 # right |
415 right = child._right_wid | 412 right = child._right_wid |
416 right_x = end_x + 1 if right is None else right.x | 413 right_x = self.right + 1 if right is None else right.x |
417 if child.x + child.width != right_x - 1: | 414 if child.right != right_x - 1: |
418 child.width = right_x - child.x - 1 | 415 child.width = right_x - child.x - 1 |
419 # bottom | 416 # bottom |
420 bottom = child._bottom_wid | 417 bottom = child._bottom_wid |
421 if bottom is None: | 418 if bottom is None: |
422 if child.y != y: | 419 if child.y != self.y: |
423 child.y = y | 420 child.y = self.y |
424 else: | 421 else: |
425 bottom_end_y = bottom.y + bottom.height | 422 if child.y != bottom.top + 1: |
426 if child.y != bottom_end_y + 1: | 423 child.y = bottom.top + 1 |
427 child.y = bottom_end_y + 1 | |
428 # top | 424 # top |
429 top = child._top_wid | 425 top = child._top_wid |
430 top_y = end_y+1 if top is None else top.y | 426 top_y = self.top+1 if top is None else top.y |
431 if child.y + child.height != top_y - 1: | 427 if child.top != top_y - 1: |
432 if child._split == "None": | 428 if child._split == "None": |
433 child.height = top_y - child.y - 1 | 429 child.height = top_y - child.y - 1 |
434 | 430 |
435 def remove_widget(self, wid): | 431 def remove_widget(self, wid): |
436 super(WidgetsHandlerLayout, self).remove_widget(wid) | 432 super(WidgetsHandlerLayout, self).remove_widget(wid) |