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.
This commit is contained in:
Norman Feske 2023-07-13 14:22:09 +02:00 committed by Christian Helmuth
parent 391c261199
commit 6895175764
2 changed files with 7 additions and 0 deletions

View File

@ -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())

View File

@ -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", [&] () {