changeset 208:c5c1dd7f88e1

root widget: improved notes: - fixed size/text_size - shorten note when necessary - don't erase notes anymore when more that 10 are available
author Goffi <goffi@goffi.org>
date Fri, 25 May 2018 12:06:08 +0200
parents a8190aecdd79
children 5e92bc937778
files cagou/core/cagou_main.py cagou/kv/root_widget.kv
diffstat 2 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/core/cagou_main.py	Fri May 25 12:04:20 2018 +0200
+++ b/cagou/core/cagou_main.py	Fri May 25 12:06:08 2018 +0200
@@ -102,8 +102,10 @@
     level = properties.OptionProperty(C.XMLUI_DATA_LVL_DEFAULT, options=list(C.XMLUI_DATA_LVLS))
 
 
-class NoteDrop(Note):
-    pass
+class NoteDrop(Label):
+    title = properties.StringProperty()
+    message = properties.StringProperty()
+    level = properties.OptionProperty(C.XMLUI_DATA_LVL_DEFAULT, options=list(C.XMLUI_DATA_LVLS))
 
 
 class NotesDrop(DropDown):
@@ -140,8 +142,6 @@
     def addNote(self, title, message, level):
         note = Note(title=title, message=message, level=level)
         self.notes.append(note)
-        if len(self.notes) > 10:
-            del self.notes[:-10]
         if self.notes_event is None:
             self.notes_event = Clock.schedule_interval(self._displayNextNote, 5)
             self._displayNextNote()
--- a/cagou/kv/root_widget.kv	Fri May 25 12:04:20 2018 +0200
+++ b/cagou/kv/root_widget.kv	Fri May 25 12:06:08 2018 +0200
@@ -23,6 +23,11 @@
 
 <Note>:
     text: self.message
+    text_size: self.parent.size if self.parent else (100, 100)
+    halign: 'center'
+    padding_x: dp(5)
+    shorten: True
+    shorten_from: 'right'
 
 <NoteDrop>:
     canvas.before:
@@ -32,9 +37,10 @@
             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'
-    height: self.texture_size[1]
+    size: self.texture_size
     padding: dp(2), dp(10)
 
 <NotesDrop>: