Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorLayer::ISurfaceAnimator Class Referenceabstract

Hook point for show/hide transitions on Surfaces. More...

#include <phosphor-layer/include/PhosphorLayer/ISurfaceAnimator.h>

Inheritance diagram for PhosphorLayer::ISurfaceAnimator:
[legend]

Public Types

using CompletionCallback = std::function< void()>
 Invoked when a show/hide animation completes.
 

Public Member Functions

 ISurfaceAnimator ()=default
 
virtual ~ISurfaceAnimator ()=default
 
virtual void beginShow (Surface *surface, QQuickItem *rootItem, CompletionCallback onComplete)=0
 Begin a show transition for surface.
 
virtual void beginHide (Surface *surface, QQuickItem *rootItem, CompletionCallback onComplete)=0
 Begin a hide transition for surface.
 
virtual void cancel (Surface *surface)=0
 Interrupt any in-flight animation for surface.
 

Detailed Description

Hook point for show/hide transitions on Surfaces.

Primary animation authoring happens in the consumer's QML — Behavior on opacity { NumberAnimation { duration: 150 } } is almost always the right answer for fade-in/out. This interface exists for cases the QML side cannot cover:

  • Pre-show measurement (e.g. a panel that needs its content sized before the compositor places it).
  • Post-hide cleanup that must wait for an animation to finish before the library tears down the transport handle.
  • Orchestrated transitions across multiple surfaces (fade out modal as primary fades in).

Most consumers pass nullptr and animate entirely within QML. The default implementation (NoOpSurfaceAnimator) does exactly that — it exists so code paths can always call through the interface without null-checking.

Threading

All hooks are called on the GUI thread.

Contract

Implementations must call onComplete exactly once per hook invocation. Failing to do so will strand the Surface in a transient visibility state and eventually trigger a warning + forced transition.

Member Typedef Documentation

◆ CompletionCallback

Invoked when a show/hide animation completes.

The animator must call this exactly once per beginShow/beginHide call. Safe to invoke synchronously for no-op animators.

Constructor & Destructor Documentation

◆ ISurfaceAnimator()

PhosphorLayer::ISurfaceAnimator::ISurfaceAnimator ( )
default

◆ ~ISurfaceAnimator()

virtual PhosphorLayer::ISurfaceAnimator::~ISurfaceAnimator ( )
virtualdefault

Member Function Documentation

◆ beginHide()

virtual void PhosphorLayer::ISurfaceAnimator::beginHide ( Surface surface,
QQuickItem *  rootItem,
CompletionCallback  onComplete 
)
pure virtual

Begin a hide transition for surface.

The Surface is transitioning Shown → Hidden. The animator should fade/slide the content, then invoke onComplete. The library does not delay window->hide() waiting for this — the current contract is "animate for visual polish, but the surface is considered hidden the moment hide() is called".

Implemented in PhosphorAnimationLayer::SurfaceAnimator, and PhosphorLayer::NoOpSurfaceAnimator.

◆ beginShow()

virtual void PhosphorLayer::ISurfaceAnimator::beginShow ( Surface surface,
QQuickItem *  rootItem,
CompletionCallback  onComplete 
)
pure virtual

Begin a show transition for surface.

The Surface has just become visible (Hidden → Shown). The animator can mutate rootItem (opacity, scale, y-offset) and drive an animation. Invoke onComplete when the transition finishes; the library uses this as a no-op today but a future version may defer compositor sync until the completion signal arrives.

Implemented in PhosphorAnimationLayer::SurfaceAnimator, and PhosphorLayer::NoOpSurfaceAnimator.

◆ cancel()

virtual void PhosphorLayer::ISurfaceAnimator::cancel ( Surface surface)
pure virtual

Interrupt any in-flight animation for surface.

Called when the Surface is destroyed or the animation is superseded by an opposite transition (show-while-hiding).

Implemented in PhosphorAnimationLayer::SurfaceAnimator, and PhosphorLayer::NoOpSurfaceAnimator.


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