menu_view: propagate widget version attr

The 'Widget::_version' attribute was meant to allow the deliberate
replacement of a widget by a same-named widget by changing the version
while keeping the name, thereby suppressing any geomety animation.

However, the implementation missed to populate the attribute with the
value provided by the dialog ROM, prompting the unconditional
re-creation of the widget whenever a 'version' attribute was specified.
Even though this had the (desired) effect of preventing geometry
animations, it could cause feedback loops between hover reports and
dialog ROMs because the 'hover_changed' condition in 'Menu_view::Main'
would always stay true while a versioned widget is hovered.
This commit is contained in:
Norman Feske 2023-09-27 15:05:31 +02:00 committed by Christian Helmuth
parent 76adfff091
commit 391c261199

View File

@ -102,18 +102,23 @@ class Menu_view::Widget : List_model<Widget>::Element
} }
}; };
static Name node_name(Xml_node node) static Name node_name(Xml_node const &node)
{ {
return node.attribute_value("name", Name(node.type())); return node.attribute_value("name", Name(node.type()));
} }
static Version node_version(Xml_node const &node)
{
return node.attribute_value("version", Version());
}
static Animated_rect::Steps motion_steps() { return { 60 }; }; static Animated_rect::Steps motion_steps() { return { 60 }; };
protected: protected:
Type_name const _type_name; Type_name const _type_name;
Name const _name; Name const _name;
Version const _version { }; Version const _version;
Unique_id const _unique_id; Unique_id const _unique_id;
@ -143,7 +148,7 @@ class Menu_view::Widget : List_model<Widget>::Element
{ {
return node.has_type(w._type_name.string()) return node.has_type(w._type_name.string())
&& Widget::node_name(node) == w._name && Widget::node_name(node) == w._name
&& node.attribute_value("version", Version()) == w._version; && node_version(node) == w._version;
} }
} _model_update_policy { _factory }; } _model_update_policy { _factory };
@ -218,6 +223,7 @@ class Menu_view::Widget : List_model<Widget>::Element
: :
_type_name(node.type()), _type_name(node.type()),
_name(node_name(node)), _name(node_name(node)),
_version(node_version(node)),
_unique_id(unique_id), _unique_id(unique_id),
_factory(factory) _factory(factory)
{ } { }