跳转至

ui/widget/material/base/painter_layer.cpp

Material Design Painter Layer Implementation. More...

Namespaces

Name
cf
cf::ui
cf::ui::widget
cf::ui::widget::material
cf::ui::widget::material::base

Detailed Description

Material Design Painter Layer Implementation.

Author: Material Design Framework Team

Version: 0.1

Since: 0.1

Date: 2026-02-28

Provides basic color and opacity overlay rendering for state layers. This is the simplest component in Layer 4, serving as the foundation for more complex behavior components.

Source code

#include "painter_layer.h"
#include <QPainter>
#include <QPainterPath>

namespace cf::ui::widget::material::base {

PainterLayer::PainterLayer(QObject* parent)
    : QObject(parent), cached_color_(Qt::black), opacity_(1.0f) {}

void PainterLayer::paint(QPainter* painter, const QPainterPath& clipPath) {
    if (!painter || opacity_ <= 0.0f) {
        return;
    }

    painter->save();
    painter->setClipPath(clipPath);

    // Convert CFColor to QColor and apply opacity
    QColor color = cached_color_.native_color();
    color.setAlphaF(color.alphaF() * opacity_);

    painter->fillPath(clipPath, color);
    painter->restore();
}

} // namespace cf::ui::widget::material::base

Updated on 2026-03-09 at 10:14:01 +0000