Moved zoom out button to right side above chart.
This commit is contained in:
parent
10e3115c39
commit
c20bd17029
|
@ -12,6 +12,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Statistic {
|
namespace Statistic {
|
||||||
|
|
||||||
|
QString Header::title() const {
|
||||||
|
return _title.toString();
|
||||||
|
}
|
||||||
|
|
||||||
void Header::setTitle(QString title) {
|
void Header::setTitle(QString title) {
|
||||||
_title.setText(st::statisticsHeaderTitleTextStyle, std::move(title));
|
_title.setText(st::statisticsHeaderTitleTextStyle, std::move(title));
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ class Header final : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
using Ui::RpWidget::RpWidget;
|
using Ui::RpWidget::RpWidget;
|
||||||
|
|
||||||
|
[[nodiscard]] QString title() const;
|
||||||
void setTitle(QString title);
|
void setTitle(QString title);
|
||||||
void setRightInfo(QString rightInfo);
|
void setRightInfo(QString rightInfo);
|
||||||
|
|
||||||
|
|
|
@ -1260,6 +1260,7 @@ void ChartWidget::processLocalZoom(int xIndex) {
|
||||||
) | rpl::start_with_next([=](const QRect &g) {
|
) | rpl::start_with_next([=](const QRect &g) {
|
||||||
header->setGeometry(g);
|
header->setGeometry(g);
|
||||||
}, header->lifetime());
|
}, header->lifetime());
|
||||||
|
header->setTitle(_header->title());
|
||||||
header->setRightInfo(_chartData.getDayString(xIndex));
|
header->setRightInfo(_chartData.getDayString(xIndex));
|
||||||
|
|
||||||
const auto enableMouse = [=](bool value) {
|
const auto enableMouse = [=](bool value) {
|
||||||
|
@ -1291,6 +1292,9 @@ void ChartWidget::processLocalZoom(int xIndex) {
|
||||||
header,
|
header,
|
||||||
tr::lng_stats_zoom_out(),
|
tr::lng_stats_zoom_out(),
|
||||||
st::statisticsHeaderButton);
|
st::statisticsHeaderButton);
|
||||||
|
zoomOutButton->moveToRight(
|
||||||
|
0,
|
||||||
|
(st::statisticsChartHeaderHeight - zoomOutButton->height()) / 2);
|
||||||
zoomOutButton->show();
|
zoomOutButton->show();
|
||||||
zoomOutButton->setTextTransform(
|
zoomOutButton->setTextTransform(
|
||||||
Ui::RoundButton::TextTransform::NoTransform);
|
Ui::RoundButton::TextTransform::NoTransform);
|
||||||
|
@ -1324,8 +1328,6 @@ void ChartWidget::processLocalZoom(int xIndex) {
|
||||||
|
|
||||||
Ui::Animations::ShowWidgets({ header });
|
Ui::Animations::ShowWidgets({ header });
|
||||||
|
|
||||||
zoomOutButton->moveToLeft(0, 0);
|
|
||||||
|
|
||||||
const auto finish = [=](const Limits &zoomLimitIndices) {
|
const auto finish = [=](const Limits &zoomLimitIndices) {
|
||||||
createMouseTracking();
|
createMouseTracking();
|
||||||
_footer->xPercentageLimitsChange(
|
_footer->xPercentageLimitsChange(
|
||||||
|
@ -1460,11 +1462,17 @@ void ChartWidget::setZoomedChartData(
|
||||||
|
|
||||||
const auto customHeader = Ui::CreateChild<Header>(
|
const auto customHeader = Ui::CreateChild<Header>(
|
||||||
_zoomedChartWidget.get());
|
_zoomedChartWidget.get());
|
||||||
const auto xIndex = std::distance(
|
{
|
||||||
begin(_chartData.x),
|
const auto xIndex = std::distance(
|
||||||
ranges::find(_chartData.x, x));
|
begin(_chartData.x),
|
||||||
if ((xIndex >= 0) && (xIndex < _chartData.x.size())) {
|
ranges::find(_chartData.x, x));
|
||||||
customHeader->setRightInfo(_chartData.getDayString(xIndex));
|
customHeader->setTitle(_header->title());
|
||||||
|
if ((xIndex >= 0) && (xIndex < _chartData.x.size())) {
|
||||||
|
customHeader->setRightInfo(_chartData.getDayString(xIndex));
|
||||||
|
}
|
||||||
|
const auto &headerPadding = st::statisticsChartHeaderPadding;
|
||||||
|
customHeader->moveToLeft(headerPadding.left(), headerPadding.top());
|
||||||
|
customHeader->resizeToWidth(width() - rect::m::sum::h(headerPadding));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto zoomOutButton = Ui::CreateChild<Ui::RoundButton>(
|
const auto zoomOutButton = Ui::CreateChild<Ui::RoundButton>(
|
||||||
|
@ -1473,6 +1481,9 @@ void ChartWidget::setZoomedChartData(
|
||||||
st::statisticsHeaderButton);
|
st::statisticsHeaderButton);
|
||||||
zoomOutButton->setTextTransform(
|
zoomOutButton->setTextTransform(
|
||||||
Ui::RoundButton::TextTransform::NoTransform);
|
Ui::RoundButton::TextTransform::NoTransform);
|
||||||
|
zoomOutButton->moveToRight(
|
||||||
|
0,
|
||||||
|
(st::statisticsChartHeaderHeight - zoomOutButton->height()) / 2);
|
||||||
zoomOutButton->setClickedCallback([=] {
|
zoomOutButton->setClickedCallback([=] {
|
||||||
shownValue(
|
shownValue(
|
||||||
) | rpl::start_with_next([=](bool shown) {
|
) | rpl::start_with_next([=](bool shown) {
|
||||||
|
@ -1486,13 +1497,6 @@ void ChartWidget::setZoomedChartData(
|
||||||
|
|
||||||
Ui::Animations::ShowWidgets({ _zoomedChartWidget.get(), customHeader });
|
Ui::Animations::ShowWidgets({ _zoomedChartWidget.get(), customHeader });
|
||||||
Ui::Animations::HideWidgets({ this });
|
Ui::Animations::HideWidgets({ this });
|
||||||
|
|
||||||
{
|
|
||||||
const auto &headerPadding = st::statisticsChartHeaderPadding;
|
|
||||||
customHeader->moveToLeft(headerPadding.left(), headerPadding.top());
|
|
||||||
customHeader->resizeToWidth(width() - rect::m::sum::h(headerPadding));
|
|
||||||
}
|
|
||||||
zoomOutButton->moveToLeft(0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<float64> ChartWidget::zoomRequests() {
|
rpl::producer<float64> ChartWidget::zoomRequests() {
|
||||||
|
|
|
@ -68,7 +68,7 @@ statisticsHeaderDatesTextStyle: TextStyle(defaultTextStyle) {
|
||||||
}
|
}
|
||||||
statisticsHeaderButton: RoundButton(defaultLightButton) {
|
statisticsHeaderButton: RoundButton(defaultLightButton) {
|
||||||
width: -14px;
|
width: -14px;
|
||||||
height: statisticsChartHeaderHeight;
|
height: 20px;
|
||||||
textTop: 2px;
|
textTop: 2px;
|
||||||
font: font(11px semibold);
|
font: font(11px semibold);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue