40 lines
719 B
C++
40 lines
719 B
C++
#include <psemek/ui/rich_button.hpp>
|
|
|
|
namespace psemek::ui
|
|
{
|
|
|
|
element::children_range rich_button::children() const
|
|
{
|
|
return children_range{children_};
|
|
}
|
|
|
|
rich_button::~rich_button()
|
|
{
|
|
release_children();
|
|
}
|
|
|
|
void rich_button::set_label(std::shared_ptr<struct label> label)
|
|
{
|
|
if (icon())
|
|
set_icon(nullptr);
|
|
|
|
if (label_) label_->set_parent(nullptr);
|
|
|
|
label_ = std::move(label);
|
|
children_[0] = label_.get();
|
|
if (label_) label_->set_parent(this);
|
|
}
|
|
|
|
void rich_button::set_icon(std::shared_ptr<image_view> icon)
|
|
{
|
|
if (label())
|
|
set_label(nullptr);
|
|
|
|
if (icon_) icon_->set_parent(nullptr);
|
|
|
|
icon_ = std::move(icon);
|
|
children_[0] = icon_.get();
|
|
if (icon_) icon_->set_parent(this);
|
|
}
|
|
|
|
}
|