menu_view: update hover in primary touch events

This patch simplifies the use of the menu_view in scenarios where no
absolute motion events but only touch events occur. Previously, such
scenarios required the creation of artificial absolute motion events
via the event filter.

Issue #4514
This commit is contained in:
Norman Feske 2022-05-20 14:06:49 +02:00 committed by Christian Helmuth
parent 1f3b6490f2
commit e3f00ce5fc

View File

@ -324,18 +324,30 @@ void Menu_view::Main::_handle_input()
ev.handle_seq_number([&] (Input::Seq_number seq_number) {
_input_seq_number.update(seq_number); });
ev.handle_absolute_motion([&] (int x, int y) {
auto hover_at = [&] (int x, int y)
{
_dialog_hovered = true;
_hovered_position = Point(x, y) - _position;
});
};
auto unhover = [&] ()
{
_dialog_hovered = false;
_hovered_position = Point();
};
ev.handle_absolute_motion([&] (int x, int y) {
hover_at(x, y); });
ev.handle_touch([&] (Input::Touch_id id, float x, float y) {
if (id.value == 0)
hover_at((int)x, (int)y); });
/*
* Reset hover model when losing the focus
*/
if (ev.hover_leave()) {
_dialog_hovered = false;
_hovered_position = Point();
}
if (ev.hover_leave())
unhover();
});
bool const hover_changed = orig_dialog_hovered != _dialog_hovered