HackStudioWidget.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
  4. * Copyright (c) 2020, the SerenityOS developers
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright notice, this
  11. * list of conditions and the following disclaimer.
  12. *
  13. * 2. Redistributions in binary form must reproduce the above copyright notice,
  14. * this list of conditions and the following disclaimer in the documentation
  15. * and/or other materials provided with the distribution.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  18. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  23. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  24. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  25. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  26. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. #pragma once
  29. #include "Debugger/DebugInfoWidget.h"
  30. #include "Debugger/DisassemblyWidget.h"
  31. #include "EditorWrapper.h"
  32. #include "FindInFilesWidget.h"
  33. #include "FormEditorWidget.h"
  34. #include "Git/DiffViewer.h"
  35. #include "Git/GitWidget.h"
  36. #include "Locator.h"
  37. #include "Project.h"
  38. #include "TerminalWrapper.h"
  39. #include <LibGUI/Splitter.h>
  40. #include <LibGUI/Widget.h>
  41. #include <LibThread/Thread.h>
  42. namespace HackStudio {
  43. class HackStudioWidget : public GUI::Widget {
  44. C_OBJECT(HackStudioWidget)
  45. public:
  46. virtual ~HackStudioWidget() override;
  47. void open_file(const String& filename);
  48. Vector<String> selected_file_names() const;
  49. void update_actions();
  50. Project& project();
  51. GUI::TextEditor& current_editor();
  52. EditorWrapper& current_editor_wrapper();
  53. void set_current_editor_wrapper(RefPtr<EditorWrapper>);
  54. String currently_open_file() const { return m_currently_open_file; }
  55. void initialize_menubar(GUI::MenuBar&);
  56. private:
  57. static String get_full_path_of_serenity_source(const String& file);
  58. HackStudioWidget(const String& path_to_project);
  59. void open_project(String filename);
  60. enum class EditMode {
  61. Text,
  62. Form,
  63. Diff,
  64. };
  65. void set_edit_mode(EditMode);
  66. NonnullRefPtr<GUI::Menu> create_project_tree_view_context_menu();
  67. NonnullRefPtr<GUI::Action> create_new_action();
  68. NonnullRefPtr<GUI::Action> create_open_selected_action();
  69. NonnullRefPtr<GUI::Action> create_add_existing_file_action();
  70. NonnullRefPtr<GUI::Action> create_delete_action();
  71. NonnullRefPtr<GUI::Action> create_switch_to_next_editor_action();
  72. NonnullRefPtr<GUI::Action> create_switch_to_previous_editor_action();
  73. NonnullRefPtr<GUI::Action> create_remove_current_editor_action();
  74. NonnullRefPtr<GUI::Action> create_open_action();
  75. NonnullRefPtr<GUI::Action> create_save_action();
  76. NonnullRefPtr<GUI::Action> create_add_editor_action();
  77. NonnullRefPtr<GUI::Action> create_add_terminal_action();
  78. NonnullRefPtr<GUI::Action> create_remove_current_terminal_action();
  79. NonnullRefPtr<GUI::Action> create_debug_action();
  80. NonnullRefPtr<GUI::Action> create_build_action();
  81. NonnullRefPtr<GUI::Action> create_run_action();
  82. NonnullRefPtr<GUI::Action> create_stop_action();
  83. void add_new_editor(GUI::Widget& parent);
  84. NonnullRefPtr<EditorWrapper> get_editor_of_file(const String& file_name);
  85. String get_project_executable_path() const;
  86. void on_action_tab_change();
  87. void reveal_action_tab(GUI::Widget&);
  88. void initialize_debugger();
  89. void create_project_tree_view(GUI::Widget& parent);
  90. void create_form_editor(GUI::Widget& parent);
  91. void create_toolbar(GUI::Widget& parent);
  92. void create_action_tab(GUI::Widget& parent);
  93. void create_app_menubar(GUI::MenuBar&);
  94. void create_project_menubar(GUI::MenuBar&);
  95. void create_edit_menubar(GUI::MenuBar&);
  96. void create_build_menubar(GUI::MenuBar&);
  97. void create_view_menubar(GUI::MenuBar&);
  98. void create_help_menubar(GUI::MenuBar&);
  99. void run(TerminalWrapper& wrapper);
  100. void build(TerminalWrapper& wrapper);
  101. void hide_action_tabs();
  102. NonnullRefPtrVector<EditorWrapper> m_all_editor_wrappers;
  103. RefPtr<EditorWrapper> m_current_editor_wrapper;
  104. String m_currently_open_file;
  105. OwnPtr<Project> m_project;
  106. RefPtr<GUI::TreeView> m_project_tree_view;
  107. RefPtr<GUI::VerticalSplitter> m_right_hand_splitter;
  108. RefPtr<GUI::StackWidget> m_right_hand_stack;
  109. RefPtr<GUI::Splitter> m_editors_splitter;
  110. RefPtr<GUI::Widget> m_form_inner_container;
  111. RefPtr<FormEditorWidget> m_form_editor_widget;
  112. RefPtr<GUI::TreeView> m_form_widget_tree_view;
  113. RefPtr<DiffViewer> m_diff_viewer;
  114. RefPtr<GitWidget> m_git_widget;
  115. RefPtr<GUI::Menu> m_project_tree_view_context_menu;
  116. RefPtr<GUI::TabWidget> m_action_tab_widget;
  117. RefPtr<TerminalWrapper> m_terminal_wrapper;
  118. RefPtr<Locator> m_locator;
  119. RefPtr<FindInFilesWidget> m_find_in_files_widget;
  120. RefPtr<DebugInfoWidget> m_debug_info_widget;
  121. RefPtr<DisassemblyWidget> m_disassembly_widget;
  122. RefPtr<LibThread::Thread> m_debugger_thread;
  123. RefPtr<EditorWrapper> m_current_editor_in_execution;
  124. RefPtr<GUI::Action> m_new_action;
  125. RefPtr<GUI::Action> m_open_selected_action;
  126. RefPtr<GUI::Action> m_add_existing_file_action;
  127. RefPtr<GUI::Action> m_delete_action;
  128. RefPtr<GUI::Action> m_switch_to_next_editor;
  129. RefPtr<GUI::Action> m_switch_to_previous_editor;
  130. RefPtr<GUI::Action> m_remove_current_editor_action;
  131. RefPtr<GUI::Action> m_open_action;
  132. RefPtr<GUI::Action> m_save_action;
  133. RefPtr<GUI::Action> m_add_editor_action;
  134. RefPtr<GUI::Action> m_add_terminal_action;
  135. RefPtr<GUI::Action> m_remove_current_terminal_action;
  136. RefPtr<GUI::Action> m_stop_action;
  137. RefPtr<GUI::Action> m_debug_action;
  138. RefPtr<GUI::Action> m_build_action;
  139. RefPtr<GUI::Action> m_run_action;
  140. };
  141. }