1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 20:15:08 +00:00

VisualBuilder: Make it possible to insert widgets from the toolbox.

This commit is contained in:
Andreas Kling 2019-04-11 04:13:11 +02:00
parent c71ece77fa
commit 75c76f6692
3 changed files with 41 additions and 6 deletions

View file

@ -2,10 +2,17 @@
#include "VBWidget.h"
#include <LibGUI/GPainter.h>
static VBForm* s_current;
VBForm* VBForm::current()
{
return s_current;
}
VBForm::VBForm(const String& name, GWidget* parent)
: GWidget(parent)
, m_name(name)
{
s_current = this;
set_fill_with_background_color(true);
set_background_color(Color::LightGray);
set_greedy_for_hits(true);
@ -23,6 +30,14 @@ VBForm::VBForm(const String& name, GWidget* parent)
m_widgets.append(move(button1));
}
void VBForm::insert_widget(WidgetType type)
{
auto widget = VBWidget::create(type, *this);
widget->set_rect({ m_next_insertion_position, { m_grid_size * 10 + 1, m_grid_size * 5 + 1 } });
m_next_insertion_position.move_by(m_grid_size, m_grid_size);
m_widgets.append(move(widget));
}
VBForm::~VBForm()
{
}