sculpt: deprecate original 'Dialog' interface

By renaming 'Dialog' to 'Deprecated_dialog', we become able to use the
name 'Dialog' for the new API while temporarily keeping the original
interface in tact.

Issue #5008
This commit is contained in:
Norman Feske 2023-07-12 16:20:15 +02:00 committed by Christian Helmuth
parent f90058488f
commit 37d5bdbae5
30 changed files with 199 additions and 179 deletions

View File

@ -45,7 +45,7 @@ struct Sculpt::Deploy
Runtime_info const &_runtime_info;
Dialog::Generator &_dialog_generator;
Deprecated_dialog::Generator &_dialog_generator;
Runtime_config_generator &_runtime_config_generator;
@ -291,7 +291,7 @@ struct Sculpt::Deploy
Deploy(Env &env, Allocator &alloc, Registry<Child_state> &child_states,
Runtime_info const &runtime_info,
Dialog::Generator &dialog_generator,
Deprecated_dialog::Generator &dialog_generator,
Runtime_config_generator &runtime_config_generator,
Depot_query &depot_query,
Attached_rom_dataspace const &launcher_listing_rom,

View File

@ -290,12 +290,12 @@ void Graph::generate(Xml_generator &xml) const
}
Dialog::Hover_result Graph::hover(Xml_node hover)
Deprecated_dialog::Hover_result Graph::hover(Xml_node hover)
{
Hover_result const storage_dialog_hover_result =
_storage_dialog->match_sub_dialog(hover, "depgraph", "frame", "vbox", "frame", "vbox");
Dialog::Hover_result const hover_result = Dialog::any_hover_changed(
Deprecated_dialog::Hover_result const hover_result = Deprecated_dialog::any_hover_changed(
storage_dialog_hover_result,
_ram_fs_dialog.match_sub_dialog(hover, "depgraph", "frame", "vbox", "frame", "vbox"),
_node_button_item.match(hover, "depgraph", "frame", "vbox", "button", "name"),

View File

@ -37,7 +37,7 @@
namespace Sculpt { struct Graph; }
struct Sculpt::Graph : Dialog
struct Sculpt::Graph : Deprecated_dialog
{
Runtime_state &_runtime_state;
Runtime_config const &_runtime_config;

View File

@ -55,7 +55,7 @@ namespace Sculpt { struct Main; }
struct Sculpt::Main : Input_event_handler,
Dialog::Generator,
Deprecated_dialog::Generator,
Runtime_config_generator,
Storage::Target_user,
Network::Action,
@ -70,7 +70,7 @@ struct Sculpt::Main : Input_event_handler,
Popup_dialog::Construction_info,
Depot_query,
Panel_dialog::State,
Dialog,
Deprecated_dialog,
Popup_dialog::Refresh,
Menu_view::Hover_update_handler,
Screensaver::Action
@ -526,14 +526,14 @@ struct Sculpt::Main : Input_event_handler,
}
/**
* Dialog interface
* Deprecated_dialog interface
*/
Hover_result hover(Xml_node) override { return Hover_result::UNMODIFIED; }
void reset() override { }
/**
* Dialog interface
* Deprecated_dialog interface
*/
void generate(Xml_generator &xml) const override
{
@ -590,7 +590,7 @@ struct Sculpt::Main : Input_event_handler,
}
/**
* Dialog::Generator interface
* Deprecated_dialog::Generator interface
*/
void generate_dialog() override
{

View File

@ -18,7 +18,7 @@ using namespace Sculpt;
void Menu_view::_handle_hover()
{
using Hover_result = Dialog::Hover_result;
using Hover_result = Deprecated_dialog::Hover_result;
_hover_rom.update();
@ -55,7 +55,7 @@ void Menu_view::_handle_hover()
Menu_view::Menu_view(Env &env, Registry<Child_state> &registry,
Dialog &dialog, Start_name const &name,
Deprecated_dialog &dialog, Start_name const &name,
Ram_quota ram_quota, Cap_quota cap_quota,
Session_label const &dialog_report_name,
Session_label const &hover_rom_name,

View File

@ -34,7 +34,7 @@ struct Sculpt::Menu_view : Noncopyable
virtual void menu_view_hover_updated() = 0;
};
Dialog &_dialog;
Deprecated_dialog &_dialog;
Hover_update_handler &_hover_update_handler;
@ -64,7 +64,7 @@ struct Sculpt::Menu_view : Noncopyable
enum class Alpha { OPAQUE, ALPHA };
Menu_view(Env &, Registry<Child_state> &registry,
Dialog &, Start_name const &, Ram_quota, Cap_quota,
Deprecated_dialog &, Start_name const &, Ram_quota, Cap_quota,
Session_label const &dialog_report_name,
Session_label const &hover_rom_name,
Hover_update_handler &,

View File

@ -33,7 +33,7 @@ struct Sculpt::Storage : Storage_dialog::Action, Ram_fs_dialog::Action
Allocator &_alloc;
Dialog::Generator &_dialog_generator;
Deprecated_dialog::Generator &_dialog_generator;
Runtime_config_generator &_runtime_config_generator;
@ -185,10 +185,10 @@ struct Sculpt::Storage : Storage_dialog::Action, Ram_fs_dialog::Action
Storage(Env &env, Allocator &alloc,
Registry<Child_state> &child_states,
Dialog::Generator &dialog_generator,
Runtime_config_generator &runtime_config_generator,
Target_user &target_user)
Registry<Child_state> &child_states,
Deprecated_dialog::Generator &dialog_generator,
Runtime_config_generator &runtime_config_generator,
Target_user &target_user)
:
_env(env), _alloc(alloc),
_dialog_generator(dialog_generator),

View File

@ -308,7 +308,7 @@ struct Sculpt::Depot_users_dialog
Hover_result hover(Xml_node const &hover)
{
return Dialog::any_hover_changed(
return Deprecated_dialog::any_hover_changed(
_user .match(hover, "frame", "vbox", "hbox", "name"),
_button.match(hover, "frame", "vbox", "hbox", "hbox", "float", "button", "name")
);

View File

@ -0,0 +1,144 @@
/*
* \brief Menu-view dialog handling
* \author Norman Feske
* \date 2018-05-18
*/
/*
* Copyright (C) 2018 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _VIEW__DEPRECATED_DIALOG_H_
#define _VIEW__DEPRECATED_DIALOG_H_
/* Genode includes */
#include <input/event.h>
#include <util/xml_generator.h>
/* local includes */
#include "types.h"
#include <view/hoverable_item.h>
namespace Sculpt { struct Deprecated_dialog; }
struct Sculpt::Deprecated_dialog : Interface
{
/**
* Interface for triggering the (re-)generation of a menu-view dialog
*
* This interface ls implemented by a top-level dialog and called by a sub
* dialog.
*/
struct Generator : Interface { virtual void generate_dialog() = 0; };
bool hovered = false;
enum class Click_result { CONSUMED, IGNORED };
enum class Clack_result { CONSUMED, IGNORED };
using Hover_result = Hoverable_item::Hover_result;
virtual void reset() = 0;
virtual Hover_result hover(Xml_node hover) = 0;
virtual void generate(Xml_generator &xml) const = 0;
static Hover_result any_hover_changed(Hover_result head)
{
return head;
}
template <typename... TAIL>
static Hover_result any_hover_changed(Hover_result head, TAIL... args)
{
if (head == Hover_result::CHANGED)
return Hover_result::CHANGED;
return any_hover_changed(args...);
}
Hover_result _match_sub_dialog(Xml_node node)
{
hovered = true;
return hover(node);
}
template <typename... TAIL>
Hover_result _match_sub_dialog(Xml_node hover, char const *sub_node,
TAIL &&... tail)
{
Hover_result result = Hover_result::UNMODIFIED;
hover.with_optional_sub_node(sub_node, [&] (Xml_node sub_hover) {
if (_match_sub_dialog(sub_hover, tail...) == Hover_result::CHANGED)
result = Hover_result::CHANGED; });
return result;
}
template <typename... ARGS>
Hover_result match_sub_dialog(ARGS &&... args)
{
bool const orig_hovered = hovered;
hovered = false;
Hover_result const result = _match_sub_dialog(args...);
/* reset internal hover state of the dialog if no longer hovered */
if (orig_hovered && !hovered)
(void)this->hover(Xml_node("<empty/>"));
return result;
}
/*
* Helpe for the 'Sculpt::match_sub_dialog' implementation below
*/
template <typename DIALOG>
struct _Recurse
{
DIALOG &dialog;
Hover_result result = Hover_result::UNMODIFIED;
_Recurse(DIALOG &dialog) : dialog(dialog) { }
template <typename... TAIL>
void match(Xml_node const &hover, char const *head, TAIL &&... tail)
{
hover.with_optional_sub_node(head, [&] (Xml_node const &sub_node) {
match(sub_node, tail...); });
}
void match(Xml_node const &hover) { result = dialog.hover(hover); }
};
};
namespace Sculpt {
template <typename DIALOG, typename... ARGS>
static inline Hoverable_item::Hover_result
match_sub_dialog(Xml_node const &hover, DIALOG &dialog, ARGS &&... args)
{
Deprecated_dialog::_Recurse recurse { dialog };
recurse.match(hover, args...);
static Xml_node const unhovered { "<empty/>" };
if (recurse.result == Hoverable_item::Hover_result::UNMODIFIED)
dialog.hover(unhovered);
return recurse.result;
}
}
#endif /* _VIEW__DEPRECATED_DIALOG_H_ */

View File

@ -1,11 +1,11 @@
/*
* \brief Menu-view dialog handling
* \author Norman Feske
* \date 2018-05-18
* \date 2023-07-12
*/
/*
* Copyright (C) 2018 Genode Labs GmbH
* Copyright (C) 2023 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
@ -14,131 +14,7 @@
#ifndef _VIEW__DIALOG_H_
#define _VIEW__DIALOG_H_
/* Genode includes */
#include <input/event.h>
#include <util/xml_generator.h>
/* local includes */
#include "types.h"
#include <view/hoverable_item.h>
namespace Sculpt { struct Dialog; }
struct Sculpt::Dialog : Interface
{
/**
* Interface for triggering the (re-)generation of a menu-view dialog
*
* This interface ls implemented by a top-level dialog and called by a sub
* dialog.
*/
struct Generator : Interface { virtual void generate_dialog() = 0; };
bool hovered = false;
enum class Click_result { CONSUMED, IGNORED };
enum class Clack_result { CONSUMED, IGNORED };
using Hover_result = Hoverable_item::Hover_result;
virtual void reset() = 0;
virtual Hover_result hover(Xml_node hover) = 0;
virtual void generate(Xml_generator &xml) const = 0;
static Hover_result any_hover_changed(Hover_result head)
{
return head;
}
template <typename... TAIL>
static Hover_result any_hover_changed(Hover_result head, TAIL... args)
{
if (head == Hover_result::CHANGED)
return Hover_result::CHANGED;
return any_hover_changed(args...);
}
Hover_result _match_sub_dialog(Xml_node node)
{
hovered = true;
return hover(node);
}
template <typename... TAIL>
Hover_result _match_sub_dialog(Xml_node hover, char const *sub_node,
TAIL &&... tail)
{
Hover_result result = Hover_result::UNMODIFIED;
hover.with_optional_sub_node(sub_node, [&] (Xml_node sub_hover) {
if (_match_sub_dialog(sub_hover, tail...) == Hover_result::CHANGED)
result = Hover_result::CHANGED; });
return result;
}
template <typename... ARGS>
Hover_result match_sub_dialog(ARGS &&... args)
{
bool const orig_hovered = hovered;
hovered = false;
Hover_result const result = _match_sub_dialog(args...);
/* reset internal hover state of the dialog if no longer hovered */
if (orig_hovered && !hovered)
(void)this->hover(Xml_node("<empty/>"));
return result;
}
/*
* Helpe for the 'Sculpt::match_sub_dialog' implementation below
*/
template <typename DIALOG>
struct _Recurse
{
DIALOG &dialog;
Hover_result result = Hover_result::UNMODIFIED;
_Recurse(DIALOG &dialog) : dialog(dialog) { }
template <typename... TAIL>
void match(Xml_node const &hover, char const *head, TAIL &&... tail)
{
hover.with_optional_sub_node(head, [&] (Xml_node const &sub_node) {
match(sub_node, tail...); });
}
void match(Xml_node const &hover) { result = dialog.hover(hover); }
};
};
namespace Sculpt {
template <typename DIALOG, typename... ARGS>
static inline Hoverable_item::Hover_result
match_sub_dialog(Xml_node const &hover, DIALOG &dialog, ARGS &&... args)
{
Dialog::_Recurse recurse { dialog };
recurse.match(hover, args...);
static Xml_node const unhovered { "<empty/>" };
if (recurse.result == Hoverable_item::Hover_result::UNMODIFIED)
dialog.hover(unhovered);
return recurse.result;
}
}
#include <view/deprecated_dialog.h>
#endif /* _VIEW__DIALOG_H_ */

View File

@ -21,7 +21,7 @@
namespace Sculpt { struct File_browser_dialog; }
struct Sculpt::File_browser_dialog : Noncopyable, Dialog
struct Sculpt::File_browser_dialog : Noncopyable, Deprecated_dialog
{
Runtime_config const &_runtime_config;
File_browser_state const &_state;

View File

@ -21,7 +21,7 @@
namespace Sculpt { struct Fs_dialog; }
struct Sculpt::Fs_dialog : Noncopyable, Dialog
struct Sculpt::Fs_dialog : Noncopyable, Deprecated_dialog
{
Storage_target const _target;
Storage_target const &_used_target;

View File

@ -279,9 +279,9 @@ void Network_dialog::generate(Xml_generator &xml) const
}
Dialog::Hover_result Network_dialog::hover(Xml_node hover)
Deprecated_dialog::Hover_result Network_dialog::hover(Xml_node hover)
{
Dialog::Hover_result const hover_result = Dialog::any_hover_changed(
Deprecated_dialog::Hover_result const hover_result = Deprecated_dialog::any_hover_changed(
_nic_item .match(hover, "frame", "vbox", "hbox", "button", "name"),
_ap_item .match(hover, "frame", "vbox", "frame", "vbox", "hbox", "name"),
_connect_item.match(hover, "frame", "vbox", "frame", "vbox", "button", "name"));

View File

@ -27,7 +27,7 @@
namespace Sculpt { struct Network_dialog; }
struct Sculpt::Network_dialog : Dialog
struct Sculpt::Network_dialog : Deprecated_dialog
{
enum Wlan_config_policy { WLAN_CONFIG_MANAGED, WLAN_CONFIG_MANUAL };

View File

@ -25,7 +25,7 @@
namespace Sculpt { struct Panel_dialog; }
struct Sculpt::Panel_dialog : Dialog
struct Sculpt::Panel_dialog : Deprecated_dialog
{
enum class Tab { FILES, COMPONENTS, INSPECT };

View File

@ -161,7 +161,7 @@ void Partition_dialog::gen_operations(Xml_generator &xml,
}
Dialog::Hover_result Partition_dialog::hover(Xml_node hover)
Deprecated_dialog::Hover_result Partition_dialog::hover(Xml_node hover)
{
Hover_result const hover_result = any_hover_changed(
_fs_dialog.hover(hover),
@ -173,7 +173,7 @@ Dialog::Hover_result Partition_dialog::hover(Xml_node hover)
}
Dialog::Click_result Partition_dialog::click(Action &action)
Deprecated_dialog::Click_result Partition_dialog::click(Action &action)
{
if (_fs_dialog.click(action) == Click_result::CONSUMED)
return Click_result::CONSUMED;
@ -213,7 +213,7 @@ Dialog::Click_result Partition_dialog::click(Action &action)
}
Dialog::Clack_result Partition_dialog::clack(Action &action)
Deprecated_dialog::Clack_result Partition_dialog::clack(Action &action)
{
if (_confirm_item.hovered("confirm")) {

View File

@ -24,7 +24,7 @@
namespace Sculpt { struct Partition_dialog; }
struct Sculpt::Partition_dialog : Dialog
struct Sculpt::Partition_dialog : Deprecated_dialog
{
Storage_target const _partition;
Storage_devices const &_storage_devices;

View File

@ -27,7 +27,7 @@
namespace Sculpt { struct Pd_route_dialog; }
struct Sculpt::Pd_route_dialog : Noncopyable, Dialog
struct Sculpt::Pd_route_dialog : Noncopyable, Deprecated_dialog
{
Route _route { "<pd/>" };
Hoverable_item _route_item { };
@ -42,14 +42,14 @@ struct Sculpt::Pd_route_dialog : Noncopyable, Dialog
Hover_result hover(Xml_node hover_node) override
{
Dialog::Hover_result const hover_result = hover(hover_node);
Deprecated_dialog::Hover_result const hover_result = hover(hover_node);
return hover_result;
}
template <typename... ARGS>
Hover_result hover(Xml_node hover, ARGS &&... args)
{
Dialog::Hover_result const hover_result = Dialog::any_hover_changed(
Deprecated_dialog::Hover_result const hover_result = Deprecated_dialog::any_hover_changed(
_route_item.match(hover, args...));
return hover_result;

View File

@ -37,7 +37,7 @@
namespace Sculpt { struct Popup_dialog; }
struct Sculpt::Popup_dialog : Dialog
struct Sculpt::Popup_dialog : Deprecated_dialog
{
using Depot_users = Attached_rom_dataspace;
using Blueprint_info = Component::Blueprint_info;
@ -163,7 +163,7 @@ struct Sculpt::Popup_dialog : Dialog
Hover_result hover(Xml_node hover) override
{
Dialog::Hover_result const hover_result = Dialog::any_hover_changed(
Deprecated_dialog::Hover_result const hover_result = Deprecated_dialog::any_hover_changed(
_item .match(hover, "frame", "vbox", "hbox", "name"),
_action_item .match(hover, "frame", "vbox", "button", "name"),
_install_item.match(hover, "frame", "vbox", "float", "vbox", "float", "button", "name"),
@ -172,7 +172,7 @@ struct Sculpt::Popup_dialog : Dialog
_pd_route.hover(hover, "frame", "vbox", "frame", "vbox", "hbox", "name");
if (_resources.constructed() &&
hover_result == Dialog::Hover_result::UNMODIFIED)
hover_result == Deprecated_dialog::Hover_result::UNMODIFIED)
return _resources->match_sub_dialog(hover, "frame", "vbox", "frame", "vbox");
return hover_result;

View File

@ -19,7 +19,7 @@
namespace Sculpt { struct Radio_choice_dialog; }
struct Sculpt::Radio_choice_dialog : Noncopyable, Dialog
struct Sculpt::Radio_choice_dialog : Noncopyable, Deprecated_dialog
{
typedef Hoverable_item::Id Id;

View File

@ -21,7 +21,7 @@
namespace Sculpt { struct Ram_fs_dialog; }
struct Sculpt::Ram_fs_dialog : Noncopyable, Dialog
struct Sculpt::Ram_fs_dialog : Noncopyable, Deprecated_dialog
{
Storage_target const &_used_target;

View File

@ -28,7 +28,7 @@
namespace Sculpt { struct Resource_dialog; }
struct Sculpt::Resource_dialog : Noncopyable, Dialog
struct Sculpt::Resource_dialog : Noncopyable, Deprecated_dialog
{
Affinity::Space const _space;
Affinity::Location _location;
@ -64,7 +64,7 @@ struct Sculpt::Resource_dialog : Noncopyable, Dialog
Hover_result hover(Xml_node hover) override
{
return Dialog::any_hover_changed(
return Deprecated_dialog::any_hover_changed(
_space_item.match(hover,
"vbox", "float", "hbox", /* _gen_dialog_section */
"vbox", "hbox", "vbox", "hbox", /* _gen_affinity_section */

View File

@ -21,7 +21,7 @@
namespace Sculpt { struct Settings_dialog; }
struct Sculpt::Settings_dialog : Noncopyable, Dialog
struct Sculpt::Settings_dialog : Noncopyable, Deprecated_dialog
{
Settings const &_settings;

View File

@ -126,7 +126,7 @@ struct Sculpt::Software_presets_dialog
Hover_result hover(Xml_node hover)
{
return Dialog::any_hover_changed(
return Deprecated_dialog::any_hover_changed(
_item.match (hover, "float", "frame", "vbox", "vbox", "hbox", "name"),
_operation.match(hover, "float", "frame", "vbox", "vbox", "float", "button", "name")
);

View File

@ -318,7 +318,7 @@ struct Sculpt::Software_update_dialog
{
_users.reset_hover();
return Dialog::any_hover_changed(
return Deprecated_dialog::any_hover_changed(
match_sub_dialog(hover, _users, "vbox", "frame", "vbox"),
_check .match(hover, "vbox", "frame", "vbox", "float", "button", "name"),
_version .match(hover, "vbox", "frame", "name"),

View File

@ -79,7 +79,7 @@ void Storage_device_dialog::generate(Xml_generator &xml, Storage_device const &d
}
Dialog::Hover_result Storage_device_dialog::hover(Xml_node hover)
Deprecated_dialog::Hover_result Storage_device_dialog::hover(Xml_node hover)
{
Hover_result result = Hover_result::UNMODIFIED;
@ -93,7 +93,7 @@ Dialog::Hover_result Storage_device_dialog::hover(Xml_node hover)
}
Dialog::Click_result Storage_device_dialog::click(Action &action)
Deprecated_dialog::Click_result Storage_device_dialog::click(Action &action)
{
Storage_target const orig_selected_target = _selected_storage_target();
@ -112,7 +112,7 @@ Dialog::Click_result Storage_device_dialog::click(Action &action)
}
Dialog::Clack_result Storage_device_dialog::clack(Action &action)
Deprecated_dialog::Clack_result Storage_device_dialog::clack(Action &action)
{
if (_partition_dialog.constructed())
return _partition_dialog->clack(action);

View File

@ -24,7 +24,7 @@
namespace Sculpt { struct Storage_device_dialog; }
struct Sculpt::Storage_device_dialog : Dialog
struct Sculpt::Storage_device_dialog : Deprecated_dialog
{
Storage_device::Label const _device;
Storage_devices const &_storage_devices;

View File

@ -124,7 +124,7 @@ void Storage_dialog::gen_usb_storage_devices(Xml_generator &xml) const
}
Dialog::Hover_result Storage_dialog::hover(Xml_node hover)
Deprecated_dialog::Hover_result Storage_dialog::hover(Xml_node hover)
{
Hover_result result = Hover_result::UNMODIFIED;
@ -136,7 +136,7 @@ Dialog::Hover_result Storage_dialog::hover(Xml_node hover)
}
Dialog::Click_result Storage_dialog::click(Action &action)
Deprecated_dialog::Click_result Storage_dialog::click(Action &action)
{
Selectable_item::Id const old_selected_device = _device_item._selected;
@ -161,7 +161,7 @@ Dialog::Click_result Storage_dialog::click(Action &action)
}
Dialog::Clack_result Storage_dialog::clack(Action &action)
Deprecated_dialog::Clack_result Storage_dialog::clack(Action &action)
{
if (_storage_device_dialog.constructed()
&& _storage_device_dialog->clack(action) == Clack_result::CONSUMED)

View File

@ -23,7 +23,7 @@
namespace Sculpt { struct Storage_dialog; }
struct Sculpt::Storage_dialog : Dialog
struct Sculpt::Storage_dialog : Deprecated_dialog
{
Storage_devices const &_storage_devices;

View File

@ -24,7 +24,7 @@
namespace Sculpt { struct System_dialog; }
struct Sculpt::System_dialog : Noncopyable, Dialog
struct Sculpt::System_dialog : Noncopyable, Deprecated_dialog
{
using Depot_users = Depot_users_dialog::Depot_users;
using Image_index = Attached_rom_dataspace;