sculpt: basic interaction with runtime view

This patch enables the user to click on a component in the runtime view
to reveal more information such as the used/assigned RAM/caps and
secondary dependencies.
This commit is contained in:
Norman Feske 2018-08-23 13:39:21 +02:00 committed by Christian Helmuth
parent cdef4c2548
commit cbe6ef210f
6 changed files with 142 additions and 11 deletions

View File

@ -84,6 +84,8 @@ install_config {
report="nitpicker -> hover"/>
<policy label="leitzentrale -> manager -> displays"
report="nitpicker -> displays"/>
<policy label="leitzentrale -> manager -> runtime_view_hover"
report="runtime -> runtime_view -> hover"/>
<policy label="runtime -> runtime_view -> dialog"
report="leitzentrale -> manager -> runtime_view_dialog"/>
</config>
@ -253,6 +255,8 @@ install_config {
<child name="report_rom"/> </service>
<service name="ROM" label="manager -> displays">
<child name="report_rom"/> </service>
<service name="ROM" label="manager -> runtime_view_hover">
<child name="report_rom"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
@ -267,6 +271,8 @@ install_config {
<child name="config_rom"/> </service>
<service name="ROM" label="runtime_view -> dialog">
<child name="report_rom"/> </service>
<service name="Report" label="runtime_view -> hover">
<child name="report_rom"/> </service>
<service name="File_system" label="config">
<child name="config_fs" label="rw"/> </service>
<service name="File_system" label="report">

View File

@ -72,6 +72,8 @@ install_config {
report="nitpicker -> displays"/>
<policy label="runtime -> runtime_view -> dialog"
report="leitzentrale -> manager -> runtime_view_dialog"/>
<policy label="leitzentrale -> manager -> runtime_view_hover"
report="runtime -> runtime_view -> hover"/>
</config>
</start>
@ -383,6 +385,8 @@ install_config {
<child name="config_fs_rom"/> </service>
<service name="ROM" label="manager -> nitpicker_hover">
<child name="report_rom"/> </service>
<service name="ROM" label="manager -> runtime_view_hover">
<child name="report_rom"/> </service>
<service name="Report" label="manager -> runtime_view_dialog">
<child name="report_rom"/> </service>
<service name="Report"> <child name="fs_report"/> </service>
@ -433,6 +437,8 @@ install_config {
<service name="Nitpicker"> <child name="nitpicker"/> </service>
<service name="Timer"> <child name="timer"/> </service>
<service name="Report" label_suffix="-> shape"> <child name="pointer"/> </service>
<service name="Report" label="runtime_view -> hover">
<child name="report_rom"/> </service>
<service name="Report"> <child name="fs_report"/> </service>
<service name="LOG" label="unlogged"> <parent/> </service>
<service name="LOG"> <child name="log"/> </service>

View File

@ -185,6 +185,7 @@
<service name="ROM" label="nitpicker_hover"> <parent/> </service>
<service name="ROM" label_prefix="report ->"> <parent/> </service>
<service name="ROM" label="menu_view_hover"> <child name="report_rom"/> </service>
<service name="ROM" label="runtime_view_hover"> <parent/> </service>
<service name="ROM" label="window_list"> <child name="report_rom"/> </service>
<service name="ROM" label="decorator_margins"> <child name="report_rom"/> </service>
<service name="Nitpicker"> <parent/> </service>

View File

@ -23,6 +23,7 @@
/* local includes */
#include <types.h>
#include <xml.h>
#include <model/capacity.h>
namespace Sculpt { struct Graph; }
@ -31,6 +32,8 @@ struct Sculpt::Graph
{
Env &_env;
Runtime_state &_runtime_state;
Storage_target const &_sculpt_partition;
Expanding_reporter _graph_dialog_reporter { _env, "dialog", "runtime_view_dialog" };
@ -42,9 +45,18 @@ struct Sculpt::Graph
*/
Attached_rom_dataspace _runtime_config_rom { _env, "config -> managed/runtime" };
Attached_rom_dataspace _hover_rom { _env, "runtime_view_hover" };
Signal_handler<Graph> _runtime_config_handler {
_env.ep(), *this, &Graph::_handle_runtime_config };
Signal_handler<Graph> _hover_handler {
_env.ep(), *this, &Graph::_handle_hover };
Hoverable_item _node_button_item { };
bool _hovered = false;
typedef Start_name Node_name;
/**
@ -93,10 +105,8 @@ struct Sculpt::Graph
});
}
void _handle_runtime_config()
void _gen_graph_dialog()
{
_runtime_config_rom.update();
Xml_node const config = _runtime_config_rom.xml();
_graph_dialog_reporter.generate([&] (Xml_generator &xml) {
@ -107,6 +117,8 @@ struct Sculpt::Graph
Start_name const name = start.attribute_value("name", Start_name());
Runtime_state::Info const info = _runtime_state.info(name);
gen_named_node(xml, "frame", name, [&] () {
Node_name primary_dep = _primary_dependency(start);
@ -117,10 +129,33 @@ struct Sculpt::Graph
if (primary_dep.valid())
xml.attribute("dep", primary_dep);
gen_named_node(xml, "button", name, [&] () {
xml.node("label", [&] () {
xml.attribute("text", name);
xml.node("vbox", [&] () {
gen_named_node(xml, "button", name, [&] () {
_node_button_item.gen_button_attr(xml, name);
if (info.selected)
xml.attribute("selected", "yes");
xml.node("label", [&] () {
xml.attribute("text", name);
});
});
if (info.selected) {
String<100> const
ram (Capacity{info.assigned_ram - info.avail_ram}, " / ",
Capacity{info.assigned_ram}),
caps(info.assigned_caps - info.avail_caps, " / ",
info.assigned_caps, " caps");
gen_named_node(xml, "label", "ram", [&] () {
xml.attribute("text", ram); });
gen_named_node(xml, "label", "caps", [&] () {
xml.attribute("text", caps); });
}
});
});
});
@ -129,7 +164,9 @@ struct Sculpt::Graph
Start_name const name = start.attribute_value("name", Start_name());
bool const show_details = false;
Runtime_state::Info const info = _runtime_state.info(name);
bool const show_details = info.selected;
if (show_details) {
_for_each_secondary_dep(start, [&] (Start_name const &dep) {
@ -144,11 +181,45 @@ struct Sculpt::Graph
});
}
Graph(Env &env, Storage_target const &sculpt_partition)
void _handle_runtime_config()
{
_runtime_config_rom.update();
_gen_graph_dialog();
}
void _handle_hover()
{
_hover_rom.update();
Xml_node const hover = _hover_rom.xml();
_hovered = (hover.num_sub_nodes() != 0);
bool const changed =
_node_button_item.match(hover, "dialog", "depgraph", "frame", "vbox", "button", "name");
if (changed)
_gen_graph_dialog();
}
Graph(Env &env, Runtime_state &runtime_state,
Storage_target const &sculpt_partition)
:
_env(env), _sculpt_partition(sculpt_partition)
_env(env), _runtime_state(runtime_state), _sculpt_partition(sculpt_partition)
{
_runtime_config_rom.sigh(_runtime_config_handler);
_hover_rom.sigh(_hover_handler);
}
bool hovered() const { return _hovered; }
void click()
{
if (_node_button_item._hovered.valid()) {
_runtime_state.toggle_selection(_node_button_item._hovered);
_gen_graph_dialog();
}
}
};

View File

@ -297,6 +297,8 @@ struct Sculpt::Main : Input_event_handler,
if (_hovered_dialog == Hovered::STORAGE) _storage.dialog.click(_storage);
if (_hovered_dialog == Hovered::NETWORK) _network.dialog.click(_network);
if (_hovered_dialog == Hovered::RUNTIME) _network.dialog.click(_network);
if (_graph.hovered()) _graph.click();
}
if (ev.key_release(Input::BTN_LEFT))
@ -377,7 +379,7 @@ struct Sculpt::Main : Input_event_handler,
** Runtime graph **
*******************/
Graph _graph { _env, _storage._sculpt_partition };
Graph _graph { _env, _runtime_state, _storage._sculpt_partition };
Main(Env &env) : _env(env)

View File

@ -26,6 +26,19 @@ namespace Sculpt { class Runtime_state; }
class Sculpt::Runtime_state : public Runtime_info
{
public:
struct Info
{
bool selected;
unsigned long assigned_ram;
unsigned long avail_ram;
unsigned long assigned_caps;
unsigned long avail_caps;
};
private:
Allocator &_alloc;
@ -34,6 +47,8 @@ class Sculpt::Runtime_state : public Runtime_info
{
Start_name const name;
Info info { false, 0, 0, 0, 0 };
Child(Start_name const &name) : name(name) { }
};
@ -53,7 +68,22 @@ class Sculpt::Runtime_state : public Runtime_info
Child(node.attribute_value("name", Start_name()));
}
void update_element(Child &, Xml_node) { }
void update_element(Child &child, Xml_node node)
{
if (node.has_sub_node("ram")) {
Xml_node const ram = node.sub_node("ram");
child.info.assigned_ram = max(ram.attribute_value("assigned", Number_of_bytes()),
ram.attribute_value("quota", Number_of_bytes()));
child.info.avail_ram = ram.attribute_value("avail", Number_of_bytes());
}
if (node.has_sub_node("caps")) {
Xml_node const caps = node.sub_node("caps");
child.info.assigned_caps = max(caps.attribute_value("assigned", 0UL),
caps.attribute_value("quota", 0UL));
child.info.avail_caps = caps.attribute_value("avail", 0UL);
}
}
static bool element_matches_xml_node(Child const &elem, Xml_node node)
{
@ -82,6 +112,21 @@ class Sculpt::Runtime_state : public Runtime_info
result = true; });
return result;
}
Info info(Start_name const &name) const
{
Info result { .selected = false, 0, 0, 0, 0 };
_children.for_each([&] (Child const &child) {
if (child.name == name)
result = child.info; });
return result;
}
void toggle_selection(Start_name const &name)
{
_children.for_each([&] (Child &child) {
child.info.selected = (child.name == name) && !child.info.selected; });
}
};
#endif /* _MODEL__RUNTIME_STATE_H_ */