Mercurial > fife-parpg
changeset 328:d8bcff5f7222
PyChan: adaptLayout performance fix.
author | phoku@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 24 Aug 2009 09:20:28 +0000 |
parents | e496e3681855 |
children | aca5744f017a |
files | engine/extensions/pychan/widgets/layout.py |
diffstat | 1 files changed, 21 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/engine/extensions/pychan/widgets/layout.py Fri Aug 21 23:54:39 2009 +0000 +++ b/engine/extensions/pychan/widgets/layout.py Mon Aug 24 09:20:28 2009 +0000 @@ -83,18 +83,23 @@ #print "SPACERS",self.spacer index = 0 + n = len(expandable_items) while used_space < available_space and expandable_items: - index = index % len(expandable_items) + index = index % n + delta = (available_space - used_space) / n + if delta == 0: + delta = 1 expander = expandable_items[index] old_width = expander.width - expander.width += 1 - if old_width == expander.width: + expander.width += delta + delta = expander.width - old_width + if delta == 0: expandable_items.pop(index) + n -= 1 else: - used_space += 1 + used_space += delta index += 1 - #print "AS/US - after",self,[o.width for o in expandable_items] #print "SPACERS",self.spacer self._applyWidth(spacers = self.spacer[:]) @@ -116,16 +121,22 @@ #print "AS/US - before",self,[o.height for o in expandable_items] index = 0 + n = len(expandable_items) while used_space < available_space and expandable_items: - index = index % len(expandable_items) + index = index % n + delta = (available_space - used_space) / n + if delta == 0: + delta = 1 expander = expandable_items[index] - old_width = expander.height - expander.height += 1 - if old_width == expander.height: + old_height = expander.height + expander.height += delta + delta = expander.height - old_height + if delta == 0: expandable_items.pop(index) + n -= 1 else: - used_space += 1 + used_space += delta index += 1 #print "AS/US - after",self,[o.height for o in expandable_items]