Fixed incorrect position of sliders in chart footer in some cases.

This commit is contained in:
23rd 2023-10-11 05:45:57 +03:00 committed by John Preston
parent 2dc45ac907
commit 0dec803177

View file

@ -232,6 +232,8 @@ public:
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
int resizeGetHeight(int newWidth) override;
private: private:
void moveSide(bool left, float64 x); void moveSide(bool left, float64 x);
void moveCenter( void moveCenter(
@ -276,24 +278,6 @@ ChartWidget::Footer::Footer(not_null<Ui::RpWidget*> parent)
st::statisticsChartLineWidth, st::statisticsChartLineWidth,
Qt::SolidLine, Qt::SolidLine,
Qt::RoundCap) { Qt::RoundCap) {
sizeValue(
) | rpl::start_with_next([=](const QSize &s) {
if (s.isNull()) {
return;
}
const auto was = xPercentageLimits();
const auto w = float64(st::statisticsChartFooterSideWidth);
_width = s.width() - w;
_widthBetweenSides = s.width() - w * 2.;
_mask = Ui::RippleAnimation::RoundRectMask(
s - QSize(0, st::lineWidth * 2),
st::boxRadius);
_frame = _mask;
if (_widthBetweenSides && was.max) {
setXPercentageLimits(was);
}
}, lifetime());
sizeValue( sizeValue(
) | rpl::take(2) | rpl::start_with_next([=](const QSize &s) { ) | rpl::take(2) | rpl::start_with_next([=](const QSize &s) {
moveSide(false, s.width()); moveSide(false, s.width());
@ -378,6 +362,25 @@ ChartWidget::Footer::Footer(not_null<Ui::RpWidget*> parent)
}, lifetime()); }, lifetime());
} }
int ChartWidget::Footer::resizeGetHeight(int newWidth) {
const auto h = st::statisticsChartFooterHeight;
if (!newWidth) {
return h;
}
const auto was = xPercentageLimits();
const auto w = float64(st::statisticsChartFooterSideWidth);
_width = newWidth - w;
_widthBetweenSides = newWidth - w * 2.;
_mask = Ui::RippleAnimation::RoundRectMask(
QSize(newWidth, h - st::lineWidth * 2),
st::boxRadius);
_frame = _mask;
if (_widthBetweenSides && was.max) {
setXPercentageLimits(was);
}
return h;
}
Limits ChartWidget::Footer::xPercentageLimits() const { Limits ChartWidget::Footer::xPercentageLimits() const {
return { return {
.min = _widthBetweenSides ? _leftSide.min / _widthBetweenSides : 0., .min = _widthBetweenSides ? _leftSide.min / _widthBetweenSides : 0.,
@ -867,14 +870,13 @@ int ChartWidget::resizeGetHeight(int newWidth) {
+ filtersHeight; + filtersHeight;
{ {
if (footerArea) { if (footerArea) {
_footer->setGeometry( _footer->resizeToWidth(newWidth);
_footer->moveToLeft(
0, 0,
resultHeight resultHeight
- st::statisticsChartFooterHeight - st::statisticsChartFooterHeight
- filtersTopSkip - filtersTopSkip
- filtersHeight, - filtersHeight);
newWidth,
st::statisticsChartFooterHeight);
} }
if (_filterButtons) { if (_filterButtons) {
_filterButtons->moveToLeft(0, resultHeight - filtersHeight); _filterButtons->moveToLeft(0, resultHeight - filtersHeight);