ui/widget/material/base/elevation_controller.h¶
Material Design elevation controller for shadow rendering. More...
Namespaces¶
| Name |
|---|
| cf |
| cf::ui |
| cf::ui::widget |
| cf::ui::widget::material |
| cf::ui::widget::material::base |
Classes¶
| Name | |
|---|---|
| class | cf::ui::widget::material::base::MdElevationController Material Design elevation controller. |
Detailed Description¶
Material Design elevation controller for shadow rendering.
Author: N/A
Version: N/A
Since: N/A
Date: N/A
Manages elevation levels and shadow rendering for Material Design widgets. Provides animated transitions between elevation levels and tonal overlay colors for dark theme support.
Source code¶
#pragma once
#include "color.h"
#include "components/material/cfmaterial_animation_factory.h"
#include "core/material/cfmaterial_motion.h"
#include <QObject>
class QPainter;
class QPainterPath;
class QApplication;
namespace cf::ui::widget::material::base {
using CFColor = cf::ui::base::CFColor;
class CF_UI_EXPORT MdElevationController : public QObject {
Q_OBJECT
public:
explicit MdElevationController(
cf::WeakPtr<components::material::CFMaterialAnimationFactory> factory,
QObject* parent = nullptr);
void setElevation(int level);
int elevation() const;
void setLightSourceAngle(float degrees);
float lightSourceAngle() const { return m_lightSourceAngle; }
void animateTo(int level, const core::MotionSpec& spec);
void paintShadow(QPainter* painter, const QPainterPath& shape);
CFColor tonalOverlay(CFColor surface, CFColor primary) const;
void setPressed(bool pressed);
void animatePressOffsetTo(float to);
bool isPressed() const { return m_isPressed; }
float pressOffset() const;
~MdElevationController();
signals:
void pressOffsetChanged();
private:
float m_currentLevel = 0.0f;
int m_targetLevel = 0;
float m_lightSourceAngle = 15.0f;
bool m_isPressed = false;
float m_currentPressOffset = 0.0f;
cf::WeakPtr<components::material::CFMaterialAnimationFactory> m_animator;
cf::WeakPtr<components::ICFAbstractAnimation> m_pressOffsetAnimation;
void cancelCurrentAnimation();
void onAnimationFinished();
struct ShadowParams {
float blurRadius;
float offsetX;
float offsetY;
float opacity;
};
ShadowParams paramsForLevel(float level) const;
};
} // namespace cf::ui::widget::material::base
Updated on 2026-03-09 at 10:14:01 +0000