Mercurial > libervia-desktop-kivy
annotate 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 |
rev | line source |
---|---|
22 | 1 # Cagou: desktop/mobile frontend for Salut à Toi XMPP client |
2 # Copyright (C) 2016 Jérôme Poisson (goffi@goffi.org) | |
3 | |
4 # This program is free software: you can redistribute it and/or modify | |
5 # it under the terms of the GNU Affero General Public License as published by | |
6 # the Free Software Foundation, either version 3 of the License, or | |
7 # (at your option) any later version. | |
8 | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU Affero General Public License for more details. | |
13 | |
14 # You should have received a copy of the GNU Affero General Public License | |
15 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | |
44
7819e9efa250
chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents:
31
diff
changeset
|
17 |
7819e9efa250
chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents:
31
diff
changeset
|
18 <MessAvatar>: |
7819e9efa250
chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents:
31
diff
changeset
|
19 size_hint: None, None |
7819e9efa250
chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents:
31
diff
changeset
|
20 size: dp(30), dp(30) |
7819e9efa250
chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents:
31
diff
changeset
|
21 |
22 | 22 <MessagesWidget>: |
45 | 23 cols: 1 |
24 padding: dp(10) | |
25 spacing: dp(5) | |
26 size_hint: 1, None | |
27 height: self.minimum_height | |
22 | 28 |
29 <MessageWidget>: | |
45 | 30 cols: 1 |
57 | 31 mess_xhtml: mess_xhtml |
45 | 32 padding: dp(10) |
33 spacing: dp(5) | |
24
bc15b55a4114
chat: better bubble and time resizing
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
34 size_hint: 1, None |
45 | 35 height: self.minimum_height |
36 on_width: self.widthAdjust() | |
47
abb81efef3bb
chat: update avatar following quick frontend improvments
Goffi <goffi@goffi.org>
parents:
45
diff
changeset
|
37 avatar: avatar |
45 | 38 BoxLayout: |
39 id: header_box | |
40 size_hint: 1, None | |
41 height: avatar.height | |
42 MessAvatar: | |
43 id: avatar | |
44 source: root.mess_data.avatar | |
44
7819e9efa250
chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents:
31
diff
changeset
|
45 Label: |
7819e9efa250
chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents:
31
diff
changeset
|
46 id: time_label |
7819e9efa250
chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents:
31
diff
changeset
|
47 text_size: None, None |
45 | 48 size_hint: None, None |
49 size: self.texture_size | |
50 padding: dp(5), 0 | |
51 text: u"{}, {}".format(root.mess_data.nick, root.mess_data.time_text) | |
22 | 52 BoxLayout: |
45 | 53 # BoxLayout is needed here, else GridLayout won't let the Label choose its width |
54 size_hint: 1, None | |
57 | 55 height: mess_xhtml.height |
45 | 56 on_size: root.widthAdjust() |
57 | 57 SimpleXHTMLWidget: |
24
bc15b55a4114
chat: better bubble and time resizing
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
58 canvas.before: |
bc15b55a4114
chat: better bubble and time resizing
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
59 Color: |
bc15b55a4114
chat: better bubble and time resizing
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
60 rgba: 1, 1, 1, 1 |
bc15b55a4114
chat: better bubble and time resizing
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
61 BorderImage: |
45 | 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") |
24
bc15b55a4114
chat: better bubble and time resizing
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
63 pos: self.pos |
bc15b55a4114
chat: better bubble and time resizing
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
64 size: self.size |
57 | 65 id: mess_xhtml |
66 xhtml: root.message_xhtml or self.escape(root.message or u' ') | |
45 | 67 color: (0.74,0.74,0.24,1) if root.mess_data.type == "info" else (0, 0, 0, 1) |
68 padding: root.mess_padding | |
69 bold: True if root.mess_data.type == "info" else False | |
70 | |
71 | |
72 <MessageInputWidget>: | |
73 size_hint: 1, None | |
74 height: dp(40) | |
75 hint_text: "Enter your message here" |