1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 18:35:09 +00:00

VisualBuilder: Add [x, y, width, height] properties for all widgets.

At first I tried doing this as a single "rect" property but I like the
feel of the individual properties much better. :^)
This commit is contained in:
Andreas Kling 2019-04-11 22:54:04 +02:00
parent c425bc2e71
commit 3cddc3484e
5 changed files with 32 additions and 5 deletions

View file

@ -24,7 +24,10 @@ Rect VBWidget::rect() const
void VBWidget::set_rect(const Rect& rect)
{
if (rect == m_gwidget->relative_rect())
return;
m_gwidget->set_relative_rect(rect);
synchronize_properties();
}
bool VBWidget::is_selected() const
@ -74,3 +77,22 @@ void VBWidget::for_each_property(Function<void(VBProperty&)> callback)
callback(*it);
}
}
void VBWidget::synchronize_properties()
{
property_by_name("width")->set_value(m_gwidget->width());
property_by_name("height")->set_value(m_gwidget->height());
property_by_name("x")->set_value(m_gwidget->x());
property_by_name("y")->set_value(m_gwidget->y());
m_property_model->update();
}
VBProperty* VBWidget::property_by_name(const String& name)
{
for (auto& property : m_properties) {
if (property->name() == name)
return property.ptr();
}
return nullptr;
}