mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Added support to hide name and value of line in PointDetailsWidget.
This commit is contained in:
parent
41bc47eb6f
commit
ee172d951d
3 changed files with 40 additions and 6 deletions
|
@ -916,6 +916,11 @@ void ChartWidget::setupChartArea() {
|
||||||
const auto opacity = ScopedPainterOpacity(p, detailsAlpha);
|
const auto opacity = ScopedPainterOpacity(p, detailsAlpha);
|
||||||
p.fillRect(lineRect, st::windowSubTextFg);
|
p.fillRect(lineRect, st::windowSubTextFg);
|
||||||
_details.widget->setAlpha(detailsAlpha);
|
_details.widget->setAlpha(detailsAlpha);
|
||||||
|
for (const auto &line : _chartData.lines) {
|
||||||
|
_details.widget->setLineAlpha(
|
||||||
|
line.id,
|
||||||
|
_animatedChartLines.alpha(line.id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,9 +62,24 @@ PointDetailsWidget::PointDetailsWidget(
|
||||||
_textRect = _innerRect - st::statisticsDetailsPopupMargins;
|
_textRect = _innerRect - st::statisticsDetailsPopupMargins;
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
resize(calculatedWidth, height());
|
||||||
|
resizeHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PointDetailsWidget::setLineAlpha(int lineId, float64 alpha) {
|
||||||
|
for (auto &line : _lines) {
|
||||||
|
if (line.id == lineId) {
|
||||||
|
line.alpha = alpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
resizeHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PointDetailsWidget::resizeHeight() {
|
||||||
resize(
|
resize(
|
||||||
calculatedWidth,
|
width(),
|
||||||
lineYAt(chartData.lines.size())
|
lineYAt(_chartData.lines.size())
|
||||||
+ st::statisticsDetailsPopupMargins.bottom());
|
+ st::statisticsDetailsPopupMargins.bottom());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +98,7 @@ void PointDetailsWidget::setXIndex(int xIndex) {
|
||||||
_lines.reserve(_chartData.lines.size());
|
_lines.reserve(_chartData.lines.size());
|
||||||
for (const auto &dataLine : _chartData.lines) {
|
for (const auto &dataLine : _chartData.lines) {
|
||||||
auto textLine = Line();
|
auto textLine = Line();
|
||||||
|
textLine.id = dataLine.id;
|
||||||
textLine.name.setText(_textStyle, dataLine.name);
|
textLine.name.setText(_textStyle, dataLine.name);
|
||||||
textLine.value.setText(
|
textLine.value.setText(
|
||||||
_textStyle,
|
_textStyle,
|
||||||
|
@ -97,12 +113,19 @@ void PointDetailsWidget::setAlpha(float64 alpha) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
int PointDetailsWidget::lineYAt(int i) const {
|
int PointDetailsWidget::lineYAt(int index) const {
|
||||||
|
auto linesHeight = 0.;
|
||||||
|
for (auto i = 0; i < index; i++) {
|
||||||
|
const auto alpha = (i >= _lines.size()) ? 1. : _lines[i].alpha;
|
||||||
|
linesHeight += alpha
|
||||||
|
* (_textStyle.font->height
|
||||||
|
+ st::statisticsDetailsPopupMidLineSpace);
|
||||||
|
}
|
||||||
|
|
||||||
return _textRect.y()
|
return _textRect.y()
|
||||||
+ _headerStyle.font->height
|
+ _headerStyle.font->height
|
||||||
+ st::statisticsDetailsPopupMargins.bottom()
|
+ st::statisticsDetailsPopupMargins.bottom()
|
||||||
+ (_textStyle.font->height * i)
|
+ std::ceil(linesHeight);
|
||||||
+ (st::statisticsDetailsPopupMidLineSpace * i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PointDetailsWidget::paintEvent(QPaintEvent *e) {
|
void PointDetailsWidget::paintEvent(QPaintEvent *e) {
|
||||||
|
@ -133,6 +156,7 @@ void PointDetailsWidget::paintEvent(QPaintEvent *e) {
|
||||||
.outerWidth = _textRect.width() - valueWidth,
|
.outerWidth = _textRect.width() - valueWidth,
|
||||||
.availableWidth = _textRect.width(),
|
.availableWidth = _textRect.width(),
|
||||||
};
|
};
|
||||||
|
p.setOpacity(line.alpha * line.alpha);
|
||||||
p.setPen(st::boxTextFg);
|
p.setPen(st::boxTextFg);
|
||||||
line.name.draw(p, nameContext);
|
line.name.draw(p, nameContext);
|
||||||
p.setPen(line.valueColor);
|
p.setPen(line.valueColor);
|
||||||
|
|
|
@ -22,6 +22,7 @@ public:
|
||||||
[[nodiscard]] int xIndex() const;
|
[[nodiscard]] int xIndex() const;
|
||||||
void setXIndex(int xIndex);
|
void setXIndex(int xIndex);
|
||||||
void setAlpha(float64 alpha);
|
void setAlpha(float64 alpha);
|
||||||
|
void setLineAlpha(int lineId, float64 alpha);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
@ -32,12 +33,16 @@ private:
|
||||||
const style::TextStyle &_headerStyle;
|
const style::TextStyle &_headerStyle;
|
||||||
Ui::Text::String _header;
|
Ui::Text::String _header;
|
||||||
|
|
||||||
[[nodiscard]] int lineYAt(int i) const;
|
[[nodiscard]] int lineYAt(int index) const;
|
||||||
|
|
||||||
|
void resizeHeight();
|
||||||
|
|
||||||
struct Line final {
|
struct Line final {
|
||||||
|
int id = 0;
|
||||||
Ui::Text::String name;
|
Ui::Text::String name;
|
||||||
Ui::Text::String value;
|
Ui::Text::String value;
|
||||||
QColor valueColor;
|
QColor valueColor;
|
||||||
|
float64 alpha = 1.;
|
||||||
};
|
};
|
||||||
|
|
||||||
QRect _innerRect;
|
QRect _innerRect;
|
||||||
|
|
Loading…
Add table
Reference in a new issue