mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 07:33:52 +02:00
Fixed incorrect position of sliders in chart footer in some cases.
This commit is contained in:
parent
2dc45ac907
commit
0dec803177
1 changed files with 24 additions and 22 deletions
|
@ -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);
|
||||||
|
|
Loading…
Add table
Reference in a new issue