Merge pull request #4060 from ErrorNoInternet/group-reveal-by-default
feat(group): add reveal-by-default option
This commit is contained in:
@@ -375,6 +375,11 @@ 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.
|
||||
|
||||
*reveal-by-default*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Whether the child should be revealed when Waybar starts up. This has to be used with click-to-reveal to take effect.
|
||||
|
||||
Group drawers are also given the `.expanded` CSS class when they are expanded.
|
||||
|
||||
```
|
||||
|
||||
+14
-6
@@ -62,6 +62,10 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value&
|
||||
const bool left_to_right = (drawer_config["transition-left-to-right"].isBool()
|
||||
? drawer_config["transition-left-to-right"].asBool()
|
||||
: true);
|
||||
const bool reveal_by_default =
|
||||
(drawer_config["reveal-by-default"].isBool() ? drawer_config["reveal-by-default"].asBool()
|
||||
: false);
|
||||
|
||||
click_to_reveal = drawer_config["click-to-reveal"].asBool();
|
||||
reveal_delay = drawer_config["reveal-delay"].asInt();
|
||||
|
||||
@@ -73,10 +77,11 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value&
|
||||
|
||||
revealer.set_transition_type(transition_type);
|
||||
revealer.set_transition_duration(transition_duration);
|
||||
revealer.set_reveal_child(start_expanded);
|
||||
|
||||
if (start_expanded) {
|
||||
if ((click_to_reveal && reveal_by_default) || start_expanded) {
|
||||
box.set_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
|
||||
revealer.set_reveal_child(true);
|
||||
} else {
|
||||
revealer.set_reveal_child(false);
|
||||
}
|
||||
|
||||
revealer.get_style_context()->add_class("drawer");
|
||||
@@ -110,11 +115,14 @@ bool Group::handleMouseEnter(GdkEventCrossing* const& e) {
|
||||
if (reveal_delay > 0) {
|
||||
if (reveal_timeout_.connected()) {
|
||||
reveal_timeout_.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
reveal_timeout_ = Glib::signal_timeout().connect(
|
||||
[this]() { show_group(); return false; },
|
||||
reveal_delay);
|
||||
[this]() {
|
||||
show_group();
|
||||
return false;
|
||||
},
|
||||
reveal_delay);
|
||||
} else {
|
||||
show_group();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user