Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::view::BubbleMessageComponent Class Reference

#include <bubble_message.hpp>

Public Types

enum class  Phase { idle , showing , hiding }
enum class  Side { above , below , left , right }
 Anchor edge — where the bubble is placed relative to the source view's bounds. More...

Public Member Functions

 BubbleMessageComponent ()=default
void show_for (View *source, std::string text, float lifetime=3.0f)
 Begin showing the bubble anchored to source.
void move_to (Point anchor)
 Update the anchor explicitly (skip the source-view lookup).
void recompute_anchor ()
 Re-derive the position from source_view()->bounds() and the configured side().
void hide ()
 Begin fade-out.
bool tick (float dt)
 Advance time.
bool visible () const
Phase phase () const
float opacity () const
Point position () const
const std::string & text () const
View * source_view () const
float elapsed () const
void set_side (Side s)
Side side () const
void set_offset (Point offset)
 Pixel offset added to the computed anchor after the side projection.
Point offset () const
void set_lifetime (float seconds)
 Time in seconds the bubble stays visible before auto-fade.
float lifetime () const
void set_fade_duration (float seconds)
 Fade-in / fade-out duration.
float fade_duration () const

Public Attributes

std::function< void(Phase)> on_phase_change
 Optional observer fired on every phase transition.

Member Enumeration Documentation

◆ Phase

Enumerator
idle 

Not currently shown.

showing 

Visible (possibly still fading in).

hiding 

Fade-out in progress.

◆ Side

Anchor edge — where the bubble is placed relative to the source view's bounds.

The caller can pick a side and the bubble's position will be derived from source_view->bounds() whenever recompute_anchor() runs.

Enumerator
above 

Bubble sits above the top edge of the source.

below 

Bubble sits below the bottom edge of the source.

left 

Bubble sits to the left of the source.

right 

Bubble sits to the right of the source.

Constructor & Destructor Documentation

◆ BubbleMessageComponent()

pulp::view::BubbleMessageComponent::BubbleMessageComponent ( )
default

Member Function Documentation

◆ elapsed()

float pulp::view::BubbleMessageComponent::elapsed ( ) const
inline

◆ fade_duration()

float pulp::view::BubbleMessageComponent::fade_duration ( ) const
inline

◆ hide()

void pulp::view::BubbleMessageComponent::hide ( )
inline

Begin fade-out.

From showing jumps to hiding; from idle or already-hiding is a no-op.

◆ lifetime()

float pulp::view::BubbleMessageComponent::lifetime ( ) const
inline

◆ move_to()

void pulp::view::BubbleMessageComponent::move_to ( Point anchor)
inline

Update the anchor explicitly (skip the source-view lookup).

Useful when the caller wants to position the bubble at a pointer or arbitrary screen coordinate.

◆ offset()

Point pulp::view::BubbleMessageComponent::offset ( ) const
inline

◆ opacity()

float pulp::view::BubbleMessageComponent::opacity ( ) const
inline

◆ phase()

Phase pulp::view::BubbleMessageComponent::phase ( ) const
inline

◆ position()

Point pulp::view::BubbleMessageComponent::position ( ) const
inline

◆ recompute_anchor()

void pulp::view::BubbleMessageComponent::recompute_anchor ( )

Re-derive the position from source_view()->bounds() and the configured side().

Safe to call every tick. No-op if the source is null or an explicit anchor is in force.

◆ set_fade_duration()

void pulp::view::BubbleMessageComponent::set_fade_duration ( float seconds)
inline

Fade-in / fade-out duration.

◆ set_lifetime()

void pulp::view::BubbleMessageComponent::set_lifetime ( float seconds)
inline

Time in seconds the bubble stays visible before auto-fade.

0 disables auto-dismiss (caller drives hide()).

◆ set_offset()

void pulp::view::BubbleMessageComponent::set_offset ( Point offset)
inline

Pixel offset added to the computed anchor after the side projection.

Default (0, -8) — small gap above the source.

◆ set_side()

void pulp::view::BubbleMessageComponent::set_side ( Side s)
inline

◆ show_for()

void pulp::view::BubbleMessageComponent::show_for ( View * source,
std::string text,
float lifetime = 3.0f )
inline

Begin showing the bubble anchored to source.

If source is not null, recompute_anchor() will project the source's bounds().center() (offset by side) into the position. The bubble is visible immediately and fades out after lifetime seconds.

Calling show_for while already visible swaps the text, source, and resets the lifetime timer.

◆ side()

Side pulp::view::BubbleMessageComponent::side ( ) const
inline

◆ source_view()

View * pulp::view::BubbleMessageComponent::source_view ( ) const
inline

◆ text()

const std::string & pulp::view::BubbleMessageComponent::text ( ) const
inline

◆ tick()

bool pulp::view::BubbleMessageComponent::tick ( float dt)
inline

Advance time.

Drives the auto-dismiss timer + fade animations. Returns true while the bubble is still doing work (visible, fading, or counting down).

◆ visible()

bool pulp::view::BubbleMessageComponent::visible ( ) const
inline

Member Data Documentation

◆ on_phase_change

std::function<void(Phase)> pulp::view::BubbleMessageComponent::on_phase_change

Optional observer fired on every phase transition.


The documentation for this class was generated from the following file: