I do this for my
Controls,
std::unordered_set<std::string> m_controlsWithMouseOver;
std::unordered_set<std::string> m_controlsOnMouseEnter;
std::unordered_set<std::string> m_controlsOnMouseOver;
std::unordered_set<std::string> m_controlsOnMouseExit;
std::unordered_map<std::string, std::shared_ptr<Control>> m_controls;
The
m_controls variable hold all my controls;
m_controlsOnMouseEnter,
m_controlsOnMouseOver,
m_controlsOnMouseExit hold the controls that I'm checking for mouseEvents;
And
m_controlsWithMouseOver are the controls with 'Over'.
In each '
mouseMove sf::Event', I check based on those variables which function I should call, then I just call it.
control->mouseEnter();
control->mouseOver();
control->mouseExit();
And yeah, there's some ifs and elses, but not so much, just the needed.