Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions man/waybar.5.scd.in
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,22 @@ A group may hide all but one element, showing them only on mouse hover. In order
Defines the direction of the transition animation. If true, the hidden elements will slide from left to right. If false, they will slide from right to left.
When the bar is vertical, it reads as top-to-bottom.

## Drawer CSS state classes

When a group drawer is rendered, the following additional CSS classes
are applied dynamically to the drawer element based on its state:

* .drawer-open ++
Applied when the drawer is in the open state.

* .drawer-closed ++
Applied when the drawer is in the closed state.

These classes can be used in the `style.css` file to customize the
appearance of group drawers depending on whether they are expanded
or collapsed.


```
"group/power": {
"orientation": "inherit",
Expand Down
29 changes: 29 additions & 0 deletions src/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@

namespace waybar {

static void set_drawer_css_state(Gtk::Widget& w, bool open) {
auto ctx = w.get_style_context();
if (open) {
ctx->add_class("drawer-open");
ctx->remove_class("drawer-closed");
} else {
ctx->add_class("drawer-closed");
ctx->remove_class("drawer-open");
}
}

Gtk::RevealerTransitionType getPreferredTransitionType(bool is_vertical) {
/* The transition direction of a drawer is not actually determined by the transition type,
* but rather by the order of 'box' and 'revealer_box':
Expand Down Expand Up @@ -72,8 +83,12 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value&

revealer.get_style_context()->add_class("drawer");

set_drawer_css_state(revealer, /*open=*/false);

revealer.add(revealer_box);



if (left_to_right) {
box.pack_end(revealer);
} else {
Expand All @@ -87,11 +102,25 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value&
void Group::show_group() {
box.set_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
revealer.set_reveal_child(true);

if (is_drawer) {
set_drawer_css_state(revealer, /*open=*/true);
set_drawer_css_state(box, true);
}


}

void Group::hide_group() {
box.unset_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
revealer.set_reveal_child(false);


if (is_drawer) {
set_drawer_css_state(revealer, /*open=*/false);
set_drawer_css_state(box, false);
}

}

bool Group::handleMouseEnter(GdkEventCrossing* const& e) {
Expand Down