From 1cf8f820c2ee13d694bf845f26e72203d36b31c5 Mon Sep 17 00:00:00 2001 From: scorpion-26 Date: Sun, 17 Mar 2024 20:43:59 +0100 Subject: [PATCH] Add inner left box to hide the padded outer box Fixes: https://github.com/scorpion-26/gBar/issues/78 --- src/Bar.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Bar.cpp b/src/Bar.cpp index e0be365..3c06d9d 100644 --- a/src/Bar.cpp +++ b/src/Bar.cpp @@ -1241,18 +1241,24 @@ namespace Bar endLeftWidgets = -1; } - auto left = Widget::Create(); - left->SetSpacing({6, false}); - left->SetClass("left"); - left->SetOrientation(Utils::GetOrientation()); + auto leftWithPadding = Widget::Create(); + leftWithPadding->SetSpacing({6, false}); + leftWithPadding->SetClass("left-with-padding"); + leftWithPadding->SetOrientation(Utils::GetOrientation()); // For centerTime the width of the left widget handles the centering. // For not centerTime we want to set it as much right as possible. So let this expand as much as possible. - Utils::SetTransform(*left, {endLeftWidgets, !Config::Get().centerWidgets, Alignment::Left, 12, 0}); + Utils::SetTransform(*leftWithPadding, {endLeftWidgets, !Config::Get().centerWidgets, Alignment::Left, 12, 0}); + + auto left = Widget::Create(); + left->SetClass("left"); + left->SetOrientation(Utils::GetOrientation()); + Utils::SetTransform(*left, {-1, false, Alignment::Left}); for (auto& widget : Config::Get().widgetsLeft) { ChooseWidgetToDraw(widget, *left, Side::Left); } + leftWithPadding->AddChild(std::move(left)); auto center = Widget::Create(); center->SetClass("center"); @@ -1276,7 +1282,7 @@ namespace Bar ChooseWidgetToDraw(widget, *right, Side::Right); } - mainWidget->AddChild(std::move(left)); + mainWidget->AddChild(std::move(leftWithPadding)); mainWidget->AddChild(std::move(center)); mainWidget->AddChild(std::move(right)); }