File indexing completed on 2024-05-12 03:45:46
0001 /* 0002 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #pragma once 0007 0008 #include <QColor> 0009 #include <QSGGeometryNode> 0010 0011 class QSGGeometry; 0012 class QSGFlatColorMaterial; 0013 0014 /** 0015 * @class RectNode 0016 * @short QSGGeometryNode derived class that draws filled and non-filled rectangles 0017 * 0018 * @author Artem Fedoskin 0019 * @version 1.0 0020 */ 0021 class RectNode : public QSGGeometryNode 0022 { 0023 public: 0024 explicit RectNode(bool filled = false); 0025 0026 /** 0027 * @brief setRect sets rectangle to display 0028 * @param x - x coordinate of left-top corner 0029 * @param y - y coordinate of left-top corner 0030 * @param w - width 0031 * @param h - height 0032 */ 0033 void setRect(int x, int y, int w, int h); 0034 0035 /** setColor sets the color of rectangle */ 0036 void setColor(const QColor &color); 0037 0038 /** 0039 * @brief setFilled sets whether the rectangle should be filled or no 0040 * @param filled true to be filled, false otherwise 0041 */ 0042 void setFilled(bool filled); 0043 0044 private: 0045 QSGGeometry *m_geometry { nullptr }; 0046 QSGFlatColorMaterial *m_material { nullptr }; 0047 bool m_filled { false }; 0048 };