From ffc25fde538d316f52dd073a89f20276672f23ec Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 19 Jul 2023 17:08:27 +0200 Subject: [PATCH] sculpt: apply Dialog API to diag, panel, and graph This patch partially converts the Sculpt manager to the dialog API. At this stage, both the old utilities and the new dialog API are still used simultaneously. Issue #5008 --- .../recipes/src/sculpt_manager/content.mk | 2 +- repos/gems/sculpt/leitzentrale/default | 13 +- repos/gems/src/app/sculpt_manager/deploy.cc | 17 +- repos/gems/src/app/sculpt_manager/deploy.h | 10 +- repos/gems/src/app/sculpt_manager/graph.cc | 607 ++++++++---------- repos/gems/src/app/sculpt_manager/graph.h | 83 ++- repos/gems/src/app/sculpt_manager/main.cc | 335 +++++----- .../gems/src/app/sculpt_manager/model/popup.h | 2 - repos/gems/src/app/sculpt_manager/storage.cc | 4 +- repos/gems/src/app/sculpt_manager/storage.h | 33 +- repos/gems/src/app/sculpt_manager/target.mk | 3 +- .../sculpt_manager/view/deprecated_dialog.h | 8 - .../gems/src/app/sculpt_manager/view/dialog.h | 356 ++++++++++ ...load_status.h => download_status_dialog.h} | 47 +- .../src/app/sculpt_manager/view/fs_dialog.h | 92 --- .../app/sculpt_manager/view/fs_operations.h | 61 ++ .../app/sculpt_manager/view/layout_helper.h | 26 - .../app/sculpt_manager/view/panel_dialog.cc | 88 +-- .../app/sculpt_manager/view/panel_dialog.h | 53 +- .../sculpt_manager/view/partition_dialog.cc | 240 ------- .../sculpt_manager/view/partition_dialog.h | 77 --- .../view/partition_operations.cc | 161 +++++ .../view/partition_operations.h | 57 ++ .../app/sculpt_manager/view/ram_fs_dialog.h | 98 +-- .../view/software_presets_dialog.h | 2 +- .../view/software_update_dialog.h | 2 +- .../view/software_version_dialog.h | 2 +- .../view/storage_device_dialog.cc | 124 ++-- .../view/storage_device_dialog.h | 76 +-- .../app/sculpt_manager/view/storage_dialog.cc | 172 ----- .../app/sculpt_manager/view/storage_dialog.h | 193 +++++- 31 files changed, 1454 insertions(+), 1590 deletions(-) rename repos/gems/src/app/sculpt_manager/view/{download_status.h => download_status_dialog.h} (53%) delete mode 100644 repos/gems/src/app/sculpt_manager/view/fs_dialog.h create mode 100644 repos/gems/src/app/sculpt_manager/view/fs_operations.h delete mode 100644 repos/gems/src/app/sculpt_manager/view/partition_dialog.cc delete mode 100644 repos/gems/src/app/sculpt_manager/view/partition_dialog.h create mode 100644 repos/gems/src/app/sculpt_manager/view/partition_operations.cc create mode 100644 repos/gems/src/app/sculpt_manager/view/partition_operations.h delete mode 100644 repos/gems/src/app/sculpt_manager/view/storage_dialog.cc diff --git a/repos/gems/recipes/src/sculpt_manager/content.mk b/repos/gems/recipes/src/sculpt_manager/content.mk index ba423e8632..05c275782b 100644 --- a/repos/gems/recipes/src/sculpt_manager/content.mk +++ b/repos/gems/recipes/src/sculpt_manager/content.mk @@ -2,7 +2,7 @@ SRC_DIR := src/app/sculpt_manager include $(GENODE_DIR)/repos/base/recipes/src/content.inc -MIRROR_FROM_REP_DIR := include/depot src/app/depot_deploy +MIRROR_FROM_REP_DIR := include/depot src/app/depot_deploy include/dialog content: $(MIRROR_FROM_REP_DIR) diff --git a/repos/gems/sculpt/leitzentrale/default b/repos/gems/sculpt/leitzentrale/default index 9cc73ec70f..45bbd1607a 100644 --- a/repos/gems/sculpt/leitzentrale/default +++ b/repos/gems/sculpt/leitzentrale/default @@ -95,7 +95,6 @@ - @@ -119,10 +118,9 @@ - - + - + - + @@ -259,7 +257,6 @@ - diff --git a/repos/gems/src/app/sculpt_manager/deploy.cc b/repos/gems/src/app/sculpt_manager/deploy.cc index fe627f6c7b..d520983cd0 100644 --- a/repos/gems/src/app/sculpt_manager/deploy.cc +++ b/repos/gems/src/app/sculpt_manager/deploy.cc @@ -33,7 +33,7 @@ bool Sculpt::Deploy::update_child_conditions() } -void Sculpt::Deploy::gen_child_diagnostics(Xml_generator &xml) const +void Sculpt::Deploy::view_diag(Scope<> &s) const { /* * Collect messages in registry, avoiding duplicates @@ -59,7 +59,7 @@ void Sculpt::Deploy::gen_child_diagnostics(Xml_generator &xml) const }; _children.for_each_unsatisfied_child([&] (Xml_node start, Xml_node launcher, - Start_name const &name) { + Start_name const &name) { gen_missing_dependencies(start, name); gen_missing_dependencies(launcher, name); }); @@ -67,17 +67,8 @@ void Sculpt::Deploy::gen_child_diagnostics(Xml_generator &xml) const /* * Generate dialog elements, drop consumed messages from the registry */ - int count = 0; messages.for_each([&] (Registered_message &message) { - gen_named_node(xml, "hbox", String<20>(count++), [&] () { - gen_named_node(xml, "float", "left", [&] () { - xml.attribute("west", "yes"); - xml.node("label", [&] () { - xml.attribute("text", message); - xml.attribute("font", "annotation/regular"); - }); - }); - }); + s.sub_scope(message); destroy(_alloc, &message); }); } @@ -170,7 +161,7 @@ void Sculpt::Deploy::handle_deploy() /* apply runtime condition checks */ update_child_conditions(); - _dialog_generator.generate_dialog(); + _action.refresh_deploy_dialog(); _runtime_config_generator.generate_runtime_config(); } } diff --git a/repos/gems/src/app/sculpt_manager/deploy.h b/repos/gems/src/app/sculpt_manager/deploy.h index b8315b6994..d1e5edec68 100644 --- a/repos/gems/src/app/sculpt_manager/deploy.h +++ b/repos/gems/src/app/sculpt_manager/deploy.h @@ -45,7 +45,9 @@ struct Sculpt::Deploy Runtime_info const &_runtime_info; - Deprecated_dialog::Generator &_dialog_generator; + struct Action : Interface { virtual void refresh_deploy_dialog() = 0; }; + + Action &_action; Runtime_config_generator &_runtime_config_generator; @@ -248,7 +250,7 @@ struct Sculpt::Deploy return !all_satisfied; } - void gen_child_diagnostics(Xml_generator &xml) const; + void view_diag(Scope<> &) const; void gen_runtime_start_nodes(Xml_generator &, Prio_levels, Affinity::Space) const; @@ -291,7 +293,7 @@ struct Sculpt::Deploy Deploy(Env &env, Allocator &alloc, Registry &child_states, Runtime_info const &runtime_info, - Deprecated_dialog::Generator &dialog_generator, + Action &action, Runtime_config_generator &runtime_config_generator, Depot_query &depot_query, Attached_rom_dataspace const &launcher_listing_rom, @@ -300,7 +302,7 @@ struct Sculpt::Deploy : _env(env), _alloc(alloc), _child_states(child_states), _runtime_info(runtime_info), - _dialog_generator(dialog_generator), + _action(action), _runtime_config_generator(runtime_config_generator), _depot_query(depot_query), _launcher_listing_rom(launcher_listing_rom), diff --git a/repos/gems/src/app/sculpt_manager/graph.cc b/repos/gems/src/app/sculpt_manager/graph.cc index 394aef0b4f..17efbfad03 100644 --- a/repos/gems/src/app/sculpt_manager/graph.cc +++ b/repos/gems/src/app/sculpt_manager/graph.cc @@ -18,43 +18,90 @@ using namespace Sculpt; -void Graph::_gen_selected_node_content(Xml_generator &xml, Start_name const &name, - Runtime_state::Info const &info) const +namespace Dialog { struct Parent_node; } + +struct Dialog::Parent_node : Sub_scope +{ + template + static void view_sub_scope(SCOPE &s, TEXT const &text) + { + s.node("frame", [&] { + s.sub_node("label", [&] { + s.attribute("text", Sculpt::Start_name(" ", text, " ")); }); }); + } + + template + static void with_narrowed_at(AT const &, FN const &) { } +}; + + +namespace Dialog { struct Selectable_node; } + +struct Dialog::Selectable_node +{ + struct Attr + { + bool selected; + bool important; + Start_name primary_dep; + Start_name pretty_name; + }; + + template + static void view(Scope &s, Id const &id, + Attr const &attr, FN const &selected_fn) + { + s.sub_scope(id, [&] (Scope &s) { + + if (!attr.important) + s.attribute("style", "unimportant"); + + if (attr.primary_dep.valid()) { + s.attribute("dep", attr.primary_dep); + if (!attr.important) + s.attribute("dep_visible", false); + } + + s.sub_scope([&] (Scope &s) { + + s.sub_scope