Add stretching of modules and modules-center toggling
This Patch allows the stretching of modules-{left,center,right} as well add a "expand" flag to AModule. This allows one module to consume the leftover space. To allow the left or right modules to fully consume the center, the changes also include a way to remove the center box (center_) altogether.
This commit is contained in:
36
src/bar.cpp
36
src/bar.cpp
@ -534,13 +534,22 @@ void waybar::Bar::getModules(const Factory& factory, const std::string& pos,
|
||||
|
||||
auto waybar::Bar::setupWidgets() -> void {
|
||||
window.add(box_);
|
||||
box_.pack_start(left_, false, false);
|
||||
if (config["fixed-center"].isBool() ? config["fixed-center"].asBool() : true) {
|
||||
box_.set_center_widget(center_);
|
||||
} else {
|
||||
box_.pack_start(center_, true, false);
|
||||
|
||||
bool expand_left = config["expand-left"].isBool() ? config["expand-left"].asBool() : false;
|
||||
bool expand_center = config["expand-center"].isBool() ? config["expand-center"].asBool() : false;
|
||||
bool expand_right = config["expand-right"].isBool() ? config["expand-right"].asBool() : false;
|
||||
bool no_center = config["no-center"].isBool() ? config["no-center"].asBool() : false;
|
||||
|
||||
box_.pack_start(left_, expand_left, expand_left);
|
||||
if (!no_center) {
|
||||
if (config["fixed-center"].isBool() ? config["fixed-center"].asBool() : true) {
|
||||
box_.set_center_widget(center_);
|
||||
} else {
|
||||
spdlog::error("No fixed center_");
|
||||
box_.pack_start(center_, true, expand_center);
|
||||
}
|
||||
}
|
||||
box_.pack_end(right_, false, false);
|
||||
box_.pack_end(right_, expand_right, expand_right);
|
||||
|
||||
// Convert to button code for every module that is used.
|
||||
setupAltFormatKeyForModuleList("modules-left");
|
||||
@ -549,14 +558,21 @@ auto waybar::Bar::setupWidgets() -> void {
|
||||
|
||||
Factory factory(*this, config);
|
||||
getModules(factory, "modules-left");
|
||||
getModules(factory, "modules-center");
|
||||
if (!no_center) {
|
||||
getModules(factory, "modules-center");
|
||||
}
|
||||
getModules(factory, "modules-right");
|
||||
|
||||
for (auto const& module : modules_left_) {
|
||||
left_.pack_start(*module, false, false);
|
||||
left_.pack_start(*module, module->expandEnabled(), module->expandEnabled());
|
||||
}
|
||||
for (auto const& module : modules_center_) {
|
||||
center_.pack_start(*module, false, false);
|
||||
|
||||
if (!no_center) {
|
||||
for (auto const& module : modules_center_) {
|
||||
center_.pack_start(*module, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
std::reverse(modules_right_.begin(), modules_right_.end());
|
||||
for (auto const& module : modules_right_) {
|
||||
right_.pack_end(*module, false, false);
|
||||
|
Reference in New Issue
Block a user