Merge pull request #2881 from jramrath/drawer-direction
Fix: drawer not appearing on configured side
This commit is contained in:
commit
b6f4a0dae2
|
@ -9,21 +9,20 @@
|
||||||
|
|
||||||
namespace waybar {
|
namespace waybar {
|
||||||
|
|
||||||
const Gtk::RevealerTransitionType getPreferredTransitionType(bool is_vertical, bool left_to_right) {
|
const 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':
|
||||||
|
* 'REVEALER_TRANSITION_TYPE_SLIDE_LEFT' and 'REVEALER_TRANSITION_TYPE_SLIDE_RIGHT'
|
||||||
|
* will result in the same thing.
|
||||||
|
* However: we still need to differentiate between vertical and horizontal transition types.
|
||||||
|
*/
|
||||||
|
|
||||||
if (is_vertical) {
|
if (is_vertical) {
|
||||||
if (left_to_right) {
|
|
||||||
return Gtk::RevealerTransitionType::REVEALER_TRANSITION_TYPE_SLIDE_DOWN;
|
|
||||||
} else {
|
|
||||||
return Gtk::RevealerTransitionType::REVEALER_TRANSITION_TYPE_SLIDE_UP;
|
return Gtk::RevealerTransitionType::REVEALER_TRANSITION_TYPE_SLIDE_UP;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (left_to_right) {
|
|
||||||
return Gtk::RevealerTransitionType::REVEALER_TRANSITION_TYPE_SLIDE_RIGHT;
|
|
||||||
} else {
|
} else {
|
||||||
return Gtk::RevealerTransitionType::REVEALER_TRANSITION_TYPE_SLIDE_LEFT;
|
return Gtk::RevealerTransitionType::REVEALER_TRANSITION_TYPE_SLIDE_LEFT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Group::Group(const std::string& name, const std::string& id, const Json::Value& config,
|
Group::Group(const std::string& name, const std::string& id, const Json::Value& config,
|
||||||
bool vertical)
|
bool vertical)
|
||||||
|
@ -64,7 +63,7 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value&
|
||||||
? drawer_config["transition-left-to-right"].asBool()
|
? drawer_config["transition-left-to-right"].asBool()
|
||||||
: true);
|
: true);
|
||||||
|
|
||||||
auto transition_type = getPreferredTransitionType(vertical, left_to_right);
|
auto transition_type = getPreferredTransitionType(vertical);
|
||||||
|
|
||||||
revealer.set_transition_type(transition_type);
|
revealer.set_transition_type(transition_type);
|
||||||
revealer.set_transition_duration(transition_duration);
|
revealer.set_transition_duration(transition_duration);
|
||||||
|
@ -73,7 +72,13 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value&
|
||||||
revealer.get_style_context()->add_class("drawer");
|
revealer.get_style_context()->add_class("drawer");
|
||||||
|
|
||||||
revealer.add(revealer_box);
|
revealer.add(revealer_box);
|
||||||
|
|
||||||
|
if (left_to_right) {
|
||||||
|
box.pack_end(revealer);
|
||||||
|
}
|
||||||
|
else {
|
||||||
box.pack_start(revealer);
|
box.pack_start(revealer);
|
||||||
|
}
|
||||||
|
|
||||||
addHoverHandlerTo(revealer);
|
addHoverHandlerTo(revealer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue