From 4653e2eb3b67898a6aa0d1c8db58d0500f4e60c0 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Sat, 28 Jan 2023 21:57:04 +0100 Subject: [PATCH] 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. --- repos/gems/recipes/pkg/touch_keyboard/runtime | 3 ++- repos/gems/src/app/touch_keyboard/README | 7 ++++++- repos/gems/src/app/touch_keyboard/main.cc | 10 ++++++++++ .../touch_keyboard/touch_keyboard_dialog.cc | 19 +++++++------------ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/repos/gems/recipes/pkg/touch_keyboard/runtime b/repos/gems/recipes/pkg/touch_keyboard/runtime index 2754ebc584..0ebe3944d8 100644 --- a/repos/gems/recipes/pkg/touch_keyboard/runtime +++ b/repos/gems/recipes/pkg/touch_keyboard/runtime @@ -23,7 +23,8 @@ - + diff --git a/repos/gems/src/app/touch_keyboard/README b/repos/gems/src/app/touch_keyboard/README index b0cedf137f..da4196f280 100644 --- a/repos/gems/src/app/touch_keyboard/README +++ b/repos/gems/src/app/touch_keyboard/README @@ -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. -! +! + +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 diff --git a/repos/gems/src/app/touch_keyboard/main.cc b/repos/gems/src/app/touch_keyboard/main.cc index 8694744466..1c9f39e721 100644 --- a/repos/gems/src/app/touch_keyboard/main.cc +++ b/repos/gems/src/app/touch_keyboard/main.cc @@ -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 _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); } }; diff --git a/repos/gems/src/app/touch_keyboard/touch_keyboard_dialog.cc b/repos/gems/src/app/touch_keyboard/touch_keyboard_dialog.cc index 5e772e7f02..3a0c16f9a8 100644 --- a/repos/gems/src/app/touch_keyboard/touch_keyboard_dialog.cc +++ b/repos/gems/src/app/touch_keyboard/touch_keyboard_dialog.cc @@ -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); - }); - }); + _maps.for_each([&] (Map const &map) { + gen_map(map); }); } @@ -105,13 +102,11 @@ 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) { - 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()); - hovered_key_id = button.attribute_value("name", Key::Id()); - }); + 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()); + hovered_key_id = button.attribute_value("name", Key::Id()); }); }); });