# HG changeset patch # User Goffi # Date 1524911508 -7200 # Node ID 60b2b2bad747bcedaac753f0cbc0e54b89ff1f7f # Parent ef09dce878c77ae0505f7e0b231a7c596bac9b23 core (widget selector): adjusted selector size to content, and added some spacing diff -r ef09dce878c7 -r 60b2b2bad747 cagou/core/cagou_widget.py --- 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) diff -r ef09dce878c7 -r 60b2b2bad747 cagou/kv/cagou_widget.kv --- 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" : - 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