/* 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 "styles/style_widgets.h" #include "ui/rp_widget.h" #include "ui/effects/animations.h" #include "base/object_ptr.h" #include namespace Ui { class InputField; class CrossButton; class ScrollArea; class MultiSelect : public RpWidget { public: MultiSelect( QWidget *parent, const style::MultiSelect &st, rpl::producer placeholder = nullptr); QString getQuery() const; void setInnerFocus(); void clearQuery(); void setQueryChangedCallback(Fn callback); void setSubmittedCallback(Fn callback); void setCancelledCallback(Fn callback); void setResizedCallback(Fn callback); enum class AddItemWay { Default, SkipAnimation, }; using PaintRoundImage = Fn; void addItem(uint64 itemId, const QString &text, style::color color, PaintRoundImage paintRoundImage, AddItemWay way = AddItemWay::Default); void addItemInBunch(uint64 itemId, const QString &text, style::color color, PaintRoundImage paintRoundImage); void finishItemsBunch(); void setItemText(uint64 itemId, const QString &text); void setItemRemovedCallback(Fn callback); void removeItem(uint64 itemId); int getItemsCount() const; QVector getItems() const; bool hasItem(uint64 itemId) const; protected: int resizeGetHeight(int newWidth) override; bool eventFilter(QObject *o, QEvent *e) override; private: void scrollTo(int activeTop, int activeBottom); const style::MultiSelect &_st; object_ptr _scroll; class Inner; QPointer _inner; Fn _resizedCallback; Fn _queryChangedCallback; }; } // namespace Ui