From 4426fa952bb28ebdcca580174d2642dacc8a81b2 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Sun, 23 Jun 2024 16:08:58 +0100 Subject: [PATCH] Center Layouts menu items --- modules/app_components/layout.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/app_components/layout.py b/modules/app_components/layout.py index 66e566c..b6410d2 100644 --- a/modules/app_components/layout.py +++ b/modules/app_components/layout.py @@ -104,7 +104,8 @@ def draw(self, ctx, focused=False): # Draw label label_lines = utils.wrap_text(ctx, self.label, tokens.label_font_size) for line in label_lines: - ctx.move_to(0, self.height) + width = ctx.text_width(line) + ctx.move_to(115 - width / 2, self.height) ctx.text(line) self.height += ctx.font_size @@ -114,7 +115,8 @@ def draw(self, ctx, focused=False): ctx.font_size = tokens.ten_pt value_lines = utils.wrap_text(ctx, self.value, tokens.label_font_size, 230) for line in value_lines: - ctx.move_to(10, self.height) + width = ctx.text_width(line) + ctx.move_to(115 - width / 2, self.height) ctx.text(line) self.height += ctx.font_size