Mercurial > libervia-desktop-kivy
comparison 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 |
comparison
equal
deleted
inserted
replaced
57:a51ea7874e43 | 58:7aa2ffff9067 |
---|---|
12 # GNU Affero General Public License for more details. | 12 # GNU Affero General Public License for more details. |
13 | 13 |
14 # You should have received a copy of the GNU Affero General Public License | 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/>. | 15 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 |
17 | |
18 <SimpleXHTMLWidgetEscapedText>: | |
19 size_hint: None, None | |
20 size: self.texture_size | |
21 | |
22 <SimpleXHTMLWidgetText>: | |
23 size_hint: None, None | |
24 size: self.texture_size | |
25 | |
26 <SimpleXHTMLWidgetImage>: | |
27 size_hint: 1, None | |
17 | 28 |
18 <MessAvatar>: | 29 <MessAvatar>: |
19 size_hint: None, None | 30 size_hint: None, None |
20 size: dp(30), dp(30) | 31 size: dp(30), dp(30) |
21 | 32 |
59 Color: | 70 Color: |
60 rgba: 1, 1, 1, 1 | 71 rgba: 1, 1, 1, 1 |
61 BorderImage: | 72 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") | 73 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 | 74 pos: self.pos |
64 size: self.size | 75 size: self.content_width, self.height |
65 id: mess_xhtml | 76 id: mess_xhtml |
77 size_hint: 0.8, None | |
78 height: self.minimum_height | |
66 xhtml: root.message_xhtml or self.escape(root.message or u' ') | 79 xhtml: root.message_xhtml or self.escape(root.message or u' ') |
67 color: (0.74,0.74,0.24,1) if root.mess_data.type == "info" else (0, 0, 0, 1) | 80 color: (0.74,0.74,0.24,1) if root.mess_data.type == "info" else (0, 0, 0, 1) |
68 padding: root.mess_padding | 81 padding: root.mess_padding |
69 bold: True if root.mess_data.type == "info" else False | 82 bold: True if root.mess_data.type == "info" else False |
70 | 83 |
71 | |
72 <MessageInputWidget>: | 84 <MessageInputWidget>: |
73 size_hint: 1, None | 85 size_hint: 1, None |
74 height: dp(40) | 86 height: dp(40) |
75 hint_text: "Enter your message here" | 87 hint_text: "Enter your message here" |