SpaceAnalyzer: Port to GML compiler

This commit is contained in:
Kemal Zebari 2023-09-26 22:13:34 -07:00 committed by Jelle Raaijmakers
parent 986130d9ea
commit 18124a5611
5 changed files with 30 additions and 11 deletions

View file

@ -3,18 +3,15 @@ serenity_component(
TARGETS SpaceAnalyzer
)
stringify_gml(SpaceAnalyzer.gml SpaceAnalyzerGML.h space_analyzer_gml)
compile_gml(SpaceAnalyzer.gml SpaceAnalyzerGML.cpp)
set(SOURCES
ProgressWindow.cpp
SpaceAnalyzerGML.cpp
Tree.cpp
TreeMapWidget.cpp
main.cpp
)
set(GENERATED_SOURCES
SpaceAnalyzerGML.h
)
serenity_app(SpaceAnalyzer ICON app-space-analyzer)
target_link_libraries(SpaceAnalyzer PRIVATE LibCore LibDesktop LibFileSystem LibGfx LibGUI LibIPC LibMain)

View file

@ -0,0 +1,23 @@
/*
* Copyright (c) 2023, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/Widget.h>
namespace SpaceAnalyzer {
class MainWidget final : public GUI::Widget {
C_OBJECT(MainWidget)
public:
static ErrorOr<NonnullRefPtr<MainWidget>> try_create();
virtual ~MainWidget() override = default;
private:
MainWidget() = default;
};
}

View file

@ -1,4 +1,4 @@
@GUI::Widget {
@SpaceAnalyzer::MainWidget {
layout: @GUI::VerticalBoxLayout {
spacing: 0
}

View file

@ -17,8 +17,6 @@
#include <LibGfx/Font/Font.h>
#include <WindowServer/WindowManager.h>
REGISTER_WIDGET(SpaceAnalyzer, TreeMapWidget)
namespace SpaceAnalyzer {
static constexpr Array colors = {

View file

@ -5,12 +5,12 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "MainWidget.h"
#include "Tree.h"
#include "TreeMapWidget.h"
#include <AK/LexicalPath.h>
#include <AK/String.h>
#include <AK/URL.h>
#include <Applications/SpaceAnalyzer/SpaceAnalyzerGML.h>
#include <LibDesktop/Launcher.h>
#include <LibFileSystem/FileSystem.h>
#include <LibGUI/Application.h>
@ -53,8 +53,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_icon(app_icon.bitmap_for_size(16));
// Load widgets.
auto main_widget = window->set_main_widget<GUI::Widget>();
TRY(main_widget->load_from_gml(space_analyzer_gml));
auto main_widget = TRY(SpaceAnalyzer::MainWidget::try_create());
window->set_main_widget(main_widget);
auto& breadcrumbbar = *main_widget->find_descendant_of_type_named<GUI::Breadcrumbbar>("breadcrumbbar");
auto& tree_map_widget = *main_widget->find_descendant_of_type_named<SpaceAnalyzer::TreeMapWidget>("tree_map");
auto& statusbar = *main_widget->find_descendant_of_type_named<GUI::Statusbar>("statusbar");