diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-11 22:03:55 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-11 22:03:55 +0200 |
commit | ec841f3a23cd754033930b543b98f543eef97460 (patch) | |
tree | aa4dfe3a15ad079ee6812d18eecb7b4c75ebdd19 /Applications/VisualBuilder | |
parent | 21d4b1c2fc0ffde3bb883b58e656b5bc6dbfbeac (diff) | |
download | serenity-ec841f3a23cd754033930b543b98f543eef97460.zip |
VisualBuilder: Move properties window to its own class.
Diffstat (limited to 'Applications/VisualBuilder')
-rw-r--r-- | Applications/VisualBuilder/Makefile | 1 | ||||
-rw-r--r-- | Applications/VisualBuilder/VBPropertiesWindow.cpp | 21 | ||||
-rw-r--r-- | Applications/VisualBuilder/VBPropertiesWindow.h | 17 | ||||
-rw-r--r-- | Applications/VisualBuilder/main.cpp | 26 |
4 files changed, 43 insertions, 22 deletions
diff --git a/Applications/VisualBuilder/Makefile b/Applications/VisualBuilder/Makefile index 53b796ee35..c2bb96cce1 100644 --- a/Applications/VisualBuilder/Makefile +++ b/Applications/VisualBuilder/Makefile @@ -4,6 +4,7 @@ OBJS = \ VBWidgetRegistry.o \ VBWidgetPropertyModel.o \ VBProperty.o \ + VBPropertiesWindow.o \ main.o APP = VisualBuilder diff --git a/Applications/VisualBuilder/VBPropertiesWindow.cpp b/Applications/VisualBuilder/VBPropertiesWindow.cpp new file mode 100644 index 0000000000..c13d5baa55 --- /dev/null +++ b/Applications/VisualBuilder/VBPropertiesWindow.cpp @@ -0,0 +1,21 @@ +#include "VBPropertiesWindow.h" +#include <LibGUI/GWidget.h> +#include <LibGUI/GBoxLayout.h> +#include <LibGUI/GTableView.h> + +VBPropertiesWindow::VBPropertiesWindow() +{ + set_title("Properties"); + set_rect(780, 200, 200, 280); + + auto* widget = new GWidget; + widget->set_fill_with_background_color(true); + widget->set_layout(make<GBoxLayout>(Orientation::Vertical)); + set_main_widget(widget); + + m_table_view = new GTableView(widget); +} + +VBPropertiesWindow::~VBPropertiesWindow() +{ +} diff --git a/Applications/VisualBuilder/VBPropertiesWindow.h b/Applications/VisualBuilder/VBPropertiesWindow.h new file mode 100644 index 0000000000..a15dfefc12 --- /dev/null +++ b/Applications/VisualBuilder/VBPropertiesWindow.h @@ -0,0 +1,17 @@ +#pragma once + +#include <LibGUI/GWindow.h> + +class GTableView; + +class VBPropertiesWindow final : public GWindow { +public: + VBPropertiesWindow(); + virtual ~VBPropertiesWindow() override; + + GTableView& table_view() { return *m_table_view; } + const GTableView& table_view() const { return *m_table_view; } + +private: + GTableView* m_table_view { nullptr }; +}; diff --git a/Applications/VisualBuilder/main.cpp b/Applications/VisualBuilder/main.cpp index a7cb966964..b994315a36 100644 --- a/Applications/VisualBuilder/main.cpp +++ b/Applications/VisualBuilder/main.cpp @@ -9,25 +9,23 @@ #include "VBForm.h" #include "VBWidget.h" #include "VBWidgetPropertyModel.h" +#include "VBPropertiesWindow.h" #include <unistd.h> #include <stdio.h> #include <signal.h> #include <fcntl.h> static GWindow* make_toolbox_window(); -static GWindow* make_properties_window(); - -GTableView* g_property_table_view; int main(int argc, char** argv) { GApplication app(argc, argv); - auto* propbox = make_properties_window(); + auto* propbox = new VBPropertiesWindow; auto* form1 = new VBForm("Form1"); - form1->on_widget_selected = [] (VBWidget* widget) { - g_property_table_view->set_model(widget ? &widget->property_model() : nullptr); + form1->on_widget_selected = [propbox] (VBWidget* widget) { + propbox->table_view().set_model(widget ? &widget->property_model() : nullptr); }; auto menubar = make<GMenuBar>(); @@ -137,19 +135,3 @@ GWindow* make_toolbox_window() }; return window; } - -GWindow* make_properties_window() -{ - auto* window = new GWindow; - window->set_title("Properties"); - window->set_rect(780, 200, 200, 280); - - auto* widget = new GWidget; - widget->set_fill_with_background_color(true); - widget->set_layout(make<GBoxLayout>(Orientation::Vertical)); - window->set_main_widget(widget); - - g_property_table_view = new GTableView(widget); - - return window; -} |