init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
145
Telegram/SourceFiles/ui/controls/tabbed_search.h
Normal file
145
Telegram/SourceFiles/ui/controls/tabbed_search.h
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
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 "base/timer.h"
|
||||
#include "base/qt/qt_compare.h"
|
||||
#include "ui/rp_widget.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/text/text_custom_emoji.h"
|
||||
|
||||
namespace style {
|
||||
struct EmojiPan;
|
||||
struct TabbedSearch;
|
||||
} // namespace style
|
||||
|
||||
namespace anim {
|
||||
enum class type : uchar;
|
||||
} // namespace anim
|
||||
|
||||
namespace Ui {
|
||||
|
||||
class InputField;
|
||||
class IconButton;
|
||||
class CrossButton;
|
||||
class RpWidget;
|
||||
template <typename Widget>
|
||||
class FadeWrap;
|
||||
|
||||
enum class EmojiGroupType {
|
||||
Normal,
|
||||
Greeting,
|
||||
Premium,
|
||||
};
|
||||
|
||||
struct EmojiGroup {
|
||||
QString iconId;
|
||||
std::vector<QString> emoticons;
|
||||
EmojiGroupType type = EmojiGroupType::Normal;
|
||||
|
||||
friend inline auto operator<=>(
|
||||
const EmojiGroup &a,
|
||||
const EmojiGroup &b) = default;
|
||||
};
|
||||
|
||||
[[nodiscard]] const QString &PremiumGroupFakeEmoticon();
|
||||
|
||||
struct SearchDescriptor {
|
||||
const style::TabbedSearch &st;
|
||||
rpl::producer<std::vector<EmojiGroup>> groups;
|
||||
Text::CustomEmojiFactory customEmojiFactory;
|
||||
};
|
||||
|
||||
class SearchWithGroups final : public RpWidget {
|
||||
public:
|
||||
SearchWithGroups(QWidget *parent, SearchDescriptor descriptor);
|
||||
|
||||
[[nodiscard]] rpl::producer<> escapes() const;
|
||||
[[nodiscard]] rpl::producer<std::vector<QString>> queryValue() const;
|
||||
[[nodiscard]] auto debouncedQueryValue() const
|
||||
-> rpl::producer<std::vector<QString>>;
|
||||
|
||||
void cancel();
|
||||
void setLoading(bool loading);
|
||||
void stealFocus();
|
||||
void returnFocus();
|
||||
|
||||
[[nodiscard]] static int IconSizeOverride();
|
||||
|
||||
private:
|
||||
int resizeGetHeight(int newWidth) override;
|
||||
void wheelEvent(QWheelEvent *e) override;
|
||||
|
||||
[[nodiscard]] int clampGroupsLeft(int width, int desiredLeft) const;
|
||||
void moveGroupsBy(int width, int delta);
|
||||
void moveGroupsTo(int width, int to);
|
||||
void scrollGroupsToIcon(int iconLeft, int iconRight);
|
||||
void scrollGroupsToStart();
|
||||
void scrollGroupsTo(int left);
|
||||
|
||||
[[nodiscard]] anim::type animated() const;
|
||||
void initField();
|
||||
void initGroups();
|
||||
void initEdges();
|
||||
void initButtons();
|
||||
|
||||
void ensureRounding(int size, float64 rounding);
|
||||
|
||||
const style::TabbedSearch &_st;
|
||||
not_null<FadeWrap<IconButton>*> _search;
|
||||
not_null<FadeWrap<IconButton>*> _back;
|
||||
not_null<CrossButton*> _cancel;
|
||||
not_null<InputField*> _field;
|
||||
QPointer<QWidget> _focusTakenFrom;
|
||||
not_null<FadeWrap<RpWidget>*> _groups;
|
||||
not_null<RpWidget*> _fade;
|
||||
rpl::variable<float64> _fadeOpacity = 0.;
|
||||
int _fadeLeftStart = 0;
|
||||
|
||||
rpl::variable<int> _fieldPlaceholderWidth;
|
||||
rpl::variable<bool> _fieldEmpty = true;
|
||||
Ui::Animations::Simple _groupsLeftAnimation;
|
||||
int _groupsLeftTo = 0;
|
||||
|
||||
QImage _rounding;
|
||||
|
||||
rpl::variable<std::vector<QString>> _query;
|
||||
rpl::variable<std::vector<QString>> _debouncedQuery;
|
||||
rpl::variable<QString> _chosenGroup;
|
||||
base::Timer _debounceTimer;
|
||||
bool _inited = false;
|
||||
|
||||
};
|
||||
|
||||
class TabbedSearch final {
|
||||
public:
|
||||
TabbedSearch(
|
||||
not_null<RpWidget*> parent,
|
||||
const style::EmojiPan &st,
|
||||
SearchDescriptor &&descriptor);
|
||||
|
||||
[[nodiscard]] int height() const;
|
||||
[[nodiscard]] QImage grab();
|
||||
|
||||
[[nodiscard]] rpl::producer<> escapes() const;
|
||||
[[nodiscard]] rpl::producer<std::vector<QString>> queryValue() const;
|
||||
[[nodiscard]] auto debouncedQueryValue() const
|
||||
->rpl::producer<std::vector<QString>>;
|
||||
|
||||
void cancel();
|
||||
void setLoading(bool loading);
|
||||
void stealFocus();
|
||||
void returnFocus();
|
||||
|
||||
private:
|
||||
const style::EmojiPan &_st;
|
||||
SearchWithGroups _search;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Ui
|
||||
Reference in New Issue
Block a user