Merge pull request #3422 from RobertMueller2/issue_feat_3256

feat/issue 3256: Toggle drawer state
This commit is contained in:
Alexis Rouillard
2024-07-16 14:19:30 +02:00
committed by GitHub
3 changed files with 37 additions and 3 deletions

View File

@ -62,6 +62,7 @@ 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);
click_to_reveal = drawer_config["click-to-reveal"].asBool();
auto transition_type = getPreferredTransitionType(vertical);
@ -83,18 +84,42 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value&
event_box_.add(box);
}
bool Group::handleMouseEnter(GdkEventCrossing* const& e) {
void Group::show_group() {
box.set_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
revealer.set_reveal_child(true);
}
void Group::hide_group() {
box.unset_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
revealer.set_reveal_child(false);
}
bool Group::handleMouseEnter(GdkEventCrossing* const& e) {
if (!click_to_reveal) {
show_group();
}
return false;
}
bool Group::handleMouseLeave(GdkEventCrossing* const& e) {
box.unset_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
revealer.set_reveal_child(false);
if (!click_to_reveal) {
hide_group();
}
return false;
}
bool Group::handleToggle(GdkEventButton* const& e) {
if (!click_to_reveal || e->button != 1) {
return false;
}
if (box.get_state_flags() & Gtk::StateFlags::STATE_FLAG_PRELIGHT) {
hide_group();
} else {
show_group();
}
return true;
}
auto Group::update() -> void {
// noop
}