Moved out chart header to separated files.
This commit is contained in:
parent
6ffe555f6a
commit
32cd454554
|
@ -1282,6 +1282,8 @@ PRIVATE
|
|||
settings/settings_type.h
|
||||
settings/settings_websites.cpp
|
||||
settings/settings_websites.h
|
||||
statistics/chart_header_widget.cpp
|
||||
statistics/chart_header_widget.h
|
||||
statistics/chart_horizontal_lines_data.cpp
|
||||
statistics/chart_horizontal_lines_data.h
|
||||
statistics/chart_widget.cpp
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "statistics/chart_header_widget.h"
|
||||
|
||||
#include "ui/painter.h"
|
||||
#include "styles/style_statistics.h"
|
||||
|
||||
namespace Statistic {
|
||||
|
||||
void Header::setTitle(QString title) {
|
||||
_titleWidth = st::statisticsHeaderTitleTextStyle.font->width(title);
|
||||
_title.setText(st::statisticsHeaderTitleTextStyle, std::move(title));
|
||||
}
|
||||
|
||||
void Header::setRightInfo(QString rightInfo) {
|
||||
_rightInfo.setText(
|
||||
st::statisticsHeaderDatesTextStyle,
|
||||
std::move(rightInfo));
|
||||
}
|
||||
|
||||
void Header::paintEvent(QPaintEvent *e) {
|
||||
auto p = Painter(this);
|
||||
|
||||
p.fillRect(rect(), st::boxBg);
|
||||
|
||||
p.setPen(st::boxTextFg);
|
||||
const auto top = (height()
|
||||
- st::statisticsHeaderTitleTextStyle.font->height) / 2;
|
||||
_title.drawLeftElided(p, 0, top, width(), width());
|
||||
_rightInfo.drawRightElided(
|
||||
p,
|
||||
0,
|
||||
top,
|
||||
width() - _titleWidth,
|
||||
width(),
|
||||
1,
|
||||
style::al_right);
|
||||
}
|
||||
|
||||
} // namespace Statistic
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "ui/rp_widget.h"
|
||||
|
||||
namespace Statistic {
|
||||
|
||||
class Header final : public Ui::RpWidget {
|
||||
public:
|
||||
using Ui::RpWidget::RpWidget;
|
||||
|
||||
void setTitle(QString title);
|
||||
void setRightInfo(QString rightInfo);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
private:
|
||||
Ui::Text::String _title;
|
||||
Ui::Text::String _rightInfo;
|
||||
int _titleWidth = 0;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Statistic
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/effects/show_animation.h"
|
||||
#include "base/qt/qt_key_modifiers.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "statistics/chart_header_widget.h"
|
||||
#include "statistics/chart_lines_filter_widget.h"
|
||||
#include "statistics/point_details_widget.h"
|
||||
#include "statistics/view/abstract_chart_view.h"
|
||||
|
@ -164,53 +165,6 @@ void RpMouseWidget::mouseReleaseEvent(QMouseEvent *e) {
|
|||
_mouseStateChanged.fire({ e->pos(), QEvent::MouseButtonRelease });
|
||||
}
|
||||
|
||||
class ChartWidget::Header final : public RpWidget {
|
||||
public:
|
||||
using RpWidget::RpWidget;
|
||||
|
||||
void setTitle(QString title);
|
||||
void setRightInfo(QString rightInfo);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
private:
|
||||
Ui::Text::String _title;
|
||||
Ui::Text::String _rightInfo;
|
||||
int _titleWidth = 0;
|
||||
|
||||
};
|
||||
|
||||
void ChartWidget::Header::setTitle(QString title) {
|
||||
_titleWidth = st::statisticsHeaderTitleTextStyle.font->width(title);
|
||||
_title.setText(st::statisticsHeaderTitleTextStyle, std::move(title));
|
||||
}
|
||||
|
||||
void ChartWidget::Header::setRightInfo(QString rightInfo) {
|
||||
_rightInfo.setText(
|
||||
st::statisticsHeaderDatesTextStyle,
|
||||
std::move(rightInfo));
|
||||
}
|
||||
|
||||
void ChartWidget::Header::paintEvent(QPaintEvent *e) {
|
||||
auto p = Painter(this);
|
||||
|
||||
p.fillRect(rect(), st::boxBg);
|
||||
|
||||
p.setPen(st::boxTextFg);
|
||||
const auto top = (height()
|
||||
- st::statisticsHeaderTitleTextStyle.font->height) / 2;
|
||||
_title.drawLeftElided(p, 0, top, width(), width());
|
||||
_rightInfo.drawRightElided(
|
||||
p,
|
||||
0,
|
||||
top,
|
||||
width() - _titleWidth,
|
||||
width(),
|
||||
1,
|
||||
style::al_right);
|
||||
}
|
||||
|
||||
class ChartWidget::Footer final : public RpMouseWidget {
|
||||
public:
|
||||
using PaintCallback = Fn<void(QPainter &, const QRect &)>;
|
||||
|
|
|
@ -20,6 +20,7 @@ class RpMouseWidget;
|
|||
class PointDetailsWidget;
|
||||
class ChartLinesFilterWidget;
|
||||
class AbstractChartView;
|
||||
class Header;
|
||||
|
||||
class ChartWidget : public Ui::RpWidget {
|
||||
public:
|
||||
|
@ -50,7 +51,6 @@ protected:
|
|||
int resizeGetHeight(int newWidth) override;
|
||||
|
||||
private:
|
||||
class Header;
|
||||
class Footer;
|
||||
|
||||
class ChartAnimationController final {
|
||||
|
|
Loading…
Reference in New Issue