Added support to hide chart elements with opacity from chart view.
This commit is contained in:
parent
a9b0464726
commit
7ac9ab3a51
|
@ -47,6 +47,7 @@ void PaintBottomLine(
|
|||
int y,
|
||||
int captionIndicesOffset) {
|
||||
p.setFont(st::statisticsDetailsBottomCaptionStyle.font);
|
||||
const auto opacity = p.opacity();
|
||||
|
||||
const auto startXIndex = chartData.findStartIndex(
|
||||
xPercentageLimits.min);
|
||||
|
@ -105,7 +106,8 @@ void PaintBottomLine(
|
|||
0.,
|
||||
1. + ((chartWidth - rect::right(r)) / edgeAlphaSize))
|
||||
: 1.;
|
||||
p.setOpacity(edgeAlpha
|
||||
p.setOpacity(opacity
|
||||
* edgeAlpha
|
||||
* (hasFastAlpha ? fastAlpha : resultAlpha));
|
||||
p.drawText(r, chartData.getDayString(i), style::al_center);
|
||||
}
|
||||
|
@ -450,7 +452,11 @@ void ChartWidget::Footer::paintEvent(QPaintEvent *e) {
|
|||
if (_paintChartCallback) {
|
||||
auto q = QPainter(&_frame);
|
||||
|
||||
_paintChartCallback(q, Rect(innerRect.size()));
|
||||
{
|
||||
const auto opacity = q.opacity();
|
||||
_paintChartCallback(q, Rect(innerRect.size()));
|
||||
q.setOpacity(opacity);
|
||||
}
|
||||
|
||||
q.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||
q.drawImage(0, 0, _mask);
|
||||
|
|
|
@ -39,9 +39,9 @@ void ChartHorizontalLinesView::setChartData(
|
|||
void ChartHorizontalLinesView::paintHorizontalLines(
|
||||
QPainter &p,
|
||||
const QRect &r) {
|
||||
const auto alpha = p.opacity();
|
||||
for (auto &horizontalLine : _horizontalLines) {
|
||||
const auto alpha = p.opacity();
|
||||
p.setOpacity(horizontalLine.alpha);
|
||||
p.setOpacity(alpha * horizontalLine.alpha);
|
||||
for (const auto &line : horizontalLine.lines) {
|
||||
const auto lineRect = QRect(
|
||||
0,
|
||||
|
@ -50,8 +50,8 @@ void ChartHorizontalLinesView::paintHorizontalLines(
|
|||
st::lineWidth);
|
||||
p.fillRect(lineRect, st::windowSubTextFg);
|
||||
}
|
||||
p.setOpacity(alpha);
|
||||
}
|
||||
p.setOpacity(alpha);
|
||||
}
|
||||
|
||||
void ChartHorizontalLinesView::paintCaptionsToHorizontalLines(
|
||||
|
@ -59,9 +59,9 @@ void ChartHorizontalLinesView::paintCaptionsToHorizontalLines(
|
|||
const QRect &r) {
|
||||
const auto offset = r.y() - st::statisticsChartHorizontalLineCaptionSkip;
|
||||
p.setFont(st::statisticsDetailsBottomCaptionStyle.font);
|
||||
const auto alpha = p.opacity();
|
||||
for (auto &horizontalLine : _horizontalLines) {
|
||||
const auto alpha = p.opacity();
|
||||
p.setOpacity(horizontalLine.alpha);
|
||||
p.setOpacity(alpha * horizontalLine.alpha);
|
||||
for (const auto &line : horizontalLine.lines) {
|
||||
const auto y = offset + r.height() * line.relativeValue;
|
||||
p.setPen(_isDouble ? _leftPen : st::windowSubTextFg);
|
||||
|
@ -83,8 +83,8 @@ void ChartHorizontalLinesView::paintCaptionsToHorizontalLines(
|
|||
: line.scaledLineCaption);
|
||||
}
|
||||
}
|
||||
p.setOpacity(alpha);
|
||||
}
|
||||
p.setOpacity(alpha);
|
||||
}
|
||||
|
||||
void ChartHorizontalLinesView::computeRelative(
|
||||
|
|
|
@ -71,6 +71,7 @@ void LinearChartView::paint(QPainter &p, const PaintContext &c) {
|
|||
c.heightLimits,
|
||||
c.rect.size());
|
||||
|
||||
const auto opacity = p.opacity();
|
||||
const auto imageSize = c.rect.size() * style::DevicePixelRatio();
|
||||
const auto cacheScale = 1. / style::DevicePixelRatio();
|
||||
auto &caches = (c.footer ? _footerCaches : _mainCaches);
|
||||
|
@ -117,6 +118,7 @@ void LinearChartView::paint(QPainter &p, const PaintContext &c) {
|
|||
cache.lastToken = cacheToken;
|
||||
cache.image = std::move(image);
|
||||
}
|
||||
p.setOpacity(opacity);
|
||||
}
|
||||
|
||||
void LinearChartView::paintSelectedXIndex(
|
||||
|
|
|
@ -130,10 +130,11 @@ void StackLinearChartView::paintChartOrZoomAnimation(
|
|||
const PaintContext &c) {
|
||||
if (_transitionProgress == 1.) {
|
||||
if (c.footer) {
|
||||
return paintZoomedFooter(p, c);
|
||||
paintZoomedFooter(p, c);
|
||||
} else {
|
||||
return paintZoomed(p, c);
|
||||
paintZoomed(p, c);
|
||||
}
|
||||
return p.setOpacity(0.);
|
||||
}
|
||||
const auto &[localStart, localEnd] = _lastPaintedXIndices;
|
||||
_skipPoints = std::vector<bool>(c.chartData.lines.size(), false);
|
||||
|
@ -365,7 +366,7 @@ void StackLinearChartView::paintChartOrZoomAnimation(
|
|||
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
|
||||
p.fillRect(c.rect, st::boxBg);
|
||||
p.fillRect(c.rect + QMargins(0, 0, 0, st::lineWidth), st::boxBg);
|
||||
if (!ovalPath.isEmpty()) {
|
||||
p.setClipPath(ovalPath);
|
||||
}
|
||||
|
@ -401,13 +402,18 @@ void StackLinearChartView::paintChartOrZoomAnimation(
|
|||
p.setPen(st::boxBg);
|
||||
p.drawPath(ovalPath);
|
||||
}
|
||||
|
||||
if (!ovalPath.isEmpty()) {
|
||||
p.setClipRect(c.rect, Qt::NoClip);
|
||||
}
|
||||
p.setOpacity(1. - _transitionProgress);
|
||||
}
|
||||
|
||||
void StackLinearChartView::paintZoomed(QPainter &p, const PaintContext &c) {
|
||||
if (c.footer) {
|
||||
return;
|
||||
}
|
||||
p.fillRect(c.rect, st::boxBg);
|
||||
p.fillRect(c.rect + QMargins(0, 0, 0, st::lineWidth), st::boxBg);
|
||||
const auto center = QPointF(c.rect.center());
|
||||
const auto side = (c.rect.width() / 2.) * kCircleSizeRatio;
|
||||
const auto rectF = QRectF(
|
||||
|
|
Loading…
Reference in New Issue