2017-04-08 13:27:53 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-04-08 13:27:53 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2022-03-14 14:50:24 +00:00
|
|
|
#include "base/timer.h"
|
2017-10-05 15:35:52 +00:00
|
|
|
#include "ui/rp_widget.h"
|
2019-04-02 09:13:30 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2022-03-14 14:50:24 +00:00
|
|
|
#include "ui/dragging_scroll_manager.h"
|
2017-04-08 13:27:53 +00:00
|
|
|
#include "ui/widgets/tooltip.h"
|
|
|
|
#include "ui/widgets/scroll_area.h"
|
2018-01-09 17:08:31 +00:00
|
|
|
#include "history/view/history_view_top_bar_widget.h"
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2022-07-28 17:03:38 +00:00
|
|
|
struct ClickContext;
|
|
|
|
struct ClickHandlerContext;
|
|
|
|
|
2018-01-27 17:26:24 +00:00
|
|
|
namespace Data {
|
2018-01-29 18:09:08 +00:00
|
|
|
struct Group;
|
2020-05-28 14:32:10 +00:00
|
|
|
class CloudImageView;
|
2018-01-27 17:26:24 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
2018-01-17 16:21:01 +00:00
|
|
|
namespace HistoryView {
|
|
|
|
class ElementDelegate;
|
2021-09-15 14:49:06 +00:00
|
|
|
class EmojiInteractions;
|
2018-01-27 13:59:24 +00:00
|
|
|
struct TextState;
|
|
|
|
struct StateRequest;
|
|
|
|
enum class CursorState : char;
|
|
|
|
enum class PointState : char;
|
2019-01-18 08:11:15 +00:00
|
|
|
class EmptyPainter;
|
2019-09-13 06:06:02 +00:00
|
|
|
class Element;
|
2018-01-17 16:21:01 +00:00
|
|
|
} // namespace HistoryView
|
|
|
|
|
2021-12-15 15:25:48 +00:00
|
|
|
namespace HistoryView::Reactions {
|
|
|
|
class Manager;
|
2022-08-16 15:52:49 +00:00
|
|
|
struct ChosenReaction;
|
2021-12-15 15:25:48 +00:00
|
|
|
struct ButtonParameters;
|
|
|
|
} // namespace HistoryView::Reactions
|
|
|
|
|
2017-04-08 13:27:53 +00:00
|
|
|
namespace Window {
|
2019-06-06 10:21:40 +00:00
|
|
|
class SessionController;
|
2017-04-08 13:27:53 +00:00
|
|
|
} // namespace Window
|
|
|
|
|
|
|
|
namespace Ui {
|
2021-08-27 20:44:47 +00:00
|
|
|
class ChatTheme;
|
2021-09-03 10:17:07 +00:00
|
|
|
class ChatStyle;
|
2017-04-08 13:27:53 +00:00
|
|
|
class PopupMenu;
|
2021-02-15 17:37:22 +00:00
|
|
|
enum class ReportReason;
|
2022-02-11 06:38:44 +00:00
|
|
|
struct ChatPaintContext;
|
2021-07-02 15:29:13 +00:00
|
|
|
class PathShiftGradient;
|
2017-04-08 13:27:53 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2022-05-16 12:32:24 +00:00
|
|
|
namespace Dialogs::Ui {
|
2022-08-09 11:12:19 +00:00
|
|
|
using namespace ::Ui;
|
2022-05-16 12:32:24 +00:00
|
|
|
class VideoUserpic;
|
|
|
|
} // namespace Dialogs::Ui
|
|
|
|
|
2022-01-04 21:11:29 +00:00
|
|
|
class HistoryInner;
|
|
|
|
class HistoryMainElementDelegate;
|
|
|
|
class HistoryMainElementDelegateMixin {
|
|
|
|
public:
|
|
|
|
void setCurrent(HistoryInner *widget) {
|
|
|
|
_widget = widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual not_null<HistoryView::ElementDelegate*> delegate() = 0;
|
|
|
|
virtual ~HistoryMainElementDelegateMixin();
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class HistoryMainElementDelegate;
|
|
|
|
|
|
|
|
HistoryMainElementDelegateMixin();
|
|
|
|
|
|
|
|
HistoryInner *_widget = nullptr;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-04-08 13:27:53 +00:00
|
|
|
class HistoryWidget;
|
2017-10-05 15:35:52 +00:00
|
|
|
class HistoryInner
|
|
|
|
: public Ui::RpWidget
|
2021-05-25 12:42:26 +00:00
|
|
|
, public Ui::AbstractTooltipShower {
|
2017-04-08 13:27:53 +00:00
|
|
|
public:
|
2018-01-11 19:33:26 +00:00
|
|
|
using Element = HistoryView::Element;
|
2018-01-11 13:07:29 +00:00
|
|
|
|
2017-10-05 15:35:52 +00:00
|
|
|
HistoryInner(
|
2017-12-06 14:15:41 +00:00
|
|
|
not_null<HistoryWidget*> historyWidget,
|
2020-04-30 09:16:42 +00:00
|
|
|
not_null<Ui::ScrollArea*> scroll,
|
2019-06-06 10:21:40 +00:00
|
|
|
not_null<Window::SessionController*> controller,
|
2017-12-06 14:15:41 +00:00
|
|
|
not_null<History*> history);
|
2021-12-13 14:03:47 +00:00
|
|
|
~HistoryInner();
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2021-08-27 20:44:47 +00:00
|
|
|
[[nodiscard]] Main::Session &session() const;
|
|
|
|
[[nodiscard]] not_null<Ui::ChatTheme*> theme() const {
|
|
|
|
return _theme.get();
|
|
|
|
}
|
2019-07-24 11:13:51 +00:00
|
|
|
|
2022-02-11 06:38:44 +00:00
|
|
|
Ui::ChatPaintContext preparePaintContext(const QRect &clip) const;
|
|
|
|
|
2017-04-08 13:27:53 +00:00
|
|
|
void messagesReceived(PeerData *peer, const QVector<MTPMessage> &messages);
|
|
|
|
void messagesReceivedDown(PeerData *peer, const QVector<MTPMessage> &messages);
|
|
|
|
|
2021-12-15 15:25:48 +00:00
|
|
|
[[nodiscard]] TextForMimeData getSelectedText() const;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
|
|
|
void touchScrollUpdated(const QPoint &screenPos);
|
|
|
|
|
2021-07-19 10:02:36 +00:00
|
|
|
void setItemsRevealHeight(int revealHeight);
|
|
|
|
void changeItemsRevealHeight(int revealHeight);
|
2020-02-11 11:23:51 +00:00
|
|
|
void checkHistoryActivation();
|
2017-10-04 12:39:59 +00:00
|
|
|
void recountHistoryGeometry();
|
2017-04-08 13:27:53 +00:00
|
|
|
void updateSize();
|
|
|
|
|
|
|
|
void repaintItem(const HistoryItem *item);
|
2018-01-11 19:33:26 +00:00
|
|
|
void repaintItem(const Element *view);
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2021-12-15 15:25:48 +00:00
|
|
|
[[nodiscard]] bool canCopySelected() const;
|
|
|
|
[[nodiscard]] bool canDeleteSelected() const;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2021-12-15 15:25:48 +00:00
|
|
|
[[nodiscard]] auto getSelectionState() const
|
|
|
|
-> HistoryView::TopBarWidget::SelectedState;
|
2018-01-26 15:40:11 +00:00
|
|
|
void clearSelected(bool onlyTextSelection = false);
|
2021-12-15 15:25:48 +00:00
|
|
|
[[nodiscard]] MessageIdsList getSelectedItems() const;
|
|
|
|
[[nodiscard]] bool hasSelectedItems() const;
|
|
|
|
[[nodiscard]] bool inSelectionMode() const;
|
|
|
|
[[nodiscard]] bool elementIntersectsRange(
|
2019-05-14 09:50:44 +00:00
|
|
|
not_null<const Element*> view,
|
|
|
|
int from,
|
|
|
|
int till) const;
|
2019-08-01 12:55:14 +00:00
|
|
|
void elementStartStickerLoop(not_null<const Element*> view);
|
2022-06-04 23:44:08 +00:00
|
|
|
[[nodiscard]] float64 elementHighlightOpacity(
|
|
|
|
not_null<const HistoryItem*> item) const;
|
2020-01-14 11:55:18 +00:00
|
|
|
void elementShowPollResults(
|
|
|
|
not_null<PollData*> poll,
|
|
|
|
FullMsgId context);
|
2021-06-16 20:24:35 +00:00
|
|
|
void elementOpenPhoto(
|
|
|
|
not_null<PhotoData*> photo,
|
|
|
|
FullMsgId context);
|
2021-06-16 21:31:15 +00:00
|
|
|
void elementOpenDocument(
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
FullMsgId context,
|
|
|
|
bool showInMediaView = false);
|
2021-06-18 06:20:49 +00:00
|
|
|
void elementCancelUpload(const FullMsgId &context);
|
2020-04-30 10:11:05 +00:00
|
|
|
void elementShowTooltip(
|
|
|
|
const TextWithEntities &text,
|
|
|
|
Fn<void()> hiddenCallback);
|
2020-06-23 17:21:58 +00:00
|
|
|
bool elementIsGifPaused();
|
2020-11-10 16:38:21 +00:00
|
|
|
void elementSendBotCommand(
|
|
|
|
const QString &command,
|
|
|
|
const FullMsgId &context);
|
2020-11-10 18:51:20 +00:00
|
|
|
void elementHandleViaClick(not_null<UserData*> bot);
|
2021-05-27 00:44:12 +00:00
|
|
|
bool elementIsChatWide();
|
2021-07-02 15:29:13 +00:00
|
|
|
not_null<Ui::PathShiftGradient*> elementPathShiftGradient();
|
2021-07-26 14:37:19 +00:00
|
|
|
void elementReplyTo(const FullMsgId &to);
|
2021-09-14 16:55:35 +00:00
|
|
|
void elementStartInteraction(not_null<const Element*> view);
|
2022-04-26 16:31:10 +00:00
|
|
|
void elementStartPremium(
|
|
|
|
not_null<const Element*> view,
|
|
|
|
Element *replacing);
|
|
|
|
void elementCancelPremium(not_null<const Element*> view);
|
2021-12-24 10:01:58 +00:00
|
|
|
void elementShowSpoilerAnimation();
|
2017-04-08 13:27:53 +00:00
|
|
|
|
|
|
|
void updateBotInfo(bool recount = true);
|
|
|
|
|
|
|
|
bool wasSelectedText() const;
|
|
|
|
|
|
|
|
// updates history->scrollTopItem/scrollTopOffset
|
|
|
|
void visibleAreaUpdated(int top, int bottom);
|
|
|
|
|
|
|
|
int historyHeight() const;
|
|
|
|
int historyScrollTop() const;
|
|
|
|
int migratedTop() const;
|
|
|
|
int historyTop() const;
|
|
|
|
int historyDrawTop() const;
|
2018-01-11 13:07:29 +00:00
|
|
|
|
2021-02-15 17:37:22 +00:00
|
|
|
void setChooseReportReason(Ui::ReportReason reason);
|
|
|
|
void clearChooseReportReason();
|
|
|
|
|
2018-01-11 13:07:29 +00:00
|
|
|
// -1 if should not be visible, -2 if bad history()
|
|
|
|
int itemTop(const HistoryItem *item) const;
|
2018-01-11 19:33:26 +00:00
|
|
|
int itemTop(const Element *view) const;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2020-10-22 12:40:33 +00:00
|
|
|
// Returns (view, offset-from-top).
|
|
|
|
[[nodiscard]] std::pair<Element*, int> findViewForPinnedTracking(
|
|
|
|
int top) const;
|
|
|
|
|
2017-04-08 13:27:53 +00:00
|
|
|
void notifyIsBotChanged();
|
|
|
|
void notifyMigrateUpdated();
|
|
|
|
|
2018-01-17 16:21:01 +00:00
|
|
|
// Ui::AbstractTooltipShower interface.
|
2017-04-08 13:27:53 +00:00
|
|
|
QString tooltipText() const override;
|
|
|
|
QPoint tooltipPos() const override;
|
2019-09-16 11:14:06 +00:00
|
|
|
bool tooltipWindowActive() const override;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2021-09-29 00:00:11 +00:00
|
|
|
void onParentGeometryChanged();
|
|
|
|
|
2022-07-28 17:03:38 +00:00
|
|
|
[[nodiscard]] Fn<HistoryView::ElementDelegate*()> elementDelegateFactory(
|
|
|
|
FullMsgId itemId) const;
|
|
|
|
[[nodiscard]] ClickHandlerContext prepareClickHandlerContext(
|
|
|
|
FullMsgId itemId) const;
|
|
|
|
[[nodiscard]] ClickContext prepareClickContext(
|
|
|
|
Qt::MouseButton button,
|
|
|
|
FullMsgId itemId) const;
|
|
|
|
|
2022-01-04 21:11:29 +00:00
|
|
|
[[nodiscard]] static auto DelegateMixin()
|
|
|
|
-> std::unique_ptr<HistoryMainElementDelegateMixin>;
|
2018-01-17 16:21:01 +00:00
|
|
|
|
2017-04-08 13:27:53 +00:00
|
|
|
protected:
|
|
|
|
bool focusNextPrevChild(bool next) override;
|
|
|
|
|
2017-10-05 15:35:52 +00:00
|
|
|
bool eventHook(QEvent *e) override; // calls touchEvent when necessary
|
2017-04-08 13:27:53 +00:00
|
|
|
void touchEvent(QTouchEvent *e);
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent *e) override;
|
2021-10-19 13:00:21 +00:00
|
|
|
void enterEventHook(QEnterEvent *e) override;
|
2017-04-08 13:27:53 +00:00
|
|
|
void leaveEventHook(QEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
2017-04-15 21:05:57 +00:00
|
|
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2021-09-29 00:00:11 +00:00
|
|
|
private:
|
2017-04-08 13:27:53 +00:00
|
|
|
void onTouchSelect();
|
|
|
|
void onTouchScrollTimer();
|
|
|
|
|
2017-12-16 15:00:20 +00:00
|
|
|
class BotAbout;
|
2022-08-16 15:52:49 +00:00
|
|
|
using ChosenReaction = HistoryView::Reactions::ChosenReaction;
|
2022-05-16 12:32:24 +00:00
|
|
|
using VideoUserpic = Dialogs::Ui::VideoUserpic;
|
2017-12-16 15:00:20 +00:00
|
|
|
using SelectedItems = std::map<HistoryItem*, TextSelection, std::less<>>;
|
2017-06-21 21:38:31 +00:00
|
|
|
enum class MouseAction {
|
|
|
|
None,
|
|
|
|
PrepareDrag,
|
|
|
|
Dragging,
|
|
|
|
PrepareSelect,
|
|
|
|
Selecting,
|
|
|
|
};
|
2017-12-15 18:36:28 +00:00
|
|
|
enum class SelectAction {
|
|
|
|
Select,
|
|
|
|
Deselect,
|
|
|
|
Invert,
|
|
|
|
};
|
2018-01-11 13:07:29 +00:00
|
|
|
enum class EnumItemsDirection {
|
|
|
|
TopToBottom,
|
|
|
|
BottomToTop,
|
|
|
|
};
|
2018-01-27 13:59:24 +00:00
|
|
|
using CursorState = HistoryView::CursorState;
|
|
|
|
using PointState = HistoryView::PointState;
|
|
|
|
using TextState = HistoryView::TextState;
|
|
|
|
using StateRequest = HistoryView::StateRequest;
|
|
|
|
|
2018-01-11 13:07:29 +00:00
|
|
|
// This function finds all history items that are displayed and calls template method
|
|
|
|
// for each found message (in given direction) in the passed history with passed top offset.
|
|
|
|
//
|
2018-01-11 19:33:26 +00:00
|
|
|
// Method has "bool (*Method)(not_null<Element*> view, int itemtop, int itembottom)" signature
|
2018-01-11 13:07:29 +00:00
|
|
|
// if it returns false the enumeration stops immidiately.
|
|
|
|
template <bool TopToBottom, typename Method>
|
|
|
|
void enumerateItemsInHistory(History *history, int historytop, Method method);
|
|
|
|
|
|
|
|
template <EnumItemsDirection direction, typename Method>
|
|
|
|
void enumerateItems(Method method) {
|
|
|
|
constexpr auto TopToBottom = (direction == EnumItemsDirection::TopToBottom);
|
|
|
|
if (TopToBottom && _migrated) {
|
|
|
|
enumerateItemsInHistory<TopToBottom>(_migrated, migratedTop(), method);
|
|
|
|
}
|
|
|
|
enumerateItemsInHistory<TopToBottom>(_history, historyTop(), method);
|
|
|
|
if (!TopToBottom && _migrated) {
|
|
|
|
enumerateItemsInHistory<TopToBottom>(_migrated, migratedTop(), method);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This function finds all userpics on the left that are displayed and calls template method
|
|
|
|
// for each found userpic (from the top to the bottom) using enumerateItems() method.
|
|
|
|
//
|
2018-01-11 19:33:26 +00:00
|
|
|
// Method has "bool (*Method)(not_null<Element*> view, int userpicTop)" signature
|
2018-01-11 13:07:29 +00:00
|
|
|
// if it returns false the enumeration stops immidiately.
|
|
|
|
template <typename Method>
|
|
|
|
void enumerateUserpics(Method method);
|
|
|
|
|
|
|
|
// This function finds all date elements that are displayed and calls template method
|
|
|
|
// for each found date element (from the bottom to the top) using enumerateItems() method.
|
|
|
|
//
|
2018-01-11 19:33:26 +00:00
|
|
|
// Method has "bool (*Method)(not_null<Element*> view, int itemtop, int dateTop)" signature
|
2018-01-11 13:07:29 +00:00
|
|
|
// if it returns false the enumeration stops immidiately.
|
|
|
|
template <typename Method>
|
|
|
|
void enumerateDates(Method method);
|
2017-12-15 18:36:28 +00:00
|
|
|
|
2018-01-27 13:59:24 +00:00
|
|
|
void scrollDateCheck();
|
|
|
|
void scrollDateHideByTimer();
|
2018-01-21 19:21:08 +00:00
|
|
|
bool canHaveFromUserpics() const;
|
2017-06-21 21:38:31 +00:00
|
|
|
void mouseActionStart(const QPoint &screenPos, Qt::MouseButton button);
|
2018-01-27 13:59:24 +00:00
|
|
|
void mouseActionUpdate();
|
2017-06-21 21:38:31 +00:00
|
|
|
void mouseActionUpdate(const QPoint &screenPos);
|
|
|
|
void mouseActionFinish(const QPoint &screenPos, Qt::MouseButton button);
|
|
|
|
void mouseActionCancel();
|
2018-01-27 19:21:41 +00:00
|
|
|
std::unique_ptr<QMimeData> prepareDrag();
|
2017-06-21 21:38:31 +00:00
|
|
|
void performDrag();
|
|
|
|
|
2021-09-03 10:17:07 +00:00
|
|
|
void paintEmpty(
|
|
|
|
Painter &p,
|
|
|
|
not_null<const Ui::ChatStyle*> st,
|
|
|
|
int width,
|
|
|
|
int height);
|
2019-01-22 07:50:21 +00:00
|
|
|
|
2018-12-24 10:12:45 +00:00
|
|
|
QPoint mapPointToItem(QPoint p, const Element *view) const;
|
|
|
|
QPoint mapPointToItem(QPoint p, const HistoryItem *item) const;
|
2018-01-11 13:07:29 +00:00
|
|
|
|
2017-04-15 21:05:57 +00:00
|
|
|
void showContextMenu(QContextMenuEvent *e, bool showFromTouch = false);
|
2018-01-11 13:07:29 +00:00
|
|
|
void cancelContextDownload(not_null<DocumentData*> document);
|
|
|
|
void openContextGif(FullMsgId itemId);
|
|
|
|
void saveContextGif(FullMsgId itemId);
|
|
|
|
void copyContextText(FullMsgId itemId);
|
|
|
|
void showContextInFolder(not_null<DocumentData*> document);
|
|
|
|
void savePhotoToFile(not_null<PhotoData*> photo);
|
2018-07-13 21:25:47 +00:00
|
|
|
void saveDocumentToFile(
|
|
|
|
FullMsgId contextId,
|
|
|
|
not_null<DocumentData*> document);
|
2021-11-25 14:33:53 +00:00
|
|
|
void copyContextImage(not_null<PhotoData*> photo, FullMsgId itemId);
|
2018-01-11 13:07:29 +00:00
|
|
|
void showStickerPackInfo(not_null<DocumentData*> document);
|
2017-04-15 21:05:57 +00:00
|
|
|
|
2017-10-05 15:35:52 +00:00
|
|
|
void itemRemoved(not_null<const HistoryItem*> item);
|
2018-03-09 11:44:42 +00:00
|
|
|
void viewRemoved(not_null<const Element*> view);
|
2017-04-08 13:27:53 +00:00
|
|
|
|
|
|
|
void touchResetSpeed();
|
|
|
|
void touchUpdateSpeed();
|
|
|
|
void touchDeaccelerate(int32 elapsed);
|
|
|
|
|
|
|
|
void adjustCurrent(int32 y) const;
|
|
|
|
void adjustCurrent(int32 y, History *history) const;
|
2018-01-11 19:33:26 +00:00
|
|
|
Element *prevItem(Element *item);
|
|
|
|
Element *nextItem(Element *item);
|
|
|
|
void updateDragSelection(Element *dragSelFrom, Element *dragSelTo, bool dragSelecting);
|
2017-12-15 16:25:47 +00:00
|
|
|
TextSelection itemRenderSelection(
|
2018-01-11 19:33:26 +00:00
|
|
|
not_null<Element*> view,
|
2017-12-15 16:25:47 +00:00
|
|
|
int selfromy,
|
|
|
|
int seltoy) const;
|
2017-12-16 15:00:20 +00:00
|
|
|
TextSelection computeRenderSelection(
|
|
|
|
not_null<const SelectedItems*> selected,
|
2018-01-14 16:02:25 +00:00
|
|
|
not_null<Element*> view) const;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
|
|
|
void toggleScrollDateShown();
|
|
|
|
void repaintScrollDateCallback();
|
|
|
|
bool displayScrollDate() const;
|
|
|
|
void scrollDateHide();
|
|
|
|
void keepScrollDateForNow();
|
|
|
|
|
|
|
|
void applyDragSelection();
|
2017-12-15 16:25:47 +00:00
|
|
|
void applyDragSelection(not_null<SelectedItems*> toItems) const;
|
|
|
|
void addSelectionRange(
|
|
|
|
not_null<SelectedItems*> toItems,
|
|
|
|
not_null<History*> history,
|
|
|
|
int fromblock,
|
|
|
|
int fromitem,
|
|
|
|
int toblock,
|
|
|
|
int toitem) const;
|
2017-12-15 18:36:28 +00:00
|
|
|
bool isSelected(
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<SelectedItems*> toItems,
|
|
|
|
not_null<HistoryItem*> item) const;
|
2018-01-27 17:26:24 +00:00
|
|
|
bool isSelectedGroup(
|
|
|
|
not_null<SelectedItems*> toItems,
|
|
|
|
not_null<const Data::Group*> group) const;
|
2017-12-15 18:36:28 +00:00
|
|
|
bool isSelectedAsGroup(
|
|
|
|
not_null<SelectedItems*> toItems,
|
|
|
|
not_null<HistoryItem*> item) const;
|
|
|
|
bool goodForSelection(
|
|
|
|
not_null<SelectedItems*> toItems,
|
|
|
|
not_null<HistoryItem*> item,
|
|
|
|
int &totalCount) const;
|
|
|
|
void addToSelection(
|
|
|
|
not_null<SelectedItems*> toItems,
|
|
|
|
not_null<HistoryItem*> item) const;
|
|
|
|
void removeFromSelection(
|
|
|
|
not_null<SelectedItems*> toItems,
|
|
|
|
not_null<HistoryItem*> item) const;
|
|
|
|
void changeSelection(
|
|
|
|
not_null<SelectedItems*> toItems,
|
|
|
|
not_null<HistoryItem*> item,
|
|
|
|
SelectAction action) const;
|
|
|
|
void changeSelectionAsGroup(
|
2017-12-15 16:25:47 +00:00
|
|
|
not_null<SelectedItems*> toItems,
|
|
|
|
not_null<HistoryItem*> item,
|
|
|
|
SelectAction action) const;
|
2018-01-11 13:07:29 +00:00
|
|
|
void forwardItem(FullMsgId itemId);
|
|
|
|
void forwardAsGroup(FullMsgId itemId);
|
2017-12-15 18:36:28 +00:00
|
|
|
void deleteItem(not_null<HistoryItem*> item);
|
2018-01-11 13:07:29 +00:00
|
|
|
void deleteItem(FullMsgId itemId);
|
|
|
|
void deleteAsGroup(FullMsgId itemId);
|
2018-05-10 14:15:16 +00:00
|
|
|
void reportItem(FullMsgId itemId);
|
|
|
|
void reportAsGroup(FullMsgId itemId);
|
2020-09-17 13:26:53 +00:00
|
|
|
void blockSenderItem(FullMsgId itemId);
|
|
|
|
void blockSenderAsGroup(FullMsgId itemId);
|
2018-01-27 13:59:24 +00:00
|
|
|
void copySelectedText();
|
2021-12-15 15:25:48 +00:00
|
|
|
|
2021-12-29 13:06:08 +00:00
|
|
|
[[nodiscard]] auto reactionButtonParameters(
|
2021-12-15 15:25:48 +00:00
|
|
|
not_null<const Element*> view,
|
2021-12-25 20:01:49 +00:00
|
|
|
QPoint position,
|
2021-12-29 13:06:08 +00:00
|
|
|
const HistoryView::TextState &reactionState) const
|
|
|
|
-> HistoryView::Reactions::ButtonParameters;
|
2022-04-11 08:34:56 +00:00
|
|
|
void toggleFavoriteReaction(not_null<Element*> view) const;
|
2022-08-16 15:52:49 +00:00
|
|
|
void reactionChosen(const ChosenReaction &reaction);
|
2022-08-19 12:08:11 +00:00
|
|
|
void premiumPromoChosen(FullMsgId context);
|
2021-11-05 17:37:01 +00:00
|
|
|
|
|
|
|
void setupSharingDisallowed();
|
2021-11-25 14:33:53 +00:00
|
|
|
[[nodiscard]] bool hasCopyRestriction(HistoryItem *item = nullptr) const;
|
|
|
|
bool showCopyRestriction(HistoryItem *item = nullptr);
|
|
|
|
[[nodiscard]] bool hasCopyRestrictionForSelected() const;
|
|
|
|
bool showCopyRestrictionForSelected();
|
2021-11-05 17:37:01 +00:00
|
|
|
[[nodiscard]] bool hasSelectRestriction() const;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2022-05-16 12:32:24 +00:00
|
|
|
VideoUserpic *validateVideoUserpic(not_null<PeerData*> peer);
|
|
|
|
|
2017-04-08 13:27:53 +00:00
|
|
|
// Does any of the shown histories has this flag set.
|
2018-01-13 12:45:11 +00:00
|
|
|
bool hasPendingResizedItems() const;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2020-04-30 09:16:42 +00:00
|
|
|
const not_null<HistoryWidget*> _widget;
|
|
|
|
const not_null<Ui::ScrollArea*> _scroll;
|
|
|
|
const not_null<Window::SessionController*> _controller;
|
2019-01-18 08:11:15 +00:00
|
|
|
const not_null<PeerData*> _peer;
|
|
|
|
const not_null<History*> _history;
|
2022-01-04 21:11:29 +00:00
|
|
|
const not_null<HistoryView::ElementDelegate*> _elementDelegate;
|
2021-09-15 14:49:06 +00:00
|
|
|
const std::unique_ptr<HistoryView::EmojiInteractions> _emojiInteractions;
|
2021-08-27 20:44:47 +00:00
|
|
|
std::shared_ptr<Ui::ChatTheme> _theme;
|
2020-04-30 09:16:42 +00:00
|
|
|
|
2018-01-11 13:07:29 +00:00
|
|
|
History *_migrated = nullptr;
|
2022-01-04 21:11:29 +00:00
|
|
|
HistoryView::ElementDelegate *_migratedElementDelegate = nullptr;
|
2018-01-21 19:21:08 +00:00
|
|
|
int _contentWidth = 0;
|
2018-01-11 13:07:29 +00:00
|
|
|
int _historyPaddingTop = 0;
|
2021-07-19 10:02:36 +00:00
|
|
|
int _revealHeight = 0;
|
2018-01-11 13:07:29 +00:00
|
|
|
|
2020-04-30 09:16:42 +00:00
|
|
|
// Save visible area coords for painting / pressing userpics.
|
|
|
|
int _visibleAreaTop = 0;
|
|
|
|
int _visibleAreaBottom = 0;
|
|
|
|
|
2019-01-15 11:57:45 +00:00
|
|
|
// With migrated history we perhaps do not need to display
|
|
|
|
// the first _history message date (just skip it by height).
|
2018-01-11 13:07:29 +00:00
|
|
|
int _historySkipHeight = 0;
|
|
|
|
|
|
|
|
std::unique_ptr<BotAbout> _botAbout;
|
2019-01-18 08:11:15 +00:00
|
|
|
std::unique_ptr<HistoryView::EmptyPainter> _emptyPainter;
|
2018-01-11 13:07:29 +00:00
|
|
|
|
|
|
|
mutable History *_curHistory = nullptr;
|
|
|
|
mutable int _curBlock = 0;
|
|
|
|
mutable int _curItem = 0;
|
|
|
|
|
|
|
|
style::cursor _cursor = style::cur_default;
|
|
|
|
SelectedItems _selected;
|
2021-02-15 17:37:22 +00:00
|
|
|
std::optional<Ui::ReportReason> _chooseForReportReason;
|
2018-01-11 13:07:29 +00:00
|
|
|
|
2021-07-02 15:29:13 +00:00
|
|
|
const std::unique_ptr<Ui::PathShiftGradient> _pathGradient;
|
2021-05-27 00:44:12 +00:00
|
|
|
bool _isChatWide = false;
|
|
|
|
|
2019-08-01 12:55:14 +00:00
|
|
|
base::flat_set<not_null<const HistoryItem*>> _animatedStickersPlayed;
|
2020-05-28 14:32:10 +00:00
|
|
|
base::flat_map<
|
|
|
|
not_null<PeerData*>,
|
|
|
|
std::shared_ptr<Data::CloudImageView>> _userpics, _userpicsCache;
|
2022-02-15 02:20:55 +00:00
|
|
|
base::flat_map<
|
|
|
|
MsgId,
|
|
|
|
std::shared_ptr<Data::CloudImageView>> _sponsoredUserpics;
|
2022-05-16 12:32:24 +00:00
|
|
|
base::flat_map<
|
|
|
|
not_null<PeerData*>,
|
|
|
|
std::unique_ptr<VideoUserpic>> _videoUserpics;
|
2019-08-01 11:42:24 +00:00
|
|
|
|
2021-12-15 15:25:48 +00:00
|
|
|
std::unique_ptr<HistoryView::Reactions::Manager> _reactionsManager;
|
2022-08-19 12:08:11 +00:00
|
|
|
rpl::variable<HistoryItem*> _reactionsItem;
|
2021-12-13 14:03:47 +00:00
|
|
|
|
2017-06-21 21:38:31 +00:00
|
|
|
MouseAction _mouseAction = MouseAction::None;
|
|
|
|
TextSelectType _mouseSelectType = TextSelectType::Letters;
|
|
|
|
QPoint _dragStartPosition;
|
|
|
|
QPoint _mousePosition;
|
|
|
|
HistoryItem *_mouseActionItem = nullptr;
|
2017-12-15 16:25:47 +00:00
|
|
|
HistoryItem *_dragStateItem = nullptr;
|
2018-01-27 13:59:24 +00:00
|
|
|
CursorState _mouseCursorState = CursorState();
|
2017-06-21 21:38:31 +00:00
|
|
|
uint16 _mouseTextSymbol = 0;
|
|
|
|
bool _pressWasInactive = false;
|
2021-12-30 23:17:34 +00:00
|
|
|
bool _recountedAfterPendingResizedItems = false;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
|
|
|
QPoint _trippleClickPoint;
|
2021-09-29 00:00:11 +00:00
|
|
|
base::Timer _trippleClickTimer;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
Element *_dragSelFrom = nullptr;
|
|
|
|
Element *_dragSelTo = nullptr;
|
2017-04-08 13:27:53 +00:00
|
|
|
bool _dragSelecting = false;
|
|
|
|
bool _wasSelectedText = false; // was some text selected in current drag action
|
|
|
|
|
2017-06-21 21:38:31 +00:00
|
|
|
// scroll by touch support (at least Windows Surface tablets)
|
2017-04-08 13:27:53 +00:00
|
|
|
bool _touchScroll = false;
|
|
|
|
bool _touchSelect = false;
|
|
|
|
bool _touchInProgress = false;
|
|
|
|
QPoint _touchStart, _touchPrevPos, _touchPos;
|
2021-09-29 00:00:11 +00:00
|
|
|
base::Timer _touchSelectTimer;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2022-03-14 14:19:52 +00:00
|
|
|
Ui::DraggingScrollManager _selectScroll;
|
2021-10-30 06:11:27 +00:00
|
|
|
|
2021-11-05 17:37:01 +00:00
|
|
|
rpl::variable<bool> _sharingDisallowed = false;
|
|
|
|
|
2017-04-08 13:27:53 +00:00
|
|
|
Ui::TouchScrollState _touchScrollState = Ui::TouchScrollState::Manual;
|
|
|
|
bool _touchPrevPosValid = false;
|
|
|
|
bool _touchWaitingAcceleration = false;
|
|
|
|
QPoint _touchSpeed;
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time _touchSpeedTime = 0;
|
|
|
|
crl::time _touchAccelerationTime = 0;
|
|
|
|
crl::time _touchTime = 0;
|
2021-09-29 00:00:11 +00:00
|
|
|
base::Timer _touchScrollTimer;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
2021-12-24 10:01:58 +00:00
|
|
|
Ui::Animations::Simple _spoilerOpacity;
|
|
|
|
|
2022-01-14 15:42:24 +00:00
|
|
|
// _menu must be destroyed before _whoReactedMenuLifetime.
|
|
|
|
rpl::lifetime _whoReactedMenuLifetime;
|
2018-01-11 13:07:29 +00:00
|
|
|
base::unique_qptr<Ui::PopupMenu> _menu;
|
2017-04-08 13:27:53 +00:00
|
|
|
|
|
|
|
bool _scrollDateShown = false;
|
2019-04-02 09:13:30 +00:00
|
|
|
Ui::Animations::Simple _scrollDateOpacity;
|
2017-04-08 13:27:53 +00:00
|
|
|
SingleQueuedInvokation _scrollDateCheck;
|
2018-01-27 13:59:24 +00:00
|
|
|
base::Timer _scrollDateHideTimer;
|
2018-01-11 19:33:26 +00:00
|
|
|
Element *_scrollDateLastItem = nullptr;
|
2017-04-08 13:27:53 +00:00
|
|
|
int _scrollDateLastItemTop = 0;
|
|
|
|
ClickHandlerPtr _scrollDateLink;
|
|
|
|
|
|
|
|
};
|