details:   https://code.tryton.org/tryton/commit/df7409d417d4
branch:    7.6
user:      Cédric Krier <[email protected]>
date:      Tue Dec 02 13:39:07 2025 +0100
description:
        Make icon badge independent of the view box of the SVG
        (grafted from 7173c77acabbd6f8d9af4412d20b18d701e591dd)
diffstat:

 tryton/tryton/common/common.py |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r cff0ba38985f -r df7409d417d4 tryton/tryton/common/common.py
--- a/tryton/tryton/common/common.py    Thu Oct 02 09:42:19 2025 +0200
+++ b/tryton/tryton/common/common.py    Tue Dec 02 13:39:07 2025 +0100
@@ -140,6 +140,10 @@
                 ET.register_namespace('', 'http://www.w3.org/2000/svg')
                 root = ET.fromstring(data)
                 root.attrib['fill'] = color
+                if view_box := root.attrib.get('viewBox'):
+                    min_x, min_y, width, height = map(
+                        float, view_box.split(' '))
+                    factor = max(width, height) / 24
                 if badge:
                     if not isinstance(badge, str):
                         try:
@@ -147,9 +151,9 @@
                         except IndexError:
                             badge = color
                     ET.SubElement(root, 'circle', {
-                            'cx': '20',
-                            'cy': '4',
-                            'r': '4',
+                            'cx': str(20 * factor + min_x),
+                            'cy': str(4 * factor + min_y),
+                            'r': str(4 * factor),
                             'fill': badge,
                             })
                 data = ET.tostring(root)

Reply via email to