diff src/cagou/plugins/plugin_wid_chat.kv @ 58:7aa2ffff9067

chat: <img/> tag handling first draft: We need to have several widgets to handle <img/> (label(s) + image(s)), which make sizing and positioning complicated. To make things simpler, we use a simple trick when several widgets are present: we split the labels in as many labels as there are words, so we can take profit of the StackLayout. The split is done after the XHTML is parsed, so after all the widgets are present, and is done only once. This means that label need to be reparsed to be splitted. This is not perfect, but should be a reasonable solutions until we implement a real XHTML engine (probably CEF widget and Webview). image sizing and alignment is not handled correcly now, should be fixed soon.
author Goffi <goffi@goffi.org>
date Wed, 28 Sep 2016 22:02:36 +0200
parents a51ea7874e43
children 2aa44a82d0e7
line wrap: on
line diff
--- a/src/cagou/plugins/plugin_wid_chat.kv	Sun Sep 25 16:06:56 2016 +0200
+++ b/src/cagou/plugins/plugin_wid_chat.kv	Wed Sep 28 22:02:36 2016 +0200
@@ -15,6 +15,17 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
+<SimpleXHTMLWidgetEscapedText>:
+    size_hint: None, None
+    size: self.texture_size
+
+<SimpleXHTMLWidgetText>:
+    size_hint: None, None
+    size: self.texture_size
+
+<SimpleXHTMLWidgetImage>:
+    size_hint: 1, None
+
 <MessAvatar>:
     size_hint: None, None
     size: dp(30), dp(30)
@@ -61,14 +72,15 @@
                 BorderImage:
                     source: app.expand("{media}/misc/black.png") if root.mess_data.type == "info" else app.expand("{media}/misc/borders/{}.jpg", "blue" if root.mess_data.own_mess else "gray")
                     pos: self.pos
-                    size: self.size
+                    size: self.content_width, self.height
             id: mess_xhtml
+            size_hint: 0.8, None
+            height: self.minimum_height
             xhtml: root.message_xhtml or self.escape(root.message or u' ')
             color: (0.74,0.74,0.24,1) if root.mess_data.type == "info" else (0, 0, 0, 1)
             padding: root.mess_padding
             bold: True if root.mess_data.type == "info" else False
 
-
 <MessageInputWidget>:
     size_hint: 1, None
     height: dp(40)