59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
#include <psemek/ui/impl/storage_base.hpp>
|
|
|
|
#include <psemek/react/join.hpp>
|
|
|
|
namespace psemek::ui::impl
|
|
{
|
|
|
|
storage_base::storage_base()
|
|
: child_size_constraints_(size_constraints::max())
|
|
, size_constraints_(react::join(child_size_constraints_))
|
|
{}
|
|
|
|
void storage_base::reshape(geom::box<float, 2> const & new_shape)
|
|
{
|
|
single_container::reshape(new_shape);
|
|
|
|
if (auto child = this->child())
|
|
child->reshape(new_shape);
|
|
}
|
|
|
|
react::value<struct size_constraints> storage_base::size_constraints() const
|
|
{
|
|
if (auto child = this->child())
|
|
return child->size_constraints();
|
|
|
|
return impl::size_constraints::max();
|
|
}
|
|
|
|
void storage_base::set_child(std::unique_ptr<component> child)
|
|
{
|
|
if (child)
|
|
child_size_constraints_.set(child->size_constraints());
|
|
else
|
|
child_size_constraints_.set(size_constraints::max());
|
|
single_container::set_child(std::move(child));
|
|
}
|
|
|
|
std::unique_ptr<component> storage_base::release_child()
|
|
{
|
|
child_size_constraints_.set(size_constraints::max());
|
|
return single_container::release_child();
|
|
}
|
|
|
|
void storage_base::update(storage const & value)
|
|
{
|
|
util::hash_map<std::string, react::source<std::any>> new_values;
|
|
|
|
for (auto const & p : value.values)
|
|
{
|
|
auto & v = (new_values[p.first] = p.second);
|
|
|
|
if (auto it = values_.find(p.first); it != values_.end())
|
|
v.set(*(it->second));
|
|
}
|
|
|
|
values_ = std::move(new_values);
|
|
}
|
|
|
|
}
|