changeset 247:cf61a011f731

core (notes), common (symbol): added an icon showing note level: because of Symbol binding, it was difficult to precisely set the icon position, so Symbol has been modified to remove bindings. Added consts for INFO, WARNING and ERROR colors.
author Goffi <goffi@goffi.org>
date Sat, 26 Jan 2019 20:24:48 +0100
parents 15e47bbb192c
children b6e33b35538b
files cagou/core/cagou_main.py cagou/core/common.py cagou/core/constants.py cagou/kv/common.kv cagou/kv/common_widgets.kv cagou/kv/root_widget.kv cagou/plugins/plugin_wid_file_sharing.kv cagou/plugins/plugin_wid_remote.kv
diffstat 8 files changed, 49 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/core/cagou_main.py	Fri Jan 04 13:20:29 2019 +0100
+++ b/cagou/core/cagou_main.py	Sat Jan 26 20:24:48 2019 +0100
@@ -106,7 +106,7 @@
                                       options=list(C.XMLUI_DATA_LVLS))
 
 
-class NoteDrop(Label):
+class NoteDrop(BoxLayout):
     title = properties.StringProperty()
     message = properties.StringProperty()
     level = properties.OptionProperty(C.XMLUI_DATA_LVL_DEFAULT,
--- a/cagou/core/common.py	Fri Jan 04 13:20:29 2019 +0100
+++ b/cagou/core/common.py	Sat Jan 26 20:24:48 2019 +0100
@@ -71,7 +71,6 @@
 class Symbol(Label):
     symbol_map = None
     symbol = properties.StringProperty()
-    margin = properties.NumericProperty(0)
 
     def __init__(self, **kwargs):
         if self.symbol_map is None:
--- a/cagou/core/constants.py	Fri Jan 04 13:20:29 2019 +0100
+++ b/cagou/core/constants.py	Sat Jan 26 20:24:48 2019 +0100
@@ -34,9 +34,14 @@
     TRANSFER_UPLOAD = u"upload"
     TRANSFER_SEND = u"send"
 
-    COLOR_PRIM = [0.98, 0.98, 0.98, 1]
-    COLOR_PRIM_LIGHT = [1, 1, 1, 1]
-    COLOR_PRIM_DARK = [0.78, 0.78, 0.78, 1]
-    COLOR_SEC = [0.27, 0.54, 1.0, 1]
-    COLOR_SEC_LIGHT = [0.51, 0.73, 1.0, 1]
-    COLOR_SEC_DARK = [0.0, 0.37, 0.8, 1]
+    COLOR_PRIM = (0.98, 0.98, 0.98, 1)
+    COLOR_PRIM_LIGHT = (1, 1, 1, 1)
+    COLOR_PRIM_DARK = (0.78, 0.78, 0.78, 1)
+    COLOR_SEC = (0.27, 0.54, 1.0, 1)
+    COLOR_SEC_LIGHT = (0.51, 0.73, 1.0, 1)
+    COLOR_SEC_DARK = (0.0, 0.37, 0.8, 1)
+
+    COLOR_INFO = COLOR_PRIM_LIGHT
+    COLOR_WARNING = (1.0, 1.0, 0.0, 1)
+    COLOR_ERROR = (1.0, 0.0, 0.0, 1)
+
--- a/cagou/kv/common.kv	Fri Jan 04 13:20:29 2019 +0100
+++ b/cagou/kv/common.kv	Sat Jan 26 20:24:48 2019 +0100
@@ -47,11 +47,11 @@
             size: self.size
 
 <Symbol>:
-    width: self.height
+    width: dp(35)
+    height: dp(35)
     font_name: app.expand('{media}/fonts/fontello/font/fontello.ttf')
     text_size: self.size
-    font_size: self.width - self.margin
-    margin: dp(5)
+    font_size: dp(30)
     halign: 'center'
     valign: 'middle'
     bg_color: 0, 0, 0, 0
@@ -85,4 +85,3 @@
 <ActionSymbol>:
     bg_color: 0, 0, 0, 0
     color: app.c_sec_light
-    margin: dp(10)
--- a/cagou/kv/common_widgets.kv	Fri Jan 04 13:20:29 2019 +0100
+++ b/cagou/kv/common_widgets.kv	Sat Jan 26 20:24:48 2019 +0100
@@ -26,8 +26,8 @@
     Symbol:
         size_hint: 1, None
         height: dp(80)
+        font_size: dp(40)
         symbol: root.getSymbol()
-        margin: dp(40)
         color: 0, 0, 0, 1
     Label:
         size_hint: None, None
--- a/cagou/kv/root_widget.kv	Fri Jan 04 13:20:29 2019 +0100
+++ b/cagou/kv/root_widget.kv	Sat Jan 26 20:24:48 2019 +0100
@@ -15,6 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #:import IconButton cagou.core.common.IconButton
+#:import C cagou.core.constants.Const
 
 # <NotifIcon>:
 #     source: app.expand("{media}/icons/muchoslava/png/cagou_profil_bleu_32.png")
@@ -30,23 +31,46 @@
     shorten_from: 'right'
 
 <NoteDrop>:
+    orientation: 'horizontal'
+    size_hint: 1, None
+    height: label.height
+    symbol: symbol
     canvas.before:
         BorderImage:
             pos: self.pos
             size: self.size
             source: 'atlas://data/images/defaulttheme/button'
-    size_hint: 1, None
-    color: 1, 1, 1, 1
-    text: self.message
-    text_size: self.width, None
-    halign: 'center'
-    size: self.texture_size
-    padding: dp(2), dp(10)
+    Widget:
+        size_hint: None, 1
+        width: dp(20)
+    Symbol:
+        id: symbol
+        size_hint: None, None
+        width: dp(30)
+        height: label.height
+        padding_y: dp(10)
+        valign: 'top'
+        haligh: 'right'
+        symbol: root.level
+        color:
+            {C.XMLUI_DATA_LVL_INFO: app.c_prim_light,\
+            C.XMLUI_DATA_LVL_WARNING: C.COLOR_WARNING,\
+            C.XMLUI_DATA_LVL_ERROR: C.COLOR_ERROR}[root.level]
+    Label:
+        id: label
+        size_hint: 1, None
+        color: 1, 1, 1, 1
+        text: root.message
+        text_size: self.width, None
+        halign: 'center'
+        size: self.texture_size
+        padding: dp(2), dp(10)
 
 <NotesDrop>:
     clear_btn: clear_btn.__self__
     auto_width: False
-    size_hint: 0.8, None
+    size_hint: 0.9, None
+    size_hint_max_x: dp(400)
     canvas.before:
         Color:
             rgba: 0.8, 0.8, 0.8, 1
--- a/cagou/plugins/plugin_wid_file_sharing.kv	Fri Jan 04 13:20:29 2019 +0100
+++ b/cagou/plugins/plugin_wid_file_sharing.kv	Sat Jan 26 20:24:48 2019 +0100
@@ -45,8 +45,8 @@
     Symbol:
         size_hint: 1, None
         height: dp(80)
+        font_size: dp(40)
         symbol: 'folder-open-empty' if root.is_dir else 'doc'
-        margin: dp(40)
         color: (1, 0, 0, 1) if root.shared else (0, 0, 0, 1) if root.is_dir else app.c_prim_dark
     Label:
         size_hint: None, None
--- a/cagou/plugins/plugin_wid_remote.kv	Fri Jan 04 13:20:29 2019 +0100
+++ b/cagou/plugins/plugin_wid_remote.kv	Sat Jan 26 20:24:48 2019 +0100
@@ -39,7 +39,6 @@
         size_hint: 1, None
         height: dp(80)
         symbol: 'video'
-        margin: dp(40)
         color: 0, 0, 0, 1
     Label:
         size_hint: None, None