diff cagou/core/common.py @ 193:284cb5c467b0

core (common): split JidItem in 3 classes: - JidItem to only view an Entity - JidButton to allow to click - JidToggle to select
author Goffi <goffi@goffi.org>
date Wed, 23 May 2018 18:40:58 +0200
parents 7177fe2d9725
children 30be583dbabc
line wrap: on
line diff
--- a/cagou/core/common.py	Tue May 22 19:25:23 2018 +0200
+++ b/cagou/core/common.py	Wed May 23 18:40:58 2018 +0200
@@ -23,7 +23,9 @@
 from kivy.uix.image import Image
 from kivy.uix.label import Label
 from kivy.uix.behaviors import ButtonBehavior
+from kivy.uix.behaviors import ToggleButtonBehavior
 from kivy.uix.boxlayout import BoxLayout
+from cagou.core.constants import Const as C
 from kivy import properties
 from cagou import G
 import json
@@ -38,7 +40,9 @@
     pass
 
 
-class JidItem(ButtonBehavior, BoxLayout):
+class JidItem(BoxLayout):
+    bg_color = properties.ListProperty([0.2, 0.2, 0.2, 1])
+    color = properties.ListProperty([1, 1, 1, 1])
 
     def __init__(self, jid, profile, **kwargs):
         self.jid = jid
@@ -55,6 +59,14 @@
             return host.getAvatar(self.jid, profile=self.profile) or host.getDefaultAvatar(self.jid)
 
 
+class JidButton(ButtonBehavior, JidItem):
+    pass
+
+
+class JidToggle(ToggleButtonBehavior, JidItem):
+    selected_color = properties.ListProperty(C.COLOR_SEC_DARK)
+
+
 class Symbol(Label):
     symbol_map = None
     symbol = properties.StringProperty()