summaryrefslogtreecommitdiffstats
path: root/stats/chartitem.h
diff options
context:
space:
mode:
Diffstat (limited to 'stats/chartitem.h')
-rw-r--r--stats/chartitem.h41
1 files changed, 40 insertions, 1 deletions
diff --git a/stats/chartitem.h b/stats/chartitem.h
index f13cb3bc4..93c80547f 100644
--- a/stats/chartitem.h
+++ b/stats/chartitem.h
@@ -11,6 +11,7 @@ class QSGGeometry;
class QSGGeometryNode;
class QSGFlatColorMaterial;
class QSGImageNode;
+class QSGRectangleNode;
class QSGTexture;
class StatsView;
enum class ChartZValue : int;
@@ -20,7 +21,6 @@ public:
ChartItem(StatsView &v, ChartZValue z);
virtual ~ChartItem();
virtual void render() = 0; // Only call on render thread!
- QRectF getRect() const;
bool dirty; // If true, call render() when rebuilding the scene
ChartItem *dirtyPrev, *dirtyNext; // Double linked list of dirty items
const ChartZValue zValue;
@@ -64,6 +64,22 @@ private:
double radius;
};
+// Attention: text is only drawn after calling setColor()!
+class ChartTextItem : public ChartPixmapItem {
+public:
+ ChartTextItem(StatsView &v, ChartZValue z, const QFont &f, const std::vector<QString> &text, bool center);
+ void setColor(const QColor &color);
+private:
+ QFont f;
+ double fontHeight;
+ bool center;
+ struct Item {
+ QString s;
+ double width;
+ };
+ std::vector<Item> items;
+};
+
class ChartLineItem : public ChartItem {
public:
ChartLineItem(StatsView &v, ChartZValue z, QColor color, double width);
@@ -74,6 +90,7 @@ private:
QPointF from, to;
QColor color;
double width;
+ bool horizontal;
bool positionDirty;
bool materialDirty;
std::unique_ptr<QSGGeometryNode> node;
@@ -81,4 +98,26 @@ private:
std::unique_ptr<QSGGeometry> geometry;
};
+// A bar in a bar chart: a rectangle bordered by lines.
+class ChartBarItem : public ChartItem {
+public:
+ ChartBarItem(StatsView &v, ChartZValue z, double borderWidth, bool horizontal);
+ ~ChartBarItem();
+ void setColor(QColor color, QColor borderColor);
+ void setRect(const QRectF &rect);
+ QRectF getRect() const;
+ void render() override; // Only call on render thread!
+private:
+ QColor color, borderColor;
+ double borderWidth;
+ QRectF rect;
+ bool horizontal;
+ bool positionDirty;
+ bool colorDirty;
+ std::unique_ptr<QSGRectangleNode> node;
+ std::unique_ptr<QSGGeometryNode> borderNode;
+ std::unique_ptr<QSGFlatColorMaterial> borderMaterial;
+ std::unique_ptr<QSGGeometry> borderGeometry;
+};
+
#endif