2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-11-08 16:55:58 -03:00
|
|
|
#include "FormEditorWidget.h"
|
2019-11-10 17:45:32 -03:00
|
|
|
#include "CursorTool.h"
|
2019-11-08 16:55:58 -03:00
|
|
|
#include "FormWidget.h"
|
2019-11-11 15:13:36 -03:00
|
|
|
#include "WidgetTreeModel.h"
|
2020-02-06 16:33:02 -03:00
|
|
|
#include <LibGUI/Painter.h>
|
2019-11-08 16:55:58 -03:00
|
|
|
|
2020-08-17 10:22:30 -03:00
|
|
|
namespace HackStudio {
|
|
|
|
|
|
2020-02-23 06:57:42 -03:00
|
|
|
FormEditorWidget::FormEditorWidget()
|
|
|
|
|
: m_tool(make<CursorTool>(*this))
|
2019-11-08 16:55:58 -03:00
|
|
|
{
|
|
|
|
|
set_fill_with_background_color(true);
|
|
|
|
|
|
2020-02-23 06:57:42 -03:00
|
|
|
m_form_widget = add<FormWidget>();
|
2019-11-11 15:13:36 -03:00
|
|
|
m_widget_tree_model = WidgetTreeModel::create(*m_form_widget);
|
2019-11-08 16:55:58 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FormEditorWidget::~FormEditorWidget()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-02 11:07:41 -03:00
|
|
|
void FormEditorWidget::paint_event(GUI::PaintEvent& event)
|
2019-11-08 16:55:58 -03:00
|
|
|
{
|
2020-02-02 11:07:41 -03:00
|
|
|
GUI::Frame::paint_event(event);
|
2019-11-08 16:55:58 -03:00
|
|
|
|
2020-02-02 11:07:41 -03:00
|
|
|
GUI::Painter painter(*this);
|
2019-11-08 16:55:58 -03:00
|
|
|
painter.add_clip_rect(event.rect());
|
|
|
|
|
}
|
2019-11-10 17:45:32 -03:00
|
|
|
|
|
|
|
|
void FormEditorWidget::set_tool(NonnullOwnPtr<Tool> tool)
|
|
|
|
|
{
|
|
|
|
|
m_tool->detach();
|
|
|
|
|
m_tool = move(tool);
|
|
|
|
|
m_tool->attach();
|
|
|
|
|
}
|
2019-11-11 15:13:36 -03:00
|
|
|
|
|
|
|
|
WidgetTreeModel& FormEditorWidget::model()
|
|
|
|
|
{
|
|
|
|
|
return *m_widget_tree_model;
|
|
|
|
|
}
|
2020-08-17 10:22:30 -03:00
|
|
|
|
|
|
|
|
}
|