Add justify config option for Labels

This is especially useful for centering labels on vertical bars.
This commit is contained in:
Merlin Sievers 2024-02-05 14:44:59 +01:00
parent 4c5ff80bbd
commit 89b3203bfa
1 changed files with 11 additions and 0 deletions

View File

@ -49,6 +49,17 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st
label_.set_xalign(align);
}
}
if (config_["justify"].isString()) {
auto justify_str = config_["justify"].asString();
if (justify_str == "left") {
label_.set_justify(Gtk::Justification::JUSTIFY_LEFT);
} else if (justify_str == "right") {
label_.set_justify(Gtk::Justification::JUSTIFY_RIGHT);
} else if (justify_str == "center") {
label_.set_justify(Gtk::Justification::JUSTIFY_CENTER);
}
}
}
auto ALabel::update() -> void { AModule::update(); }