# HG changeset patch # User Goffi # Date 1576841377 -3600 # Node ID 51520ce981544eb966bba3b853b6a539382279d4 # Parent dddea9684a8e07c7d797b52f3e662415382906a6 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. diff -r dddea9684a8e -r 51520ce98154 cagou/core/common_widgets.py --- a/cagou/core/common_widgets.py Fri Dec 20 12:29:37 2019 +0100 +++ b/cagou/core/common_widgets.py Fri Dec 20 12:29:37 2019 +0100 @@ -39,14 +39,20 @@ do_layout_event = properties.ObjectProperty(None, allownone=True) layout_delay_s = properties.NumericProperty(0.2) + #: set this to X to force next X layouts to be done without delay + dont_delay_next_layouts = properties.NumericProperty(0) def do_layout(self, *args, **kwargs): if self.do_layout_event is not None: self.do_layout_event.cancel() - real_do_layout = super().do_layout - self.do_layout_event = Clock.schedule_once( - lambda dt: real_do_layout(*args, **kwargs), - self.layout_delay_s) + if self.dont_delay_next_layouts>0: + self.dont_delay_next_layouts-=1 + super().do_layout() + else: + real_do_layout = super().do_layout + self.do_layout_event = Clock.schedule_once( + lambda dt: real_do_layout(*args, **kwargs), + self.layout_delay_s) class Identities(object): diff -r dddea9684a8e -r 51520ce98154 cagou/plugins/plugin_wid_chat.py --- a/cagou/plugins/plugin_wid_chat.py Fri Dec 20 12:29:37 2019 +0100 +++ b/cagou/plugins/plugin_wid_chat.py Fri Dec 20 12:29:37 2019 +0100 @@ -559,6 +559,9 @@ def createMessage(self, message): self.appendMessage(message) + # we need to render immediatly next 2 layouts to avoid an unpleasant flickering + # when sending or receiving a message + self.messages_widget.dont_delay_next_layouts = 2 def appendMessage(self, mess_data): """Append a message Widget to the history