changeset 164:60b2b2bad747

core (widget selector): adjusted selector size to content, and added some spacing
author Goffi <goffi@goffi.org>
date Sat, 28 Apr 2018 12:31:48 +0200
parents ef09dce878c7
children e6ec8ff62d87
files cagou/core/cagou_widget.py cagou/kv/cagou_widget.kv
diffstat 2 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/core/cagou_widget.py	Sat Apr 28 11:06:48 2018 +0200
+++ b/cagou/core/cagou_widget.py	Sat Apr 28 12:31:48 2018 +0200
@@ -29,6 +29,7 @@
 
 
 class HeaderWidgetChoice(ButtonBehavior, BoxLayout):
+
     def __init__(self, cagou_widget, plugin_info):
         self.plugin_info = plugin_info
         super(HeaderWidgetChoice, self).__init__()
@@ -47,6 +48,14 @@
             choice = HeaderWidgetChoice(cagou_widget, plugin_info)
             self.add_widget(choice)
 
+    def add_widget(self, *args):
+        widget = args[0]
+        widget.bind(minimum_width=self.set_width)
+        return super(HeaderWidgetSelector, self).add_widget(*args)
+
+    def set_width(self, choice, minimum_width):
+        self.width = max([c.minimum_width for c in self.container.children])
+
 
 class CagouWidget(BoxLayout):
     header_input = properties.ObjectProperty(None)
--- a/cagou/kv/cagou_widget.kv	Sat Apr 28 11:06:48 2018 +0200
+++ b/cagou/kv/cagou_widget.kv	Sat Apr 28 12:31:48 2018 +0200
@@ -25,22 +25,24 @@
             source: 'atlas://data/images/defaulttheme/button'
     size_hint_y: None
     height: dp(44)
+    spacing: dp(20)
+    padding: dp(5), dp(3), dp(10), dp(3)
     Image:
         size_hint: None, 1
         source: root.plugin_info['icon_medium']
         allow_stretch: True
-        width: self.texture_size[0]*self.height/(self.texture_size[1] or 1)
+        width: self.height
     Label:
-        size_hint: 1, 1
+        size_hint: None, 1
         text: root.plugin_info['name']
         color: 1, 1, 1, 1
         bold: True
-        text_size: self.size
+        size: self.texture_size
         halign: "center"
         valign: "middle"
 
 <HeaderWidgetSelector>:
-    size_hint: 0.3, None
+    size_hint: None, None
     auto_width: False
     canvas.before:
         Color:
@@ -56,12 +58,13 @@
         id: header_box
         size_hint: 1, None
         height: dp(32)
+        spacing: dp(3)
         HeaderWidgetCurrent:
             on_release: root.selector.open(self)
             source: root.plugin_info['icon_small']
             size_hint: None, 1
             allow_stretch: True
-            width: self.texture_size[0]*self.height/(self.texture_size[1] or 1)
+            width: self.height
         TextInput:
             id: header_input
             multiline: False