comparison 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
comparison
equal deleted inserted replaced
56:817a45e6d7e3 57:a51ea7874e43
26 size_hint: 1, None 26 size_hint: 1, None
27 height: self.minimum_height 27 height: self.minimum_height
28 28
29 <MessageWidget>: 29 <MessageWidget>:
30 cols: 1 30 cols: 1
31 mess_label: mess_label 31 mess_xhtml: mess_xhtml
32 padding: dp(10) 32 padding: dp(10)
33 spacing: dp(5) 33 spacing: dp(5)
34 size_hint: 1, None 34 size_hint: 1, None
35 height: self.minimum_height 35 height: self.minimum_height
36 on_width: self.widthAdjust() 36 on_width: self.widthAdjust()
50 padding: dp(5), 0 50 padding: dp(5), 0
51 text: u"{}, {}".format(root.mess_data.nick, root.mess_data.time_text) 51 text: u"{}, {}".format(root.mess_data.nick, root.mess_data.time_text)
52 BoxLayout: 52 BoxLayout:
53 # BoxLayout is needed here, else GridLayout won't let the Label choose its width 53 # BoxLayout is needed here, else GridLayout won't let the Label choose its width
54 size_hint: 1, None 54 size_hint: 1, None
55 height: mess_label.height 55 height: mess_xhtml.height
56 on_size: root.widthAdjust() 56 on_size: root.widthAdjust()
57 Label: 57 SimpleXHTMLWidget:
58 canvas.before: 58 canvas.before:
59 Color: 59 Color:
60 rgba: 1, 1, 1, 1 60 rgba: 1, 1, 1, 1
61 BorderImage: 61 BorderImage:
62 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") 62 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")
63 pos: self.pos 63 pos: self.pos
64 size: self.size 64 size: self.size
65 id: mess_label 65 id: mess_xhtml
66 xhtml: root.message_xhtml or self.escape(root.message or u' ')
66 color: (0.74,0.74,0.24,1) if root.mess_data.type == "info" else (0, 0, 0, 1) 67 color: (0.74,0.74,0.24,1) if root.mess_data.type == "info" else (0, 0, 0, 1)
67 padding: root.mess_padding 68 padding: root.mess_padding
68 text_size: None, None
69 size_hint: None, None
70 size: self.texture_size
71 bold: True if root.mess_data.type == "info" else False 69 bold: True if root.mess_data.type == "info" else False
72 text: root.message or u' '
73 # on_texture_size: root.widthAdjust()
74 70
75 71
76 <MessageInputWidget>: 72 <MessageInputWidget>:
77 size_hint: 1, None 73 size_hint: 1, None
78 height: dp(40) 74 height: dp(40)