Merge pull request #3145 from haug1/feat/hover-for-all-modules-by-class

feat(#2989): (optional) hover for all modules
This commit is contained in:
Alexis Rouillard
2024-04-20 23:39:41 +02:00
committed by GitHub
4 changed files with 34 additions and 0 deletions

View File

@ -27,6 +27,9 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
spdlog::warn("Wrong actions section configuration. See config by index: {}", it.index());
}
event_box_.signal_enter_notify_event().connect(sigc::mem_fun(*this, &AModule::handleMouseEnter));
event_box_.signal_leave_notify_event().connect(sigc::mem_fun(*this, &AModule::handleMouseLeave));
// configure events' user commands
// hasUserEvent is true if any element from eventMap_ is satisfying the condition in the lambda
bool hasUserEvent =
@ -83,6 +86,20 @@ auto AModule::doAction(const std::string& name) -> void {
}
}
bool AModule::handleMouseEnter(GdkEventCrossing* const& e) {
if (auto* module = event_box_.get_child(); module != nullptr) {
module->set_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
}
return true;
}
bool AModule::handleMouseLeave(GdkEventCrossing* const& e) {
if (auto* module = event_box_.get_child(); module != nullptr) {
module->unset_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
}
return true;
}
bool AModule::handleToggle(GdkEventButton* const& e) { return handleUserEvent(e); }
bool AModule::handleRelease(GdkEventButton* const& e) { return handleUserEvent(e); }