68 text_ = std::move(
text);
69 lifetime_ = std::max(0.0f,
lifetime);
75 opacity_.animate_to(1.0f, fade_duration_);
83 explicit_anchor_ = anchor;
84 has_explicit_anchor_ =
true;
85 position_ = compute_offset(anchor);
97 opacity_.animate_to(0.0f, fade_duration_);
109 opacity_.advance(dt);
111 if (lifetime_ > 0.0f && elapsed_ >= lifetime_) {
116 opacity_.advance(dt);
117 if (!opacity_.animating()) {
120 has_explicit_anchor_ =
false;
134 float opacity()
const {
return opacity_.value(); }
136 const std::string&
text()
const {
return text_; }
152 void set_lifetime(
float seconds) { lifetime_ = std::max(0.0f, seconds); }
157 fade_duration_ = std::max(0.0f, seconds);
166 return {anchor.x + offset_.x, anchor.y + offset_.y};
169 View* source_ =
nullptr;
173 Point offset_{0, -8};
174 Point explicit_anchor_{};
175 bool has_explicit_anchor_ =
false;
178 float lifetime_ = 3.0f;
179 float elapsed_ = 0.0f;
180 float fade_duration_ = 0.12f;
181 ValueAnimation opacity_{0.0f};
Phase phase() const
Definition bubble_message.hpp:133
bool tick(float dt)
Advance time.
Definition bubble_message.hpp:104
bool visible() const
Definition bubble_message.hpp:130
BubbleMessageComponent()=default
Side
Anchor edge — where the bubble is placed relative to the source view's bounds.
Definition bubble_message.hpp:49
@ above
Bubble sits above the top edge of the source.
Definition bubble_message.hpp:50
@ below
Bubble sits below the bottom edge of the source.
Definition bubble_message.hpp:51
@ right
Bubble sits to the right of the source.
Definition bubble_message.hpp:53
@ left
Bubble sits to the left of the source.
Definition bubble_message.hpp:52
float fade_duration() const
Definition bubble_message.hpp:159
View * source_view() const
Definition bubble_message.hpp:137
void recompute_anchor()
Re-derive the position from source_view()->bounds() and the configured side().
Point offset() const
Definition bubble_message.hpp:148
std::function< void(Phase)> on_phase_change
Optional observer fired on every phase transition.
Definition bubble_message.hpp:162
float opacity() const
Definition bubble_message.hpp:134
void show_for(View *source, std::string text, float lifetime=3.0f)
Begin showing the bubble anchored to source.
Definition bubble_message.hpp:66
Phase
Definition bubble_message.hpp:39
@ hiding
Fade-out in progress.
Definition bubble_message.hpp:42
@ showing
Visible (possibly still fading in).
Definition bubble_message.hpp:41
@ idle
Not currently shown.
Definition bubble_message.hpp:40
void set_fade_duration(float seconds)
Fade-in / fade-out duration.
Definition bubble_message.hpp:156
void hide()
Begin fade-out.
Definition bubble_message.hpp:95
Point position() const
Definition bubble_message.hpp:135
float elapsed() const
Definition bubble_message.hpp:138
void set_lifetime(float seconds)
Time in seconds the bubble stays visible before auto-fade.
Definition bubble_message.hpp:152
void set_side(Side s)
Definition bubble_message.hpp:142
float lifetime() const
Definition bubble_message.hpp:153
void move_to(Point anchor)
Update the anchor explicitly (skip the source-view lookup).
Definition bubble_message.hpp:82
void set_offset(Point offset)
Pixel offset added to the computed anchor after the side projection.
Definition bubble_message.hpp:147
const std::string & text() const
Definition bubble_message.hpp:136
Side side() const
Definition bubble_message.hpp:143
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ s
Definition input_events.hpp:41
Definition geometry.hpp:20