2019-11-08 20:55:58 +01:00
|
|
|
#include "FormEditorWidget.h"
|
2019-11-10 21:45:32 +01:00
|
|
|
#include "CursorTool.h"
|
2019-11-08 20:55:58 +01:00
|
|
|
#include "FormWidget.h"
|
2019-11-11 19:13:36 +01:00
|
|
|
#include "WidgetTreeModel.h"
|
2019-11-08 20:55:58 +01:00
|
|
|
#include <LibGUI/GPainter.h>
|
|
|
|
|
|
|
|
|
|
FormEditorWidget::FormEditorWidget(GWidget* parent)
|
|
|
|
|
: GScrollableWidget(parent)
|
2019-11-10 21:45:32 +01:00
|
|
|
, m_tool(make<CursorTool>(*this))
|
2019-11-08 20:55:58 +01:00
|
|
|
{
|
|
|
|
|
set_fill_with_background_color(true);
|
2019-11-08 21:46:33 +01:00
|
|
|
set_background_color(Color::MidGray);
|
2019-11-08 20:55:58 +01:00
|
|
|
|
|
|
|
|
set_frame_shape(FrameShape::Container);
|
|
|
|
|
set_frame_shadow(FrameShadow::Sunken);
|
|
|
|
|
set_frame_thickness(2);
|
|
|
|
|
|
|
|
|
|
m_form_widget = FormWidget::construct(*this);
|
2019-11-11 19:13:36 +01:00
|
|
|
m_widget_tree_model = WidgetTreeModel::create(*m_form_widget);
|
2019-11-08 20:55:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FormEditorWidget::~FormEditorWidget()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FormEditorWidget::paint_event(GPaintEvent& event)
|
|
|
|
|
{
|
|
|
|
|
GFrame::paint_event(event);
|
|
|
|
|
|
|
|
|
|
GPainter painter(*this);
|
|
|
|
|
painter.add_clip_rect(event.rect());
|
|
|
|
|
}
|
2019-11-10 21:45:32 +01:00
|
|
|
|
|
|
|
|
void FormEditorWidget::set_tool(NonnullOwnPtr<Tool> tool)
|
|
|
|
|
{
|
|
|
|
|
m_tool->detach();
|
|
|
|
|
m_tool = move(tool);
|
|
|
|
|
m_tool->attach();
|
|
|
|
|
}
|
2019-11-11 19:13:36 +01:00
|
|
|
|
|
|
|
|
WidgetTreeModel& FormEditorWidget::model()
|
|
|
|
|
{
|
|
|
|
|
return *m_widget_tree_model;
|
|
|
|
|
}
|