From cb432ffe8c28a5a27daf2cf24ea2733a636e0a24 Mon Sep 17 00:00:00 2001 From: Itamar Date: Fri, 21 Aug 2020 11:51:32 +0300 Subject: [PATCH] HackStudio: Add icons for "step in" and "step out" --- Base/res/icons/16x16/debug-step-in.png | Bin 0 -> 261 bytes Base/res/icons/16x16/debug-step-out.png | Bin 0 -> 289 bytes .../HackStudio/Debugger/DebugInfoWidget.cpp | 27 ++++++++++-------- .../HackStudio/Debugger/DebugInfoWidget.h | 6 ++-- DevTools/HackStudio/Debugger/Debugger.cpp | 2 +- DevTools/HackStudio/main.cpp | 6 ++-- 6 files changed, 21 insertions(+), 20 deletions(-) create mode 100644 Base/res/icons/16x16/debug-step-in.png create mode 100644 Base/res/icons/16x16/debug-step-out.png diff --git a/Base/res/icons/16x16/debug-step-in.png b/Base/res/icons/16x16/debug-step-in.png new file mode 100644 index 0000000000000000000000000000000000000000..00c86d98f281d26907a0dcc7ccc0c1e213a7b44e GIT binary patch literal 261 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7*pj^6T^Rm@;DWu&Co?cG za29w(7Bet#3xhBt!>l`ypEIn-sYB`!F{z`!uc)5S5w;`G|dw|Scl zcwGINgoGBk#;UzGaCnx;aP6ekU-iEnQ++C;9@eRDsx5hIA$mNEf%%Nc3)Tp(t1CCz zy6}I@+jq8G_QAAbx!o)to+oB5j*2^G^7REvOLv(WpPPYV@gtK4TaKs$bHir@?S3u! zl`ypEIW%SMpYFZHz`(H1)5S5w;`G@`fqaJ) zc-rh2Ncr0EUw_D8-Ov8PYImRh?3+i}+cGC4emJSG*|_BI$@|wX9OO-5d47set_enabled(false); - m_singlestep_action->set_enabled(false); + + m_step_in_action = GUI::Action::create("Step In", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-step-in.png"), [&](auto&) { + }); + + m_step_out_action = GUI::Action::create("Step Out", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-step-out.png"), [&](auto&) { + }); m_toolbar->add_action(*m_continue_action); m_toolbar->add_action(*m_singlestep_action); + m_toolbar->add_action(*m_step_in_action); + m_toolbar->add_action(*m_step_out_action); + + set_debug_actions_enabled(false); } DebugInfoWidget::DebugInfoWidget() @@ -140,16 +148,11 @@ void DebugInfoWidget::program_stopped() m_variables_view->set_model({}); } -GUI::Action& DebugInfoWidget::continue_action() +void DebugInfoWidget::set_debug_actions_enabled(bool enabled) { - ASSERT(m_continue_action); - return *m_continue_action; + m_continue_action->set_enabled(enabled); + m_singlestep_action->set_enabled(enabled); + m_step_in_action->set_enabled(enabled); + m_step_out_action->set_enabled(enabled); } - -GUI::Action& DebugInfoWidget::singlestep_action() -{ - ASSERT(m_singlestep_action); - return *m_singlestep_action; -} - } diff --git a/DevTools/HackStudio/Debugger/DebugInfoWidget.h b/DevTools/HackStudio/Debugger/DebugInfoWidget.h index 5e1bcd6918..727c89f912 100644 --- a/DevTools/HackStudio/Debugger/DebugInfoWidget.h +++ b/DevTools/HackStudio/Debugger/DebugInfoWidget.h @@ -45,9 +45,7 @@ public: void update_state(const DebugSession&, const PtraceRegisters&); void program_stopped(); - - GUI::Action& continue_action(); - GUI::Action& singlestep_action(); + void set_debug_actions_enabled(bool enabled); private: explicit DebugInfoWidget(); @@ -59,6 +57,8 @@ private: RefPtr m_toolbar; RefPtr m_continue_action; RefPtr m_singlestep_action; + RefPtr m_step_in_action; + RefPtr m_step_out_action; }; } diff --git a/DevTools/HackStudio/Debugger/Debugger.cpp b/DevTools/HackStudio/Debugger/Debugger.cpp index 2d2de35d25..6e65a794d7 100644 --- a/DevTools/HackStudio/Debugger/Debugger.cpp +++ b/DevTools/HackStudio/Debugger/Debugger.cpp @@ -78,7 +78,7 @@ void Debugger::on_breakpoint_change(const String& file, size_t line, BreakpointC auto address = session->debug_info().get_instruction_from_source(position.file_path, position.line_number); if (!address.has_value()) { dbg() << "Warning: couldn't get instruction address from source"; - // TODO: Currently, the GUI will indicate that a breakpoint was inserted/remove at this line, + // TODO: Currently, the GUI will indicate that a breakpoint was inserted/removed at this line, // regardless of whether we actually succeeded to insert it. (For example a breakpoint on a comment, or an include statemanet). // We should indicate failure via a return value from this function, and not update the breakpoint GUI if we fail. return; diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index 2e36e748c9..989e57558e 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -631,8 +631,7 @@ int main_impl(int argc, char** argv) current_editor_in_execution = get_editor_of_file(source_position.value().file_path); current_editor_in_execution->editor().set_execution_position(source_position.value().line_number - 1); debug_info_widget.update_state(*Debugger::the().session(), regs); - debug_info_widget.continue_action().set_enabled(true); - debug_info_widget.singlestep_action().set_enabled(true); + debug_info_widget.set_debug_actions_enabled(true); reveal_action_tab(debug_info_widget); })); Core::EventLoop::wake(); @@ -642,8 +641,7 @@ int main_impl(int argc, char** argv) [&]() { dbg() << "Program continued"; Core::EventLoop::main().post_event(*g_window, make([&](auto&) { - debug_info_widget.continue_action().set_enabled(false); - debug_info_widget.singlestep_action().set_enabled(false); + debug_info_widget.set_debug_actions_enabled(false); if (current_editor_in_execution) { current_editor_in_execution->editor().clear_execution_position(); }