From 2639267e1f654cc7ee4e7a8202628d1fbacfd592 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Sun, 19 Nov 2023 21:42:12 -0500 Subject: [PATCH] Center navbar buttons --- playlet-lib/src/components/NavBar/NavBar.bs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/playlet-lib/src/components/NavBar/NavBar.bs b/playlet-lib/src/components/NavBar/NavBar.bs index 670686dc..9c233000 100644 --- a/playlet-lib/src/components/NavBar/NavBar.bs +++ b/playlet-lib/src/components/NavBar/NavBar.bs @@ -47,6 +47,18 @@ function PopulateButtons() as void m.top.focusable = buttons.Count() > 0 m.top.focusIndex = m.top.focusIndex + + CenterButtons() +end function + +function CenterButtons() + parent = m.buttonGroup.getParent() + parentWidth = parent.width + parentHeight = parent.height + + rect = m.buttonGroup.boundingRect() + + m.buttonGroup.translation = [parentWidth / 2 - rect.width / 2, parentHeight / 2 - rect.height / 2] end function function onKeyEvent(key as string, press as boolean) as boolean