Repository navigation
Expand file tree
/
Copy pathemoji_picker_overlay.h
More file actions
112 lines (93 loc) · 3.05 KB
/
Copy pathemoji_picker_overlay.h
File metadata and controls
112 lines (93 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
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"
#include "ui/effects/animations.h"
#include "ui/emoji_config.h"
#include "ui/widgets/shadow.h"
namespace Ui {
class AbstractButton;
class FlatLabel;
class ScrollArea;
class SearchWithGroups;
} // namespace Ui
namespace ChatHelpers {
struct EmojiPickerOverlayDescriptor {
QString aboutText;
std::vector<EmojiPtr> recent;
int maxSelected = 0;
bool allowExpand = true;
std::vector<EmojiPtr> initialSelected;
};
class EmojiPickerOverlay final : public Ui::RpWidget {
public:
EmojiPickerOverlay(
QWidget *parent,
EmojiPickerOverlayDescriptor descriptor);
~EmojiPickerOverlay();
struct Metrics {
QMargins shadowExtent;
int tailHeight = 0;
int collapsedHeight = 0;
int expandedHeight = 0;
int totalCollapsedHeight = 0;
int totalExpandedHeight = 0;
};
[[nodiscard]] static Metrics EstimateMetrics(const QString &aboutText);
[[nodiscard]] const std::vector<EmojiPtr> &selected() const;
[[nodiscard]] rpl::producer<std::vector<EmojiPtr>> selectedValue() const;
void setExpanded(bool expanded);
[[nodiscard]] bool expanded() const;
[[nodiscard]] rpl::producer<bool> expandedValue() const;
[[nodiscard]] int collapsedHeight() const;
[[nodiscard]] int expandedHeight() const;
[[nodiscard]] QMargins shadowExtent() const;
[[nodiscard]] int totalCollapsedHeight() const;
[[nodiscard]] int totalExpandedHeight() const;
protected:
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
private:
class Strip;
class Grid;
void relayout();
void toggleEmoji(EmojiPtr emoji, bool fromGrid);
void notifySelectionChanged();
void setupSearch();
void applySearchQuery(std::vector<QString> query);
void refreshGridEmojis();
void startExpandAnimation(bool expanded);
void applyExpandProgress();
void paintTailBubble(QPainter &p, const QRect &bubble, float64 opacity);
[[nodiscard]] float64 currentExpandValue() const;
[[nodiscard]] int currentShownHeight() const;
[[nodiscard]] int tailHeight() const;
[[nodiscard]] QRect bubbleRect() const;
[[nodiscard]] QRect bubbleShownRect() const;
const QString _aboutText;
const std::vector<EmojiPtr> _recent;
const int _maxSelected;
const bool _allowExpand;
std::vector<EmojiPtr> _allForGrid;
std::vector<QString> _query;
bool _nothingFound = false;
std::vector<EmojiPtr> _selectedList;
rpl::variable<std::vector<EmojiPtr>> _selectedVar;
rpl::variable<bool> _expanded = false;
std::unique_ptr<Ui::FlatLabel> _about;
Strip *_strip = nullptr;
Ui::AbstractButton *_expandButton = nullptr;
Ui::SearchWithGroups *_search = nullptr;
std::unique_ptr<Ui::ScrollArea> _scroll;
Grid *_grid = nullptr;
Ui::FlatLabel *_notFound = nullptr;
Ui::Animations::Simple _expandAnim;
Ui::BoxShadow _shadow;
};
} // namespace ChatHelpers