mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Added ability to hide footer of chart on demand from backend.
This commit is contained in:
parent
2479b56c3b
commit
3b5a007db5
3 changed files with 46 additions and 21 deletions
|
@ -61,6 +61,8 @@ struct StatisticalChart {
|
||||||
|
|
||||||
float64 timeStep = 0.;
|
float64 timeStep = 0.;
|
||||||
|
|
||||||
|
bool isFooterHidden = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StatisticalGraph final {
|
struct StatisticalGraph final {
|
||||||
|
|
|
@ -836,6 +836,8 @@ ChartWidget::ChartWidget(not_null<Ui::RpWidget*> parent)
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
setupChartArea();
|
setupChartArea();
|
||||||
|
// We have to create the footer,
|
||||||
|
// even if it has to be hidden, otherwise it breaks some things.
|
||||||
setupFooter();
|
setupFooter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,36 +867,39 @@ int ChartWidget::resizeGetHeight(int newWidth) {
|
||||||
_header->moveToLeft(headerPadding.left(), headerPadding.top());
|
_header->moveToLeft(headerPadding.left(), headerPadding.top());
|
||||||
_header->resizeToWidth(newWidth - rect::m::sum::h(headerPadding));
|
_header->resizeToWidth(newWidth - rect::m::sum::h(headerPadding));
|
||||||
}
|
}
|
||||||
const auto headerHeight = rect::m::sum::v(headerPadding)
|
const auto headerArea = rect::m::sum::v(headerPadding)
|
||||||
+ _header->height();
|
+ _header->height();
|
||||||
const auto resultHeight = headerHeight
|
const auto footerArea = (!_footer->isHidden())
|
||||||
|
? (st::statisticsChartFooterHeight + st::statisticsChartFooterSkip)
|
||||||
|
: 0;
|
||||||
|
const auto resultHeight = headerArea
|
||||||
+ st::statisticsChartHeight
|
+ st::statisticsChartHeight
|
||||||
+ st::statisticsChartFooterHeight
|
+ footerArea
|
||||||
+ st::statisticsChartFooterSkip
|
|
||||||
+ filtersTopSkip
|
+ filtersTopSkip
|
||||||
+ filtersHeight;
|
+ filtersHeight;
|
||||||
{
|
{
|
||||||
_footer->setGeometry(
|
if (footerArea) {
|
||||||
0,
|
_footer->setGeometry(
|
||||||
resultHeight
|
0,
|
||||||
- st::statisticsChartFooterHeight
|
resultHeight
|
||||||
- filtersTopSkip
|
- st::statisticsChartFooterHeight
|
||||||
- filtersHeight,
|
- filtersTopSkip
|
||||||
newWidth,
|
- filtersHeight,
|
||||||
st::statisticsChartFooterHeight);
|
newWidth,
|
||||||
|
st::statisticsChartFooterHeight);
|
||||||
|
}
|
||||||
if (_filterButtons) {
|
if (_filterButtons) {
|
||||||
_filterButtons->moveToLeft(0, resultHeight - filtersHeight);
|
_filterButtons->moveToLeft(0, resultHeight - filtersHeight);
|
||||||
}
|
}
|
||||||
_chartArea->setGeometry(
|
_chartArea->setGeometry(
|
||||||
0,
|
0,
|
||||||
headerHeight,
|
headerArea,
|
||||||
newWidth,
|
newWidth,
|
||||||
resultHeight
|
resultHeight
|
||||||
- headerHeight
|
- headerArea
|
||||||
- st::statisticsChartFooterHeight
|
- footerArea
|
||||||
- filtersTopSkip
|
- filtersTopSkip
|
||||||
- filtersHeight
|
- filtersHeight);
|
||||||
- st::statisticsChartFooterSkip);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
updateChartFullWidth(newWidth);
|
updateChartFullWidth(newWidth);
|
||||||
|
@ -906,7 +911,9 @@ int ChartWidget::resizeGetHeight(int newWidth) {
|
||||||
|
|
||||||
void ChartWidget::updateChartFullWidth(int w) {
|
void ChartWidget::updateChartFullWidth(int w) {
|
||||||
const auto finalXLimits = _animationController.finalXLimits();
|
const auto finalXLimits = _animationController.finalXLimits();
|
||||||
_bottomLine.chartFullWidth = w / (finalXLimits.max - finalXLimits.min);
|
_bottomLine.chartFullWidth = (finalXLimits.max == finalXLimits.min)
|
||||||
|
? 0
|
||||||
|
: (w / (finalXLimits.max - finalXLimits.min));
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect ChartWidget::chartAreaRect() const {
|
QRect ChartWidget::chartAreaRect() const {
|
||||||
|
@ -1266,6 +1273,9 @@ bool ChartWidget::hasLocalZoom() const {
|
||||||
void ChartWidget::processLocalZoom(int xIndex) {
|
void ChartWidget::processLocalZoom(int xIndex) {
|
||||||
using Type = AbstractChartView::LocalZoomArgs::Type;
|
using Type = AbstractChartView::LocalZoomArgs::Type;
|
||||||
constexpr auto kFooterZoomDuration = crl::time(400);
|
constexpr auto kFooterZoomDuration = crl::time(400);
|
||||||
|
if (_footer->isHidden()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto wasZoom = _footer->xPercentageLimits();
|
const auto wasZoom = _footer->xPercentageLimits();
|
||||||
|
|
||||||
const auto header = Ui::CreateChild<Header>(this);
|
const auto header = Ui::CreateChild<Header>(this);
|
||||||
|
@ -1390,6 +1400,7 @@ void ChartWidget::setupFilterButtons() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_filterButtons = base::make_unique_q<ChartLinesFilterWidget>(this);
|
_filterButtons = base::make_unique_q<ChartLinesFilterWidget>(this);
|
||||||
|
_filterButtons->show();
|
||||||
|
|
||||||
_filterButtons->buttonEnabledChanges(
|
_filterButtons->buttonEnabledChanges(
|
||||||
) | rpl::start_with_next([=](const ChartLinesFilterWidget::Entry &e) {
|
) | rpl::start_with_next([=](const ChartLinesFilterWidget::Entry &e) {
|
||||||
|
@ -1418,6 +1429,10 @@ void ChartWidget::setChartData(
|
||||||
}, _waitingSizeLifetime);
|
}, _waitingSizeLifetime);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (_chartData) {
|
||||||
|
// We don't really support a replacement of chart data in runtime.
|
||||||
|
return;
|
||||||
|
}
|
||||||
_chartData = std::move(chartData);
|
_chartData = std::move(chartData);
|
||||||
FillLineColorsByKey(_chartData);
|
FillLineColorsByKey(_chartData);
|
||||||
|
|
||||||
|
@ -1425,6 +1440,10 @@ void ChartWidget::setChartData(
|
||||||
_chartView->setLinesFilterController(_linesFilterController);
|
_chartView->setLinesFilterController(_linesFilterController);
|
||||||
_rulersView.setChartData(_chartData, type, _linesFilterController);
|
_rulersView.setChartData(_chartData, type, _linesFilterController);
|
||||||
|
|
||||||
|
if (_chartData.isFooterHidden) {
|
||||||
|
_footer->hide();
|
||||||
|
}
|
||||||
|
|
||||||
setupDetails();
|
setupDetails();
|
||||||
setupFilterButtons();
|
setupFilterButtons();
|
||||||
|
|
||||||
|
@ -1439,15 +1458,13 @@ void ChartWidget::setChartData(
|
||||||
_chartView,
|
_chartView,
|
||||||
_linesFilterController,
|
_linesFilterController,
|
||||||
0);
|
0);
|
||||||
updateChartFullWidth(_chartArea->width());
|
|
||||||
updateHeader();
|
updateHeader();
|
||||||
updateBottomDates();
|
|
||||||
_animationController.finish();
|
_animationController.finish();
|
||||||
_rulersView.add(_animationController.finalHeightLimits(), false);
|
_rulersView.add(_animationController.finalHeightLimits(), false);
|
||||||
|
|
||||||
RpWidget::showChildren();
|
|
||||||
_chartArea->update();
|
_chartArea->update();
|
||||||
_footer->update();
|
_footer->update();
|
||||||
|
|
||||||
RpWidget::resizeToWidth(width());
|
RpWidget::resizeToWidth(width());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,12 @@ Data::StatisticalChart StatisticalChartFromJSON(const QByteArray &json) {
|
||||||
|
|
||||||
{
|
{
|
||||||
const auto subchart = root.value(u"subchart"_q).toObject();
|
const auto subchart = root.value(u"subchart"_q).toObject();
|
||||||
|
const auto subchartShowIt = subchart.constFind(u"show"_q);
|
||||||
|
if (subchartShowIt != subchart.constEnd()) {
|
||||||
|
if (subchartShowIt->isBool()) {
|
||||||
|
result.isFooterHidden = !(subchartShowIt->toBool());
|
||||||
|
}
|
||||||
|
}
|
||||||
const auto defaultZoomIt = subchart.constFind(u"defaultZoom"_q);
|
const auto defaultZoomIt = subchart.constFind(u"defaultZoom"_q);
|
||||||
auto min = int(0);
|
auto min = int(0);
|
||||||
auto max = int(result.x.size() - 1);
|
auto max = int(result.x.size() - 1);
|
||||||
|
|
Loading…
Add table
Reference in a new issue