1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
auto PropertiesViewer::construct() -> void {
setCollapsible();
setVisible(false);
propertiesLabel.setText("Properties Viewer").setFont(Font().setBold());
propertiesView.setEditable(false).setFont(Font().setFamily(Font::Mono));
liveOption.setText("Live");
refreshButton.setText("Refresh").onActivate([&] {
refresh();
});
}
auto PropertiesViewer::reload() -> void {
propertiesList.reset();
for(auto properties : ares::Node::enumerate<ares::Node::Debugger::Properties>(emulator->root)) {
ComboButtonItem item{&propertiesList};
item.setAttribute<ares::Node::Debugger::Properties>("node", properties);
item.setText(properties->name());
}
eventChange();
}
auto PropertiesViewer::unload() -> void {
propertiesList.reset();
eventChange();
}
auto PropertiesViewer::refresh() -> void {
if(auto item = propertiesList.selected()) {
if(auto properties = item.attribute<ares::Node::Debugger::Properties>("node")) {
propertiesView.setText(properties->query());
}
} else {
propertiesView.setText();
}
}
auto PropertiesViewer::liveRefresh() -> void {
if(visible() && liveOption.checked()) refresh();
}
auto PropertiesViewer::eventChange() -> void {
refresh();
}
auto PropertiesViewer::setVisible(bool visible) -> PropertiesViewer& {
if(visible) refresh();
VerticalLayout::setVisible(visible);
return *this;
}
|