changeset 3005:595b8857538b

primitivus: better popup sizing: - showPopUp now takes absolute height and width, this makes more sense than the relative ones used before - if height or width is not set, a default is used which depend of the type of the widget (it's smaller if the widget is a note) - size is set to a low value for widget alerts - size is bigger else fix 324
author Goffi <goffi@goffi.org>
date Sun, 14 Jul 2019 20:42:14 +0200
parents d86cddc1cd05
children ba9aaf7d6cd0
files sat_frontends/primitivus/primitivus
diffstat 1 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/sat_frontends/primitivus/primitivus	Sun Jul 14 20:38:34 2019 +0200
+++ b/sat_frontends/primitivus/primitivus	Sun Jul 14 20:42:14 2019 +0200
@@ -586,7 +586,7 @@
         """
         popup = sat_widgets.Alert(title, message)
         popup.setCallback('ok', lambda dummy: self.removePopUp(popup))
-        self.showPopUp(popup)
+        self.showPopUp(popup, width=75, height=20)
         return popup
 
     def removePopUp(self, widget=None):
@@ -612,10 +612,24 @@
         else:
             self.redraw()
 
-    def showPopUp(self, pop_up_widget, perc_width=40, perc_height=40, align='center', valign='middle'):
-        "Show a pop-up window if possible, else put it in queue"
+    def showPopUp(self, pop_up_widget, width=None, height=None, align='center',
+                  valign='middle'):
+        """Show a pop-up window if possible, else put it in queue
+
+        @param pop_up_widget: pop up to show
+        @param width(int, None): width of the popup
+            None to use default
+        @param height(int, None): height of the popup
+            None to use default
+        @param align: same as for [urwid.Overlay]
+        """
+        if width == None:
+            width = 75 if isinstance(pop_up_widget, xmlui.PrimitivusNoteDialog) else 135
+        if height == None:
+            height = 20 if isinstance(pop_up_widget, xmlui.PrimitivusNoteDialog) else 40
         if not isinstance(self.loop.widget, urwid.Overlay):
-            display_widget = urwid.Overlay(pop_up_widget, self.main_widget, align, ('relative', perc_width), valign, ('relative', perc_height))
+            display_widget = urwid.Overlay(
+                pop_up_widget, self.main_widget, align, width, valign, height)
             self.loop.widget = display_widget
             self.redraw()
         else: