Add inner left box to hide the padded outer box

Fixes: https://github.com/scorpion-26/gBar/issues/78
This commit is contained in:
scorpion-26 2024-03-17 20:43:59 +01:00
parent cb160d8608
commit 1cf8f820c2

View file

@ -1241,18 +1241,24 @@ namespace Bar
endLeftWidgets = -1; endLeftWidgets = -1;
} }
auto left = Widget::Create<Box>(); auto leftWithPadding = Widget::Create<Box>();
left->SetSpacing({6, false}); leftWithPadding->SetSpacing({6, false});
left->SetClass("left"); leftWithPadding->SetClass("left-with-padding");
left->SetOrientation(Utils::GetOrientation()); leftWithPadding->SetOrientation(Utils::GetOrientation());
// For centerTime the width of the left widget handles the centering. // 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. // 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<Box>();
left->SetClass("left");
left->SetOrientation(Utils::GetOrientation());
Utils::SetTransform(*left, {-1, false, Alignment::Left});
for (auto& widget : Config::Get().widgetsLeft) for (auto& widget : Config::Get().widgetsLeft)
{ {
ChooseWidgetToDraw(widget, *left, Side::Left); ChooseWidgetToDraw(widget, *left, Side::Left);
} }
leftWithPadding->AddChild(std::move(left));
auto center = Widget::Create<Box>(); auto center = Widget::Create<Box>();
center->SetClass("center"); center->SetClass("center");
@ -1276,7 +1282,7 @@ namespace Bar
ChooseWidgetToDraw(widget, *right, Side::Right); ChooseWidgetToDraw(widget, *right, Side::Right);
} }
mainWidget->AddChild(std::move(left)); mainWidget->AddChild(std::move(leftWithPadding));
mainWidget->AddChild(std::move(center)); mainWidget->AddChild(std::move(center));
mainWidget->AddChild(std::move(right)); mainWidget->AddChild(std::move(right));
} }