From dea66025b91832df59c435afd9b72966ef1e61b1 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Tue, 11 Aug 2020 17:54:40 +0300 Subject: Fixed centering a sheet not under root --- src/ui/util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ui/util.c b/src/ui/util.c index 71539fa0..36fd91eb 100644 --- a/src/ui/util.c +++ b/src/ui/util.c @@ -484,7 +484,10 @@ iWidget *makeSheet_Widget(const char *id) { void centerSheet_Widget(iWidget *sheet) { arrange_Widget(sheet); const iInt2 rootSize = rootSize_Window(get_Window()); - sheet->rect.pos.x = rootSize.x / 2 - sheet->rect.size.x / 2; + const iInt2 orig = localCoord_Widget( + sheet->parent, + init_I2(rootSize.x / 2 - sheet->rect.size.x / 2, bounds_Widget(sheet).pos.y)); + sheet->rect.pos = orig; postRefresh_App(); } -- cgit v1.2.3