changeset 68:4a1e1012337e

chat: fixed chat messages width
author Goffi <goffi@goffi.org>
date Sat, 17 Dec 2016 14:34:45 +0100
parents 5f7f72c2635f
children a9c6b089070d
files src/cagou/plugins/plugin_wid_chat.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/cagou/plugins/plugin_wid_chat.py	Sat Dec 17 14:32:40 2016 +0100
+++ b/src/cagou/plugins/plugin_wid_chat.py	Sat Dec 17 14:34:45 2016 +0100
@@ -156,16 +156,23 @@
         if len(self.children) == 1:
             wid = self.children[0]
             if isinstance(wid, Label):
+                # we have simple text
                 try:
                     full_width = wid._full_width
                 except AttributeError:
+                    # on first time, we need the required size
+                    # for the full text, without width limit
                     wid.size_hint = (None, None)
                     wid.texture_update()
                     full_width = wid._full_width = wid.texture_size[0]
+
                 if full_width > width:
                     wid.text_size = width, None
+                    wid.width = width
                 else:
                     wid.text_size = None, None
+                    wid.texture_update()
+                    wid.width = wid.texture_size[0]
                 self.content_width = wid.width + self.padding[0] + self.padding[2]
             else:
                 wid.size_hint(1, None)