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

@ -95,8 +95,9 @@ private:
bool isOutside; // Is shown outside of bar
BarLabel(StatsView &view, const std::vector<QString> &labels, int bin_nr, int binCount);
void setVisible(bool visible);
void updatePosition(bool horizontal, bool center, const QRectF &rect, int bin_nr, int binCount, const QColor &background);
void highlight(bool highlight, int bin_nr, int binCount, const QColor &background);
void updatePosition(bool horizontal, bool center, const QRectF &rect, int bin_nr, int binCount,
const QColor &background, const StatsTheme &theme);
void highlight(bool highlight, int bin_nr, int binCount, const QColor &background, const StatsTheme &theme);
};
struct SubItem {
@ -109,8 +110,8 @@ private:
bool selected;
QColor fill;
void updatePosition(BarSeries *series, bool horizontal, bool stacked,
double from, double to, int binCount);
void highlight(bool highlight, int binCount);
double from, double to, int binCount, const StatsTheme &theme);
void highlight(bool highlight, int binCount, const StatsTheme &theme);
};
struct Item {
@ -123,9 +124,11 @@ private:
Item(BarSeries *series, double lowerBound, double upperBound,
std::vector<SubItem> subitems,
const QString &binName, const StatsOperationResults &res, int total, bool horizontal,
bool stacked, int binCount);
void updatePosition(BarSeries *series, bool horizontal, bool stacked, int binCount);
void highlight(int subitem, bool highlight, int binCount);
bool stacked, int binCount,
const StatsTheme &theme);
void updatePosition(BarSeries *series, bool horizontal, bool stacked, int binCount,
const StatsTheme &theme);
void highlight(int subitem, bool highlight, int binCount, const StatsTheme &theme);
int getSubItemUnderMouse(const QPointF &f, bool horizontal, bool stacked) const;
};