From 6895175764f0b6d9d27d7a434e3686dcfb9fb4b3 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 13 Jul 2023 14:22:09 +0200 Subject: [PATCH] menu_view: omit label hover details by default Each hover change of the character position within a label results in a new hover report, which needs to be evaluated by the application. For the common cases where labels are used as button texts or for presenting passive information, the level of detail is not needed while the recurring hover reports induce overhead at the application side. This patch mitigates this overhead by excluding labels from the hover reporting by default. For use cases that actually depend of precise hover reporting of labels, for example an editable text area, the hover reporting can be enabled by setting the 'hover="yes"' attribute of the label. --- repos/gems/src/app/menu_view/label_widget.h | 6 ++++++ repos/gems/src/app/text_area/dialog.cc | 1 + 2 files changed, 7 insertions(+) diff --git a/repos/gems/src/app/menu_view/label_widget.h b/repos/gems/src/app/menu_view/label_widget.h index 8f130a8e16..bf66721e52 100644 --- a/repos/gems/src/app/menu_view/label_widget.h +++ b/repos/gems/src/app/menu_view/label_widget.h @@ -32,6 +32,8 @@ struct Menu_view::Label_widget : Widget, Cursor::Glyph_position Animated_color _color; + bool _hover = false; /* report hover details */ + int _min_width = 0; int _min_height = 0; @@ -61,6 +63,7 @@ struct Menu_view::Label_widget : Widget, Cursor::Glyph_position _text = Text(""); _min_width = 0; _min_height = 0; + _hover = node.attribute_value("hover", false); _factory.styles.with_label_style(node, [&] (Label_style style) { _color.fade_to(style.color, Animated_color::Steps{80}); }); @@ -139,6 +142,9 @@ struct Menu_view::Label_widget : Widget, Cursor::Glyph_position Hovered hovered(Point at) const override { + if (!_hover) + return Hovered { .unique_id = { }, .detail = { } }; + Unique_id const hovered_id = Widget::hovered(at).unique_id; if (!hovered_id.valid()) diff --git a/repos/gems/src/app/text_area/dialog.cc b/repos/gems/src/app/text_area/dialog.cc index cfacdfe12e..04a037111e 100644 --- a/repos/gems/src/app/text_area/dialog.cc +++ b/repos/gems/src/app/text_area/dialog.cc @@ -128,6 +128,7 @@ void Dialog::produce_xml(Xml_generator &xml) xml.node("label", [&] () { xml.attribute("font", "monospace/regular"); xml.attribute("text", String<512>(line)); + xml.attribute("hover", "yes"); if (_cursor.y.value == at.value) xml.node("cursor", [&] () {