Support retrieving ui:🪟:on_close callback & explicitly closing a window
This commit is contained in:
parent
9c70c8e19e
commit
9481997034
2 changed files with 15 additions and 0 deletions
|
|
@ -15,7 +15,9 @@ namespace psemek::ui
|
|||
|
||||
virtual label * caption() = 0;
|
||||
virtual std::shared_ptr<element> set_child(std::shared_ptr<element> c) = 0;
|
||||
virtual on_close_callback on_close() const = 0;
|
||||
virtual void on_close(on_close_callback callback) = 0;
|
||||
virtual void close() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -291,6 +291,8 @@ namespace psemek::ui
|
|||
|
||||
on_close_ = [this]
|
||||
{
|
||||
if (!parent()) return;
|
||||
|
||||
if (auto p = dynamic_cast<container *>(parent()))
|
||||
p->remove_child(this);
|
||||
else
|
||||
|
|
@ -329,11 +331,22 @@ namespace psemek::ui
|
|||
return children_range{children_};
|
||||
}
|
||||
|
||||
on_close_callback on_close() const override
|
||||
{
|
||||
return on_close_;
|
||||
}
|
||||
|
||||
void on_close(on_close_callback callback) override
|
||||
{
|
||||
on_close_ = std::move(callback);
|
||||
}
|
||||
|
||||
void close() override
|
||||
{
|
||||
if (on_close_)
|
||||
on_close_();
|
||||
}
|
||||
|
||||
bool on_event(mouse_move const & e) override
|
||||
{
|
||||
mouse_ = e.position;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue