Mercurial > libervia-desktop-kivy
comparison cagou/core/common_widgets.py @ 329:51520ce98154
common_widgets (DelayedBoxLayout), chat: don't delay layout on new message:
DelayedBoxLayout has a new `dont_delay_next_layouts` property to skip delaying for the
next X sizing. This is used in chat widget to avoid unpleasant flickering when a new
message is sent or received.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 20 Dec 2019 12:29:37 +0100 |
parents | 4374cb741eb5 |
children | 3002704318e3 |
comparison
equal
deleted
inserted
replaced
328:dddea9684a8e | 329:51520ce98154 |
---|---|
37 # XXX: thanks to Alexander Taylor for his blog post at | 37 # XXX: thanks to Alexander Taylor for his blog post at |
38 # https://blog.kivy.org/2019/07/a-delayed-resize-layout-in-kivy/ | 38 # https://blog.kivy.org/2019/07/a-delayed-resize-layout-in-kivy/ |
39 | 39 |
40 do_layout_event = properties.ObjectProperty(None, allownone=True) | 40 do_layout_event = properties.ObjectProperty(None, allownone=True) |
41 layout_delay_s = properties.NumericProperty(0.2) | 41 layout_delay_s = properties.NumericProperty(0.2) |
42 #: set this to X to force next X layouts to be done without delay | |
43 dont_delay_next_layouts = properties.NumericProperty(0) | |
42 | 44 |
43 def do_layout(self, *args, **kwargs): | 45 def do_layout(self, *args, **kwargs): |
44 if self.do_layout_event is not None: | 46 if self.do_layout_event is not None: |
45 self.do_layout_event.cancel() | 47 self.do_layout_event.cancel() |
46 real_do_layout = super().do_layout | 48 if self.dont_delay_next_layouts>0: |
47 self.do_layout_event = Clock.schedule_once( | 49 self.dont_delay_next_layouts-=1 |
48 lambda dt: real_do_layout(*args, **kwargs), | 50 super().do_layout() |
49 self.layout_delay_s) | 51 else: |
52 real_do_layout = super().do_layout | |
53 self.do_layout_event = Clock.schedule_once( | |
54 lambda dt: real_do_layout(*args, **kwargs), | |
55 self.layout_delay_s) | |
50 | 56 |
51 | 57 |
52 class Identities(object): | 58 class Identities(object): |
53 | 59 |
54 def __init__(self, entity_ids): | 60 def __init__(self, entity_ids): |