# HG changeset patch # User Goffi # Date 1523638625 -7200 # Node ID 53fb221ad084443eaedd164f1f3d5c7cdea22e24 # Parent b9139c87f393164d92167fe64672db20bfcb2425 plugin chat: layout change: - minimum_height is now working with BoxLayout, there is not reason anymore to use GridLayout for messages - the avatar is now on the left on its own, and message header + body are on the right, aligned diff -r b9139c87f393 -r 53fb221ad084 cagou/plugins/plugin_wid_chat.kv --- a/cagou/plugins/plugin_wid_chat.kv Fri Apr 13 18:57:04 2018 +0200 +++ b/cagou/plugins/plugin_wid_chat.kv Fri Apr 13 18:57:05 2018 +0200 @@ -46,52 +46,54 @@ size: self.size : - cols: 1 - mess_xhtml: mess_xhtml - padding: 0 - spacing: 0 size_hint: 1, None - height: self.minimum_height + height: right_part.minimum_height on_width: self.widthAdjust() avatar: avatar delivery: delivery + mess_xhtml: mess_xhtml BoxLayout: - id: header_box - size_hint: 1, None - height: avatar.height if root.mess_data.type != C.MESS_TYPE_INFO else 0 - opacity: 1 if root.mess_data.type != C.MESS_TYPE_INFO else 0 + orientation: 'vertical' + width: avatar.width + size_hint: None, 1 MessAvatar: id: avatar - Label: - id: time_label - color: (0, 0, 0, 1) if root.mess_data.own_mess else (0.55,0.55,0.55,1) - text_size: None, None - size_hint: None, None - size: self.texture_size - padding: dp(5), 0 - markup: True - valign: 'middle' - text: u"[b]{}[/b], {}".format(escape(root.mess_data.nick), root.mess_data.time_text) - Label: - id: delivery - text_size: None, None - size_hint: None, None - size: self.texture_size - padding: dp(5), 0 - # XXX: DejaVuSans font is needed as check mark is not in Roboto - # this can be removed when Kivy will be able to handle fallback mechanism - # which will allow us to use fonts with more unicode characters - font_name: "DejaVuSans" - text: u'' - color: 0, 1, 0, 1 + Widget: + # use to push the avatar on the top + size_hint: 1, 1 BoxLayout: - # BoxLayout is needed here, else GridLayout won't let the Label choose its width - size_hint: 1, None - height: mess_xhtml.height - on_size: root.widthAdjust() + orientation: 'vertical' + id: right_part + BoxLayout: + id: header_box + size_hint: 1, None + height: time_label.height if root.mess_data.type != C.MESS_TYPE_INFO else 0 + opacity: 1 if root.mess_data.type != C.MESS_TYPE_INFO else 0 + Label: + id: time_label + color: (0, 0, 0, 1) if root.mess_data.own_mess else (0.55,0.55,0.55,1) + text_size: None, None + size_hint: None, None + size: self.texture_size + padding: dp(5), 0 + markup: True + valign: 'middle' + text: u"[b]{}[/b], {}".format(escape(root.mess_data.nick), root.mess_data.time_text) + Label: + id: delivery + text_size: None, None + size_hint: None, None + size: self.texture_size + padding: dp(5), 0 + # XXX: DejaVuSans font is needed as check mark is not in Roboto + # this can be removed when Kivy will be able to handle fallback mechanism + # which will allow us to use fonts with more unicode characters + font_name: "DejaVuSans" + text: u'' + color: 0.4, 0.4, 0.4, 1 SimpleXHTMLWidget: id: mess_xhtml - size_hint: 0.8, None + size_hint: 1, 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) diff -r b9139c87f393 -r 53fb221ad084 cagou/plugins/plugin_wid_chat.py --- a/cagou/plugins/plugin_wid_chat.py Fri Apr 13 18:57:04 2018 +0200 +++ b/cagou/plugins/plugin_wid_chat.py Fri Apr 13 18:57:05 2018 +0200 @@ -59,7 +59,7 @@ pass -class MessageWidget(GridLayout): +class MessageWidget(BoxLayout): mess_data = properties.ObjectProperty() mess_xhtml = properties.ObjectProperty() mess_padding = (dp(5), dp(5))