diff cagou/kv/common.kv @ 397:54f6a47cc60a

core (common): added a notifications counter on ContactButton and use it in JidSelector: A notifications counter is drawned above avatar if `nofifs` key is present and not empty in `data`. This is used in JidSelector to show counter when necessary with opened chats.
author Goffi <goffi@goffi.org>
date Sun, 09 Feb 2020 23:47:29 +0100
parents 841045d5a937
children f7476818f9fb
line wrap: on
line diff
--- a/cagou/kv/common.kv	Sun Feb 09 23:47:29 2020 +0100
+++ b/cagou/kv/common.kv	Sun Feb 09 23:47:29 2020 +0100
@@ -15,26 +15,51 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
+<NotifLabel>:
+    background_color: 1, 0, 0, 1
+    size_hint: None, None
+    text_size: None, root.height
+    padding_x: sp(5)
+    size: self.texture_size
+    bold: True
+    canvas.before:
+        Color:
+            rgba: root.background_color
+        Ellipse:
+            size: self.size
+            pos: self.pos
+
+
 <ContactItem>:
     size_hint: None, None
     width: self.base_width
     height: self.minimum_height
     orientation: 'vertical'
-    Avatar:
-        id: avatar
+    avatar: avatar
+    avatar_layout: avatar_layout
+    FloatLayout:
+        id: avatar_layout
         size_hint: 1, None
         height: dp(60)
-        source: root.data.get('avatar') or app.default_avatar
-        allow_stretch: True
-    Label:
-        id: jid_label
-        size_hint: None, None
-        text_size: root.base_width, None
-        size: self.texture_size
-        text: root.data.get('nick', root.jid.node or root.jid)
-        bold: True
-        valign: 'middle'
-        halign: 'center'
+        Avatar:
+            id: avatar
+            pos_hint: {'x': 0, 'y': 0}
+            source: root.data.get('avatar') or app.default_avatar
+            allow_stretch: True
+    BoxLayout:
+        id: label_box
+        size_hint: 1, None
+        height: self.minimum_height
+        Label:
+            size_hint: 1, None
+            height: self.font_size + sp(5)
+            text_size: self.size
+            shorten: True
+            shorten_from: "right"
+            text: root.data.get('nick', root.jid.node or root.jid)
+            bold: True
+            valign: 'middle'
+            halign: 'center'
 
 
 <JidItem>: