2019-04-11 17:13:19 +03:00
|
|
|
#include "VBProperty.h"
|
2019-04-19 02:05:59 +03:00
|
|
|
#include "VBWidget.h"
|
2019-04-11 17:13:19 +03:00
|
|
|
|
2019-04-19 02:05:59 +03:00
|
|
|
VBProperty::VBProperty(VBWidget& widget, const String& name, const GVariant& value)
|
|
|
|
: m_widget(widget)
|
|
|
|
, m_name(name)
|
2019-04-11 17:13:19 +03:00
|
|
|
, m_value(value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-04-19 02:05:59 +03:00
|
|
|
VBProperty::VBProperty(VBWidget& widget, const String& name, Function<GVariant(const GWidget&)>&& getter, Function<void(GWidget&, const GVariant&)>&& setter)
|
|
|
|
: m_widget(widget)
|
|
|
|
, m_name(name)
|
2019-04-14 05:14:23 +03:00
|
|
|
, m_getter(move(getter))
|
|
|
|
, m_setter(move(setter))
|
|
|
|
{
|
|
|
|
ASSERT(m_getter);
|
|
|
|
ASSERT(m_setter);
|
|
|
|
}
|
|
|
|
|
2019-04-11 17:13:19 +03:00
|
|
|
VBProperty::~VBProperty()
|
|
|
|
{
|
|
|
|
}
|
2019-04-19 02:05:59 +03:00
|
|
|
|
|
|
|
void VBProperty::set_value(const GVariant& value)
|
|
|
|
{
|
|
|
|
if (m_value == value)
|
|
|
|
return;
|
|
|
|
m_value = value;
|
|
|
|
if (m_setter)
|
|
|
|
m_setter(*m_widget.gwidget(), value);
|
|
|
|
m_widget.property_did_change();
|
|
|
|
}
|