mirror of
https://github.com/rad4day/Waybar.git
synced 2025-07-14 07:02:30 +02:00
group module: configurable orientation
currently, the orientation of group modules is always the opposite of the bar. Change it so that: * the default orientation of the group module is always the opposite of its parent, even for nested groups * the orientation can be overridden in the config * css ID and class are set for the group element
This commit is contained in:
@ -6,9 +6,30 @@
|
||||
|
||||
namespace waybar {
|
||||
|
||||
Group::Group(const std::string& name, const Bar& bar, const Json::Value& config)
|
||||
: AModule(config, name, "", false, false),
|
||||
box{bar.vertical ? Gtk::ORIENTATION_HORIZONTAL : Gtk::ORIENTATION_VERTICAL, 0} {}
|
||||
Group::Group(const std::string& name, const std::string& id, const Json::Value& config,
|
||||
bool vertical)
|
||||
: AModule(config, name, id, false, false),
|
||||
box{vertical ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL, 0} {
|
||||
box.set_name(name_);
|
||||
if (!id.empty()) {
|
||||
box.get_style_context()->add_class(id);
|
||||
}
|
||||
|
||||
// default orientation: orthogonal to parent
|
||||
auto orientation =
|
||||
config_["orientation"].empty() ? "orthogonal" : config_["orientation"].asString();
|
||||
if (orientation == "inherit") {
|
||||
// keep orientation passed
|
||||
} else if (orientation == "orthogonal") {
|
||||
box.set_orientation(vertical ? Gtk::ORIENTATION_HORIZONTAL : Gtk::ORIENTATION_VERTICAL);
|
||||
} else if (orientation == "vertical") {
|
||||
box.set_orientation(Gtk::ORIENTATION_VERTICAL);
|
||||
} else if (orientation == "horizontal") {
|
||||
box.set_orientation(Gtk::ORIENTATION_HORIZONTAL);
|
||||
} else {
|
||||
throw std::runtime_error("Invalid orientation value: " + orientation);
|
||||
}
|
||||
}
|
||||
|
||||
auto Group::update() -> void {
|
||||
// noop
|
||||
|
Reference in New Issue
Block a user