sculpt_manager: move Network::_menu_view to Main::

By decoupling the network dialog's menu view from the 'Network' class,
we become able to host the network dialog in the same menu view instance
as other dialogs.
This commit is contained in:
Norman Feske 2022-08-23 15:30:20 +02:00 committed by Christian Helmuth
parent 6f2237fc46
commit 5a0b4c98aa
3 changed files with 37 additions and 32 deletions

View File

@ -53,6 +53,7 @@ struct Sculpt::Main : Input_event_handler,
Dialog::Generator,
Runtime_config_generator,
Storage::Target_user,
Network::Action,
Graph::Action,
Panel_dialog::Action,
Popup_dialog::Action,
@ -179,7 +180,7 @@ struct Sculpt::Main : Input_event_handler,
_pci_info.wifi_present = true;
});
_network.update_view();
update_network_dialog();
}
@ -213,8 +214,20 @@ struct Sculpt::Main : Input_event_handler,
generate_runtime_config();
}
Network _network { _env, _heap, *this, _child_states, *this, _runtime_state, _pci_info };
Network _network { _env, _heap, _child_states, *this, *this, _runtime_state, _pci_info };
Menu_view _network_menu_view { _env, _child_states, _network.dialog, "network_view",
Ram_quota{4*1024*1024}, Cap_quota{150},
"network_dialog", "network_view_hover",
*this };
/**
* Network::Action interface
*/
void update_network_dialog() override
{
_network_menu_view.generate();
}
/************
@ -637,9 +650,9 @@ struct Sculpt::Main : Input_event_handler,
_settings_menu_view.generate();
_clicked_seq_number.destruct();
}
else if (_network.dialog_hovered(seq)) {
else if (_network_menu_view.hovered(seq)) {
_network.dialog.click(_network);
_network.update_view();
_network_menu_view.generate();
_clicked_seq_number.destruct();
}
else if (_file_browser_menu_view.hovered(seq)) {
@ -1541,7 +1554,7 @@ void Sculpt::Main::_handle_gui_mode()
_panel_menu_view.min_width = _screen_size.w();
unsigned const menu_width = max((unsigned)(_font_size_px*21.0), 320u);
_main_menu_view.min_width = menu_width;
_network.min_dialog_width(menu_width);
_network_menu_view.min_width = menu_width;
/* font size may has changed, propagate fonts config of runtime view */
generate_runtime_config();
@ -1830,7 +1843,7 @@ void Sculpt::Main::_generate_runtime_config(Xml_generator &xml) const
_panel_menu_view.gen_start_node(xml);
_main_menu_view.gen_start_node(xml);
_settings_menu_view.gen_start_node(xml);
_network._menu_view.gen_start_node(xml);
_network_menu_view.gen_start_node(xml);
_popup_menu_view.gen_start_node(xml);
_file_browser_menu_view.gen_start_node(xml);

View File

@ -50,7 +50,7 @@ void Sculpt::Network::handle_key_press(Codepoint code)
if (_wifi_connection.state == Wifi_connection::CONNECTING)
wifi_connect(_wifi_connection.bssid);
_menu_view.generate();
_action.update_network_dialog();
}
@ -126,7 +126,7 @@ void Sculpt::Network::_handle_wlan_accesspoints()
Access_point_update_policy policy(_alloc);
_access_points.update_from_xml(policy, _wlan_accesspoints_rom.xml());
_menu_view.generate();
_action.update_network_dialog();
}
@ -134,7 +134,7 @@ void Sculpt::Network::_handle_wlan_state()
{
_wlan_state_rom.update();
_wifi_connection = Wifi_connection::from_xml(_wlan_state_rom.xml());
_menu_view.generate();
_action.update_network_dialog();
}
@ -146,7 +146,7 @@ void Sculpt::Network::_handle_nic_router_state()
_nic_state = Nic_state::from_xml(_nic_router_state_rom.xml());
if (_nic_state.ipv4 != old_nic_state.ipv4)
_menu_view.generate();
_action.update_network_dialog();
/* if the nic state becomes ready, consider spawning the update subsystem */
if (old_nic_state.ready() != _nic_state.ready())
@ -193,7 +193,7 @@ void Sculpt::Network::_handle_nic_router_config(Xml_node config)
_update_nic_target_from_config(config);
_generate_nic_router_config();
_runtime_config_generator.generate_runtime_config();
_menu_view.generate();
_action.update_network_dialog();
}

View File

@ -20,6 +20,7 @@
/* local includes */
#include <model/child_exit_state.h>
#include <model/pci_info.h>
#include <view/network_dialog.h>
#include <menu_view.h>
#include <runtime.h>
@ -35,9 +36,14 @@ struct Sculpt::Network : Network_dialog::Action
Allocator &_alloc;
Registry<Child_state> &_child_states;
struct Action : Interface
{
virtual void update_network_dialog() = 0;
};
Menu_view::Hover_update_handler &_hover_update_handler;
Action &_action;
Registry<Child_state> &_child_states;
Runtime_config_generator &_runtime_config_generator;
@ -101,19 +107,6 @@ struct Sculpt::Network : Network_dialog::Action
_wifi_connection, _nic_state, wpa_passphrase, _wlan_config_policy,
_pci_info };
Menu_view _menu_view { _env, _child_states, dialog, "network_view",
Ram_quota{4*1024*1024}, Cap_quota{150},
"network_dialog", "network_view_hover",
_hover_update_handler };
void min_dialog_width(unsigned value) { _menu_view.min_width = value; }
bool dialog_hovered(Input::Seq_number seq) const { return _menu_view.hovered(seq); }
void update_view() { _menu_view.generate(); }
void trigger_dialog_restart() { _menu_view.trigger_restart(); }
Managed_config<Network> _wlan_config {
_env, "config", "wifi", *this, &Network::_handle_wlan_config };
@ -121,7 +114,7 @@ struct Sculpt::Network : Network_dialog::Action
{
if (_wlan_config.try_generate_manually_managed()) {
_wlan_config_policy = Network_dialog::WLAN_CONFIG_MANUAL;
_menu_view.generate();
_action.update_network_dialog();
return;
}
@ -144,7 +137,7 @@ struct Sculpt::Network : Network_dialog::Action
_nic_target.managed_type = type;
_generate_nic_router_config();
_runtime_config_generator.generate_runtime_config();
_menu_view.generate();
_action.update_network_dialog();
}
}
@ -219,13 +212,12 @@ struct Sculpt::Network : Network_dialog::Action
_runtime_config_generator.generate_runtime_config();
}
Network(Env &env, Allocator &alloc, Registry<Child_state> &child_states,
Menu_view::Hover_update_handler &hover_update_handler,
Network(Env &env, Allocator &alloc, Action &action,
Registry<Child_state> &child_states,
Runtime_config_generator &runtime_config_generator,
Runtime_info const &runtime_info, Pci_info const &pci_info)
:
_env(env), _alloc(alloc), _child_states(child_states),
_hover_update_handler(hover_update_handler),
_env(env), _alloc(alloc), _action(action), _child_states(child_states),
_runtime_config_generator(runtime_config_generator),
_runtime_info(runtime_info), _pci_info(pci_info)
{