subsurface/stats/statscolors.h
Berthold Stoeger b5aac29cea 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>
2022-03-16 15:26:54 -07:00

55 lines
1.7 KiB
C++

// SPDX-License-Identifier: GPL-2.0
// Color constants for the various series
#ifndef STATSCOLORS_H
#define STATSCOLORS_H
#include <vector>
#include <QColor>
#include <QString>
class QSGTexture;
class StatsTheme {
public:
StatsTheme();
virtual QString name() const = 0;
QColor backgroundColor;
QColor fillColor;
QColor borderColor;
QColor selectedColor;
QColor selectedBorderColor;
QColor highlightedColor;
QColor highlightedBorderColor;
// The dark and light label colors are with respect to the light theme.
// In the dark theme, dark is light and light is dark. Might want to change the names!
QColor darkLabelColor;
QColor lightLabelColor;
QColor axisColor;
QColor gridColor;
QColor informationBorderColor;
QColor informationColor;
QColor legendColor;
QColor legendBorderColor;
QColor quartileMarkerColor;
QColor regressionItemColor;
QColor meanMarkerColor;
QColor medianMarkerColor;
QColor selectionLassoColor;
QColor selectionOverlayColor;
virtual QColor binColor(int bin, int numBins) const = 0;
virtual QColor labelColor(int bin, size_t numBins) const = 0;
// These are cashes for the QSG rendering engine
// Note: Originally these were std::unique_ptrs, which automatically
// freed the textures on exit. However, destroying textures after
// QApplication finished its thread leads to crashes. Therefore, these
// are now normal pointers and the texture objects are leaked.
mutable QSGTexture *scatterItemTexture = nullptr;
mutable QSGTexture *scatterItemSelectedTexture = nullptr;
mutable QSGTexture *scatterItemHighlightedTexture = nullptr;
mutable QSGTexture *selectedTexture = nullptr; // A checkerboard pattern.
};
extern std::vector<const StatsTheme *> statsThemes;
#endif