details: https://code.tryton.org/tryton/commit/944e2d85186a
branch: 6.0
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 | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diffs (28 lines):
diff -r e479c10db536 -r 944e2d85186a tryton/tryton/common/common.py
--- a/tryton/tryton/common/common.py Thu Oct 16 16:07:52 2025 +0200
+++ b/tryton/tryton/common/common.py Tue Dec 02 13:39:07 2025 +0100
@@ -135,6 +135,11 @@
ET.register_namespace('', 'http://www.w3.org/2000/svg')
root = ET.fromstring(data)
root.attrib['fill'] = color
+ view_box = root.attrib.get('viewBox')
+ if view_box:
+ min_x, min_y, width, height = map(
+ float, view_box.split(' '))
+ factor = max(width, height) / 24
if badge:
if not isinstance(badge, str):
try:
@@ -142,9 +147,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)