Fluent-Qt

Particles 粒子特效

ParticleBackdrop 粒子背景

可配置的粒子动画背景。

示例

粒子背景的真实 Gallery 示例

用法

流动丝带

setEffect() 选择效果,setParticleCount() 和 setMaximumFrameRate() 控制密度和帧率;减弱动效模式下动画会停止。

#include <FluentQt/Particles.h>
using namespace fluent::particles;

auto* backdrop = new ParticleBackdrop(this);
backdrop->setEffect(ParticleBackdrop::FlowingRibbons);
backdrop->setBackgroundMode(ParticleBackdrop::Solid);
backdrop->setParticleCount(240);
backdrop->setMaximumFrameRate(30);
backdrop->setMinimumHeight(240);
backdrop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);

fluent::particles::ParticleBackdrop

继承自 QWidget · FluentElement · QMLPlus

在调用方组合的内容后方,用 CPU 绘制可切换预设的粒子背景。

构造函数

属性

Effect effect
读取 effect()设置 setEffect()通知 effectChanged()
bool animationEnabled
读取 isAnimationEnabled()设置 setAnimationEnabled()通知 animationEnabledChanged()
bool animating

策略与可见性收敛后的实际计时状态。

读取 isAnimating()通知 animatingChanged()
bool gpuAccelerationEnabled

允许可选 Spatial 合成器加速绘制,默认关闭。

读取 isGpuAccelerationEnabled()设置 setGpuAccelerationEnabled()通知 gpuAccelerationEnabledChanged()
qreal speed
读取 speed()设置 setSpeed()通知 speedChanged()
int particleCount
读取 particleCount()设置 setParticleCount()通知 particleCountChanged()
int maximumFrameRate
读取 maximumFrameRate()设置 setMaximumFrameRate()通知 maximumFrameRateChanged()
bool interactive
读取 isInteractive()设置 setInteractive()通知 interactiveChanged()
bool pauseWhenInactive
读取 isPauseWhenInactive()设置 setPauseWhenInactive()通知 pauseWhenInactiveChanged()
BackgroundMode backgroundMode
读取 backgroundMode()设置 setBackgroundMode()通知 backgroundModeChanged()
QMarginsF fadeMargins
读取 fadeMargins()设置 setFadeMargins()通知 fadeMarginsChanged()

方法

void setEffect(Effect effect)

切换特效并重置运动相位,保留其他设置;忽略无效值。

bool isAnimating() const

策略与可见性收敛后的实际计时状态。

bool isGpuAccelerationEnabled() const

允许可选 Spatial 合成器加速绘制,默认关闭。

void setGpuAccelerationEnabled(bool enabled)

允许可选 Spatial 合成器加速绘制,默认关闭。

void setSpeed(qreal speed)

设置 0 到 4 倍速度,零表示静止。

void setParticleCount(int count)

设置粒子总数,范围 0 到 960;流动光带的光带、微粒与拖尾不计入此数量。

void setMaximumFrameRate(int framesPerSecond)

将计划帧率限制为每秒 1 到 60 帧。

void setPauseWhenInactive(bool pause)

控制应用失活时是否暂停。

void setFadeMargins(const QMarginsF& margins)

设置非负的边缘渐隐宽度,单位为逻辑像素。

void triggerRipple(const QPointF& position)

动效允许时,在局部坐标处产生装饰涟漪,最多同时保留三圈。

信号

void animatingChanged(bool animating)

策略与可见性收敛后的实际计时状态。

void gpuAccelerationEnabledChanged(bool enabled)

允许可选 Spatial 合成器加速绘制,默认关闭。

枚举

enum Effect

内置的 CPU 粒子特效。

  • FlowingRibbons 轨道光带与拖尾亮点。
  • FloatingDots 缓慢向上漂浮的柔和光点。
  • Starfield 向观察者迎面飞来的星空。
enum BackgroundMode

背景合成方式。

  • Transparent
  • Solid

析构函数

子类扩展接口

方法

继承自 fluent::FluentElement

方法

static void setTheme(Theme theme)

更新全局主题,并通知所有活跃的 FluentElement 实例。

static void setThemeDeferred(Theme theme)

以可见元素优先的批次调度主题刷新,避免阻塞当前交互。

static Theme currentTheme()

返回当前生效的全局主题。

static bool themeUsesDarkAppearance(Theme theme)

返回指定主题是否使用暗色底的 chrome 与材质 token。

static void refreshTheme()

在设计 token 变化后重新广播当前主题以触发重绘。

static int themeGeneration()

每次主题变化自增的单调计数器,用于过期判断。

Theme effectiveTheme() const

解析此元素实际使用的主题,会优先读取 QWidget 父链上的局部主题覆盖。

bool effectiveThemeUsesDarkAppearance() const

返回此元素的实际主题是否使用暗色底 chrome。

bool setThemeOverrides(const QJsonObject& overrides)

供组件侧访问的设计 token 接口。

QJsonObject themeOverrides() const

返回当前元素的覆盖配置。

void clearThemeOverrides()

恢复全部 token 跟随全局主题。

const Colors& themeColorsRef() const

对当前色板的零拷贝访问(用于绘制热路径)。

Material::AcrylicToken themeAcrylic() const

材质、阴影和自适应布局 token。

QColor themeBackdrop(bool active) const

给定激活状态下的窗口 chrome 背景色。

virtual void onThemeUpdated()

全局主题变化后调用。

枚举

enum Theme

解析设计 token 时使用的全局视觉主题。

  • Light = 0
  • Dark = 1
  • HighContrast = 2

类型与别名

struct Colors

返回给组件使用的设计 token 快照。

继承自 fluent::QMLPlus

方法

AnchorLayout::Anchors* anchors()

返回 QWidget 宿主的可变锚点配置。

void setState(const QString& name)

应用具名 state;名称为空时恢复默认状态。

void addState(const QMLState& state)

注册或替换一个具名 state 定义。

void evaluateStates()

重新计算条件;按注册顺序选择首个成立的条件。

QMLPlusRuntime* runtime()

返回按需创建、由宿主持有的状态观察对象。

void setAnchors(const AnchorLayout::Anchors& anchors)

替换宿主的全部锚点,并使父布局失效。

void resetAnchors()

清除宿主全部锚点,并使父布局失效。

void addTransition(const StateTransition& transition)

按优先顺序注册状态过渡。

void setBehavior(const char* propertyName, const PropertyAnimation& animation)

设置宿主受管理属性写入时使用的默认动画。

void clearBehavior(const char* propertyName)

移除后续受管理写入使用的默认动画。

bool writeProperty(const char* propertyName, const QVariant& value)

通过 Behavior 写入宿主属性,且不移除该属性的绑定。

Qt 基类完整成员:QWidget