Support arbitrary post-draw effect in ui::controller
This commit is contained in:
parent
14d7dda788
commit
6e289b3b90
2 changed files with 12 additions and 0 deletions
|
|
@ -22,6 +22,8 @@ namespace psemek::ui
|
|||
void set_hint_delay(float seconds);
|
||||
void on_hint(util::function<void(element *)> callback);
|
||||
|
||||
void set_post_draw_effect(util::function<void(element *, painter &)> effect);
|
||||
|
||||
void reshape(geom::box<float, 2> const & shape);
|
||||
|
||||
bool event(mouse_move const & e);
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ namespace psemek::ui
|
|||
util::function<void(element *)> on_hint;
|
||||
std::optional<std::weak_ptr<element>> hinted_element = std::nullopt;
|
||||
std::optional<std::string> hint_called = std::nullopt;
|
||||
util::function<void(element *, struct painter &)> post_draw_effect;
|
||||
|
||||
impl(async::event_loop * loop);
|
||||
|
||||
|
|
@ -212,6 +213,11 @@ namespace psemek::ui
|
|||
impl().on_hint = std::move(callback);
|
||||
}
|
||||
|
||||
void controller::set_post_draw_effect(util::function<void(element *, painter &)> effect)
|
||||
{
|
||||
impl().post_draw_effect = std::move(effect);
|
||||
}
|
||||
|
||||
void controller::reshape(geom::box<float, 2> const & shape)
|
||||
{
|
||||
impl().root->reshape(shape);
|
||||
|
|
@ -321,7 +327,11 @@ namespace psemek::ui
|
|||
for (auto c : elem->children())
|
||||
if (c) self(c);
|
||||
if (visible)
|
||||
{
|
||||
elem->post_draw(impl().painter);
|
||||
if (impl().post_draw_effect)
|
||||
impl().post_draw_effect(elem, impl().painter);
|
||||
}
|
||||
});
|
||||
|
||||
visitor(impl().root.get());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue