mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
56e02dbcc0
commit
b5aac29cea
25 changed files with 272 additions and 166 deletions
|
@ -26,7 +26,8 @@ static const double axisTitleSpaceVertical = 2.0; // Space between labels and ti
|
|||
|
||||
StatsAxis::StatsAxis(StatsView &view, const QString &title, bool horizontal, bool labelsBetweenTicks) :
|
||||
ChartPixmapItem(view, ChartZValue::Axes),
|
||||
line(view.createChartItem<ChartLineItem>(ChartZValue::Axes, axisColor, axisWidth)),
|
||||
theme(view.getCurrentTheme()),
|
||||
line(view.createChartItem<ChartLineItem>(ChartZValue::Axes, theme.axisColor, axisWidth)),
|
||||
title(title), horizontal(horizontal), labelsBetweenTicks(labelsBetweenTicks),
|
||||
size(1.0), zeroOnScreen(0.0), min(0.0), max(1.0), labelWidth(0.0)
|
||||
{
|
||||
|
@ -128,7 +129,7 @@ void StatsAxis::addLabel(const QFontMetrics &fm, const QString &label, double po
|
|||
|
||||
void StatsAxis::addTick(double pos)
|
||||
{
|
||||
ticks.push_back({ view.createChartItem<ChartLineItem>(ChartZValue::Axes, axisColor, axisTickWidth), pos });
|
||||
ticks.push_back({ view.createChartItem<ChartLineItem>(ChartZValue::Axes, theme.axisColor, axisTickWidth), pos });
|
||||
}
|
||||
|
||||
std::vector<double> StatsAxis::ticksPositions() const
|
||||
|
@ -190,7 +191,7 @@ void StatsAxis::setSize(double sizeIn)
|
|||
offset = QPointF(round(offsetX), round(offsetY));
|
||||
img->fill(Qt::transparent);
|
||||
|
||||
painter->setPen(QPen(darkLabelColor));
|
||||
painter->setPen(QPen(theme.darkLabelColor));
|
||||
painter->setFont(labelFont);
|
||||
for (const Label &label: labels) {
|
||||
double x = (label.pos - min) / (max - min) * size + offset.x() - round(label.width / 2.0);
|
||||
|
@ -219,7 +220,7 @@ void StatsAxis::setSize(double sizeIn)
|
|||
offset = QPointF(round(offsetX), round(offsetY));
|
||||
img->fill(Qt::transparent);
|
||||
|
||||
painter->setPen(QPen(darkLabelColor));
|
||||
painter->setPen(QPen(theme.darkLabelColor));
|
||||
painter->setFont(labelFont);
|
||||
for (const Label &label: labels) {
|
||||
double y = (min - label.pos) / (max - min) * size + offset.y() - round(fontHeight / 2.0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue