mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Replaced bad sizeValue with intended resizeGetHeight in chart widget.
This commit is contained in:
parent
fcc6aaed91
commit
7b921dea3b
2 changed files with 41 additions and 53 deletions
|
@ -829,53 +829,58 @@ ChartWidget::ChartWidget(not_null<Ui::RpWidget*> parent)
|
||||||
_footer->update();
|
_footer->update();
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
sizeValue(
|
setupChartArea();
|
||||||
) | rpl::filter([](const QSize &s) {
|
setupFooter();
|
||||||
return !s.isNull();
|
}
|
||||||
}) | rpl::start_with_next([=](const QSize &s) {
|
|
||||||
const auto filtersHeight = _filterButtons
|
int ChartWidget::resizeGetHeight(int newWidth) {
|
||||||
? _filterButtons->height()
|
if (_filterButtons) {
|
||||||
: 0;
|
auto texts = std::vector<QString>();
|
||||||
|
auto colors = std::vector<QColor>();
|
||||||
|
auto ids = std::vector<int>();
|
||||||
|
texts.reserve(_chartData.lines.size());
|
||||||
|
colors.reserve(_chartData.lines.size());
|
||||||
|
ids.reserve(_chartData.lines.size());
|
||||||
|
for (const auto &line : _chartData.lines) {
|
||||||
|
texts.push_back(line.name);
|
||||||
|
colors.push_back(line.color);
|
||||||
|
ids.push_back(line.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
_filterButtons->fillButtons(texts, colors, ids, newWidth);
|
||||||
|
}
|
||||||
|
const auto filtersHeight = _filterButtons
|
||||||
|
? _filterButtons->height()
|
||||||
|
: 0;
|
||||||
|
const auto resultHeight = st::statisticsChartHeight
|
||||||
|
+ st::statisticsChartFooterHeight
|
||||||
|
+ st::statisticsChartFooterSkip
|
||||||
|
+ filtersHeight;
|
||||||
|
{
|
||||||
_footer->setGeometry(
|
_footer->setGeometry(
|
||||||
0,
|
0,
|
||||||
s.height() - st::statisticsChartFooterHeight - filtersHeight,
|
resultHeight - st::statisticsChartFooterHeight - filtersHeight,
|
||||||
s.width(),
|
newWidth,
|
||||||
st::statisticsChartFooterHeight);
|
st::statisticsChartFooterHeight);
|
||||||
if (_filterButtons) {
|
if (_filterButtons) {
|
||||||
_filterButtons->setGeometry(
|
_filterButtons->show();
|
||||||
0,
|
_filterButtons->moveToLeft(0, resultHeight - filtersHeight);
|
||||||
s.height() - filtersHeight,
|
|
||||||
s.width(),
|
|
||||||
filtersHeight);
|
|
||||||
}
|
}
|
||||||
_chartArea->setGeometry(
|
_chartArea->setGeometry(
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
s.width(),
|
newWidth,
|
||||||
s.height()
|
resultHeight
|
||||||
- st::statisticsChartFooterHeight
|
- st::statisticsChartFooterHeight
|
||||||
- filtersHeight
|
- filtersHeight
|
||||||
- st::statisticsChartFooterSkip);
|
- st::statisticsChartFooterSkip);
|
||||||
|
|
||||||
{
|
{
|
||||||
updateChartFullWidth(s.width());
|
updateChartFullWidth(newWidth);
|
||||||
updateBottomDates();
|
updateBottomDates();
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}
|
||||||
|
return resultHeight;
|
||||||
setupChartArea();
|
|
||||||
setupFooter();
|
|
||||||
|
|
||||||
resizeHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChartWidget::resizeHeight() {
|
|
||||||
resize(
|
|
||||||
width(),
|
|
||||||
st::statisticsChartHeight
|
|
||||||
+ st::statisticsChartFooterHeight
|
|
||||||
+ st::statisticsChartFooterSkip
|
|
||||||
+ (_filterButtons ? _filterButtons->height() : 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChartWidget::updateChartFullWidth(int w) {
|
void ChartWidget::updateChartFullWidth(int w) {
|
||||||
|
@ -1192,26 +1197,7 @@ void ChartWidget::setupFilterButtons() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_filterButtons = base::make_unique_q<ChartLinesFilterWidget>(this);
|
_filterButtons = base::make_unique_q<ChartLinesFilterWidget>(this);
|
||||||
|
_filterButtons->show();
|
||||||
sizeValue(
|
|
||||||
) | rpl::filter([](const QSize &s) {
|
|
||||||
return s.width() > 0;
|
|
||||||
}) | rpl::take(2) | rpl::start_with_next([=](const QSize &s) {
|
|
||||||
auto texts = std::vector<QString>();
|
|
||||||
auto colors = std::vector<QColor>();
|
|
||||||
auto ids = std::vector<int>();
|
|
||||||
texts.reserve(_chartData.lines.size());
|
|
||||||
colors.reserve(_chartData.lines.size());
|
|
||||||
ids.reserve(_chartData.lines.size());
|
|
||||||
for (const auto &line : _chartData.lines) {
|
|
||||||
texts.push_back(line.name);
|
|
||||||
colors.push_back(line.color);
|
|
||||||
ids.push_back(line.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
_filterButtons->fillButtons(texts, colors, ids, s.width());
|
|
||||||
resizeHeight();
|
|
||||||
}, _filterButtons->lifetime());
|
|
||||||
|
|
||||||
_filterButtons->buttonEnabledChanges(
|
_filterButtons->buttonEnabledChanges(
|
||||||
) | rpl::start_with_next([=](const ChartLinesFilterWidget::Entry &e) {
|
) | rpl::start_with_next([=](const ChartLinesFilterWidget::Entry &e) {
|
||||||
|
|
|
@ -39,6 +39,9 @@ public:
|
||||||
float64 fixedAlpha = 0.;
|
float64 fixedAlpha = 0.;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int resizeGetHeight(int newWidth) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Footer;
|
class Footer;
|
||||||
|
|
||||||
|
@ -123,7 +126,6 @@ private:
|
||||||
|
|
||||||
void updateBottomDates();
|
void updateBottomDates();
|
||||||
|
|
||||||
void resizeHeight();
|
|
||||||
void updateChartFullWidth(int w);
|
void updateChartFullWidth(int w);
|
||||||
|
|
||||||
const base::unique_qptr<RpMouseWidget> _chartArea;
|
const base::unique_qptr<RpMouseWidget> _chartArea;
|
||||||
|
|
Loading…
Add table
Reference in a new issue