diff src/cagou/plugins/plugin_wid_chat.kv @ 57:a51ea7874e43

chat: XHTML parsing first draft: a XHTML mini parser is used so rich text can be handled. For now it manages only a few basic elements (bold, italic, color). Body sizing/alignment is currenly broken.
author Goffi <goffi@goffi.org>
date Sun, 25 Sep 2016 16:06:56 +0200
parents abb81efef3bb
children 7aa2ffff9067
line wrap: on
line diff
--- a/src/cagou/plugins/plugin_wid_chat.kv	Fri Sep 16 11:49:36 2016 +0200
+++ b/src/cagou/plugins/plugin_wid_chat.kv	Sun Sep 25 16:06:56 2016 +0200
@@ -28,7 +28,7 @@
 
 <MessageWidget>:
     cols: 1
-    mess_label: mess_label
+    mess_xhtml: mess_xhtml
     padding: dp(10)
     spacing: dp(5)
     size_hint: 1, None
@@ -52,9 +52,9 @@
     BoxLayout:
         # BoxLayout is needed here, else GridLayout won't let the Label choose its width
         size_hint: 1, None
-        height: mess_label.height
+        height: mess_xhtml.height
         on_size: root.widthAdjust()
-        Label:
+        SimpleXHTMLWidget:
             canvas.before:
                 Color:
                     rgba: 1, 1, 1, 1
@@ -62,15 +62,11 @@
                     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
-            id: mess_label
+            id: mess_xhtml
+            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
-            text_size: None, None
-            size_hint: None, None
-            size: self.texture_size
             bold: True if root.mess_data.type == "info" else False
-            text: root.message or u'  '
-            # on_texture_size: root.widthAdjust()
 
 
 <MessageInputWidget>: