Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
222cc116 by Nicolas Évrard at 2023-03-14T10:26:08+01:00
Fill the empty spaces when computing alignment while expanded

Closes #12141
- - - - -


2 changed files:

- tryton/tryton/common/common.py
- tryton/tryton/gui/window/view_form/view/form.py


Changes:

=====================================
tryton/tryton/common/common.py
=====================================
@@ -1458,6 +1458,8 @@
 def get_align(float_, expand=True):
     "Convert float align into Gtk.Align"
     value = float(float_)
+    if expand:
+        return Gtk.Align.FILL
     if value < 0.5:
         return Gtk.Align.START
     elif value == 0.5:
@@ -1461,10 +1463,7 @@
     if value < 0.5:
         return Gtk.Align.START
     elif value == 0.5:
-        if expand:
-            return Gtk.Align.FILL
-        else:
-            return Gtk.Align.CENTER
+        return Gtk.Align.CENTER
     else:
         return Gtk.Align.END
 


=====================================
tryton/tryton/gui/window/view_form/view/form.py
=====================================
@@ -279,5 +279,8 @@
             return
         vbox = VBox(attrs=attributes)
         if attributes.get('string'):
+            attributes.setdefault('xexpand', 0)
+            attributes.setdefault('xalign', 0)
+            attributes.setdefault('yalign', 0.5)
             label = Label(label=attributes['string'], attrs=attributes)
             label.set_halign(get_align(
@@ -282,5 +285,5 @@
             label = Label(label=attributes['string'], attrs=attributes)
             label.set_halign(get_align(
-                    attributes.get('xalign', 0.0),
-                    bool(attributes.get('xexpand', True))))
+                    attributes['xalign'],
+                    bool(attributes.get('xexpand'))))
             label.set_valign(get_align(
@@ -286,6 +289,8 @@
             label.set_valign(get_align(
-                    attributes.get('yalign', 0.5),
-                    bool(attributes.get('yexpand', False))))
+                    attributes['yalign'],
+                    bool(attributes.get('yexpand'))))
+            label.props.xalign = float(attributes['xalign'])
+            label.props.yalign = float(attributes['yalign'])
             vbox.pack_start(label, expand=True, fill=True, padding=0)
             self.view.state_widgets.append(label)
             if name:
@@ -303,5 +308,7 @@
             attributes['xalign'] = 0.0
 
         attributes.setdefault('xexpand', 0)
+        attributes.setdefault('xalign', 1)
+        attributes.setdefault('yalign', 0.5)
         label = Label(label=attributes.get('string', ''), attrs=attributes)
         label.set_halign(get_align(
@@ -306,7 +313,7 @@
         label = Label(label=attributes.get('string', ''), attrs=attributes)
         label.set_halign(get_align(
-                attributes.get('xalign', 1.0),
+                attributes['xalign'],
                 bool(attributes.get('xexpand'))))
         label.set_valign(get_align(
                 attributes.get('yalign', 0.5),
                 bool(attributes.get('yexpand'))))
@@ -309,7 +316,9 @@
                 bool(attributes.get('xexpand'))))
         label.set_valign(get_align(
                 attributes.get('yalign', 0.5),
                 bool(attributes.get('yexpand'))))
+        label.props.xalign = float(attributes['xalign'])
+        label.props.yalign = float(attributes['yalign'])
         label.set_angle(int(attributes.get('angle', 0)))
         self.view.state_widgets.append(label)
         self.container.add(label, attributes)



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/222cc11614e680688e09f0ba09d33e2daf93042f

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/222cc11614e680688e09f0ba09d33e2daf93042f
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to