comparison cagou/plugins/plugin_wid_chat.kv @ 138:53fb221ad084

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
author Goffi <goffi@goffi.org>
date Fri, 13 Apr 2018 18:57:05 +0200
parents 84b18c131a81
children 33498be369ca
comparison
equal deleted inserted replaced
137:b9139c87f393 138:53fb221ad084
44 Rectangle: 44 Rectangle:
45 pos: self.pos 45 pos: self.pos
46 size: self.size 46 size: self.size
47 47
48 <MessageWidget>: 48 <MessageWidget>:
49 cols: 1
50 mess_xhtml: mess_xhtml
51 padding: 0
52 spacing: 0
53 size_hint: 1, None 49 size_hint: 1, None
54 height: self.minimum_height 50 height: right_part.minimum_height
55 on_width: self.widthAdjust() 51 on_width: self.widthAdjust()
56 avatar: avatar 52 avatar: avatar
57 delivery: delivery 53 delivery: delivery
54 mess_xhtml: mess_xhtml
58 BoxLayout: 55 BoxLayout:
59 id: header_box 56 orientation: 'vertical'
60 size_hint: 1, None 57 width: avatar.width
61 height: avatar.height if root.mess_data.type != C.MESS_TYPE_INFO else 0 58 size_hint: None, 1
62 opacity: 1 if root.mess_data.type != C.MESS_TYPE_INFO else 0
63 MessAvatar: 59 MessAvatar:
64 id: avatar 60 id: avatar
65 Label: 61 Widget:
66 id: time_label 62 # use to push the avatar on the top
67 color: (0, 0, 0, 1) if root.mess_data.own_mess else (0.55,0.55,0.55,1) 63 size_hint: 1, 1
68 text_size: None, None
69 size_hint: None, None
70 size: self.texture_size
71 padding: dp(5), 0
72 markup: True
73 valign: 'middle'
74 text: u"[b]{}[/b], {}".format(escape(root.mess_data.nick), root.mess_data.time_text)
75 Label:
76 id: delivery
77 text_size: None, None
78 size_hint: None, None
79 size: self.texture_size
80 padding: dp(5), 0
81 # XXX: DejaVuSans font is needed as check mark is not in Roboto
82 # this can be removed when Kivy will be able to handle fallback mechanism
83 # which will allow us to use fonts with more unicode characters
84 font_name: "DejaVuSans"
85 text: u''
86 color: 0, 1, 0, 1
87 BoxLayout: 64 BoxLayout:
88 # BoxLayout is needed here, else GridLayout won't let the Label choose its width 65 orientation: 'vertical'
89 size_hint: 1, None 66 id: right_part
90 height: mess_xhtml.height 67 BoxLayout:
91 on_size: root.widthAdjust() 68 id: header_box
69 size_hint: 1, None
70 height: time_label.height if root.mess_data.type != C.MESS_TYPE_INFO else 0
71 opacity: 1 if root.mess_data.type != C.MESS_TYPE_INFO else 0
72 Label:
73 id: time_label
74 color: (0, 0, 0, 1) if root.mess_data.own_mess else (0.55,0.55,0.55,1)
75 text_size: None, None
76 size_hint: None, None
77 size: self.texture_size
78 padding: dp(5), 0
79 markup: True
80 valign: 'middle'
81 text: u"[b]{}[/b], {}".format(escape(root.mess_data.nick), root.mess_data.time_text)
82 Label:
83 id: delivery
84 text_size: None, None
85 size_hint: None, None
86 size: self.texture_size
87 padding: dp(5), 0
88 # XXX: DejaVuSans font is needed as check mark is not in Roboto
89 # this can be removed when Kivy will be able to handle fallback mechanism
90 # which will allow us to use fonts with more unicode characters
91 font_name: "DejaVuSans"
92 text: u''
93 color: 0.4, 0.4, 0.4, 1
92 SimpleXHTMLWidget: 94 SimpleXHTMLWidget:
93 id: mess_xhtml 95 id: mess_xhtml
94 size_hint: 0.8, None 96 size_hint: 1, None
95 height: self.minimum_height 97 height: self.minimum_height
96 xhtml: root.message_xhtml or self.escape(root.message or u' ') 98 xhtml: root.message_xhtml or self.escape(root.message or u' ')
97 color: (0.74,0.74,0.24,1) if root.mess_data.type == "info" else (0, 0, 0, 1) 99 color: (0.74,0.74,0.24,1) if root.mess_data.type == "info" else (0, 0, 0, 1)
98 padding: root.mess_padding 100 padding: root.mess_padding
99 bold: True if root.mess_data.type == "info" else False 101 bold: True if root.mess_data.type == "info" else False