diff src/cagou/core/xmlui.py @ 29:8b5827c43155

notes first draft: Implementation of XMLUI notes. There is a new header on top of root widget which display notifications, and notes are shown for a couple of seconds. A blue Cagou head appear when there are notes, and user can display 10 last when clicking on it. This header will probably not be present on platforms such as Android, because there is already a system-wide notifications handler which can be used instead (saving visual space).
author Goffi <goffi@goffi.org>
date Sun, 21 Aug 2016 15:15:25 +0200
parents 56838ad5c84b
children c21d1be2e54c
line wrap: on
line diff
--- a/src/cagou/core/xmlui.py	Sun Aug 21 15:02:18 2016 +0200
+++ b/src/cagou/core/xmlui.py	Sun Aug 21 15:15:25 2016 +0200
@@ -27,6 +27,10 @@
 from kivy.uix.label import Label
 from kivy.uix.button import Button
 from kivy.uix.widget import Widget
+from cagou import G
+
+
+## Widgets ##
 
 
 class TextWidget(xmlui.TextWidget, Label):
@@ -48,6 +52,9 @@
         return self.text
 
 
+## Containers ##
+
+
 class VerticalContainer(xmlui.VerticalContainer, BoxLayout):
 
     def __init__(self, xmlui_parent):
@@ -57,6 +64,22 @@
         self.add_widget(widget)
 
 
+## Dialogs ##
+
+
+class NoteDialog(xmlui.NoteDialog):
+
+    def __init__(self, _xmlui_parent, title, message, level):
+        xmlui.NoteDialog.__init__(self, _xmlui_parent)
+        self.title, self.message, self.level = title, message, level
+
+    def _xmluiShow(self):
+        G.host.addNote(self.title, self.message, self.level)
+
+
+## Factory ##
+
+
 class WidgetFactory(object):
 
     def __getattr__(self, attr):
@@ -65,6 +88,9 @@
             return cls
 
 
+## Core ##
+
+
 class Title(Label):
 
     def __init__(self, *args, **kwargs):
@@ -106,5 +132,10 @@
         self.add_widget(Widget()) # to have elements on the top
 
 
+class XMLUIDialog(xmlui.XMLUIDialog):
+    dialog_factory = WidgetFactory()
+
+
 xmlui.registerClass(xmlui.CLASS_PANEL, XMLUIPanel)
+xmlui.registerClass(xmlui.CLASS_DIALOG, XMLUIDialog)
 create = xmlui.create