event-manager.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. EventManager::EventManager(View* view) : PanelList(view, Size{~0, ~0}) {
  2. setCollapsible().setVisible(false);
  3. listView.onChange([&] { onChange(); });
  4. listView.onToggle([&](auto item) { onToggle(item); });
  5. }
  6. auto EventManager::show() -> void {
  7. listView.selectNone().doChange();
  8. refresh();
  9. setVisible(true);
  10. }
  11. auto EventManager::hide() -> void {
  12. setVisible(false);
  13. }
  14. auto EventManager::refresh() -> void {
  15. listView.reset();
  16. if(auto root = emulator.root) {
  17. for(auto& node : *root) refresh(node);
  18. }
  19. }
  20. auto EventManager::refresh(higan::Node::Object node) -> void {
  21. if(auto tracer = node->cast<higan::Node::Tracer>()) {
  22. ListViewItem item{&listView};
  23. item.setAttribute<higan::Node::Tracer>("tracer", tracer);
  24. item.setCheckable();
  25. item.setChecked(tracer->enabled());
  26. item.setText({tracer->component(), " ", tracer->name()});
  27. }
  28. for(auto& node : *node) refresh(node);
  29. }
  30. auto EventManager::onChange() -> void {
  31. }
  32. auto EventManager::onToggle(ListViewItem item) -> void {
  33. if(auto tracer = item.attribute<higan::Node::Tracer>("tracer")) {
  34. tracer->setEnabled(item.checked());
  35. }
  36. }