touch_keyboard: make background configurable

The touch-keyboard config accepts the new attributes 'opaque="yes"
and 'background=#112233' to control the dialog background. The
attributes are passed unmodified to embedded the menu view.
This commit is contained in:
Norman Feske 2023-01-28 21:57:04 +01:00 committed by Christian Helmuth
parent 611efd9921
commit 4653e2eb3b
4 changed files with 25 additions and 14 deletions

View File

@ -23,7 +23,8 @@
<start name="touch_keyboard" caps="300">
<binary name="touch_keyboard"/>
<resource name="RAM" quantum="14M"/>
<config min_width="720" min_height="480"/>
<config min_width="720" min_height="480"
opaque="yes" background="#3e3e43"/>
<route>
<service name="ROM" label="layout">
<parent label="touch_keyboard_layout.config"/> </service>

View File

@ -6,7 +6,12 @@ By default, the keyboard is positioned at the top-left corner of the screen
with the smallest possible size, given the used font. Those defaults can be
the overridden by the configuration as follows.
! <config min_width="720" min_height="360" xpos="10" ypos="10"/>
! <config min_width="720" min_height="360" xpos="10" ypos="10"
! opaque="yes" background="#000000"/>
The 'opaque' and 'background' attributes control the appearance of the
background. When setting opaque to "yes", the alpha channel is disabled
and the color specified via the 'background' attribute is applied.
The layout of the virtual keyboard is defined by a ROM module requested via
the label "layout". An example can be found at

View File

@ -46,6 +46,9 @@ struct Touch_keyboard::Main : Sandbox::Local_service_base::Wakeup,
unsigned _min_width = 0;
unsigned _min_height = 0;
bool _opaque = false;
Color _background { };
Registry<Child_state> _children { };
Child_state _menu_view_child_state { _children, "menu_view",
@ -132,6 +135,9 @@ struct Touch_keyboard::Main : Sandbox::Local_service_base::Wakeup,
if (_min_width) xml.attribute("width", _min_width);
if (_min_height) xml.attribute("height", _min_height);
if (_opaque) xml.attribute("opaque", "yes");
xml.attribute("background", String<20>(_background));
xml.node("report", [&] () {
xml.attribute("hover", "yes"); });
@ -281,6 +287,9 @@ struct Touch_keyboard::Main : Sandbox::Local_service_base::Wakeup,
_min_width = config.attribute_value("min_width", 0U);
_min_height = config.attribute_value("min_height", 0U);
_opaque = config.attribute_value("opaque", false);
_background = config.attribute_value("background", Color(127, 127, 127, 255));
_dialog.configure(_layout.xml());
}
@ -304,6 +313,7 @@ struct Touch_keyboard::Main : Sandbox::Local_service_base::Wakeup,
_layout.sigh(_config_handler);
_handle_config();
_update_sandbox_config();
log("Customized touch_keyboard_dialog opaque=", _opaque);
}
};

View File

@ -79,11 +79,8 @@ void Dialog::produce_xml(Xml_generator &xml)
gen_row(row); }); });
};
xml.node("frame", [&] () {
_maps.for_each([&] (Map const &map) {
gen_map(map);
});
});
gen_map(map); });
}
@ -105,8 +102,7 @@ void Dialog::handle_hover(Input::Seq_number seq, Xml_node const &dialog)
Row::Id hovered_row_id { };
Key::Id hovered_key_id { };
dialog.with_optional_sub_node("frame", [&] (Xml_node const &frame) {
frame.with_optional_sub_node("vbox", [&] (Xml_node const &vbox) {
dialog.with_optional_sub_node("vbox", [&] (Xml_node const &vbox) {
vbox.with_optional_sub_node("hbox", [&] (Xml_node const &hbox) {
hbox.with_optional_sub_node("vbox", [&] (Xml_node const &button) {
hovered_row_id = hbox .attribute_value("name", Row::Id());
@ -114,7 +110,6 @@ void Dialog::handle_hover(Input::Seq_number seq, Xml_node const &dialog)
});
});
});
});
_maps.for_each([&] (Map const &map) {
if (map.name != _current_map)