mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improved header style for charts.
This commit is contained in:
parent
77d23ad182
commit
2b282c8d7d
5 changed files with 36 additions and 27 deletions
|
@ -266,7 +266,7 @@ void FillOverview(
|
||||||
const auto header = content->add(
|
const auto header = content->add(
|
||||||
object_ptr<Statistic::Header>(content),
|
object_ptr<Statistic::Header>(content),
|
||||||
st::statisticsLayerMargins);
|
st::statisticsLayerMargins);
|
||||||
header->resize(header->width(), st::statisticsChartHeaderHeight);
|
header->resizeToWidth(header->width());
|
||||||
header->setTitle(tr::lng_stats_overview_title(tr::now));
|
header->setTitle(tr::lng_stats_overview_title(tr::now));
|
||||||
const auto formatter = u"MMM d"_q;
|
const auto formatter = u"MMM d"_q;
|
||||||
const auto from = QDateTime::fromSecsSinceEpoch(startDate);
|
const auto from = QDateTime::fromSecsSinceEpoch(startDate);
|
||||||
|
|
|
@ -13,10 +13,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Statistic {
|
namespace Statistic {
|
||||||
|
|
||||||
void Header::setTitle(QString title) {
|
void Header::setTitle(QString title) {
|
||||||
_titleWidth = st::statisticsHeaderTitleTextStyle.font->width(title);
|
|
||||||
_title.setText(st::statisticsHeaderTitleTextStyle, std::move(title));
|
_title.setText(st::statisticsHeaderTitleTextStyle, std::move(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Header::resizeGetHeight(int newWidth) {
|
||||||
|
return st::statisticsChartHeaderHeight;
|
||||||
|
}
|
||||||
|
|
||||||
void Header::setRightInfo(QString rightInfo) {
|
void Header::setRightInfo(QString rightInfo) {
|
||||||
_rightInfo.setText(
|
_rightInfo.setText(
|
||||||
st::statisticsHeaderDatesTextStyle,
|
st::statisticsHeaderDatesTextStyle,
|
||||||
|
@ -29,17 +32,15 @@ void Header::paintEvent(QPaintEvent *e) {
|
||||||
p.fillRect(rect(), st::boxBg);
|
p.fillRect(rect(), st::boxBg);
|
||||||
|
|
||||||
p.setPen(st::boxTextFg);
|
p.setPen(st::boxTextFg);
|
||||||
const auto top = (height()
|
_title.drawLeftElided(p, 0, 0, width(), width());
|
||||||
- st::statisticsHeaderTitleTextStyle.font->height) / 2;
|
|
||||||
_title.drawLeftElided(p, 0, top, width(), width());
|
p.setPen(st::windowSubTextFg);
|
||||||
_rightInfo.drawRightElided(
|
_rightInfo.drawLeftElided(p, 0, _infoTop, width(), width());
|
||||||
p,
|
}
|
||||||
0,
|
|
||||||
top,
|
void Header::resizeEvent(QResizeEvent *e) {
|
||||||
width() - _titleWidth,
|
_infoTop = e->size().height()
|
||||||
width(),
|
- st::statisticsHeaderDatesTextStyle.font->height;
|
||||||
1,
|
|
||||||
style::al_right);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Statistic
|
} // namespace Statistic
|
||||||
|
|
|
@ -20,11 +20,14 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
|
|
||||||
|
int resizeGetHeight(int newWidth) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Text::String _title;
|
Ui::Text::String _title;
|
||||||
Ui::Text::String _rightInfo;
|
Ui::Text::String _rightInfo;
|
||||||
int _titleWidth = 0;
|
int _infoTop = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -861,18 +861,20 @@ int ChartWidget::resizeGetHeight(int newWidth) {
|
||||||
? (_filterButtons->height()
|
? (_filterButtons->height()
|
||||||
+ st::statisticsFilterButtonsPadding.bottom())
|
+ st::statisticsFilterButtonsPadding.bottom())
|
||||||
: 0;
|
: 0;
|
||||||
const auto resultHeight = st::statisticsChartHeaderHeight
|
const auto &headerPadding = st::statisticsChartHeaderPadding;
|
||||||
|
{
|
||||||
|
_header->moveToLeft(headerPadding.left(), headerPadding.top());
|
||||||
|
_header->resizeToWidth(newWidth - rect::m::sum::h(headerPadding));
|
||||||
|
}
|
||||||
|
const auto headerHeight = rect::m::sum::v(headerPadding)
|
||||||
|
+ _header->height();
|
||||||
|
const auto resultHeight = headerHeight
|
||||||
+ st::statisticsChartHeight
|
+ st::statisticsChartHeight
|
||||||
+ st::statisticsChartFooterHeight
|
+ st::statisticsChartFooterHeight
|
||||||
+ st::statisticsChartFooterSkip
|
+ st::statisticsChartFooterSkip
|
||||||
+ filtersTopSkip
|
+ filtersTopSkip
|
||||||
+ filtersHeight;
|
+ filtersHeight;
|
||||||
{
|
{
|
||||||
_header->setGeometry(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
newWidth,
|
|
||||||
st::statisticsChartHeaderHeight);
|
|
||||||
_footer->setGeometry(
|
_footer->setGeometry(
|
||||||
0,
|
0,
|
||||||
resultHeight
|
resultHeight
|
||||||
|
@ -886,9 +888,10 @@ int ChartWidget::resizeGetHeight(int newWidth) {
|
||||||
}
|
}
|
||||||
_chartArea->setGeometry(
|
_chartArea->setGeometry(
|
||||||
0,
|
0,
|
||||||
st::statisticsChartHeaderHeight,
|
headerHeight,
|
||||||
newWidth,
|
newWidth,
|
||||||
resultHeight
|
resultHeight
|
||||||
|
- headerHeight
|
||||||
- st::statisticsChartFooterHeight
|
- st::statisticsChartFooterHeight
|
||||||
- filtersTopSkip
|
- filtersTopSkip
|
||||||
- filtersHeight
|
- filtersHeight
|
||||||
|
@ -1490,7 +1493,8 @@ void ChartWidget::setZoomedChartData(
|
||||||
Ui::Animations::ShowWidgets({ _zoomedChartWidget.get(), customHeader });
|
Ui::Animations::ShowWidgets({ _zoomedChartWidget.get(), customHeader });
|
||||||
Ui::Animations::HideWidgets({ this });
|
Ui::Animations::HideWidgets({ this });
|
||||||
|
|
||||||
customHeader->setGeometry(0, 0, width(), st::statisticsChartHeaderHeight);
|
customHeader->moveToLeft(0, 0);
|
||||||
|
customHeader->resizeToWidth(width());
|
||||||
zoomOutButton->moveToLeft(0, 0);
|
zoomOutButton->moveToLeft(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ statisticsLayerMargins: margins(20px, 0px, 20px, 0px);
|
||||||
|
|
||||||
statisticsChartHeight: 150px;
|
statisticsChartHeight: 150px;
|
||||||
|
|
||||||
statisticsChartEntryPadding: margins(0px, 8px, 0px, 8px);
|
statisticsChartEntryPadding: margins(0px, 13px, 0px, 8px);
|
||||||
|
|
||||||
statisticsDetailsArrowShift: 2px;
|
statisticsDetailsArrowShift: 2px;
|
||||||
statisticsDetailsArrowStroke: 1.5;
|
statisticsDetailsArrowStroke: 1.5;
|
||||||
|
@ -30,7 +30,7 @@ statisticsChartFooterArrowSize: size(10px, 30px);
|
||||||
|
|
||||||
statisticsChartHorizontalLineCaptionSkip: 4px;
|
statisticsChartHorizontalLineCaptionSkip: 4px;
|
||||||
|
|
||||||
statisticsChartBottomCaptionHeight: 30px;
|
statisticsChartBottomCaptionHeight: 14px;
|
||||||
statisticsChartBottomCaptionSkip: 15px;
|
statisticsChartBottomCaptionSkip: 15px;
|
||||||
|
|
||||||
statisticsChartBottomCaptionMaxWidth: 44px;
|
statisticsChartBottomCaptionMaxWidth: 44px;
|
||||||
|
@ -56,12 +56,13 @@ statisticsDetailsBottomCaptionStyle: TextStyle(defaultTextStyle) {
|
||||||
statisticsPieChartFont: font(20px);
|
statisticsPieChartFont: font(20px);
|
||||||
statisticsPieChartPartOffset: 8px;
|
statisticsPieChartPartOffset: 8px;
|
||||||
|
|
||||||
statisticsChartHeaderHeight: 20px;
|
statisticsChartHeaderHeight: 36px;
|
||||||
|
statisticsChartHeaderPadding: margins(2px, 0px, 0px, 10px);
|
||||||
statisticsHeaderTitleTextStyle: TextStyle(defaultTextStyle) {
|
statisticsHeaderTitleTextStyle: TextStyle(defaultTextStyle) {
|
||||||
font: font(12px semibold);
|
font: font(13px);
|
||||||
}
|
}
|
||||||
statisticsHeaderDatesTextStyle: TextStyle(defaultTextStyle) {
|
statisticsHeaderDatesTextStyle: TextStyle(defaultTextStyle) {
|
||||||
font: font(11px semibold);
|
font: font(11px);
|
||||||
}
|
}
|
||||||
statisticsHeaderButton: RoundButton(defaultLightButton) {
|
statisticsHeaderButton: RoundButton(defaultLightButton) {
|
||||||
width: -14px;
|
width: -14px;
|
||||||
|
|
Loading…
Add table
Reference in a new issue