summaryrefslogtreecommitdiff
path: root/Userland/DevTools/HackStudio/HackStudioWidget.cpp
diff options
context:
space:
mode:
authorItamar <itamar8910@gmail.com>2021-04-10 17:38:11 +0300
committerAndreas Kling <kling@serenityos.org>2021-04-13 15:16:27 +0200
commitf52c3cabcf3c790548abfb1bb7dd106114a76328 (patch)
tree89367093bb0db691700908d4fd59fd816eae6983 /Userland/DevTools/HackStudio/HackStudioWidget.cpp
parent5adfcd54d814af3aae48a6dfef2ebb6576070aac (diff)
downloadserenity-f52c3cabcf3c790548abfb1bb7dd106114a76328.zip
HackStudio: Add ClassView tab for viewing classes in a tree structure
This enables the user to view and navigate classes with a TreeView that is updated by the LanguageServer as it parses the code. It offers a new neat way to view the project's structure :^)
Diffstat (limited to 'Userland/DevTools/HackStudio/HackStudioWidget.cpp')
-rw-r--r--Userland/DevTools/HackStudio/HackStudioWidget.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
index 623643f63c..cbb599eca3 100644
--- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp
+++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
@@ -43,6 +43,7 @@
#include "HackStudioWidget.h"
#include "Locator.h"
#include "Project.h"
+#include "ProjectDeclarations.h"
#include "TerminalWrapper.h"
#include "WidgetTool.h"
#include "WidgetTreeModel.h"
@@ -108,7 +109,7 @@ HackStudioWidget::HackStudioWidget(const String& path_to_project)
auto& left_hand_splitter = outer_splitter.add<GUI::VerticalSplitter>();
left_hand_splitter.set_fixed_width(150);
- create_project_tree_view(left_hand_splitter);
+ create_project_tab(left_hand_splitter);
m_project_tree_view_context_menu = create_project_tree_view_context_menu();
create_open_files_view(left_hand_splitter);
@@ -177,12 +178,11 @@ void HackStudioWidget::update_actions()
void HackStudioWidget::on_action_tab_change()
{
update_actions();
- auto git_widget = m_action_tab_widget->active_widget();
- if (!git_widget)
+ auto active_widget = m_action_tab_widget->active_widget();
+ if (!active_widget)
return;
- if (StringView { "GitWidget" } != git_widget->class_name())
- return;
- reinterpret_cast<GitWidget*>(git_widget)->refresh();
+ if (StringView { "GitWidget" } == active_widget->class_name())
+ reinterpret_cast<GitWidget*>(active_widget)->refresh();
}
void HackStudioWidget::open_project(const String& root_path)
@@ -743,9 +743,8 @@ void HackStudioWidget::set_current_editor_wrapper(RefPtr<EditorWrapper> editor_w
m_current_editor_wrapper = editor_wrapper;
}
-void HackStudioWidget::create_project_tree_view(GUI::Widget& parent)
+void HackStudioWidget::configure_project_tree_view()
{
- m_project_tree_view = parent.add<GUI::TreeView>();
m_project_tree_view->set_model(m_project->model());
m_project_tree_view->set_selection_mode(GUI::AbstractView::SelectionMode::MultiSelection);
@@ -937,6 +936,20 @@ void HackStudioWidget::create_action_tab(GUI::Widget& parent)
});
}
+void HackStudioWidget::create_project_tab(GUI::Widget& parent)
+{
+ m_project_tab = parent.add<GUI::TabWidget>();
+ m_project_tab->set_tab_position(GUI::TabWidget::TabPosition::Bottom);
+ m_project_tree_view = m_project_tab->add_tab<GUI::TreeView>("Files");
+ configure_project_tree_view();
+
+ m_class_view = m_project_tab->add_tab<ClassViewWidget>("ClassView");
+
+ ProjectDeclarations::the().on_update = [this]() {
+ m_class_view->refresh();
+ };
+}
+
void HackStudioWidget::create_app_menubar(GUI::MenuBar& menubar)
{
auto& file_menu = menubar.add_menu("&File");