From 1490c58f8b5b66decf9b57d735587c60e4f3d1d2 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 10 Nov 2023 17:06:52 +0100 Subject: [PATCH] dialog: Hosted::if_hovered method This method allows for the inquiry of the current hovering state, e.g., to suppress an update of the Wifi accesspoint list while the list is hovered. Issue #5008 Issue #5053 --- repos/gems/include/dialog/types.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/repos/gems/include/dialog/types.h b/repos/gems/include/dialog/types.h index 0241df3c53..c8a3a7df27 100644 --- a/repos/gems/include/dialog/types.h +++ b/repos/gems/include/dialog/types.h @@ -31,6 +31,7 @@ namespace Dialog { struct Clicked_at; struct Clacked_at; struct Dragged_at; + struct Hovered_at; static inline Clicked_at const &clicked_at(At const &at); template struct Scope; struct Sub_scope; @@ -185,6 +186,7 @@ struct Dialog::At : Noncopyable struct Dialog::Clicked_at : At { using At::At; }; struct Dialog::Clacked_at : At { using At::At; }; struct Dialog::Dragged_at : At { using At::At; }; +struct Dialog::Hovered_at : At { using At::At; }; static inline Dialog::Clicked_at const &Dialog::clicked_at(At const &at) @@ -372,6 +374,14 @@ struct Dialog::Hosted : Meta::Last::Type void propagate(Dragged_at const &at, auto &&... args) const { _with_narrowed_at(at, [&] (auto const &at) { this->drag(at, args...); }); } + bool if_hovered(Hovered_at const &at, auto const &fn) const + { + bool result = false; + _with_narrowed_at(at, [&] (Hovered_at const &at) { + result = !at._location.has_type("empty") && fn(at); }); + return result; + } + /* * \noapi used internally by 'Scope::widget' */