statistics: collect colors in a StatsTheme class

To enable rudimentary theming, collect all colors in a new
theme class. The class has to be passed down to the various
items.

In general the items save a reference to the them in the
constructor. Alternatively, they might also just query
the StatsView everytime they need to access a color.
For now, it's hard the say what is preferred: a reference
per item or a function call per invokation?

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-02-16 17:05:39 +01:00 committed by Dirk Hohndel
parent 56e02dbcc0
commit b5aac29cea
25 changed files with 272 additions and 166 deletions

View file

@ -29,6 +29,7 @@ class QuartileMarker;
class RegressionItem;
class StatsAxis;
class StatsGrid;
class StatsTheme;
class Legend;
class QSGTexture;
class RootNode; // Internal implementation detail
@ -53,6 +54,8 @@ public:
QQuickWindow *w() const; // Make window available to items
QSizeF size() const;
QRectF plotArea() const;
void setTheme(int idx); // Invalid indexes will result in the default theme. Chart must be replot for theme to become effective.
const StatsTheme &getCurrentTheme() const;
void addQSGNode(QSGNode *node, ChartZValue z); // Must only be called in render thread!
void registerChartItem(ChartItem &item);
void registerDirtyChartItem(ChartItem &item);
@ -140,6 +143,7 @@ private:
void addLineMarker(double pos, double low, double high, const QPen &pen, bool isHorizontal);
StatsState state;
const StatsTheme *currentTheme;
QFont titleFont;
std::vector<std::unique_ptr<StatsSeries>> series;
std::unique_ptr<StatsGrid> grid;