diff --git a/repos/gems/src/app/sculpt_manager/view/debug_dialog.h b/repos/gems/src/app/sculpt_manager/view/debug_dialog.h index 7b7c7dce69..bd51f0d6cf 100644 --- a/repos/gems/src/app/sculpt_manager/view/debug_dialog.h +++ b/repos/gems/src/app/sculpt_manager/view/debug_dialog.h @@ -24,15 +24,12 @@ namespace Sculpt { struct Debug_dialog; } struct Sculpt::Debug_dialog : Noncopyable, Deprecated_dialog { - bool _monitor; - bool _wait; - bool _wx; + bool _monitor = false; + bool _wait = false; + bool _wx = false; Hoverable_item _item { }; - Debug_dialog(bool monitor, bool wait, bool wx) - : _monitor(monitor), _wait(wait), _wx(wx) { } - Hover_result hover(Xml_node hover) override { return Deprecated_dialog::any_hover_changed( @@ -46,63 +43,64 @@ struct Sculpt::Debug_dialog : Noncopyable, Deprecated_dialog if (!clicked.valid()) return; - if (clicked == "monitor") - _monitor = component.monitor = !component.monitor; - else if (clicked == "wait") { - _wait = component.wait = !component.wait; - /* wait depends on wx */ - if (_wait) - _wx = component.wx = true; - } else if (clicked == "wx") { - _wx = component.wx = !component.wx; - /* wait depends on wx */ - if (!_wx) - _wait = component.wait = false; - } + if (clicked == "monitor") _monitor = !_monitor; + if (clicked == "wx") _wx = !_wx; + if (clicked == "wait") _wait = !_wait; + + /* "wx" depends on "monitor", "wait" depends on "wx" */ + _wx &= _monitor; + _wait &= _wx; + + component.wx = _wx; + component.monitor = _monitor; + component.wait = _wait; } - void _gen_menu_entry(Xml_generator &xml, Start_name const &name, - Component::Info const &text, bool selected, - char const *style = "radio") const + void _gen_checkbox(Xml_generator &xml, Start_name const &name, + Component::Info const &text, bool selected) const { - gen_named_node(xml, "hbox", name, [&] () { + gen_named_node(xml, "hbox", name, [&] { - gen_named_node(xml, "float", "left", [&] () { + gen_named_node(xml, "float", "left", [&] { xml.attribute("west", "yes"); - xml.node("hbox", [&] () { - gen_named_node(xml, "button", "button", [&] () { + xml.node("hbox", [&] { + + gen_named_node(xml, "button", "button", [&] { if (selected) xml.attribute("selected", "yes"); - xml.attribute("style", style); + xml.attribute("style", "checkbox"); _item.gen_hovered_attr(xml, name); - xml.node("hbox", [&] () { }); + xml.node("hbox", [&] { }); }); - gen_named_node(xml, "label", "name", [&] () { + gen_named_node(xml, "label", "name", [&] { xml.attribute("text", Path(" ", text)); }); }); }); - gen_named_node(xml, "hbox", "right", [&] () { }); + gen_named_node(xml, "hbox", "right", [&] { }); }); } void generate(Xml_generator &xml) const override { - xml.node("vbox", [&] () { - _gen_menu_entry(xml, "monitor", "monitor this component", _monitor, "checkbox"); - if (_monitor) { - _gen_menu_entry(xml, "wait", " wait for GDB", _wait, "checkbox"); - _gen_menu_entry(xml, "wx", " map executable segments writeable", _wx, "checkbox"); - } + xml.node("vbox", [&] { + _gen_checkbox(xml, "monitor", "Debug", _monitor); + + if (_monitor) + _gen_checkbox(xml, "wx", "Allow code patching", _wx); + + if (_wx) + _gen_checkbox(xml, "wait", "Wait for GDB", _wait); }); } void reset() override { _item._hovered = Hoverable_item::Id(); + _monitor = _wait = _wx = false; } }; diff --git a/repos/gems/src/app/sculpt_manager/view/popup_dialog.cc b/repos/gems/src/app/sculpt_manager/view/popup_dialog.cc index 06dca022ca..189f536946 100644 --- a/repos/gems/src/app/sculpt_manager/view/popup_dialog.cc +++ b/repos/gems/src/app/sculpt_manager/view/popup_dialog.cc @@ -107,25 +107,9 @@ void Popup_dialog::_gen_pkg_elements(Xml_generator &xml, }); } - if (_debug.constructed()) { - gen_named_node(xml, "frame", "debug", [&] { - xml.node("vbox", [&] () { - - bool const selected = _route_selected("debug"); - - if (!selected) - _gen_route_entry(xml, "debug", - "Debug options ...", false, "enter"); - - if (selected) { - _gen_route_entry(xml, "back", "Debug options ...", - true, "back"); - - _debug->generate(xml); - } - }); - }); - } + gen_named_node(xml, "frame", "debug", [&] { + xml.node("vbox", [&] { + _debug.generate(xml); }); }); /* * Display "Add component" button once all routes are defined @@ -457,7 +441,7 @@ void Popup_dialog::click(Action &action) } } - else if (_state == ROUTE_SELECTED) { + else if (_state == ROUTE_SELECTED || _dialog_item.hovered("debug")) { /* * Keep the routing selection open when clicking on the "Add component" @@ -495,22 +479,6 @@ void Popup_dialog::click(Action &action) _resources->click(component); }); } - } else if (_debug_dialog_selected()) { - - bool const clicked_on_different_route = clicked_route.valid() - && (clicked_route != ""); - if (clicked_on_different_route) { - - /* close debug options dialog */ - _selected_route.construct(clicked_route); - - } else { - - if (_debug.constructed()) - action.apply_to_construction([&] (Component &component) { - _debug->click(component); }); - } - } else { bool clicked_on_selected_route = false; @@ -561,4 +529,10 @@ void Popup_dialog::click(Action &action) } } } + + if (_state == PKG_SHOWN || _state == ROUTE_SELECTED) { + if (_dialog_item.hovered("debug")) + action.apply_to_construction([&] (Component &component) { + _debug.click(component); }); + } } diff --git a/repos/gems/src/app/sculpt_manager/view/popup_dialog.h b/repos/gems/src/app/sculpt_manager/view/popup_dialog.h index 42ffe7387e..2fed0b4d99 100644 --- a/repos/gems/src/app/sculpt_manager/view/popup_dialog.h +++ b/repos/gems/src/app/sculpt_manager/view/popup_dialog.h @@ -121,10 +121,12 @@ struct Sculpt::Popup_dialog : Deprecated_dialog Activatable_item _action_item { }; Activatable_item _install_item { }; Hoverable_item _route_item { }; + Hoverable_item _dialog_item { }; /* for detecting clicks into debug dialog */ Pd_route_dialog _pd_route { _runtime_config }; Constructible<Resource_dialog> _resources { }; - Constructible<Debug_dialog> _debug { }; + + Debug_dialog _debug { }; enum State { TOP_LEVEL, DEPOT_REQUESTED, DEPOT_SHOWN, DEPOT_SELECTION, INDEX_REQUESTED, INDEX_SHOWN, @@ -151,11 +153,6 @@ struct Sculpt::Popup_dialog : Deprecated_dialog return _route_selected("resources"); } - bool _debug_dialog_selected() const - { - return _route_selected("debug"); - } - template <typename FN> void _apply_to_selected_route(Action &action, FN const &fn) { @@ -174,17 +171,19 @@ struct Sculpt::Popup_dialog : Deprecated_dialog _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"), - _route_item .match(hover, "frame", "vbox", "frame", "vbox", "hbox", "name")); + _route_item .match(hover, "frame", "vbox", "frame", "vbox", "hbox", "name"), + _dialog_item .match(hover, "frame", "vbox", "frame", "name")); _pd_route.hover(hover, "frame", "vbox", "frame", "vbox", "hbox", "name"); - if (_resources.constructed() && - hover_result == Deprecated_dialog::Hover_result::UNMODIFIED) - hover_result = _resources->match_sub_dialog(hover, "frame", "vbox", "frame", "vbox"); + if (_resources.constructed()) + hover_result = Deprecated_dialog::any_hover_changed( + hover_result, + _resources->match_sub_dialog(hover, "frame", "vbox", "frame", "vbox")); - if (_debug.constructed() && - hover_result == Deprecated_dialog::Hover_result::UNMODIFIED) - hover_result = _debug->match_sub_dialog(hover, "frame", "vbox", "frame", "vbox"); + hover_result = Deprecated_dialog::any_hover_changed( + hover_result, + _debug.match_sub_dialog(hover, "frame", "vbox", "frame", "vbox")); return hover_result; } @@ -365,6 +364,7 @@ struct Sculpt::Popup_dialog : Deprecated_dialog { _item._hovered = Hoverable_item::Id(); _route_item._hovered = Hoverable_item::Id(); + _dialog_item._hovered = Hoverable_item::Id(); _action_item.reset(); _install_item.reset(); _state = TOP_LEVEL; @@ -372,7 +372,7 @@ struct Sculpt::Popup_dialog : Deprecated_dialog _selected_route.destruct(); _menu._level = 0; _resources.destruct(); - _debug.destruct(); + _debug.reset(); _pd_route.reset(); } @@ -427,9 +427,7 @@ struct Sculpt::Popup_dialog : Deprecated_dialog construction.affinity_location, construction.priority); - _debug.construct(construction.monitor, - construction.wait, - construction.wx); + _debug.reset(); construction.try_apply_blueprint(blueprint);