Move HistoryMedia to HistoryView namespace.

This commit is contained in:
John Preston 2019-08-02 14:21:09 +01:00
parent fd59147b8a
commit 850940116d
61 changed files with 739 additions and 702 deletions

View file

@ -11,18 +11,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item.h"
#include "history/history_location_manager.h"
#include "history/view/history_view_element.h"
#include "history/media/history_media_photo.h"
#include "history/media/history_media_sticker.h"
#include "history/media/history_media_gif.h"
#include "history/media/history_media_video.h"
#include "history/media/history_media_document.h"
#include "history/media/history_media_contact.h"
#include "history/media/history_media_location.h"
#include "history/media/history_media_game.h"
#include "history/media/history_media_invoice.h"
#include "history/media/history_media_call.h"
#include "history/media/history_media_web_page.h"
#include "history/media/history_media_poll.h"
#include "history/view/media/history_view_photo.h"
#include "history/view/media/history_view_sticker.h"
#include "history/view/media/history_view_gif.h"
#include "history/view/media/history_view_video.h"
#include "history/view/media/history_view_document.h"
#include "history/view/media/history_view_contact.h"
#include "history/view/media/history_view_location.h"
#include "history/view/media/history_view_game.h"
#include "history/view/media/history_view_invoice.h"
#include "history/view/media/history_view_call.h"
#include "history/view/media/history_view_web_page.h"
#include "history/view/media/history_view_poll.h"
#include "ui/image/image.h"
#include "ui/image/image_source.h"
#include "ui/text_options.h"
@ -237,7 +237,7 @@ TextWithEntities Media::consumedMessageText() const {
return {};
}
std::unique_ptr<HistoryMedia> Media::createView(
std::unique_ptr<HistoryView::Media> Media::createView(
not_null<HistoryView::Element*> message) {
return createView(message, message->data());
}
@ -471,17 +471,17 @@ bool MediaPhoto::updateSentMedia(const MTPMessageMedia &media) {
return true;
}
std::unique_ptr<HistoryMedia> MediaPhoto::createView(
std::unique_ptr<HistoryView::Media> MediaPhoto::createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) {
if (_chat) {
return std::make_unique<HistoryPhoto>(
return std::make_unique<HistoryView::Photo>(
message,
_chat,
_photo,
st::msgServicePhotoWidth);
}
return std::make_unique<HistoryPhoto>(
return std::make_unique<HistoryView::Photo>(
message,
realParent,
_photo);
@ -611,7 +611,10 @@ QString MediaFile::notificationText() const {
QString MediaFile::pinnedTextSubstring() const {
if (const auto sticker = _document->sticker()) {
if (!_emoji.isEmpty()) {
return tr::lng_action_pinned_media_emoji_sticker(tr::now, lt_emoji, _emoji);
return tr::lng_action_pinned_media_emoji_sticker(
tr::now,
lt_emoji,
_emoji);
}
return tr::lng_action_pinned_media_sticker(tr::now);
} else if (_document->isAnimation()) {
@ -637,7 +640,10 @@ TextForMimeData MediaFile::clipboardText() const {
: QString();
if (const auto sticker = _document->sticker()) {
if (!_emoji.isEmpty()) {
return tr::lng_in_dlg_sticker_emoji(tr::now, lt_emoji, _emoji);
return tr::lng_in_dlg_sticker_emoji(
tr::now,
lt_emoji,
_emoji);
}
return tr::lng_in_dlg_sticker(tr::now);
} else if (_document->isAnimation()) {
@ -759,20 +765,20 @@ bool MediaFile::updateSentMedia(const MTPMessageMedia &media) {
return true;
}
std::unique_ptr<HistoryMedia> MediaFile::createView(
std::unique_ptr<HistoryView::Media> MediaFile::createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) {
if (_document->sticker()) {
return std::make_unique<HistorySticker>(message, _document);
return std::make_unique<HistoryView::Sticker>(message, _document);
} else if (_document->isAnimation()) {
return std::make_unique<HistoryGif>(message, _document);
return std::make_unique<HistoryView::Gif>(message, _document);
} else if (_document->isVideoFile()) {
return std::make_unique<HistoryVideo>(
return std::make_unique<HistoryView::Video>(
message,
realParent,
_document);
}
return std::make_unique<HistoryDocument>(message, _document);
return std::make_unique<HistoryView::Document>(message, _document);
}
MediaContact::MediaContact(
@ -818,7 +824,9 @@ QString MediaContact::pinnedTextSubstring() const {
}
TextForMimeData MediaContact::clipboardText() const {
const auto text = qsl("[ ") + tr::lng_in_dlg_contact(tr::now) + qsl(" ]\n")
const auto text = qsl("[ ")
+ tr::lng_in_dlg_contact(tr::now)
+ qsl(" ]\n")
+ tr::lng_full_name(
tr::now,
lt_first_name,
@ -850,10 +858,10 @@ bool MediaContact::updateSentMedia(const MTPMessageMedia &media) {
return true;
}
std::unique_ptr<HistoryMedia> MediaContact::createView(
std::unique_ptr<HistoryView::Media> MediaContact::createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) {
return std::make_unique<HistoryContact>(
return std::make_unique<HistoryView::Contact>(
message,
_contact.userId,
_contact.firstName,
@ -929,10 +937,10 @@ bool MediaLocation::updateSentMedia(const MTPMessageMedia &media) {
return false;
}
std::unique_ptr<HistoryMedia> MediaLocation::createView(
std::unique_ptr<HistoryView::Media> MediaLocation::createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) {
return std::make_unique<HistoryLocation>(
return std::make_unique<HistoryView::Location>(
message,
_location,
_title,
@ -988,10 +996,10 @@ bool MediaCall::updateSentMedia(const MTPMessageMedia &media) {
return false;
}
std::unique_ptr<HistoryMedia> MediaCall::createView(
std::unique_ptr<HistoryView::Media> MediaCall::createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) {
return std::make_unique<HistoryCall>(message, &_call);
return std::make_unique<HistoryView::Call>(message, &_call);
}
QString MediaCall::Text(
@ -1083,10 +1091,10 @@ bool MediaWebPage::updateSentMedia(const MTPMessageMedia &media) {
return false;
}
std::unique_ptr<HistoryMedia> MediaWebPage::createView(
std::unique_ptr<HistoryView::Media> MediaWebPage::createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) {
return std::make_unique<HistoryWebPage>(message, _page);
return std::make_unique<HistoryView::WebPage>(message, _page);
}
MediaGame::MediaGame(
@ -1174,10 +1182,13 @@ bool MediaGame::updateSentMedia(const MTPMessageMedia &media) {
return true;
}
std::unique_ptr<HistoryMedia> MediaGame::createView(
std::unique_ptr<HistoryView::Media> MediaGame::createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) {
return std::make_unique<HistoryGame>(message, _game, _consumedText);
return std::make_unique<HistoryView::Game>(
message,
_game,
_consumedText);
}
MediaInvoice::MediaInvoice(
@ -1236,10 +1247,10 @@ bool MediaInvoice::updateSentMedia(const MTPMessageMedia &media) {
return true;
}
std::unique_ptr<HistoryMedia> MediaInvoice::createView(
std::unique_ptr<HistoryView::Media> MediaInvoice::createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) {
return std::make_unique<HistoryInvoice>(message, &_invoice);
return std::make_unique<HistoryView::Invoice>(message, &_invoice);
}
MediaPoll::MediaPoll(
@ -1299,10 +1310,10 @@ bool MediaPoll::updateSentMedia(const MTPMessageMedia &media) {
return false;
}
std::unique_ptr<HistoryMedia> MediaPoll::createView(
std::unique_ptr<HistoryView::Media> MediaPoll::createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) {
return std::make_unique<HistoryPoll>(message, _poll);
return std::make_unique<HistoryView::Poll>(message, _poll);
}
} // namespace Data

View file

@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
class HistoryItem;
class HistoryMedia;
namespace base {
template <typename Enum>
@ -23,6 +22,7 @@ using SharedMediaTypesMask = base::enum_mask<SharedMediaType>;
namespace HistoryView {
enum class Context : char;
class Element;
class Media;
} // namespace HistoryView
namespace Data {
@ -107,10 +107,10 @@ public:
// the media (all media that was generated on client side, for example).
virtual bool updateInlineResultMedia(const MTPMessageMedia &media) = 0;
virtual bool updateSentMedia(const MTPMessageMedia &media) = 0;
virtual std::unique_ptr<HistoryMedia> createView(
virtual std::unique_ptr<HistoryView::Media> createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) = 0;
std::unique_ptr<HistoryMedia> createView(
std::unique_ptr<HistoryView::Media> createView(
not_null<HistoryView::Element*> message);
private:
@ -148,7 +148,7 @@ public:
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr<HistoryMedia> createView(
std::unique_ptr<HistoryView::Media> createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) override;
@ -185,7 +185,7 @@ public:
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr<HistoryMedia> createView(
std::unique_ptr<HistoryView::Media> createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) override;
@ -214,7 +214,7 @@ public:
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr<HistoryMedia> createView(
std::unique_ptr<HistoryView::Media> createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) override;
@ -244,7 +244,7 @@ public:
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr<HistoryMedia> createView(
std::unique_ptr<HistoryView::Media> createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) override;
@ -271,7 +271,7 @@ public:
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr<HistoryMedia> createView(
std::unique_ptr<HistoryView::Media> createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) override;
@ -307,7 +307,7 @@ public:
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr<HistoryMedia> createView(
std::unique_ptr<HistoryView::Media> createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) override;
@ -338,7 +338,7 @@ public:
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr<HistoryMedia> createView(
std::unique_ptr<HistoryView::Media> createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) override;
@ -369,7 +369,7 @@ public:
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr<HistoryMedia> createView(
std::unique_ptr<HistoryView::Media> createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) override;
@ -396,7 +396,7 @@ public:
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr<HistoryMedia> createView(
std::unique_ptr<HistoryView::Media> createView(
not_null<HistoryView::Element*> message,
not_null<HistoryItem*> realParent) override;

View file

@ -20,7 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/notifications_manager.h"
#include "history/history.h"
#include "history/history_item_components.h"
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
#include "history/view/history_view_element.h"
#include "inline_bots/inline_bot_layout_item.h"
#include "storage/localstorage.h"

View file

@ -22,7 +22,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace App { // Hackish..
QString formatPhone(QString phone);
} // namespace App
namespace HistoryView {
QString FillAmountAndCurrency(uint64 amount, const QString &currency);
} // namespace HistoryView
QString formatSizeText(qint64 size);
QString formatDurationText(qint64 duration);
@ -1725,7 +1727,7 @@ Utf8String FormatDateTime(
}
Utf8String FormatMoneyAmount(uint64 amount, const Utf8String &currency) {
return FillAmountAndCurrency(
return HistoryView::FillAmountAndCurrency(
amount,
QString::fromUtf8(currency)).toUtf8();
}

View file

@ -28,7 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/observer.h"
#include "history/history.h"
#include "history/history_item.h"
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
#include "styles/style_history.h"
#include "data/data_session.h"

View file

@ -9,8 +9,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_history.h"
#include "history/history.h"
#include "history/media/history_media.h"
#include "history/media/history_media_web_page.h"
#include "history/view/media/history_view_media.h"
#include "history/view/media/history_view_web_page.h"
#include "history/history_message.h"
#include "history/history_item_components.h"
#include "history/history_item_text.h"
@ -1627,7 +1627,7 @@ void InnerWidget::performDrag() {
// return;
//} else {
// auto forwardMimeType = QString();
// auto pressedMedia = static_cast<HistoryMedia*>(nullptr);
// auto pressedMedia = static_cast<HistoryView::Media*>(nullptr);
// if (auto pressedItem = App::pressedItem()) {
// pressedMedia = pressedItem->media();
// if (_mouseCursorState == CursorState::Date

View file

@ -22,7 +22,6 @@ class HistoryBlock;
class HistoryItem;
class HistoryMessage;
class HistoryService;
class HistoryMedia;
namespace Main {
class Session;

View file

@ -13,9 +13,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/crash_reports.h"
#include "history/history.h"
#include "history/history_message.h"
#include "history/media/history_media.h"
#include "history/media/history_media_sticker.h"
#include "history/media/history_media_web_page.h"
#include "history/view/media/history_view_media.h"
#include "history/view/media/history_view_sticker.h"
#include "history/view/media/history_view_web_page.h"
#include "history/history_item_components.h"
#include "history/history_item_text.h"
#include "history/view/history_view_message.h"
@ -1087,7 +1087,7 @@ void HistoryInner::mouseActionStart(const QPoint &screenPos, Qt::MouseButton but
if (uponSelected) {
_mouseAction = MouseAction::PrepareDrag; // start text drag
} else if (!_pressWasInactive) {
if (dynamic_cast<HistorySticker*>(App::pressedItem()->media())
if (dynamic_cast<HistoryView::Sticker*>(App::pressedItem()->media())
|| _mouseCursorState == CursorState::Date) {
_mouseAction = MouseAction::PrepareDrag; // start sticker drag or by-date drag
} else {

View file

@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_element.h"
#include "history/view/history_view_service_message.h"
#include "history/history_item_components.h"
#include "history/media/history_media_grouped.h"
#include "history/view/media/history_view_media_grouped.h"
#include "history/history_service.h"
#include "history/history_message.h"
#include "history/history.h"

View file

@ -16,7 +16,6 @@ enum class UnreadMentionType;
struct HistoryMessageReplyMarkup;
class ReplyKeyboard;
class HistoryMessage;
class HistoryMedia;
namespace base {
template <typename Enum>

View file

@ -15,7 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history.h"
#include "history/history_message.h"
#include "history/view/history_view_service_message.h"
#include "history/media/history_media_document.h"
#include "history/view/media/history_view_document.h"
#include "mainwindow.h"
#include "media/audio/media_audio.h"
#include "media/player/media_player_instance.h"
@ -922,16 +922,16 @@ HistoryDocumentCaptioned::HistoryDocumentCaptioned()
}
HistoryDocumentVoicePlayback::HistoryDocumentVoicePlayback(
const HistoryDocument *that)
const HistoryView::Document *that)
: progress(0., 0.)
, progressAnimation([=](crl::time now) {
const auto nonconst = const_cast<HistoryDocument*>(that);
const auto nonconst = const_cast<HistoryView::Document*>(that);
return nonconst->voiceProgressAnimationCallback(now);
}) {
}
void HistoryDocumentVoice::ensurePlayback(
const HistoryDocument *that) const {
const HistoryView::Document *that) const {
if (!_playback) {
_playback = std::make_unique<HistoryDocumentVoicePlayback>(that);
}

View file

@ -11,11 +11,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/empty_userpic.h"
#include "ui/effects/animations.h"
class HistoryDocument;
struct WebPageData;
namespace HistoryView {
class Element;
class Document;
} // namespace HistoryView
struct HistoryMessageVia : public RuntimeComponent<HistoryMessageVia, HistoryItem> {
@ -375,7 +375,7 @@ struct HistoryMessageLogEntryOriginal
};
class FileClickHandler;
struct HistoryDocumentThumbed : public RuntimeComponent<HistoryDocumentThumbed, HistoryDocument> {
struct HistoryDocumentThumbed : public RuntimeComponent<HistoryDocumentThumbed, HistoryView::Document> {
std::shared_ptr<FileClickHandler> _linksavel;
std::shared_ptr<FileClickHandler> _linkopenwithl;
std::shared_ptr<FileClickHandler> _linkcancell;
@ -385,31 +385,31 @@ struct HistoryDocumentThumbed : public RuntimeComponent<HistoryDocumentThumbed,
mutable QString _link;
};
struct HistoryDocumentCaptioned : public RuntimeComponent<HistoryDocumentCaptioned, HistoryDocument> {
struct HistoryDocumentCaptioned : public RuntimeComponent<HistoryDocumentCaptioned, HistoryView::Document> {
HistoryDocumentCaptioned();
Ui::Text::String _caption;
};
struct HistoryDocumentNamed : public RuntimeComponent<HistoryDocumentNamed, HistoryDocument> {
struct HistoryDocumentNamed : public RuntimeComponent<HistoryDocumentNamed, HistoryView::Document> {
QString _name;
int _namew = 0;
};
struct HistoryDocumentVoicePlayback {
HistoryDocumentVoicePlayback(const HistoryDocument *that);
HistoryDocumentVoicePlayback(const HistoryView::Document *that);
int32 position = 0;
anim::value progress;
Ui::Animations::Basic progressAnimation;
};
class HistoryDocumentVoice : public RuntimeComponent<HistoryDocumentVoice, HistoryDocument> {
class HistoryDocumentVoice : public RuntimeComponent<HistoryDocumentVoice, HistoryView::Document> {
// We don't use float64 because components should align to pointer even on 32bit systems.
static constexpr float64 kFloatToIntMultiplier = 65536.;
public:
void ensurePlayback(const HistoryDocument *interfaces) const;
void ensurePlayback(const HistoryView::Document *interfaces) const;
void checkPlaybackFinished() const;
mutable std::unique_ptr<HistoryDocumentVoicePlayback> _playback;

View file

@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h"
#include "layout.h"
#include "history/history.h"
#include "history/media/history_media_invoice.h"
#include "history/view/media/history_view_invoice.h"
#include "history/history_message.h"
#include "history/history_item_components.h"
#include "history/view/history_view_service_message.h"
@ -669,7 +669,7 @@ void HistoryService::createFromMtp(const MTPDmessageService &message) {
UpdateComponents(HistoryServicePayment::Bit());
auto amount = message.vaction().c_messageActionPaymentSent().vtotal_amount().v;
auto currency = qs(message.vaction().c_messageActionPaymentSent().vcurrency());
Get<HistoryServicePayment>()->amount = FillAmountAndCurrency(amount, currency);
Get<HistoryServicePayment>()->amount = HistoryView::FillAmountAndCurrency(amount, currency);
}
if (const auto replyToMsgId = message.vreply_to_msg_id()) {
if (message.vaction().type() == mtpc_messageActionPinMessage) {

View file

@ -39,7 +39,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history.h"
#include "history/history_item.h"
#include "history/history_message.h"
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
#include "history/history_drag_area.h"
#include "history/history_inner_widget.h"
#include "history/history_item_components.h"

View file

@ -13,8 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item.h"
#include "history/history_message.h"
#include "history/history_item_text.h"
#include "history/media/history_media.h"
#include "history/media/history_media_web_page.h"
#include "history/view/media/history_view_media.h"
#include "history/view/media/history_view_web_page.h"
#include "ui/widgets/popup_menu.h"
#include "ui/image/image.h"
#include "ui/toast/toast.h"

View file

@ -11,9 +11,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_message.h"
#include "history/history_item_components.h"
#include "history/history_item.h"
#include "history/media/history_media.h"
#include "history/media/history_media_grouped.h"
#include "history/media/history_media_sticker.h"
#include "history/view/media/history_view_media.h"
#include "history/view/media/history_view_media_grouped.h"
#include "history/view/media/history_view_sticker.h"
#include "history/history.h"
#include "main/main_session.h"
#include "chat_helpers/stickers_emoji_pack.h"
@ -224,7 +224,7 @@ QDateTime Element::dateTime() const {
return _dateTime;
}
HistoryMedia *Element::media() const {
Media *Element::media() const {
return _media.get();
}
@ -331,7 +331,7 @@ void Element::refreshMedia() {
_media = nullptr;
_flags |= Flag::HiddenByGroup;
} else {
_media = std::make_unique<HistoryGroupedMedia>(
_media = std::make_unique<GroupedMedia>(
this,
group->items);
if (!pendingResize()) {
@ -345,7 +345,7 @@ void Element::refreshMedia() {
if (_data->media()) {
_media = _data->media()->createView(this);
} else if (const auto document = emojiStickers->stickerForEmoji(_data)) {
_media = std::make_unique<HistorySticker>(this, document);
_media = std::make_unique<Sticker>(this, document);
} else {
_media = nullptr;
}

View file

@ -15,8 +15,6 @@ class HistoryBlock;
class HistoryItem;
class HistoryMessage;
class HistoryService;
class HistoryMedia;
class HistoryWebPage;
namespace HistoryView {
@ -24,6 +22,7 @@ enum class PointState : char;
enum class InfoDisplayType : char;
struct StateRequest;
struct TextState;
class Media;
enum class Context : char {
History,
@ -147,7 +146,7 @@ public:
not_null<ElementDelegate*> delegate() const;
not_null<HistoryItem*> data() const;
not_null<History*> history() const;
HistoryMedia *media() const;
Media *media() const;
Context context() const;
void refreshDataId();
@ -303,7 +302,7 @@ private:
const not_null<ElementDelegate*> _delegate;
const not_null<HistoryItem*> _data;
std::unique_ptr<HistoryMedia> _media;
std::unique_ptr<Media> _media;
const QDateTime _dateTime;
int _y = 0;

View file

@ -10,8 +10,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_message.h"
#include "history/history_item_components.h"
#include "history/history_item_text.h"
#include "history/media/history_media.h"
#include "history/media/history_media_sticker.h"
#include "history/view/media/history_view_media.h"
#include "history/view/media/history_view_sticker.h"
#include "history/view/history_view_context_menu.h"
#include "history/view/history_view_element.h"
#include "history/view/history_view_message.h"
@ -888,7 +888,7 @@ bool ListWidget::requiredToStartDragging(
not_null<Element*> view) const {
if (_mouseCursorState == CursorState::Date) {
return true;
} else if (dynamic_cast<HistorySticker*>(view->media()) != nullptr) {
} else if (dynamic_cast<Sticker*>(view->media()) != nullptr) {
return true;
}
return false;

View file

@ -10,8 +10,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_cursor_state.h"
#include "history/history_item_components.h"
#include "history/history_message.h"
#include "history/media/history_media.h"
#include "history/media/history_media_web_page.h"
#include "history/view/media/history_view_media.h"
#include "history/view/media/history_view_web_page.h"
#include "history/history.h"
#include "ui/toast/toast.h"
#include "data/data_session.h"
@ -1301,11 +1301,11 @@ void Message::initLogEntryOriginal() {
if (const auto log = message()->Get<HistoryMessageLogEntryOriginal>()) {
AddComponents(LogEntryOriginal::Bit());
const auto entry = Get<LogEntryOriginal>();
entry->page = std::make_unique<HistoryWebPage>(this, log->page);
entry->page = std::make_unique<WebPage>(this, log->page);
}
}
HistoryWebPage *Message::logEntryOriginal() const {
WebPage *Message::logEntryOriginal() const {
if (const auto entry = Get<LogEntryOriginal>()) {
return entry->page.get();
}

View file

@ -14,6 +14,8 @@ struct HistoryMessageEdited;
namespace HistoryView {
class WebPage;
// Special type of Component for the channel actions log.
struct LogEntryOriginal
: public RuntimeComponent<LogEntryOriginal, Element> {
@ -22,7 +24,7 @@ struct LogEntryOriginal
LogEntryOriginal &operator=(LogEntryOriginal &&other);
~LogEntryOriginal();
std::unique_ptr<HistoryWebPage> page;
std::unique_ptr<WebPage> page;
};
@ -147,7 +149,7 @@ private:
int timeLeft() const;
int plainMaxWidth() const;
HistoryWebPage *logEntryOriginal() const;
WebPage *logEntryOriginal() const;
mutable ClickHandlerPtr _rightActionLink;
mutable ClickHandlerPtr _fastReplyLink;

View file

@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history.h"
#include "history/history_service.h"
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
#include "history/history_item_components.h"
#include "history/view/history_view_cursor_state.h"
#include "data/data_abstract_structure.h"

View file

@ -5,7 +5,7 @@ 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 "history/media/history_media_call.h"
#include "history/view/media/history_view_call.h"
#include "lang/lang_keys.h"
#include "layout.h"
@ -17,16 +17,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_media_types.h"
#include "styles/style_history.h"
namespace {
namespace HistoryView {
using TextState = HistoryView::TextState;
} // namespace
HistoryCall::HistoryCall(
Call::Call(
not_null<Element*> parent,
not_null<Data::Call*> call)
: HistoryMedia(parent) {
: Media(parent) {
_duration = call->duration;
_reason = call->finishReason;
@ -48,7 +44,7 @@ HistoryCall::HistoryCall(
}
}
QSize HistoryCall::countOptimalSize() {
QSize Call::countOptimalSize() {
const auto user = _parent->data()->history()->peer->asUser();
_link = std::make_shared<LambdaClickHandler>([=] {
if (user) {
@ -64,7 +60,7 @@ QSize HistoryCall::countOptimalSize() {
return { maxWidth, minHeight };
}
void HistoryCall::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
void Call::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
auto paintx = 0, painty = 0, paintw = width(), painth = height();
@ -102,7 +98,7 @@ void HistoryCall::draw(Painter &p, const QRect &r, TextSelection selection, crl:
icon.paint(p, paintw - st::historyCallIconPosition.x() - icon.width(), st::historyCallIconPosition.y() - topMinus, paintw);
}
TextState HistoryCall::textState(QPoint point, StateRequest request) const {
TextState Call::textState(QPoint point, StateRequest request) const {
auto result = TextState(_parent);
if (QRect(0, 0, width(), height()).contains(point)) {
result.link = _link;
@ -110,3 +106,5 @@ TextState HistoryCall::textState(QPoint point, StateRequest request) const {
}
return result;
}
} // namespace HistoryView

View file

@ -7,16 +7,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
namespace Data {
enum class CallFinishReason : char;
struct Call;
} // namespace Data
class HistoryCall : public HistoryMedia {
namespace HistoryView {
class Call : public Media {
public:
HistoryCall(
Call(
not_null<Element*> parent,
not_null<Data::Call*> call);
@ -53,3 +55,5 @@ private:
ClickHandlerPtr _link;
};
} // namespace HistoryView

View file

@ -5,7 +5,7 @@ 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 "history/media/history_media_contact.h"
#include "history/view/media/history_view_contact.h"
#include "lang/lang_keys.h"
#include "layout.h"
@ -25,12 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "styles/style_history.h"
namespace {
using TextState = HistoryView::TextState;
} // namespace
namespace HistoryView {
namespace {
ClickHandlerPtr sendMessageClickHandler(PeerData *peer) {
@ -61,13 +56,13 @@ ClickHandlerPtr addContactClickHandler(not_null<HistoryItem*> item) {
} // namespace
HistoryContact::HistoryContact(
Contact::Contact(
not_null<Element*> parent,
UserId userId,
const QString &first,
const QString &last,
const QString &phone)
: HistoryMedia(parent)
: Media(parent)
, _userId(userId)
, _fname(first)
, _lname(last)
@ -81,11 +76,11 @@ HistoryContact::HistoryContact(
_phonew = st::normalFont->width(_phone);
}
HistoryContact::~HistoryContact() {
Contact::~Contact() {
history()->owner().unregisterContactView(_userId, _parent);
}
void HistoryContact::updateSharedContactUserId(UserId userId) {
void Contact::updateSharedContactUserId(UserId userId) {
if (_userId != userId) {
history()->owner().unregisterContactView(_userId, _parent);
_userId = userId;
@ -93,7 +88,7 @@ void HistoryContact::updateSharedContactUserId(UserId userId) {
}
}
QSize HistoryContact::countOptimalSize() {
QSize Contact::countOptimalSize() {
const auto item = _parent->data();
auto maxWidth = st::msgFileMinWidth;
@ -149,7 +144,7 @@ QSize HistoryContact::countOptimalSize() {
return { maxWidth, minHeight };
}
void HistoryContact::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
void Contact::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
auto paintx = 0, painty = 0, paintw = width(), painth = height();
@ -204,7 +199,7 @@ void HistoryContact::draw(Painter &p, const QRect &r, TextSelection selection, c
p.drawTextLeft(nameleft, statustop, paintw, _phone);
}
TextState HistoryContact::textState(QPoint point, StateRequest request) const {
TextState Contact::textState(QPoint point, StateRequest request) const {
auto result = TextState(_parent);
auto nameleft = 0, nametop = 0, nameright = 0, statustop = 0, linktop = 0;
@ -223,3 +218,5 @@ TextState HistoryContact::textState(QPoint point, StateRequest request) const {
}
return result;
}
} // namespace HistoryView

View file

@ -7,21 +7,23 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
namespace Ui {
class EmptyUserpic;
} // namespace Ui
class HistoryContact : public HistoryMedia {
namespace HistoryView {
class Contact : public Media {
public:
HistoryContact(
Contact(
not_null<Element*> parent,
UserId userId,
const QString &first,
const QString &last,
const QString &phone);
~HistoryContact();
~Contact();
void draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const override;
TextState textState(QPoint point, StateRequest request) const override;
@ -69,3 +71,5 @@ private:
QString _link;
};
} // namespace HistoryView

View file

@ -5,7 +5,7 @@ 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 "history/media/history_media_document.h"
#include "history/view/media/history_view_document.h"
#include "lang/lang_keys.h"
#include "layout.h"
@ -16,25 +16,24 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history.h"
#include "history/view/history_view_element.h"
#include "history/view/history_view_cursor_state.h"
#include "history/media/history_media_common.h"
#include "history/view/media/history_view_media_common.h"
#include "ui/image/image.h"
#include "data/data_session.h"
#include "data/data_document.h"
#include "data/data_media_types.h"
#include "styles/style_history.h"
namespace HistoryView {
namespace {
constexpr auto kAudioVoiceMsgUpdateView = crl::time(100);
using TextState = HistoryView::TextState;
} // namespace
HistoryDocument::HistoryDocument(
Document::Document(
not_null<Element*> parent,
not_null<DocumentData*> document)
: HistoryFileMedia(parent, parent->data())
: File(parent, parent->data())
, _data(document) {
const auto item = parent->data();
auto caption = createCaption(item);
@ -53,19 +52,19 @@ HistoryDocument::HistoryDocument(
}
}
float64 HistoryDocument::dataProgress() const {
float64 Document::dataProgress() const {
return _data->progress();
}
bool HistoryDocument::dataFinished() const {
bool Document::dataFinished() const {
return !_data->loading() && !_data->uploading();
}
bool HistoryDocument::dataLoaded() const {
bool Document::dataLoaded() const {
return _data->loaded();
}
void HistoryDocument::createComponents(bool caption) {
void Document::createComponents(bool caption) {
uint64 mask = 0;
if (_data->isVoiceMessage()) {
mask |= HistoryDocumentVoice::Bit();
@ -102,12 +101,12 @@ void HistoryDocument::createComponents(bool caption) {
}
}
void HistoryDocument::fillNamedFromData(HistoryDocumentNamed *named) {
void Document::fillNamedFromData(HistoryDocumentNamed *named) {
const auto nameString = named->_name = _data->composeNameString();
named->_namew = st::semiboldFont->width(nameString);
}
QSize HistoryDocument::countOptimalSize() {
QSize Document::countOptimalSize() {
const auto item = _parent->data();
auto captioned = Get<HistoryDocumentCaptioned>();
@ -180,10 +179,10 @@ QSize HistoryDocument::countOptimalSize() {
return { maxWidth, minHeight };
}
QSize HistoryDocument::countCurrentSize(int newWidth) {
QSize Document::countCurrentSize(int newWidth) {
auto captioned = Get<HistoryDocumentCaptioned>();
if (!captioned) {
return HistoryFileMedia::countCurrentSize(newWidth);
return File::countCurrentSize(newWidth);
}
accumulate_min(newWidth, maxWidth());
@ -205,7 +204,7 @@ QSize HistoryDocument::countCurrentSize(int newWidth) {
return { newWidth, newHeight };
}
void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
void Document::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
const auto cornerDownload = downloadInCorner();
@ -380,7 +379,7 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection,
// rescale waveform by going in waveform.size * bar_count 1D grid
auto active = outbg ? (selected ? st::msgWaveformOutActiveSelected : st::msgWaveformOutActive) : (selected ? st::msgWaveformInActiveSelected : st::msgWaveformInActive);
auto inactive = outbg ? (selected ? st::msgWaveformOutInactiveSelected : st::msgWaveformOutInactive) : (selected ? st::msgWaveformInInactiveSelected : st::msgWaveformInInactive);
auto wf_size = wf ? wf->size() : Media::Player::kWaveformSamplesCount;
auto wf_size = wf ? wf->size() : ::Media::Player::kWaveformSamplesCount;
auto availw = namewidth + st::msgWaveformSkip;
auto activew = qRound(availw * progress);
if (!outbg
@ -458,14 +457,14 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection,
}
}
bool HistoryDocument::downloadInCorner() const {
bool Document::downloadInCorner() const {
return _data->isAudioFile()
&& _data->canBeStreamed()
&& !_data->inappPlaybackFailed()
&& IsServerMsgId(_parent->data()->id);
}
void HistoryDocument::drawCornerDownload(Painter &p, bool selected) const {
void Document::drawCornerDownload(Painter &p, bool selected) const {
if (_data->loaded() || !downloadInCorner()) {
return;
}
@ -502,7 +501,7 @@ void HistoryDocument::drawCornerDownload(Painter &p, bool selected) const {
}
}
TextState HistoryDocument::cornerDownloadTextState(
TextState Document::cornerDownloadTextState(
QPoint point,
StateRequest request) const {
auto result = TextState(_parent);
@ -520,7 +519,7 @@ TextState HistoryDocument::cornerDownloadTextState(
}
TextState HistoryDocument::textState(QPoint point, StateRequest request) const {
TextState Document::textState(QPoint point, StateRequest request) const {
auto result = TextState(_parent);
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) {
@ -576,9 +575,9 @@ TextState HistoryDocument::textState(QPoint point, StateRequest request) const {
auto namewidth = width() - nameleft - nameright;
auto waveformbottom = st::msgFilePadding.top() - topMinus + st::msgWaveformMax + st::msgWaveformMin;
if (QRect(nameleft, nametop, namewidth, waveformbottom - nametop).contains(point)) {
const auto state = Media::Player::instance()->getState(AudioMsgId::Type::Voice);
const auto state = ::Media::Player::instance()->getState(AudioMsgId::Type::Voice);
if (state.id == AudioMsgId(_data, _parent->data()->fullId(), state.id.externalPlayId())
&& !Media::Player::IsStoppedOrStopping(state.state)) {
&& !::Media::Player::IsStoppedOrStopping(state.state)) {
if (!voice->seeking()) {
voice->setSeekingStart((point.x() - nameleft) / float64(namewidth));
}
@ -617,7 +616,7 @@ TextState HistoryDocument::textState(QPoint point, StateRequest request) const {
return result;
}
void HistoryDocument::updatePressed(QPoint point) {
void Document::updatePressed(QPoint point) {
if (auto voice = Get<HistoryDocumentVoice>()) {
if (voice->seeking()) {
auto nameleft = 0, nameright = 0;
@ -634,7 +633,7 @@ void HistoryDocument::updatePressed(QPoint point) {
}
}
TextSelection HistoryDocument::adjustSelection(
TextSelection Document::adjustSelection(
TextSelection selection,
TextSelectType type) const {
if (const auto captioned = Get<HistoryDocumentCaptioned>()) {
@ -643,18 +642,18 @@ TextSelection HistoryDocument::adjustSelection(
return selection;
}
uint16 HistoryDocument::fullSelectionLength() const {
uint16 Document::fullSelectionLength() const {
if (const auto captioned = Get<HistoryDocumentCaptioned>()) {
return captioned->_caption.length();
}
return 0;
}
bool HistoryDocument::hasTextForCopy() const {
bool Document::hasTextForCopy() const {
return Has<HistoryDocumentCaptioned>();
}
TextForMimeData HistoryDocument::selectedText(TextSelection selection) const {
TextForMimeData Document::selectedText(TextSelection selection) const {
if (const auto captioned = Get<HistoryDocumentCaptioned>()) {
const auto &caption = captioned->_caption;
return captioned->_caption.toTextForMimeData(selection);
@ -662,17 +661,17 @@ TextForMimeData HistoryDocument::selectedText(TextSelection selection) const {
return TextForMimeData();
}
bool HistoryDocument::uploading() const {
bool Document::uploading() const {
return _data->uploading();
}
void HistoryDocument::setStatusSize(int newSize, qint64 realDuration) const {
void Document::setStatusSize(int newSize, qint64 realDuration) const {
auto duration = _data->isSong()
? _data->song()->duration
: (_data->isVoiceMessage()
? _data->voice()->duration
: -1);
HistoryFileMedia::setStatusSize(newSize, _data->size, duration, realDuration);
File::setStatusSize(newSize, _data->size, duration, realDuration);
if (auto thumbed = Get<HistoryDocumentThumbed>()) {
if (_statusSize == FileStatusSizeReady) {
thumbed->_link = tr::lng_media_download(tr::now).toUpper();
@ -689,7 +688,7 @@ void HistoryDocument::setStatusSize(int newSize, qint64 realDuration) const {
}
}
bool HistoryDocument::updateStatusText() const {
bool Document::updateStatusText() const {
auto showPause = false;
auto statusSize = 0;
auto realDuration = 0;
@ -706,9 +705,9 @@ bool HistoryDocument::updateStatusText() const {
}
if (_data->isVoiceMessage()) {
const auto state = Media::Player::instance()->getState(AudioMsgId::Type::Voice);
const auto state = ::Media::Player::instance()->getState(AudioMsgId::Type::Voice);
if (state.id == AudioMsgId(_data, _parent->data()->fullId(), state.id.externalPlayId())
&& !Media::Player::IsStoppedOrStopping(state.state)) {
&& !::Media::Player::IsStoppedOrStopping(state.state)) {
if (auto voice = Get<HistoryDocumentVoice>()) {
bool was = (voice->_playback != nullptr);
voice->ensurePlayback(this);
@ -727,26 +726,26 @@ bool HistoryDocument::updateStatusText() const {
statusSize = -1 - (state.position / state.frequency);
realDuration = (state.length / state.frequency);
showPause = Media::Player::ShowPauseIcon(state.state);
showPause = ::Media::Player::ShowPauseIcon(state.state);
} else {
if (auto voice = Get<HistoryDocumentVoice>()) {
voice->checkPlaybackFinished();
}
}
if (!showPause && (state.id == AudioMsgId(_data, _parent->data()->fullId(), state.id.externalPlayId()))) {
showPause = Media::Player::instance()->isSeeking(AudioMsgId::Type::Voice);
showPause = ::Media::Player::instance()->isSeeking(AudioMsgId::Type::Voice);
}
} else if (_data->isAudioFile()) {
const auto state = Media::Player::instance()->getState(AudioMsgId::Type::Song);
const auto state = ::Media::Player::instance()->getState(AudioMsgId::Type::Song);
if (state.id == AudioMsgId(_data, _parent->data()->fullId(), state.id.externalPlayId())
&& !Media::Player::IsStoppedOrStopping(state.state)) {
&& !::Media::Player::IsStoppedOrStopping(state.state)) {
statusSize = -1 - (state.position / state.frequency);
realDuration = (state.length / state.frequency);
showPause = Media::Player::ShowPauseIcon(state.state);
showPause = ::Media::Player::ShowPauseIcon(state.state);
} else {
}
if (!showPause && (state.id == AudioMsgId(_data, _parent->data()->fullId(), state.id.externalPlayId()))) {
showPause = Media::Player::instance()->isSeeking(AudioMsgId::Type::Song);
showPause = ::Media::Player::instance()->isSeeking(AudioMsgId::Type::Song);
}
}
@ -756,15 +755,15 @@ bool HistoryDocument::updateStatusText() const {
return showPause;
}
QMargins HistoryDocument::bubbleMargins() const {
QMargins Document::bubbleMargins() const {
return Get<HistoryDocumentThumbed>() ? QMargins(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top(), st::msgFileThumbPadding.left(), st::msgFileThumbPadding.bottom()) : st::msgPadding;
}
bool HistoryDocument::hideForwardedFrom() const {
bool Document::hideForwardedFrom() const {
return _data->isSong();
}
bool HistoryDocument::voiceProgressAnimationCallback(crl::time now) {
bool Document::voiceProgressAnimationCallback(crl::time now) {
if (anim::Disabled()) {
now += (2 * kAudioVoiceMsgUpdateView);
}
@ -785,16 +784,16 @@ bool HistoryDocument::voiceProgressAnimationCallback(crl::time now) {
return false;
}
void HistoryDocument::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) {
void Document::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) {
if (auto voice = Get<HistoryDocumentVoice>()) {
if (pressed && p == voice->_seekl && !voice->seeking()) {
voice->startSeeking();
} else if (!pressed && voice->seeking()) {
const auto type = AudioMsgId::Type::Voice;
const auto state = Media::Player::instance()->getState(type);
const auto state = ::Media::Player::instance()->getState(type);
if (state.id == AudioMsgId(_data, _parent->data()->fullId(), state.id.externalPlayId()) && state.length) {
const auto currentProgress = voice->seekingCurrent();
Media::Player::instance()->finishSeeking(
::Media::Player::instance()->finishSeeking(
AudioMsgId::Type::Voice,
currentProgress);
@ -805,11 +804,11 @@ void HistoryDocument::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool
voice->stopSeeking();
}
}
HistoryFileMedia::clickHandlerPressedChanged(p, pressed);
File::clickHandlerPressedChanged(p, pressed);
}
void HistoryDocument::refreshParentId(not_null<HistoryItem*> realParent) {
HistoryFileMedia::refreshParentId(realParent);
void Document::refreshParentId(not_null<HistoryItem*> realParent) {
File::refreshParentId(realParent);
const auto fullId = realParent->fullId();
if (auto thumbed = Get<HistoryDocumentThumbed>()) {
@ -825,7 +824,7 @@ void HistoryDocument::refreshParentId(not_null<HistoryItem*> realParent) {
}
}
void HistoryDocument::parentTextUpdated() {
void Document::parentTextUpdated() {
auto caption = (_parent->media() == this)
? createCaption(_parent->data())
: Ui::Text::String();
@ -839,9 +838,11 @@ void HistoryDocument::parentTextUpdated() {
history()->owner().requestViewResize(_parent);
}
TextWithEntities HistoryDocument::getCaption() const {
TextWithEntities Document::getCaption() const {
if (const auto captioned = Get<HistoryDocumentCaptioned>()) {
return captioned->_caption.toTextWithEntities();
}
return TextWithEntities();
}
} // namespace HistoryView

View file

@ -7,16 +7,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/media/history_media_file.h"
#include "history/view/media/history_view_file.h"
#include "base/runtime_composer.h"
struct HistoryDocumentNamed;
class HistoryDocument
: public HistoryFileMedia
, public RuntimeComposer<HistoryDocument> {
namespace HistoryView {
class Document
: public File
, public RuntimeComposer<Document> {
public:
HistoryDocument(
Document(
not_null<Element*> parent,
not_null<DocumentData*> document);
@ -85,3 +87,5 @@ private:
not_null<DocumentData*> _data;
};
} // namespace HistoryView

View file

@ -5,7 +5,7 @@ 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 "history/media/history_media_file.h"
#include "history/view/media/history_view_file.h"
#include "lang/lang_keys.h"
#include "layout.h"
@ -15,7 +15,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h"
#include "styles/style_history.h"
void HistoryFileMedia::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) {
namespace HistoryView {
void File::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) {
if (p == _savel || p == _cancell) {
if (active && !dataLoaded()) {
ensureAnimation();
@ -26,17 +28,17 @@ void HistoryFileMedia::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool
}
}
void HistoryFileMedia::thumbAnimationCallback() {
void File::thumbAnimationCallback() {
history()->owner().requestViewRepaint(_parent);
}
void HistoryFileMedia::clickHandlerPressedChanged(
void File::clickHandlerPressedChanged(
const ClickHandlerPtr &handler,
bool pressed) {
history()->owner().requestViewRepaint(_parent);
}
void HistoryFileMedia::setLinks(
void File::setLinks(
FileClickHandlerPtr &&openl,
FileClickHandlerPtr &&savel,
FileClickHandlerPtr &&cancell) {
@ -45,14 +47,14 @@ void HistoryFileMedia::setLinks(
_cancell = std::move(cancell);
}
void HistoryFileMedia::refreshParentId(not_null<HistoryItem*> realParent) {
void File::refreshParentId(not_null<HistoryItem*> realParent) {
const auto contextId = realParent->fullId();
_openl->setMessageId(contextId);
_savel->setMessageId(contextId);
_cancell->setMessageId(contextId);
}
void HistoryFileMedia::setStatusSize(int newSize, int fullSize, int duration, qint64 realDuration) const {
void File::setStatusSize(int newSize, int fullSize, int duration, qint64 realDuration) const {
_statusSize = newSize;
if (_statusSize == FileStatusSizeReady) {
_statusText = (duration >= 0) ? formatDurationAndSizeText(duration, fullSize) : (duration < -1 ? formatGifAndSizeText(fullSize) : formatSizeText(fullSize));
@ -67,7 +69,7 @@ void HistoryFileMedia::setStatusSize(int newSize, int fullSize, int duration, qi
}
}
void HistoryFileMedia::radialAnimationCallback(crl::time now) const {
void File::radialAnimationCallback(crl::time now) const {
const auto updated = [&] {
return _animation->radial.update(
dataProgress(),
@ -82,7 +84,7 @@ void HistoryFileMedia::radialAnimationCallback(crl::time now) const {
}
}
void HistoryFileMedia::ensureAnimation() const {
void File::ensureAnimation() const {
if (!_animation) {
_animation = std::make_unique<AnimationData>([=](crl::time now) {
radialAnimationCallback(now);
@ -90,14 +92,14 @@ void HistoryFileMedia::ensureAnimation() const {
}
}
void HistoryFileMedia::checkAnimationFinished() const {
void File::checkAnimationFinished() const {
if (_animation && !_animation->a_thumbOver.animating() && !_animation->radial.animating()) {
if (dataLoaded()) {
_animation.reset();
}
}
}
void HistoryFileMedia::setDocumentLinks(
void File::setDocumentLinks(
not_null<DocumentData*> document,
not_null<HistoryItem*> realParent) {
const auto context = realParent->fullId();
@ -107,4 +109,6 @@ void HistoryFileMedia::setDocumentLinks(
std::make_shared<DocumentCancelClickHandler>(document, context));
}
HistoryFileMedia::~HistoryFileMedia() = default;
File::~File() = default;
} // namespace HistoryView

View file

@ -7,16 +7,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
#include "ui/effects/animations.h"
#include "ui/effects/radial_animation.h"
class HistoryFileMedia : public HistoryMedia {
namespace HistoryView {
class File : public Media {
public:
HistoryFileMedia(
File(
not_null<Element*> parent,
not_null<HistoryItem*> realParent)
: HistoryMedia(parent)
: Media(parent)
, _realParent(realParent) {
}
@ -36,7 +38,7 @@ public:
return true;
}
~HistoryFileMedia();
~File();
protected:
using FileClickHandlerPtr = std::shared_ptr<FileClickHandler>;
@ -104,3 +106,5 @@ protected:
mutable std::unique_ptr<AnimationData> _animation;
};
} // namespace HistoryView

View file

@ -5,7 +5,7 @@ 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 "history/media/history_media_game.h"
#include "history/view/media/history_view_game.h"
#include "lang/lang_keys.h"
#include "layout.h"
@ -13,24 +13,20 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history.h"
#include "history/view/history_view_element.h"
#include "history/view/history_view_cursor_state.h"
#include "history/media/history_media_common.h"
#include "history/view/media/history_view_media_common.h"
#include "ui/text_options.h"
#include "data/data_session.h"
#include "data/data_game.h"
#include "data/data_media_types.h"
#include "styles/style_history.h"
namespace {
namespace HistoryView {
using TextState = HistoryView::TextState;
} // namespace
HistoryGame::HistoryGame(
Game::Game(
not_null<Element*> parent,
not_null<GameData*> data,
const TextWithEntities &consumed)
: HistoryMedia(parent)
: Media(parent)
, _data(data)
, _title(st::msgMinWidth - st::webPageLeft)
, _description(st::msgMinWidth - st::webPageLeft) {
@ -43,7 +39,7 @@ HistoryGame::HistoryGame(
history()->owner().registerGameView(_data, _parent);
}
QSize HistoryGame::countOptimalSize() {
QSize Game::countOptimalSize() {
auto lineHeight = unitedLineHeight();
const auto item = _parent->data();
@ -128,7 +124,7 @@ QSize HistoryGame::countOptimalSize() {
return { maxWidth, minHeight };
}
void HistoryGame::refreshParentId(not_null<HistoryItem*> realParent) {
void Game::refreshParentId(not_null<HistoryItem*> realParent) {
if (_openl) {
_openl->setMessageId(realParent->fullId());
}
@ -137,7 +133,7 @@ void HistoryGame::refreshParentId(not_null<HistoryItem*> realParent) {
}
}
QSize HistoryGame::countCurrentSize(int newWidth) {
QSize Game::countCurrentSize(int newWidth) {
accumulate_min(newWidth, maxWidth());
auto innerWidth = newWidth - st::msgPadding.left() - st::webPageLeft - st::msgPadding.right();
@ -186,17 +182,17 @@ QSize HistoryGame::countCurrentSize(int newWidth) {
return { newWidth, newHeight };
}
TextSelection HistoryGame::toDescriptionSelection(
TextSelection Game::toDescriptionSelection(
TextSelection selection) const {
return HistoryView::UnshiftItemSelection(selection, _title);
return UnshiftItemSelection(selection, _title);
}
TextSelection HistoryGame::fromDescriptionSelection(
TextSelection Game::fromDescriptionSelection(
TextSelection selection) const {
return HistoryView::ShiftItemSelection(selection, _title);
return ShiftItemSelection(selection, _title);
}
void HistoryGame::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
void Game::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
auto paintw = width(), painth = height();
@ -268,7 +264,7 @@ void HistoryGame::draw(Painter &p, const QRect &r, TextSelection selection, crl:
}
}
TextState HistoryGame::textState(QPoint point, StateRequest request) const {
TextState Game::textState(QPoint point, StateRequest request) const {
auto result = TextState(_parent);
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) {
@ -343,7 +339,7 @@ TextState HistoryGame::textState(QPoint point, StateRequest request) const {
return result;
}
TextSelection HistoryGame::adjustSelection(TextSelection selection, TextSelectType type) const {
TextSelection Game::adjustSelection(TextSelection selection, TextSelectType type) const {
if (!_descriptionLines || selection.to <= _title.length()) {
return _title.adjustSelection(selection, type);
}
@ -355,19 +351,19 @@ TextSelection HistoryGame::adjustSelection(TextSelection selection, TextSelectTy
return { titleSelection.from, fromDescriptionSelection(descriptionSelection).to };
}
void HistoryGame::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) {
void Game::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) {
if (_attach) {
_attach->clickHandlerActiveChanged(p, active);
}
}
void HistoryGame::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) {
void Game::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) {
if (_attach) {
_attach->clickHandlerPressedChanged(p, pressed);
}
}
TextForMimeData HistoryGame::selectedText(TextSelection selection) const {
TextForMimeData Game::selectedText(TextSelection selection) const {
auto titleResult = _title.toTextForMimeData(selection);
auto descriptionResult = _description.toTextForMimeData(
toDescriptionSelection(selection));
@ -379,7 +375,7 @@ TextForMimeData HistoryGame::selectedText(TextSelection selection) const {
return titleResult.append('\n').append(std::move(descriptionResult));
}
void HistoryGame::playAnimation(bool autoplay) {
void Game::playAnimation(bool autoplay) {
if (_attach) {
if (autoplay) {
_attach->autoplayAnimation();
@ -389,7 +385,7 @@ void HistoryGame::playAnimation(bool autoplay) {
}
}
QMargins HistoryGame::inBubblePadding() const {
QMargins Game::inBubblePadding() const {
auto lshift = st::msgPadding.left() + st::webPageLeft;
auto rshift = st::msgPadding.right();
auto bshift = isBubbleBottom() ? st::msgPadding.left() : st::mediaInBubbleSkip;
@ -397,7 +393,7 @@ QMargins HistoryGame::inBubblePadding() const {
return QMargins(lshift, tshift, rshift, bshift);
}
int HistoryGame::bottomInfoPadding() const {
int Game::bottomInfoPadding() const {
if (!isBubbleBottom()) return 0;
auto result = st::msgDateFont->height;
@ -411,7 +407,7 @@ int HistoryGame::bottomInfoPadding() const {
return result;
}
void HistoryGame::parentTextUpdated() {
void Game::parentTextUpdated() {
if (const auto media = _parent->data()->media()) {
const auto consumed = media->consumedMessageText();
if (!consumed.text.isEmpty()) {
@ -426,6 +422,8 @@ void HistoryGame::parentTextUpdated() {
}
}
HistoryGame::~HistoryGame() {
Game::~Game() {
history()->owner().unregisterGameView(_data, _parent);
}
} // namespace HistoryView

View file

@ -7,13 +7,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
class ReplyMarkupClickHandler;
class HistoryGame : public HistoryMedia {
namespace HistoryView {
class Game : public Media {
public:
HistoryGame(
Game(
not_null<Element*> parent,
not_null<GameData*> data,
const TextWithEntities &consumed);
@ -69,13 +71,13 @@ public:
return true;
}
HistoryMedia *attach() const {
Media *attach() const {
return _attach.get();
}
void parentTextUpdated() override;
~HistoryGame();
~Game();
private:
void playAnimation(bool autoplay) override;
@ -89,7 +91,7 @@ private:
not_null<GameData*> _data;
std::shared_ptr<ReplyMarkupClickHandler> _openl;
std::unique_ptr<HistoryMedia> _attach;
std::unique_ptr<Media> _attach;
int _titleLines, _descriptionLines;
@ -98,3 +100,5 @@ private:
int _gameTagWidth = 0;
};
} // namespace HistoryView

View file

@ -5,7 +5,7 @@ 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 "history/media/history_media_gif.h"
#include "history/view/media/history_view_gif.h"
#include "lang/lang_keys.h"
#include "layout.h"
@ -29,12 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_document.h"
#include "styles/style_history.h"
namespace {
using TextState = HistoryView::TextState;
} // namespace
namespace HistoryView {
namespace {
constexpr auto kMaxGifForwardedBarLines = 4;
@ -47,10 +42,10 @@ int gifMaxStatusWidth(DocumentData *document) {
} // namespace
HistoryGif::HistoryGif(
Gif::Gif(
not_null<Element*> parent,
not_null<DocumentData*> document)
: HistoryFileMedia(parent, parent->data())
: File(parent, parent->data())
, _data(document)
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) {
const auto item = parent->data();
@ -62,7 +57,7 @@ HistoryGif::HistoryGif(
_data->loadThumbnail(item->fullId());
}
QSize HistoryGif::countOptimalSize() {
QSize Gif::countOptimalSize() {
if (_parent->media() != this) {
_caption = Ui::Text::String();
} else if (_caption.hasSkipBlock()) {
@ -70,11 +65,11 @@ QSize HistoryGif::countOptimalSize() {
_parent->skipBlockWidth(),
_parent->skipBlockHeight());
}
if (_gif && _gif->state() == Media::Clip::State::Error) {
if (_gif && _gif->state() == ::Media::Clip::State::Error) {
if (!_gif->autoplay()) {
Ui::show(Box<InformBox>(tr::lng_gif_error(tr::now)));
}
setClipReader(Media::Clip::ReaderPointer::Bad());
setClipReader(::Media::Clip::ReaderPointer::Bad());
}
const auto maxSize = _data->isVideoMessage()
@ -123,7 +118,7 @@ QSize HistoryGif::countOptimalSize() {
return { maxWidth, minHeight };
}
QSize HistoryGif::countCurrentSize(int newWidth) {
QSize Gif::countCurrentSize(int newWidth) {
auto availableWidth = newWidth;
const auto maxSize = _data->isVideoMessage()
@ -156,7 +151,7 @@ QSize HistoryGif::countCurrentSize(int newWidth) {
accumulate_max(newWidth, _parent->infoWidth() + 2 * st::msgDateImgDelta + st::msgDateImgPadding.x());
const auto reader = activeRoundPlayer() ? nullptr : currentReader();
if (reader) {
const auto own = (reader->mode() == Media::Clip::Reader::Mode::Gif);
const auto own = (reader->mode() == ::Media::Clip::Reader::Mode::Gif);
if (own && !reader->started()) {
auto isRound = _data->isVideoMessage();
auto inWebPage = (_parent->media() != this);
@ -215,7 +210,7 @@ QSize HistoryGif::countCurrentSize(int newWidth) {
return { newWidth, newHeight };
}
QSize HistoryGif::videoSize() const {
QSize Gif::videoSize() const {
if (const auto player = activeRoundPlayer()) {
return player->videoSize();
} else if (const auto reader = currentReader()) {
@ -229,11 +224,11 @@ QSize HistoryGif::videoSize() const {
}
}
bool HistoryGif::autoplayEnabled() const {
bool Gif::autoplayEnabled() const {
return history()->session().settings().autoplayGifs();
}
void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
const auto item = _parent->data();
@ -311,7 +306,7 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, crl::
}
}
if (player) {
auto request = Media::Streaming::FrameRequest();
auto request = ::Media::Streaming::FrameRequest();
request.outer = QSize(usew, painth) * cIntRetinaFactor();
request.resize = QSize(_thumbw, _thumbh) * cIntRetinaFactor();
request.corners = roundCorners;
@ -537,7 +532,7 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, crl::
}
}
TextState HistoryGif::textState(QPoint point, StateRequest request) const {
TextState Gif::textState(QPoint point, StateRequest request) const {
auto result = TextState(_parent);
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) {
@ -685,15 +680,15 @@ TextState HistoryGif::textState(QPoint point, StateRequest request) const {
return result;
}
TextForMimeData HistoryGif::selectedText(TextSelection selection) const {
TextForMimeData Gif::selectedText(TextSelection selection) const {
return _caption.toTextForMimeData(selection);
}
bool HistoryGif::uploading() const {
bool Gif::uploading() const {
return _data->uploading();
}
bool HistoryGif::needsBubble() const {
bool Gif::needsBubble() const {
if (_data->isVideoMessage()) {
return false;
}
@ -708,7 +703,7 @@ bool HistoryGif::needsBubble() const {
return false;
}
int HistoryGif::additionalWidth() const {
int Gif::additionalWidth() const {
const auto item = _parent->data();
return additionalWidth(
item->Get<HistoryMessageVia>(),
@ -716,19 +711,19 @@ int HistoryGif::additionalWidth() const {
item->Get<HistoryMessageForwarded>());
}
QString HistoryGif::mediaTypeString() const {
QString Gif::mediaTypeString() const {
return _data->isVideoMessage()
? tr::lng_in_dlg_video_message(tr::now)
: qsl("GIF");
}
bool HistoryGif::isSeparateRoundVideo() const {
bool Gif::isSeparateRoundVideo() const {
return _data->isVideoMessage()
&& (_parent->media() == this)
&& !_parent->hasBubble();
}
void HistoryGif::setStatusSize(int newSize) const {
void Gif::setStatusSize(int newSize) const {
if (_data->isVideoMessage()) {
_statusSize = newSize;
if (newSize < 0) {
@ -737,11 +732,11 @@ void HistoryGif::setStatusSize(int newSize) const {
_statusText = formatDurationText(_data->getDuration());
}
} else {
HistoryFileMedia::setStatusSize(newSize, _data->size, -2, 0);
File::setStatusSize(newSize, _data->size, -2, 0);
}
}
void HistoryGif::updateStatusText() const {
void Gif::updateStatusText() const {
auto showPause = false;
auto statusSize = 0;
auto realDuration = 0;
@ -757,9 +752,9 @@ void HistoryGif::updateStatusText() const {
const auto state = video->prepareLegacyState();
if (state.length) {
auto position = int64(0);
if (Media::Player::IsStoppedAtEnd(state.state)) {
if (::Media::Player::IsStoppedAtEnd(state.state)) {
position = state.length;
} else if (!Media::Player::IsStoppedOrStopping(state.state)) {
} else if (!::Media::Player::IsStoppedOrStopping(state.state)) {
position = state.position;
}
statusSize = -1 - int((state.length - position) / state.frequency + 1);
@ -775,7 +770,7 @@ void HistoryGif::updateStatusText() const {
}
}
QString HistoryGif::additionalInfoString() const {
QString Gif::additionalInfoString() const {
if (_data->isVideoMessage()) {
updateStatusText();
return _statusText;
@ -783,18 +778,18 @@ QString HistoryGif::additionalInfoString() const {
return QString();
}
bool HistoryGif::isReadyForOpen() const {
bool Gif::isReadyForOpen() const {
return _data->loaded();
}
void HistoryGif::parentTextUpdated() {
void Gif::parentTextUpdated() {
_caption = (_parent->media() == this)
? createCaption(_parent->data())
: Ui::Text::String();
history()->owner().requestViewResize(_parent);
}
int HistoryGif::additionalWidth(const HistoryMessageVia *via, const HistoryMessageReply *reply, const HistoryMessageForwarded *forwarded) const {
int Gif::additionalWidth(const HistoryMessageVia *via, const HistoryMessageReply *reply, const HistoryMessageForwarded *forwarded) const {
int result = 0;
if (forwarded) {
accumulate_max(result, st::msgReplyPadding.left() + st::msgReplyPadding.left() + forwarded->text.maxWidth() + st::msgReplyPadding.right());
@ -807,20 +802,20 @@ int HistoryGif::additionalWidth(const HistoryMessageVia *via, const HistoryMessa
return result;
}
Media::Streaming::Player *HistoryGif::activeRoundPlayer() const {
return Media::Player::instance()->roundVideoPlayer(_parent->data());
::Media::Streaming::Player *Gif::activeRoundPlayer() const {
return ::Media::Player::instance()->roundVideoPlayer(_parent->data());
}
Media::Clip::Reader *HistoryGif::currentReader() const {
::Media::Clip::Reader *Gif::currentReader() const {
return (_gif && _gif->ready()) ? _gif.get() : nullptr;
}
Media::View::PlaybackProgress *HistoryGif::videoPlayback() const {
return Media::Player::instance()->roundVideoPlayback(_parent->data());
::Media::View::PlaybackProgress *Gif::videoPlayback() const {
return ::Media::Player::instance()->roundVideoPlayback(_parent->data());
}
void HistoryGif::clipCallback(Media::Clip::Notification notification) {
using namespace Media::Clip;
void Gif::clipCallback(::Media::Clip::Notification notification) {
using namespace ::Media::Clip;
const auto reader = _gif.get();
if (!reader) {
@ -852,7 +847,7 @@ void HistoryGif::clipCallback(Media::Clip::Notification notification) {
}
}
void HistoryGif::playAnimation(bool autoplay) {
void Gif::playAnimation(bool autoplay) {
if (_data->isVideoMessage() && !autoplay) {
return;
} else if (_gif && autoplay) {
@ -861,14 +856,14 @@ void HistoryGif::playAnimation(bool autoplay) {
Core::App().showDocument(_data, _parent->data());
return;
}
using Mode = Media::Clip::Reader::Mode;
using Mode = ::Media::Clip::Reader::Mode;
if (_gif) {
stopAnimation();
} else if (_data->loaded(DocumentData::FilePathResolve::Checked)) {
if (!autoplayEnabled()) {
history()->owner().stopAutoplayAnimations();
}
setClipReader(Media::Clip::MakeReader(
setClipReader(::Media::Clip::MakeReader(
_data,
_parent->data()->fullId(),
[=](auto notification) { clipCallback(notification); },
@ -879,7 +874,7 @@ void HistoryGif::playAnimation(bool autoplay) {
}
}
void HistoryGif::stopAnimation() {
void Gif::stopAnimation() {
if (_gif) {
clearClipReader();
history()->owner().requestViewResize(_parent);
@ -887,7 +882,7 @@ void HistoryGif::stopAnimation() {
}
}
void HistoryGif::setClipReader(Media::Clip::ReaderPointer gif) {
void Gif::setClipReader(::Media::Clip::ReaderPointer gif) {
if (_gif) {
history()->owner().unregisterAutoplayAnimation(_gif.get());
}
@ -897,26 +892,28 @@ void HistoryGif::setClipReader(Media::Clip::ReaderPointer gif) {
}
}
HistoryGif::~HistoryGif() {
Gif::~Gif() {
clearClipReader();
}
float64 HistoryGif::dataProgress() const {
float64 Gif::dataProgress() const {
return (_data->uploading() || _parent->data()->id > 0)
? _data->progress()
: 0;
}
bool HistoryGif::dataFinished() const {
bool Gif::dataFinished() const {
return (_parent->data()->id > 0)
? (!_data->loading() && !_data->uploading())
: false;
}
bool HistoryGif::dataLoaded() const {
bool Gif::dataLoaded() const {
return (_parent->data()->id > 0) ? _data->loaded() : false;
}
bool HistoryGif::needInfoDisplay() const {
bool Gif::needInfoDisplay() const {
return (_parent->data()->id < 0 || _parent->isUnderCursor());
}
} // namespace HistoryView

View file

@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/media/history_media_file.h"
#include "history/view/media/history_view_file.h"
struct HistoryMessageVia;
struct HistoryMessageReply;
@ -25,9 +25,11 @@ class Player;
} // namespace Streaming
} // namespace Media
class HistoryGif : public HistoryFileMedia {
namespace HistoryView {
class Gif : public File {
public:
HistoryGif(
Gif(
not_null<Element*> parent,
not_null<DocumentData*> document);
@ -72,16 +74,16 @@ public:
void parentTextUpdated() override;
~HistoryGif();
~Gif();
protected:
float64 dataProgress() const override;
bool dataFinished() const override;
bool dataLoaded() const override;
void setClipReader(Media::Clip::ReaderPointer gif);
void setClipReader(::Media::Clip::ReaderPointer gif);
void clearClipReader() {
setClipReader(Media::Clip::ReaderPointer());
setClipReader(::Media::Clip::ReaderPointer());
}
private:
@ -90,10 +92,10 @@ private:
QSize countOptimalSize() override;
QSize countCurrentSize(int newWidth) override;
QSize videoSize() const;
Media::Streaming::Player *activeRoundPlayer() const;
Media::Clip::Reader *currentReader() const;
Media::View::PlaybackProgress *videoPlayback() const;
void clipCallback(Media::Clip::Notification notification);
::Media::Streaming::Player *activeRoundPlayer() const;
::Media::Clip::Reader *currentReader() const;
::Media::View::PlaybackProgress *videoPlayback() const;
void clipCallback(::Media::Clip::Notification notification);
bool needInfoDisplay() const;
int additionalWidth(
@ -108,9 +110,11 @@ private:
int _thumbw = 1;
int _thumbh = 1;
Ui::Text::String _caption;
Media::Clip::ReaderPointer _gif;
::Media::Clip::ReaderPointer _gif;
void setStatusSize(int newSize) const;
void updateStatusText() const;
};
} // namespace HistoryView

View file

@ -5,37 +5,33 @@ 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 "history/media/history_media_invoice.h"
#include "history/view/media/history_view_invoice.h"
#include "lang/lang_keys.h"
#include "layout.h"
#include "history/view/history_view_element.h"
#include "history/view/history_view_cursor_state.h"
#include "history/media/history_media_photo.h"
#include "history/media/history_media_common.h"
#include "history/view/media/history_view_photo.h"
#include "history/view/media/history_view_media_common.h"
#include "ui/text_options.h"
#include "data/data_media_types.h"
#include "styles/style_history.h"
namespace {
namespace HistoryView {
using TextState = HistoryView::TextState;
} // namespace
HistoryInvoice::HistoryInvoice(
Invoice::Invoice(
not_null<Element*> parent,
not_null<Data::Invoice*> invoice)
: HistoryMedia(parent)
: Media(parent)
, _title(st::msgMinWidth)
, _description(st::msgMinWidth)
, _status(st::msgMinWidth) {
fillFromData(invoice);
}
void HistoryInvoice::fillFromData(not_null<Data::Invoice*> invoice) {
void Invoice::fillFromData(not_null<Data::Invoice*> invoice) {
if (invoice->photo) {
_attach = std::make_unique<HistoryPhoto>(
_attach = std::make_unique<Photo>(
_parent,
_parent->data(),
invoice->photo);
@ -87,7 +83,7 @@ void HistoryInvoice::fillFromData(not_null<Data::Invoice*> invoice) {
}
}
QSize HistoryInvoice::countOptimalSize() {
QSize Invoice::countOptimalSize() {
auto lineHeight = unitedLineHeight();
if (_attach) {
@ -141,7 +137,7 @@ QSize HistoryInvoice::countOptimalSize() {
return { maxWidth, minHeight };
}
QSize HistoryInvoice::countCurrentSize(int newWidth) {
QSize Invoice::countCurrentSize(int newWidth) {
accumulate_min(newWidth, maxWidth());
auto innerWidth = newWidth - st::msgPadding.left() - st::msgPadding.right();
@ -186,23 +182,23 @@ QSize HistoryInvoice::countCurrentSize(int newWidth) {
return { newWidth, newHeight };
}
TextSelection HistoryInvoice::toDescriptionSelection(
TextSelection Invoice::toDescriptionSelection(
TextSelection selection) const {
return HistoryView::UnshiftItemSelection(selection, _title);
return UnshiftItemSelection(selection, _title);
}
TextSelection HistoryInvoice::fromDescriptionSelection(
TextSelection Invoice::fromDescriptionSelection(
TextSelection selection) const {
return HistoryView::ShiftItemSelection(selection, _title);
return ShiftItemSelection(selection, _title);
}
void HistoryInvoice::refreshParentId(not_null<HistoryItem*> realParent) {
void Invoice::refreshParentId(not_null<HistoryItem*> realParent) {
if (_attach) {
_attach->refreshParentId(realParent);
}
}
void HistoryInvoice::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
void Invoice::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
auto paintw = width(), painth = height();
@ -275,7 +271,7 @@ void HistoryInvoice::draw(Painter &p, const QRect &r, TextSelection selection, c
}
}
TextState HistoryInvoice::textState(QPoint point, StateRequest request) const {
TextState Invoice::textState(QPoint point, StateRequest request) const {
auto result = TextState(_parent);
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) {
@ -337,7 +333,7 @@ TextState HistoryInvoice::textState(QPoint point, StateRequest request) const {
return result;
}
TextSelection HistoryInvoice::adjustSelection(TextSelection selection, TextSelectType type) const {
TextSelection Invoice::adjustSelection(TextSelection selection, TextSelectType type) const {
if (!_descriptionHeight || selection.to <= _title.length()) {
return _title.adjustSelection(selection, type);
}
@ -349,19 +345,19 @@ TextSelection HistoryInvoice::adjustSelection(TextSelection selection, TextSelec
return { titleSelection.from, fromDescriptionSelection(descriptionSelection).to };
}
void HistoryInvoice::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) {
void Invoice::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) {
if (_attach) {
_attach->clickHandlerActiveChanged(p, active);
}
}
void HistoryInvoice::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) {
void Invoice::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) {
if (_attach) {
_attach->clickHandlerPressedChanged(p, pressed);
}
}
TextForMimeData HistoryInvoice::selectedText(TextSelection selection) const {
TextForMimeData Invoice::selectedText(TextSelection selection) const {
auto titleResult = _title.toTextForMimeData(selection);
auto descriptionResult = _description.toTextForMimeData(
toDescriptionSelection(selection));
@ -373,7 +369,7 @@ TextForMimeData HistoryInvoice::selectedText(TextSelection selection) const {
return titleResult.append('\n').append(std::move(descriptionResult));
}
QMargins HistoryInvoice::inBubblePadding() const {
QMargins Invoice::inBubblePadding() const {
auto lshift = st::msgPadding.left();
auto rshift = st::msgPadding.right();
auto bshift = isBubbleBottom() ? st::msgPadding.top() : st::mediaInBubbleSkip;
@ -381,7 +377,7 @@ QMargins HistoryInvoice::inBubblePadding() const {
return QMargins(lshift, tshift, rshift, bshift);
}
int HistoryInvoice::bottomInfoPadding() const {
int Invoice::bottomInfoPadding() const {
if (!isBubbleBottom()) return 0;
auto result = st::msgDateFont->height;
@ -442,3 +438,5 @@ QString FillAmountAndCurrency(uint64 amount, const QString &currency) {
//auto amountText = qsl("%1,%2").arg(amountBucks).arg(amountCents, 2, 10, QChar('0'));
//return currencyText + amountText;
}
} // namespace HistoryView

View file

@ -7,15 +7,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
namespace Data {
struct Invoice;
} // namespace Data
class HistoryInvoice : public HistoryMedia {
namespace HistoryView {
class Invoice : public Media {
public:
HistoryInvoice(
Invoice(
not_null<Element*> parent,
not_null<Data::Invoice*> invoice);
@ -64,7 +66,7 @@ public:
return false;
}
HistoryMedia *attach() const {
Media *attach() const {
return _attach.get();
}
@ -79,7 +81,7 @@ private:
QMargins inBubblePadding() const;
int bottomInfoPadding() const;
std::unique_ptr<HistoryMedia> _attach;
std::unique_ptr<Media> _attach;
int _titleHeight = 0;
int _descriptionHeight = 0;
@ -92,3 +94,5 @@ private:
};
QString FillAmountAndCurrency(uint64 amount, const QString &currency);
} // namespace HistoryView

View file

@ -5,7 +5,7 @@ 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 "history/media/history_media_location.h"
#include "history/view/media/history_view_location.h"
#include "layout.h"
#include "history/history_item_components.h"
@ -19,18 +19,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_location.h"
#include "styles/style_history.h"
namespace {
namespace HistoryView {
using TextState = HistoryView::TextState;
} // namespace
HistoryLocation::HistoryLocation(
Location::Location(
not_null<Element*> parent,
not_null<Data::LocationThumbnail*> location,
const QString &title,
const QString &description)
: HistoryMedia(parent)
: Media(parent)
, _data(location)
, _title(st::msgMinWidth)
, _description(st::msgMinWidth)
@ -51,7 +47,7 @@ HistoryLocation::HistoryLocation(
}
}
QSize HistoryLocation::countOptimalSize() {
QSize Location::countOptimalSize() {
auto tw = fullWidth();
auto th = fullHeight();
if (tw > st::maxMediaSize) {
@ -79,7 +75,7 @@ QSize HistoryLocation::countOptimalSize() {
return { maxWidth, minHeight };
}
QSize HistoryLocation::countCurrentSize(int newWidth) {
QSize Location::countCurrentSize(int newWidth) {
accumulate_min(newWidth, maxWidth());
auto tw = fullWidth();
@ -114,17 +110,17 @@ QSize HistoryLocation::countCurrentSize(int newWidth) {
return { newWidth, newHeight };
}
TextSelection HistoryLocation::toDescriptionSelection(
TextSelection Location::toDescriptionSelection(
TextSelection selection) const {
return HistoryView::UnshiftItemSelection(selection, _title);
return UnshiftItemSelection(selection, _title);
}
TextSelection HistoryLocation::fromDescriptionSelection(
TextSelection Location::fromDescriptionSelection(
TextSelection selection) const {
return HistoryView::ShiftItemSelection(selection, _title);
return ShiftItemSelection(selection, _title);
}
void HistoryLocation::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
void Location::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
auto paintx = 0, painty = 0, paintw = width(), painth = height();
bool bubble = _parent->hasBubble();
@ -195,7 +191,7 @@ void HistoryLocation::draw(Painter &p, const QRect &r, TextSelection selection,
}
}
TextState HistoryLocation::textState(QPoint point, StateRequest request) const {
TextState Location::textState(QPoint point, StateRequest request) const {
auto result = TextState(_parent);
auto symbolAdd = 0;
@ -267,7 +263,7 @@ TextState HistoryLocation::textState(QPoint point, StateRequest request) const {
return result;
}
TextSelection HistoryLocation::adjustSelection(TextSelection selection, TextSelectType type) const {
TextSelection Location::adjustSelection(TextSelection selection, TextSelectType type) const {
if (_description.isEmpty() || selection.to <= _title.length()) {
return _title.adjustSelection(selection, type);
}
@ -279,7 +275,7 @@ TextSelection HistoryLocation::adjustSelection(TextSelection selection, TextSele
return { titleSelection.from, fromDescriptionSelection(descriptionSelection).to };
}
TextForMimeData HistoryLocation::selectedText(TextSelection selection) const {
TextForMimeData Location::selectedText(TextSelection selection) const {
auto titleResult = _title.toTextForMimeData(selection);
auto descriptionResult = _description.toTextForMimeData(
toDescriptionSelection(selection));
@ -291,7 +287,7 @@ TextForMimeData HistoryLocation::selectedText(TextSelection selection) const {
return titleResult.append('\n').append(std::move(descriptionResult));
}
bool HistoryLocation::needsBubble() const {
bool Location::needsBubble() const {
if (!_title.isEmpty() || !_description.isEmpty()) {
return true;
}
@ -303,10 +299,12 @@ bool HistoryLocation::needsBubble() const {
return false;
}
int HistoryLocation::fullWidth() const {
int Location::fullWidth() const {
return st::locationSize.width();
}
int HistoryLocation::fullHeight() const {
int Location::fullHeight() const {
return st::locationSize.height();
}
} // namespace HistoryView

View file

@ -7,15 +7,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
namespace Data {
struct LocationThumbnail;
} // namespace Data
class HistoryLocation : public HistoryMedia {
namespace HistoryView {
class Location : public Media {
public:
HistoryLocation(
Location(
not_null<Element*> parent,
not_null<Data::LocationThumbnail*> location,
const QString &title = QString(),
@ -67,3 +69,5 @@ private:
int fullHeight() const;
};
} // namespace HistoryView

View file

@ -5,7 +5,7 @@ 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 "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
#include "history/history_item.h"
#include "history/view/history_view_element.h"
@ -14,30 +14,25 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text_options.h"
#include "styles/style_history.h"
namespace {
namespace HistoryView {
using PointState = HistoryView::PointState;
using TextState = HistoryView::TextState;
} // namespace
Storage::SharedMediaTypesMask HistoryMedia::sharedMediaTypes() const {
Storage::SharedMediaTypesMask Media::sharedMediaTypes() const {
return {};
}
not_null<History*> HistoryMedia::history() const {
not_null<History*> Media::history() const {
return _parent->history();
}
bool HistoryMedia::isDisplayed() const {
bool Media::isDisplayed() const {
return true;
}
QSize HistoryMedia::countCurrentSize(int newWidth) {
QSize Media::countCurrentSize(int newWidth) {
return QSize(qMin(newWidth, maxWidth()), minHeight());
}
Ui::Text::String HistoryMedia::createCaption(not_null<HistoryItem*> item) const {
Ui::Text::String Media::createCaption(not_null<HistoryItem*> item) const {
if (item->emptyText()) {
return {};
}
@ -55,27 +50,25 @@ Ui::Text::String HistoryMedia::createCaption(not_null<HistoryItem*> item) const
return result;
}
TextSelection HistoryMedia::skipSelection(TextSelection selection) const {
return HistoryView::UnshiftItemSelection(
selection,
fullSelectionLength());
TextSelection Media::skipSelection(TextSelection selection) const {
return UnshiftItemSelection(selection, fullSelectionLength());
}
TextSelection HistoryMedia::unskipSelection(TextSelection selection) const {
return HistoryView::ShiftItemSelection(
selection,
fullSelectionLength());
TextSelection Media::unskipSelection(TextSelection selection) const {
return ShiftItemSelection(selection, fullSelectionLength());
}
PointState HistoryMedia::pointState(QPoint point) const {
PointState Media::pointState(QPoint point) const {
return QRect(0, 0, width(), height()).contains(point)
? PointState::Inside
: PointState::Outside;
}
TextState HistoryMedia::getStateGrouped(
TextState Media::getStateGrouped(
const QRect &geometry,
QPoint point,
StateRequest request) const {
Unexpected("Grouping method call.");
}
} // namespace HistoryView

View file

@ -23,12 +23,12 @@ using SharedMediaTypesMask = base::enum_mask<SharedMediaType>;
} // namespace Storage
namespace HistoryView {
enum class PointState : char;
enum class CursorState : char;
enum class InfoDisplayType : char;
struct TextState;
struct StateRequest;
} // namespace HistoryView
enum class MediaInBubbleState {
None,
@ -37,14 +37,9 @@ enum class MediaInBubbleState {
Bottom,
};
class HistoryMedia : public HistoryView::Object {
class Media : public Object {
public:
using Element = HistoryView::Element;
using PointState = HistoryView::PointState;
using TextState = HistoryView::TextState;
using StateRequest = HistoryView::StateRequest;
HistoryMedia(not_null<Element*> parent) : _parent(parent) {
Media(not_null<Element*> parent) : _parent(parent) {
}
[[nodiscard]] not_null<History*> history() const;
@ -231,12 +226,9 @@ public:
virtual void parentTextUpdated() {
}
virtual ~HistoryMedia() = default;
virtual ~Media() = default;
protected:
using CursorState = HistoryView::CursorState;
using InfoDisplayType = HistoryView::InfoDisplayType;
QSize countCurrentSize(int newWidth) override;
Ui::Text::String createCaption(not_null<HistoryItem*> item) const;
@ -247,3 +239,5 @@ protected:
MediaInBubbleState _inBubbleState = MediaInBubbleState::None;
};
} // namespace HistoryView

View file

@ -5,20 +5,22 @@ 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 "history/media/history_media_common.h"
#include "history/view/media/history_view_media_common.h"
#include "layout.h"
#include "data/data_document.h"
#include "history/view/history_view_element.h"
#include "history/media/history_media_grouped.h"
#include "history/media/history_media_photo.h"
#include "history/media/history_media_gif.h"
#include "history/media/history_media_document.h"
#include "history/media/history_media_sticker.h"
#include "history/media/history_media_video.h"
#include "history/media/history_media_wall_paper.h"
#include "history/view/media/history_view_media_grouped.h"
#include "history/view/media/history_view_photo.h"
#include "history/view/media/history_view_gif.h"
#include "history/view/media/history_view_document.h"
#include "history/view/media/history_view_sticker.h"
#include "history/view/media/history_view_video.h"
#include "history/view/media/history_view_wall_paper.h"
#include "styles/style_history.h"
namespace HistoryView {
int documentMaxStatusWidth(DocumentData *document) {
auto result = st::normalFont->width(formatDownloadText(document->size, document->size));
const auto duration = document->getDuration();
@ -58,33 +60,33 @@ void PaintInterpolatedIcon(
p.restore();
}
std::unique_ptr<HistoryMedia> CreateAttach(
not_null<HistoryView::Element*> parent,
std::unique_ptr<Media> CreateAttach(
not_null<Element*> parent,
DocumentData *document,
PhotoData *photo,
const std::vector<std::unique_ptr<Data::Media>> &collage,
const QString &webpageUrl) {
if (!collage.empty()) {
return std::make_unique<HistoryGroupedMedia>(parent, collage);
return std::make_unique<GroupedMedia>(parent, collage);
} else if (document) {
if (document->sticker()) {
return std::make_unique<HistorySticker>(parent, document);
return std::make_unique<Sticker>(parent, document);
} else if (document->isAnimation()) {
return std::make_unique<HistoryGif>(parent, document);
return std::make_unique<Gif>(parent, document);
} else if (document->isVideoFile()) {
return std::make_unique<HistoryVideo>(
return std::make_unique<Video>(
parent,
parent->data(),
document);
} else if (document->isWallPaper()) {
return std::make_unique<HistoryWallPaper>(
return std::make_unique<WallPaper>(
parent,
document,
webpageUrl);
}
return std::make_unique<HistoryDocument>(parent, document);
return std::make_unique<Document>(parent, document);
} else if (photo) {
return std::make_unique<HistoryPhoto>(
return std::make_unique<Photo>(
parent,
parent->data(),
photo);
@ -95,3 +97,5 @@ std::unique_ptr<HistoryMedia> CreateAttach(
int unitedLineHeight() {
return qMax(st::webPageTitleFont->height, st::webPageDescriptionFont->height);
}
} // namespace HistoryView

View file

@ -17,7 +17,10 @@ class Media;
class DocumentData;
class PhotoData;
class HistoryMedia;
namespace HistoryView {
class Media;
int documentMaxStatusWidth(DocumentData *document);
@ -28,10 +31,12 @@ void PaintInterpolatedIcon(
float64 b_ratio,
QRect rect);
std::unique_ptr<HistoryMedia> CreateAttach(
not_null<HistoryView::Element*> parent,
std::unique_ptr<Media> CreateAttach(
not_null<Element*> parent,
DocumentData *document,
PhotoData *photo,
const std::vector<std::unique_ptr<Data::Media>> &collage = {},
const QString &webpageUrl = QString());
int unitedLineHeight();
} // namespace HistoryView

View file

@ -5,7 +5,7 @@ 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 "history/media/history_media_grouped.h"
#include "history/view/media/history_view_media_grouped.h"
#include "history/history_item_components.h"
#include "history/history_message.h"
@ -21,25 +21,20 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "layout.h"
#include "styles/style_history.h"
namespace {
namespace HistoryView {
using TextState = HistoryView::TextState;
using PointState = HistoryView::PointState;
} // namespace
HistoryGroupedMedia::Part::Part(
not_null<HistoryView::Element*> parent,
GroupedMedia::Part::Part(
not_null<Element*> parent,
not_null<Data::Media*> media)
: item(media->parent())
, content(media->createView(parent, item)) {
Assert(media->canBeGrouped());
}
HistoryGroupedMedia::HistoryGroupedMedia(
GroupedMedia::GroupedMedia(
not_null<Element*> parent,
const std::vector<std::unique_ptr<Data::Media>> &medias)
: HistoryMedia(parent)
: Media(parent)
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) {
const auto truncated = ranges::view::all(
medias
@ -51,10 +46,10 @@ HistoryGroupedMedia::HistoryGroupedMedia(
Ensures(result);
}
HistoryGroupedMedia::HistoryGroupedMedia(
GroupedMedia::GroupedMedia(
not_null<Element*> parent,
const std::vector<not_null<HistoryItem*>> &items)
: HistoryMedia(parent)
: Media(parent)
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) {
const auto medias = ranges::view::all(
items
@ -66,7 +61,7 @@ HistoryGroupedMedia::HistoryGroupedMedia(
Ensures(result);
}
QSize HistoryGroupedMedia::countOptimalSize() {
QSize GroupedMedia::countOptimalSize() {
if (_caption.hasSkipBlock()) {
_caption.updateSkipBlock(
_parent->skipBlockWidth(),
@ -108,7 +103,7 @@ QSize HistoryGroupedMedia::countOptimalSize() {
return { maxWidth, minHeight };
}
QSize HistoryGroupedMedia::countCurrentSize(int newWidth) {
QSize GroupedMedia::countCurrentSize(int newWidth) {
accumulate_min(newWidth, maxWidth());
auto newHeight = 0;
if (newWidth < st::historyGroupWidthMin) {
@ -158,14 +153,14 @@ QSize HistoryGroupedMedia::countCurrentSize(int newWidth) {
return { newWidth, newHeight };
}
void HistoryGroupedMedia::refreshParentId(
void GroupedMedia::refreshParentId(
not_null<HistoryItem*> realParent) {
for (const auto &part : _parts) {
part.content->refreshParentId(part.item);
}
}
void HistoryGroupedMedia::draw(
void GroupedMedia::draw(
Painter &p,
const QRect &clip,
TextSelection selection,
@ -219,7 +214,7 @@ void HistoryGroupedMedia::draw(
}
}
TextState HistoryGroupedMedia::getPartState(
TextState GroupedMedia::getPartState(
QPoint point,
StateRequest request) const {
for (const auto &part : _parts) {
@ -235,7 +230,7 @@ TextState HistoryGroupedMedia::getPartState(
return TextState(_parent->data());
}
PointState HistoryGroupedMedia::pointState(QPoint point) const {
PointState GroupedMedia::pointState(QPoint point) const {
if (!QRect(0, 0, width(), height()).contains(point)) {
return PointState::Outside;
}
@ -247,9 +242,7 @@ PointState HistoryGroupedMedia::pointState(QPoint point) const {
return PointState::Inside;
}
HistoryView::TextState HistoryGroupedMedia::textState(
QPoint point,
StateRequest request) const {
TextState GroupedMedia::textState(QPoint point, StateRequest request) const {
auto result = getPartState(point, request);
if (!result.link && !_caption.isEmpty()) {
const auto captionw = width() - st::msgPadding.left() - st::msgPadding.right();
@ -279,7 +272,7 @@ HistoryView::TextState HistoryGroupedMedia::textState(
return result;
}
bool HistoryGroupedMedia::toggleSelectionByHandlerClick(
bool GroupedMedia::toggleSelectionByHandlerClick(
const ClickHandlerPtr &p) const {
for (const auto &part : _parts) {
if (part.content->toggleSelectionByHandlerClick(p)) {
@ -289,7 +282,7 @@ bool HistoryGroupedMedia::toggleSelectionByHandlerClick(
return false;
}
bool HistoryGroupedMedia::dragItemByHandler(const ClickHandlerPtr &p) const {
bool GroupedMedia::dragItemByHandler(const ClickHandlerPtr &p) const {
for (const auto &part : _parts) {
if (part.content->dragItemByHandler(p)) {
return true;
@ -298,18 +291,18 @@ bool HistoryGroupedMedia::dragItemByHandler(const ClickHandlerPtr &p) const {
return false;
}
TextSelection HistoryGroupedMedia::adjustSelection(
TextSelection GroupedMedia::adjustSelection(
TextSelection selection,
TextSelectType type) const {
return _caption.adjustSelection(selection, type);
}
TextForMimeData HistoryGroupedMedia::selectedText(
TextForMimeData GroupedMedia::selectedText(
TextSelection selection) const {
return _caption.toTextForMimeData(selection);
}
void HistoryGroupedMedia::clickHandlerActiveChanged(
void GroupedMedia::clickHandlerActiveChanged(
const ClickHandlerPtr &p,
bool active) {
for (const auto &part : _parts) {
@ -317,7 +310,7 @@ void HistoryGroupedMedia::clickHandlerActiveChanged(
}
}
void HistoryGroupedMedia::clickHandlerPressedChanged(
void GroupedMedia::clickHandlerPressedChanged(
const ClickHandlerPtr &p,
bool pressed) {
for (const auto &part : _parts) {
@ -330,7 +323,7 @@ void HistoryGroupedMedia::clickHandlerPressedChanged(
}
template <typename DataMediaRange>
bool HistoryGroupedMedia::applyGroup(const DataMediaRange &medias) {
bool GroupedMedia::applyGroup(const DataMediaRange &medias) {
if (validateGroupParts(medias)) {
return true;
}
@ -347,7 +340,7 @@ bool HistoryGroupedMedia::applyGroup(const DataMediaRange &medias) {
}
template <typename DataMediaRange>
bool HistoryGroupedMedia::validateGroupParts(
bool GroupedMedia::validateGroupParts(
const DataMediaRange &medias) const {
auto i = 0;
const auto count = _parts.size();
@ -360,36 +353,36 @@ bool HistoryGroupedMedia::validateGroupParts(
return (i == count);
}
not_null<HistoryMedia*> HistoryGroupedMedia::main() const {
not_null<Media*> GroupedMedia::main() const {
Expects(!_parts.empty());
return _parts.back().content.get();
}
TextWithEntities HistoryGroupedMedia::getCaption() const {
TextWithEntities GroupedMedia::getCaption() const {
return main()->getCaption();
}
Storage::SharedMediaTypesMask HistoryGroupedMedia::sharedMediaTypes() const {
Storage::SharedMediaTypesMask GroupedMedia::sharedMediaTypes() const {
return main()->sharedMediaTypes();
}
PhotoData *HistoryGroupedMedia::getPhoto() const {
PhotoData *GroupedMedia::getPhoto() const {
return main()->getPhoto();
}
DocumentData *HistoryGroupedMedia::getDocument() const {
DocumentData *GroupedMedia::getDocument() const {
return main()->getDocument();
}
HistoryMessageEdited *HistoryGroupedMedia::displayedEditBadge() const {
HistoryMessageEdited *GroupedMedia::displayedEditBadge() const {
if (!_caption.isEmpty()) {
return _parts.front().item->Get<HistoryMessageEdited>();
}
return nullptr;
}
void HistoryGroupedMedia::updateNeedBubbleState() {
void GroupedMedia::updateNeedBubbleState() {
const auto captionItem = [&]() -> HistoryItem* {
auto result = (HistoryItem*)nullptr;
for (const auto &part : _parts) {
@ -409,15 +402,15 @@ void HistoryGroupedMedia::updateNeedBubbleState() {
_needBubble = computeNeedBubble();
}
void HistoryGroupedMedia::parentTextUpdated() {
void GroupedMedia::parentTextUpdated() {
history()->owner().requestViewResize(_parent);
}
bool HistoryGroupedMedia::needsBubble() const {
bool GroupedMedia::needsBubble() const {
return _needBubble;
}
bool HistoryGroupedMedia::computeNeedBubble() const {
bool GroupedMedia::computeNeedBubble() const {
if (!_caption.isEmpty()) {
return true;
}
@ -433,6 +426,8 @@ bool HistoryGroupedMedia::computeNeedBubble() const {
return false;
}
bool HistoryGroupedMedia::needInfoDisplay() const {
bool GroupedMedia::needInfoDisplay() const {
return (_parent->data()->id < 0 || _parent->isUnderCursor());
}
} // namespace HistoryView

View file

@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
#include "data/data_document.h"
#include "data/data_photo.h"
@ -15,14 +15,16 @@ namespace Data {
class Media;
} // namespace Data
class HistoryGroupedMedia : public HistoryMedia {
namespace HistoryView {
class GroupedMedia : public Media {
public:
static constexpr auto kMaxSize = 10;
HistoryGroupedMedia(
GroupedMedia(
not_null<Element*> parent,
const std::vector<std::unique_ptr<Data::Media>> &medias);
HistoryGroupedMedia(
GroupedMedia(
not_null<Element*> parent,
const std::vector<not_null<HistoryItem*>> &items);
@ -89,11 +91,11 @@ public:
private:
struct Part {
Part(
not_null<HistoryView::Element*> parent,
not_null<Element*> parent,
not_null<Data::Media*> media);
not_null<HistoryItem*> item;
std::unique_ptr<HistoryMedia> content;
std::unique_ptr<Media> content;
RectParts sides = RectPart::None;
QRect initialGeometry;
@ -114,7 +116,7 @@ private:
bool needInfoDisplay() const;
bool computeNeedBubble() const;
not_null<HistoryMedia*> main() const;
not_null<Media*> main() const;
TextState getPartState(
QPoint point,
StateRequest request) const;
@ -124,3 +126,5 @@ private:
bool _needBubble = false;
};
} // namespace HistoryView

View file

@ -5,7 +5,7 @@ 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 "history/media/history_media_photo.h"
#include "history/view/media/history_view_photo.h"
#include "layout.h"
#include "history/history_item_components.h"
@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history.h"
#include "history/view/history_view_element.h"
#include "history/view/history_view_cursor_state.h"
#include "history/media/history_media_common.h"
#include "history/view/media/history_view_media_common.h"
#include "ui/image/image.h"
#include "ui/grouped_layout.h"
#include "data/data_session.h"
@ -21,35 +21,31 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_file_origin.h"
#include "styles/style_history.h"
namespace {
namespace HistoryView {
using TextState = HistoryView::TextState;
} // namespace
HistoryPhoto::HistoryPhoto(
Photo::Photo(
not_null<Element*> parent,
not_null<HistoryItem*> realParent,
not_null<PhotoData*> photo)
: HistoryFileMedia(parent, realParent)
: File(parent, realParent)
, _data(photo)
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) {
_caption = createCaption(realParent);
create(realParent->fullId());
}
HistoryPhoto::HistoryPhoto(
Photo::Photo(
not_null<Element*> parent,
not_null<PeerData*> chat,
not_null<PhotoData*> photo,
int width)
: HistoryFileMedia(parent, parent->data())
: File(parent, parent->data())
, _data(photo)
, _serviceWidth(width) {
create(parent->data()->fullId(), chat);
}
void HistoryPhoto::create(FullMsgId contextId, PeerData *chat) {
void Photo::create(FullMsgId contextId, PeerData *chat) {
setLinks(
std::make_shared<PhotoOpenClickHandler>(_data, contextId, chat),
std::make_shared<PhotoSaveClickHandler>(_data, contextId, chat),
@ -61,7 +57,7 @@ void HistoryPhoto::create(FullMsgId contextId, PeerData *chat) {
}
}
QSize HistoryPhoto::countOptimalSize() {
QSize Photo::countOptimalSize() {
if (_parent->media() != this) {
_caption = Ui::Text::String();
} else if (_caption.hasSkipBlock()) {
@ -104,7 +100,7 @@ QSize HistoryPhoto::countOptimalSize() {
return { maxWidth, minHeight };
}
QSize HistoryPhoto::countCurrentSize(int newWidth) {
QSize Photo::countCurrentSize(int newWidth) {
int tw = ConvertScale(_data->width()), th = ConvertScale(_data->height());
if (tw > st::maxMediaSize) {
th = (st::maxMediaSize * th) / tw;
@ -144,7 +140,7 @@ QSize HistoryPhoto::countCurrentSize(int newWidth) {
return { newWidth, newHeight };
}
void HistoryPhoto::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
void Photo::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
_data->automaticLoad(_realParent->fullId(), _parent->data());
@ -279,7 +275,7 @@ void HistoryPhoto::draw(Painter &p, const QRect &r, TextSelection selection, crl
}
}
TextState HistoryPhoto::textState(QPoint point, StateRequest request) const {
TextState Photo::textState(QPoint point, StateRequest request) const {
auto result = TextState(_parent);
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) {
@ -335,13 +331,13 @@ TextState HistoryPhoto::textState(QPoint point, StateRequest request) const {
return result;
}
QSize HistoryPhoto::sizeForGrouping() const {
QSize Photo::sizeForGrouping() const {
const auto width = _data->width();
const auto height = _data->height();
return { std::max(width, 1), std::max(height, 1) };
}
void HistoryPhoto::drawGrouped(
void Photo::drawGrouped(
Painter &p,
const QRect &clip,
TextSelection selection,
@ -448,7 +444,7 @@ void HistoryPhoto::drawGrouped(
}
}
TextState HistoryPhoto::getStateGrouped(
TextState Photo::getStateGrouped(
const QRect &geometry,
QPoint point,
StateRequest request) const {
@ -466,24 +462,24 @@ TextState HistoryPhoto::getStateGrouped(
: _savel);
}
float64 HistoryPhoto::dataProgress() const {
float64 Photo::dataProgress() const {
return _data->progress();
}
bool HistoryPhoto::dataFinished() const {
bool Photo::dataFinished() const {
return !_data->loading()
&& (!_data->uploading() || _data->waitingForAlbum());
}
bool HistoryPhoto::dataLoaded() const {
bool Photo::dataLoaded() const {
return _data->loaded();
}
bool HistoryPhoto::needInfoDisplay() const {
bool Photo::needInfoDisplay() const {
return (_parent->data()->id < 0 || _parent->isUnderCursor());
}
void HistoryPhoto::validateGroupedCache(
void Photo::validateGroupedCache(
const QRect &geometry,
RectParts corners,
not_null<uint64*> cacheKey,
@ -535,11 +531,11 @@ void HistoryPhoto::validateGroupedCache(
*cache = image->pixNoCache(_realParent->fullId(), pixWidth, pixHeight, options, width, height);
}
TextForMimeData HistoryPhoto::selectedText(TextSelection selection) const {
TextForMimeData Photo::selectedText(TextSelection selection) const {
return _caption.toTextForMimeData(selection);
}
bool HistoryPhoto::needsBubble() const {
bool Photo::needsBubble() const {
if (!_caption.isEmpty()) {
return true;
}
@ -553,13 +549,15 @@ bool HistoryPhoto::needsBubble() const {
return false;
}
bool HistoryPhoto::isReadyForOpen() const {
bool Photo::isReadyForOpen() const {
return _data->loaded();
}
void HistoryPhoto::parentTextUpdated() {
void Photo::parentTextUpdated() {
_caption = (_parent->media() == this)
? createCaption(_parent->data())
: Ui::Text::String();
history()->owner().requestViewResize(_parent);
}
} // namespace HistoryView

View file

@ -7,15 +7,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/media/history_media_file.h"
#include "history/view/media/history_view_file.h"
class HistoryPhoto : public HistoryFileMedia {
namespace HistoryView {
class Photo : public File {
public:
HistoryPhoto(
Photo(
not_null<Element*> parent,
not_null<HistoryItem*> realParent,
not_null<PhotoData*> photo);
HistoryPhoto(
Photo(
not_null<Element*> parent,
not_null<PeerData*> chat,
not_null<PhotoData*> photo,
@ -96,3 +98,5 @@ private:
Ui::Text::String _caption;
};
} // namespace HistoryView

View file

@ -5,7 +5,7 @@ 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 "history/media/history_media_poll.h"
#include "history/view/media/history_view_poll.h"
#include "lang/lang_keys.h"
#include "history/history.h"
@ -26,10 +26,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_history.h"
#include "styles/style_widgets.h"
namespace HistoryView {
namespace {
using TextState = HistoryView::TextState;
struct PercentCounterItem {
int index = 0;
int percent = 0;
@ -105,18 +104,18 @@ void CountNicePercent(
} // namespace
struct HistoryPoll::AnswerAnimation {
struct Poll::AnswerAnimation {
anim::value percent;
anim::value filling;
anim::value opacity;
};
struct HistoryPoll::AnswersAnimation {
struct Poll::AnswersAnimation {
std::vector<AnswerAnimation> data;
Ui::Animations::Simple progress;
};
struct HistoryPoll::SendingAnimation {
struct Poll::SendingAnimation {
template <typename Callback>
SendingAnimation(
const QByteArray &option,
@ -126,7 +125,7 @@ struct HistoryPoll::SendingAnimation {
Ui::InfiniteRadialAnimation animation;
};
struct HistoryPoll::Answer {
struct Poll::Answer {
Answer();
void fillText(const PollAnswer &original);
@ -144,7 +143,7 @@ struct HistoryPoll::Answer {
};
template <typename Callback>
HistoryPoll::SendingAnimation::SendingAnimation(
Poll::SendingAnimation::SendingAnimation(
const QByteArray &option,
Callback &&callback)
: option(option)
@ -153,10 +152,10 @@ HistoryPoll::SendingAnimation::SendingAnimation(
st::historyPollRadialAnimation) {
}
HistoryPoll::Answer::Answer() : text(st::msgMinWidth / 2) {
Poll::Answer::Answer() : text(st::msgMinWidth / 2) {
}
void HistoryPoll::Answer::fillText(const PollAnswer &original) {
void Poll::Answer::fillText(const PollAnswer &original) {
if (!text.isEmpty() && text.toString() == original.text) {
return;
}
@ -166,16 +165,16 @@ void HistoryPoll::Answer::fillText(const PollAnswer &original) {
Ui::WebpageTextTitleOptions());
}
HistoryPoll::HistoryPoll(
Poll::Poll(
not_null<Element*> parent,
not_null<PollData*> poll)
: HistoryMedia(parent)
: Media(parent)
, _poll(poll)
, _question(st::msgMinWidth / 2) {
history()->owner().registerPollView(_poll, _parent);
}
QSize HistoryPoll::countOptimalSize() {
QSize Poll::countOptimalSize() {
updateTexts();
const auto paddings = st::msgPadding.left() + st::msgPadding.right();
@ -214,11 +213,11 @@ QSize HistoryPoll::countOptimalSize() {
return { maxWidth, minHeight };
}
bool HistoryPoll::canVote() const {
bool Poll::canVote() const {
return !_voted && !_closed;
}
int HistoryPoll::countAnswerTop(
int Poll::countAnswerTop(
const Answer &answer,
int innerWidth) const {
auto tshift = st::historyPollQuestionTop;
@ -246,7 +245,7 @@ int HistoryPoll::countAnswerTop(
return tshift;
}
int HistoryPoll::countAnswerHeight(
int Poll::countAnswerHeight(
const Answer &answer,
int innerWidth) const {
const auto answerWidth = innerWidth
@ -257,7 +256,7 @@ int HistoryPoll::countAnswerHeight(
+ st::historyPollAnswerPadding.bottom();
}
QSize HistoryPoll::countCurrentSize(int newWidth) {
QSize Poll::countCurrentSize(int newWidth) {
const auto paddings = st::msgPadding.left() + st::msgPadding.right();
accumulate_min(newWidth, maxWidth());
@ -286,7 +285,7 @@ QSize HistoryPoll::countCurrentSize(int newWidth) {
return { newWidth, newHeight };
}
void HistoryPoll::updateTexts() {
void Poll::updateTexts() {
if (_pollVersion == _poll->version) {
return;
}
@ -315,7 +314,7 @@ void HistoryPoll::updateTexts() {
}
}
void HistoryPoll::updateAnswers() {
void Poll::updateAnswers() {
const auto changed = !ranges::equal(
_answers,
_poll->answers,
@ -345,7 +344,7 @@ void HistoryPoll::updateAnswers() {
resetAnswersAnimation();
}
ClickHandlerPtr HistoryPoll::createAnswerClickHandler(
ClickHandlerPtr Poll::createAnswerClickHandler(
const Answer &answer) const {
const auto option = answer.option;
const auto itemId = _parent->data()->fullId();
@ -354,13 +353,13 @@ ClickHandlerPtr HistoryPoll::createAnswerClickHandler(
});
}
void HistoryPoll::updateVotes() {
void Poll::updateVotes() {
_voted = _poll->voted();
updateAnswerVotes();
updateTotalVotes();
}
void HistoryPoll::checkSendingAnimation() const {
void Poll::checkSendingAnimation() const {
const auto &sending = _poll->sendingVote;
if (sending.isEmpty() == !_sendingAnimation) {
if (_sendingAnimation) {
@ -380,7 +379,7 @@ void HistoryPoll::checkSendingAnimation() const {
_sendingAnimation->animation.start();
}
void HistoryPoll::updateTotalVotes() {
void Poll::updateTotalVotes() {
if (_totalVotes == _poll->totalVoters && !_totalVotesLabel.isEmpty()) {
return;
}
@ -391,7 +390,7 @@ void HistoryPoll::updateTotalVotes() {
_totalVotesLabel.setText(st::msgDateTextStyle, string);
}
void HistoryPoll::updateAnswerVotesFromOriginal(
void Poll::updateAnswerVotesFromOriginal(
Answer &answer,
const PollAnswer &original,
int percent,
@ -411,7 +410,7 @@ void HistoryPoll::updateAnswerVotesFromOriginal(
answer.filling = answer.votes / float64(maxVotes);
}
void HistoryPoll::updateAnswerVotes() {
void Poll::updateAnswerVotes() {
if (_poll->answers.size() != _answers.size()
|| _poll->answers.empty()) {
return;
@ -452,7 +451,7 @@ void HistoryPoll::updateAnswerVotes() {
}
}
void HistoryPoll::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
void Poll::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
auto paintx = 0, painty = 0, paintw = width(), painth = height();
@ -522,20 +521,20 @@ void HistoryPoll::draw(Painter &p, const QRect &r, TextSelection selection, crl:
}
}
void HistoryPoll::resetAnswersAnimation() const {
void Poll::resetAnswersAnimation() const {
_answersAnimation = nullptr;
if (_poll->sendingVote.isEmpty()) {
_sendingAnimation = nullptr;
}
}
void HistoryPoll::radialAnimationCallback() const {
void Poll::radialAnimationCallback() const {
if (!anim::Disabled()) {
history()->owner().requestViewRepaint(_parent);
}
}
int HistoryPoll::paintAnswer(
int Poll::paintAnswer(
Painter &p,
const Answer &answer,
const AnswerAnimation *animation,
@ -619,7 +618,7 @@ int HistoryPoll::paintAnswer(
return height;
}
void HistoryPoll::paintRadio(
void Poll::paintRadio(
Painter &p,
const Answer &answer,
int left,
@ -665,7 +664,7 @@ void HistoryPoll::paintRadio(
p.setOpacity(o);
}
void HistoryPoll::paintPercent(
void Poll::paintPercent(
Painter &p,
const QString &percent,
int percentWidth,
@ -685,7 +684,7 @@ void HistoryPoll::paintPercent(
p.drawTextLeft(pleft, top + st::historyPollPercentTop, outerWidth, percent, percentWidth);
}
void HistoryPoll::paintFilling(
void Poll::paintFilling(
Painter &p,
float64 filling,
int left,
@ -714,7 +713,7 @@ void HistoryPoll::paintFilling(
p.drawRoundedRect(aleft, ftop, size, st::historyPollFillingHeight, radius, radius);
}
bool HistoryPoll::answerVotesChanged() const {
bool Poll::answerVotesChanged() const {
if (_poll->answers.size() != _answers.size()
|| _poll->answers.empty()) {
return false;
@ -727,7 +726,7 @@ bool HistoryPoll::answerVotesChanged() const {
&PollAnswer::votes);
}
void HistoryPoll::saveStateInAnimation() const {
void Poll::saveStateInAnimation() const {
if (_answersAnimation) {
return;
}
@ -747,7 +746,7 @@ void HistoryPoll::saveStateInAnimation() const {
convert);
}
bool HistoryPoll::checkAnimationStart() const {
bool Poll::checkAnimationStart() const {
if (_poll->answers.size() != _answers.size()) {
// Skip initial changes.
return false;
@ -760,7 +759,7 @@ bool HistoryPoll::checkAnimationStart() const {
return result;
}
void HistoryPoll::startAnswersAnimation() const {
void Poll::startAnswersAnimation() const {
if (!_answersAnimation) {
return;
}
@ -779,7 +778,7 @@ void HistoryPoll::startAnswersAnimation() const {
st::historyPollDuration);
}
TextState HistoryPoll::textState(QPoint point, StateRequest request) const {
TextState Poll::textState(QPoint point, StateRequest request) const {
auto result = TextState(_parent);
if (!_poll->sendingVote.isEmpty()) {
return result;
@ -821,7 +820,7 @@ TextState HistoryPoll::textState(QPoint point, StateRequest request) const {
return result;
}
void HistoryPoll::clickHandlerPressedChanged(
void Poll::clickHandlerPressedChanged(
const ClickHandlerPtr &handler,
bool pressed) {
if (!handler) return;
@ -835,7 +834,7 @@ void HistoryPoll::clickHandlerPressedChanged(
}
}
void HistoryPoll::toggleRipple(Answer &answer, bool pressed) {
void Poll::toggleRipple(Answer &answer, bool pressed) {
if (pressed) {
const auto outerWidth = width();
const auto innerWidth = outerWidth
@ -861,6 +860,8 @@ void HistoryPoll::toggleRipple(Answer &answer, bool pressed) {
}
}
HistoryPoll::~HistoryPoll() {
Poll::~Poll() {
history()->owner().unregisterPollView(_poll, _parent);
}
} // namespace HistoryView

View file

@ -7,13 +7,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
struct PollAnswer;
class HistoryPoll : public HistoryMedia {
namespace HistoryView {
class Poll : public Media {
public:
HistoryPoll(
Poll(
not_null<Element*> parent,
not_null<PollData*> poll);
@ -38,7 +40,7 @@ public:
const ClickHandlerPtr &handler,
bool pressed) override;
~HistoryPoll();
~Poll();
private:
struct AnswerAnimation;
@ -128,3 +130,5 @@ private:
mutable QPoint _lastLinkPoint;
};
} // namespace HistoryView

View file

@ -5,7 +5,7 @@ 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 "history/media/history_media_sticker.h"
#include "history/view/media/history_view_sticker.h"
#include "layout.h"
#include "boxes/sticker_set_box.h"
@ -25,37 +25,32 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lottie/lottie_single_player.h"
#include "styles/style_history.h"
namespace HistoryView {
namespace {
using TextState = HistoryView::TextState;
double GetEmojiStickerZoom(not_null<Main::Session*> session) {
return session->appConfig().get<double>("emojies_animated_zoom", 0.625);
}
} // namespace
HistorySticker::HistorySticker(
Sticker::Sticker(
not_null<Element*> parent,
not_null<DocumentData*> document)
: HistoryMedia(parent)
, _data(document)
, _emoji(_data->sticker()->alt) {
: Media(parent)
, _data(document) {
_data->loadThumbnail(parent->data()->fullId());
if (const auto emoji = Ui::Emoji::Find(_emoji)) {
_emoji = emoji->text();
}
}
HistorySticker::~HistorySticker() {
Sticker::~Sticker() {
unloadLottie();
}
bool HistorySticker::isEmojiSticker() const {
bool Sticker::isEmojiSticker() const {
return (_parent->data()->media() == nullptr);
}
QSize HistorySticker::countOptimalSize() {
QSize Sticker::countOptimalSize() {
auto sticker = _data->sticker();
if (!_packLink) {
@ -109,7 +104,7 @@ QSize HistorySticker::countOptimalSize() {
return { maxWidth, minHeight };
}
QSize HistorySticker::countCurrentSize(int newWidth) {
QSize Sticker::countCurrentSize(int newWidth) {
const auto item = _parent->data();
accumulate_min(newWidth, maxWidth());
if (_parent->media() == this) {
@ -129,7 +124,7 @@ QSize HistorySticker::countCurrentSize(int newWidth) {
return { newWidth, minHeight() };
}
void HistorySticker::setupLottie() {
void Sticker::setupLottie() {
_lottie = Stickers::LottiePlayerFromDocument(
_data,
Stickers::LottieSize::MessageHistory,
@ -147,7 +142,7 @@ void HistorySticker::setupLottie() {
}, _lifetime);
}
void HistorySticker::unloadLottie() {
void Sticker::unloadLottie() {
if (!_lottie) {
return;
}
@ -155,7 +150,7 @@ void HistorySticker::unloadLottie() {
_parent->data()->history()->owner().unregisterHeavyViewPart(_parent);
}
void HistorySticker::draw(
void Sticker::draw(
Painter &p,
const QRect &r,
TextSelection selection,
@ -164,7 +159,7 @@ void HistorySticker::draw(
if (!sticker) return;
if (sticker->animated && !_lottie && _data->loaded()) {
const_cast<HistorySticker*>(this)->setupLottie();
const_cast<Sticker*>(this)->setupLottie();
}
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
@ -301,7 +296,7 @@ void HistorySticker::draw(
}
}
TextState HistorySticker::textState(QPoint point, StateRequest request) const {
TextState Sticker::textState(QPoint point, StateRequest request) const {
auto result = TextState(_parent);
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) {
return result;
@ -376,11 +371,11 @@ TextState HistorySticker::textState(QPoint point, StateRequest request) const {
return result;
}
bool HistorySticker::needInfoDisplay() const {
bool Sticker::needInfoDisplay() const {
return (_parent->data()->id < 0 || _parent->isUnderCursor());
}
int HistorySticker::additionalWidth(const HistoryMessageVia *via, const HistoryMessageReply *reply) const {
int Sticker::additionalWidth(const HistoryMessageVia *via, const HistoryMessageReply *reply) const {
int result = 0;
if (via) {
accumulate_max(result, st::msgReplyPadding.left() + st::msgReplyPadding.left() + via->maxWidth + st::msgReplyPadding.left());
@ -391,9 +386,11 @@ int HistorySticker::additionalWidth(const HistoryMessageVia *via, const HistoryM
return result;
}
int HistorySticker::additionalWidth() const {
int Sticker::additionalWidth() const {
const auto item = _parent->data();
return additionalWidth(
item->Get<HistoryMessageVia>(),
item->Get<HistoryMessageReply>());
}
} // namespace HistoryView

View file

@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
#include "base/weak_ptr.h"
#include "base/timer.h"
@ -19,12 +19,14 @@ namespace Lottie {
class SinglePlayer;
} // namespace Lottie
class HistorySticker : public HistoryMedia, public base::has_weak_ptr {
namespace HistoryView {
class Sticker : public Media, public base::has_weak_ptr {
public:
HistorySticker(
Sticker(
not_null<Element*> parent,
not_null<DocumentData*> document);
~HistorySticker();
~Sticker();
void draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const override;
TextState textState(QPoint point, StateRequest request) const override;
@ -49,9 +51,6 @@ public:
bool customInfoLayout() const override {
return true;
}
QString emoji() const {
return _emoji;
}
bool hidesForwardedInfo() const override {
return true;
}
@ -79,11 +78,12 @@ private:
int _pixw = 1;
int _pixh = 1;
ClickHandlerPtr _packLink;
not_null<DocumentData*> _data;
QString _emoji;
DocumentData *_data = nullptr;
std::unique_ptr<Lottie::SinglePlayer> _lottie;
mutable bool _lottieOncePlayed = false;
rpl::lifetime _lifetime;
};
} // namespace HistoryView

View file

@ -5,9 +5,9 @@ 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 "history/media/history_media_video.h"
#include "history/view/media/history_view_video.h"
#include "history/media/history_media_common.h"
#include "history/view/media/history_view_media_common.h"
#include "layout.h"
#include "history/history_item_components.h"
#include "history/history_item.h"
@ -21,17 +21,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_file_origin.h"
#include "styles/style_history.h"
namespace {
namespace HistoryView {
using TextState = HistoryView::TextState;
} // namespace
HistoryVideo::HistoryVideo(
Video::Video(
not_null<Element*> parent,
not_null<HistoryItem*> realParent,
not_null<DocumentData*> document)
: HistoryFileMedia(parent, realParent)
: File(parent, realParent)
, _data(document)
, _thumbw(1)
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) {
@ -45,7 +41,7 @@ HistoryVideo::HistoryVideo(
_data->loadThumbnail(realParent->fullId());
}
QSize HistoryVideo::sizeForAspectRatio() const {
QSize Video::sizeForAspectRatio() const {
// We use size only for aspect ratio and we want to have it
// as close to the thumbnail as possible.
//if (!_data->dimensions.isEmpty()) {
@ -59,7 +55,7 @@ QSize HistoryVideo::sizeForAspectRatio() const {
return { 1, 1 };
}
QSize HistoryVideo::countOptimalDimensions() const {
QSize Video::countOptimalDimensions() const {
const auto desired = ConvertScale(_data->dimensions);
const auto size = desired.isEmpty() ? sizeForAspectRatio() : desired;
auto tw = size.width();
@ -86,7 +82,7 @@ QSize HistoryVideo::countOptimalDimensions() const {
return QSize(tw, th);
}
QSize HistoryVideo::countOptimalSize() {
QSize Video::countOptimalSize() {
if (_parent->media() != this) {
_caption = Ui::Text::String();
} else if (_caption.hasSkipBlock()) {
@ -117,7 +113,7 @@ QSize HistoryVideo::countOptimalSize() {
return { maxWidth, minHeight };
}
QSize HistoryVideo::countCurrentSize(int newWidth) {
QSize Video::countCurrentSize(int newWidth) {
const auto size = countOptimalDimensions();
auto tw = size.width();
auto th = size.height();
@ -144,13 +140,13 @@ QSize HistoryVideo::countCurrentSize(int newWidth) {
return { newWidth, newHeight };
}
bool HistoryVideo::downloadInCorner() const {
bool Video::downloadInCorner() const {
return _data->canBeStreamed()
&& !_data->inappPlaybackFailed()
&& IsServerMsgId(_parent->data()->id);
}
void HistoryVideo::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
void Video::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
_data->automaticLoad(_realParent->fullId(), _parent->data());
@ -271,7 +267,7 @@ void HistoryVideo::draw(Painter &p, const QRect &r, TextSelection selection, crl
}
}
void HistoryVideo::drawCornerStatus(Painter &p, bool selected) const {
void Video::drawCornerStatus(Painter &p, bool selected) const {
const auto padding = st::msgDateImgPadding;
const auto radial = _animation && _animation->radial.animating();
const auto cornerDownload = downloadInCorner() && !_data->loaded() && !_data->loadedInMediaCache();
@ -307,7 +303,7 @@ void HistoryVideo::drawCornerStatus(Painter &p, bool selected) const {
}
}
TextState HistoryVideo::cornerStatusTextState(
TextState Video::cornerStatusTextState(
QPoint point,
StateRequest request) const {
auto result = TextState(_parent);
@ -324,7 +320,7 @@ TextState HistoryVideo::cornerStatusTextState(
return result;
}
TextState HistoryVideo::textState(QPoint point, StateRequest request) const {
TextState Video::textState(QPoint point, StateRequest request) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) {
return {};
}
@ -380,11 +376,11 @@ TextState HistoryVideo::textState(QPoint point, StateRequest request) const {
return result;
}
QSize HistoryVideo::sizeForGrouping() const {
QSize Video::sizeForGrouping() const {
return sizeForAspectRatio();
}
void HistoryVideo::drawGrouped(
void Video::drawGrouped(
Painter &p,
const QRect &clip,
TextSelection selection,
@ -486,7 +482,7 @@ void HistoryVideo::drawGrouped(
}
}
TextState HistoryVideo::getStateGrouped(
TextState Video::getStateGrouped(
const QRect &geometry,
QPoint point,
StateRequest request) const {
@ -502,24 +498,24 @@ TextState HistoryVideo::getStateGrouped(
: _savel);
}
bool HistoryVideo::uploading() const {
bool Video::uploading() const {
return _data->uploading();
}
float64 HistoryVideo::dataProgress() const {
float64 Video::dataProgress() const {
return _data->progress();
}
bool HistoryVideo::dataFinished() const {
bool Video::dataFinished() const {
return !_data->loading()
&& (!_data->uploading() || _data->waitingForAlbum());
}
bool HistoryVideo::dataLoaded() const {
bool Video::dataLoaded() const {
return _data->loaded();
}
void HistoryVideo::validateGroupedCache(
void Video::validateGroupedCache(
const QRect &geometry,
RectParts corners,
not_null<uint64*> cacheKey,
@ -575,15 +571,15 @@ void HistoryVideo::validateGroupedCache(
height);
}
void HistoryVideo::setStatusSize(int newSize) const {
HistoryFileMedia::setStatusSize(newSize, _data->size, _data->getDuration(), 0);
void Video::setStatusSize(int newSize) const {
File::setStatusSize(newSize, _data->size, _data->getDuration(), 0);
}
TextForMimeData HistoryVideo::selectedText(TextSelection selection) const {
TextForMimeData Video::selectedText(TextSelection selection) const {
return _caption.toTextForMimeData(selection);
}
bool HistoryVideo::needsBubble() const {
bool Video::needsBubble() const {
if (!_caption.isEmpty()) {
return true;
}
@ -595,14 +591,14 @@ bool HistoryVideo::needsBubble() const {
return false;
}
void HistoryVideo::parentTextUpdated() {
void Video::parentTextUpdated() {
_caption = (_parent->media() == this)
? createCaption(_parent->data())
: Ui::Text::String();
history()->owner().requestViewResize(_parent);
}
void HistoryVideo::updateStatusText() const {
void Video::updateStatusText() const {
auto showPause = false;
auto statusSize = 0;
auto realDuration = 0;
@ -621,3 +617,5 @@ void HistoryVideo::updateStatusText() const {
setStatusSize(statusSize);
}
}
} // namespace HistoryView

View file

@ -7,11 +7,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/media/history_media_file.h"
#include "history/view/media/history_view_file.h"
class HistoryVideo : public HistoryFileMedia {
namespace HistoryView {
class Video : public File {
public:
HistoryVideo(
Video(
not_null<Element*> parent,
not_null<HistoryItem*> realParent,
not_null<DocumentData*> document);
@ -100,3 +102,5 @@ private:
QString _downloadSize;
};
} // namespace HistoryView

View file

@ -5,7 +5,7 @@ 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 "history/media/history_media_wall_paper.h"
#include "history/view/media/history_view_wall_paper.h"
#include "layout.h"
#include "history/history_item.h"
@ -17,17 +17,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/themes/window_theme.h"
#include "styles/style_history.h"
namespace {
namespace HistoryView {
using TextState = HistoryView::TextState;
} // namespace
HistoryWallPaper::HistoryWallPaper(
WallPaper::WallPaper(
not_null<Element*> parent,
not_null<DocumentData*> document,
const QString &url)
: HistoryFileMedia(parent, parent->data())
: File(parent, parent->data())
, _data(document) {
Expects(_data->hasThumbnail());
@ -38,7 +34,7 @@ HistoryWallPaper::HistoryWallPaper(
setStatusSize(FileStatusSizeReady, _data->size, -1, 0);
}
void HistoryWallPaper::fillPatternFieldsFrom(const QString &url) {
void WallPaper::fillPatternFieldsFrom(const QString &url) {
const auto paramsPosition = url.indexOf('?');
if (paramsPosition < 0) {
return;
@ -53,7 +49,7 @@ void HistoryWallPaper::fillPatternFieldsFrom(const QString &url) {
_background = paper.backgroundColor().value_or(kDefaultBackground);
}
QSize HistoryWallPaper::countOptimalSize() {
QSize WallPaper::countOptimalSize() {
auto tw = ConvertScale(_data->thumbnail()->width());
auto th = ConvertScale(_data->thumbnail()->height());
if (!tw || !th) {
@ -70,7 +66,7 @@ QSize HistoryWallPaper::countOptimalSize() {
return { maxWidth, minHeight };
}
QSize HistoryWallPaper::countCurrentSize(int newWidth) {
QSize WallPaper::countCurrentSize(int newWidth) {
auto tw = ConvertScale(_data->thumbnail()->width());
auto th = ConvertScale(_data->thumbnail()->height());
if (!tw || !th) {
@ -90,7 +86,7 @@ QSize HistoryWallPaper::countCurrentSize(int newWidth) {
return { newWidth, newHeight };
}
void HistoryWallPaper::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
void WallPaper::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
_data->automaticLoad(_realParent->fullId(), _parent->data());
@ -170,7 +166,7 @@ void HistoryWallPaper::draw(Painter &p, const QRect &r, TextSelection selection,
}
}
void HistoryWallPaper::validateThumbnail() const {
void WallPaper::validateThumbnail() const {
if (_thumbnailGood > 0) {
return;
}
@ -195,7 +191,7 @@ void HistoryWallPaper::validateThumbnail() const {
}
}
void HistoryWallPaper::prepareThumbnailFrom(
void WallPaper::prepareThumbnailFrom(
not_null<Image*> image,
int good) const {
Expects(_thumbnailGood <= good);
@ -230,7 +226,7 @@ void HistoryWallPaper::prepareThumbnailFrom(
_thumbnailGood = good;
}
TextState HistoryWallPaper::textState(QPoint point, StateRequest request) const {
TextState WallPaper::textState(QPoint point, StateRequest request) const {
auto result = TextState(_parent);
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) {
@ -252,26 +248,28 @@ TextState HistoryWallPaper::textState(QPoint point, StateRequest request) const
return result;
}
float64 HistoryWallPaper::dataProgress() const {
float64 WallPaper::dataProgress() const {
return _data->progress();
}
bool HistoryWallPaper::dataFinished() const {
bool WallPaper::dataFinished() const {
return !_data->loading()
&& (!_data->uploading() || _data->waitingForAlbum());
}
bool HistoryWallPaper::dataLoaded() const {
bool WallPaper::dataLoaded() const {
return _data->loaded();
}
bool HistoryWallPaper::isReadyForOpen() const {
bool WallPaper::isReadyForOpen() const {
return _data->loaded();
}
QString HistoryWallPaper::additionalInfoString() const {
QString WallPaper::additionalInfoString() const {
// This will force message info (time) to be displayed below
// this attachment in HistoryWebPage media.
// this attachment in WebPage media.
static auto result = QString(" ");
return result;
}
} // namespace HistoryView

View file

@ -7,11 +7,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/media/history_media_file.h"
#include "history/view/media/history_view_file.h"
class HistoryWallPaper : public HistoryFileMedia {
namespace HistoryView {
class WallPaper : public File {
public:
HistoryWallPaper(
WallPaper(
not_null<Element*> parent,
not_null<DocumentData*> document,
const QString &url = QString());
@ -61,3 +63,5 @@ private:
int _intensity = 0;
};
} // namespace HistoryView

View file

@ -5,7 +5,7 @@ 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 "history/media/history_media_web_page.h"
#include "history/view/media/history_view_web_page.h"
#include "layout.h"
#include "core/click_handler_types.h"
@ -15,7 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history.h"
#include "history/view/history_view_element.h"
#include "history/view/history_view_cursor_state.h"
#include "history/media/history_media_common.h"
#include "history/view/media/history_view_media_common.h"
#include "ui/image/image.h"
#include "ui/text_options.h"
#include "data/data_session.h"
@ -25,12 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_file_origin.h"
#include "styles/style_history.h"
namespace {
using TextState = HistoryView::TextState;
} // namespace
namespace HistoryView {
namespace {
constexpr auto kMaxOriginalEntryLines = 8192;
@ -73,17 +68,17 @@ std::vector<std::unique_ptr<Data::Media>> PrepareCollageMedia(
} // namespace
HistoryWebPage::HistoryWebPage(
WebPage::WebPage(
not_null<Element*> parent,
not_null<WebPageData*> data)
: HistoryMedia(parent)
: Media(parent)
, _data(data)
, _title(st::msgMinWidth - st::webPageLeft)
, _description(st::msgMinWidth - st::webPageLeft) {
history()->owner().registerWebPageView(_data, _parent);
}
QSize HistoryWebPage::countOptimalSize() {
QSize WebPage::countOptimalSize() {
if (_data->pendingTill) {
return { 0, 0 };
}
@ -276,7 +271,7 @@ QSize HistoryWebPage::countOptimalSize() {
return { maxWidth, minHeight };
}
QSize HistoryWebPage::countCurrentSize(int newWidth) {
QSize WebPage::countCurrentSize(int newWidth) {
if (_data->pendingTill) {
return { newWidth, minHeight() };
}
@ -373,23 +368,23 @@ QSize HistoryWebPage::countCurrentSize(int newWidth) {
return { newWidth, newHeight };
}
TextSelection HistoryWebPage::toDescriptionSelection(
TextSelection WebPage::toDescriptionSelection(
TextSelection selection) const {
return HistoryView::UnshiftItemSelection(selection, _title);
return UnshiftItemSelection(selection, _title);
}
TextSelection HistoryWebPage::fromDescriptionSelection(
TextSelection WebPage::fromDescriptionSelection(
TextSelection selection) const {
return HistoryView::ShiftItemSelection(selection, _title);
return ShiftItemSelection(selection, _title);
}
void HistoryWebPage::refreshParentId(not_null<HistoryItem*> realParent) {
void WebPage::refreshParentId(not_null<HistoryItem*> realParent) {
if (_attach) {
_attach->refreshParentId(realParent);
}
}
void HistoryWebPage::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
void WebPage::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
auto paintx = 0, painty = 0, paintw = width(), painth = height();
@ -525,11 +520,11 @@ void HistoryWebPage::draw(Painter &p, const QRect &r, TextSelection selection, c
}
}
bool HistoryWebPage::asArticle() const {
bool WebPage::asArticle() const {
return _asArticle && (_data->photo != nullptr);
}
TextState HistoryWebPage::textState(QPoint point, StateRequest request) const {
TextState WebPage::textState(QPoint point, StateRequest request) const {
auto result = TextState(_parent);
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) {
@ -615,7 +610,7 @@ TextState HistoryWebPage::textState(QPoint point, StateRequest request) const {
return result;
}
ClickHandlerPtr HistoryWebPage::replaceAttachLink(
ClickHandlerPtr WebPage::replaceAttachLink(
const ClickHandlerPtr &link) const {
if (!link || !_attach->isReadyForOpen() || !_collage.empty()) {
return link;
@ -639,7 +634,7 @@ ClickHandlerPtr HistoryWebPage::replaceAttachLink(
return link;
}
TextSelection HistoryWebPage::adjustSelection(TextSelection selection, TextSelectType type) const {
TextSelection WebPage::adjustSelection(TextSelection selection, TextSelectType type) const {
if (!_descriptionLines || selection.to <= _title.length()) {
return _title.adjustSelection(selection, type);
}
@ -651,25 +646,25 @@ TextSelection HistoryWebPage::adjustSelection(TextSelection selection, TextSelec
return { titleSelection.from, fromDescriptionSelection(descriptionSelection).to };
}
void HistoryWebPage::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) {
void WebPage::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) {
if (_attach) {
_attach->clickHandlerActiveChanged(p, active);
}
}
void HistoryWebPage::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) {
void WebPage::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) {
if (_attach) {
_attach->clickHandlerPressedChanged(p, pressed);
}
}
bool HistoryWebPage::enforceBubbleWidth() const {
bool WebPage::enforceBubbleWidth() const {
return (_attach != nullptr)
&& (_data->document != nullptr)
&& _data->document->isWallPaper();
}
void HistoryWebPage::playAnimation(bool autoplay) {
void WebPage::playAnimation(bool autoplay) {
if (_attach) {
if (autoplay) {
_attach->autoplayAnimation();
@ -679,13 +674,13 @@ void HistoryWebPage::playAnimation(bool autoplay) {
}
}
bool HistoryWebPage::isDisplayed() const {
bool WebPage::isDisplayed() const {
const auto item = _parent->data();
return !_data->pendingTill
&& !item->Has<HistoryMessageLogEntryOriginal>();
}
TextForMimeData HistoryWebPage::selectedText(TextSelection selection) const {
TextForMimeData WebPage::selectedText(TextSelection selection) const {
auto titleResult = _title.toTextForMimeData(selection);
auto descriptionResult = _description.toTextForMimeData(
toDescriptionSelection(selection));
@ -698,7 +693,7 @@ TextForMimeData HistoryWebPage::selectedText(TextSelection selection) const {
return titleResult.append('\n').append(std::move(descriptionResult));
}
QMargins HistoryWebPage::inBubblePadding() const {
QMargins WebPage::inBubblePadding() const {
auto lshift = st::msgPadding.left() + st::webPageLeft;
auto rshift = st::msgPadding.right();
auto bshift = isBubbleBottom() ? st::msgPadding.left() : st::mediaInBubbleSkip;
@ -706,11 +701,11 @@ QMargins HistoryWebPage::inBubblePadding() const {
return QMargins(lshift, tshift, rshift, bshift);
}
bool HistoryWebPage::isLogEntryOriginal() const {
bool WebPage::isLogEntryOriginal() const {
return _parent->data()->isLogEntry() && _parent->media() != this;
}
int HistoryWebPage::bottomInfoPadding() const {
int WebPage::bottomInfoPadding() const {
if (!isBubbleBottom()) return 0;
auto result = st::msgDateFont->height;
@ -724,12 +719,14 @@ int HistoryWebPage::bottomInfoPadding() const {
return result;
}
QString HistoryWebPage::displayedSiteName() const {
QString WebPage::displayedSiteName() const {
return (_data->document && _data->document->isWallPaper())
? tr::lng_media_chat_background(tr::now)
: _data->siteName;
}
HistoryWebPage::~HistoryWebPage() {
WebPage::~WebPage() {
history()->owner().unregisterWebPageView(_data, _parent);
}
} // namespace HistoryView

View file

@ -7,15 +7,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
namespace Data {
class Media;
} // namespace Data
class HistoryWebPage : public HistoryMedia {
namespace HistoryView {
class WebPage : public Media {
public:
HistoryWebPage(
WebPage(
not_null<Element*> parent,
not_null<WebPageData*> data);
@ -76,11 +78,11 @@ public:
}
bool enforceBubbleWidth() const override;
HistoryMedia *attach() const {
Media *attach() const {
return _attach.get();
}
~HistoryWebPage();
~WebPage();
private:
void playAnimation(bool autoplay) override;
@ -100,7 +102,7 @@ private:
not_null<WebPageData*> _data;
std::vector<std::unique_ptr<Data::Media>> _collage;
ClickHandlerPtr _openl;
std::unique_ptr<HistoryMedia> _attach;
std::unique_ptr<Media> _attach;
bool _asArticle = false;
int _dataVersion = -1;
@ -117,3 +119,5 @@ private:
int _pixh = 0;
};
} // namespace HistoryView

View file

@ -1557,7 +1557,7 @@ bool ListWidget::requiredToStartDragging(
if (_mouseCursorState == CursorState::Date) {
return true;
}
// return dynamic_cast<HistorySticker*>(layout->getMedia());
// return dynamic_cast<Sticker*>(layout->getMedia());
return false;
}
@ -1948,7 +1948,7 @@ void ListWidget::performDrag() {
// return;
//} else {
// auto forwardMimeType = QString();
// auto pressedMedia = static_cast<HistoryMedia*>(nullptr);
// auto pressedMedia = static_cast<HistoryView::Media*>(nullptr);
// if (auto pressedItem = _pressState.layout) {
// pressedMedia = pressedItem->getMedia();
// if (_mouseCursorState == CursorState::Date || (pressedMedia && pressedMedia->dragItem())) {

View file

@ -47,7 +47,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history.h"
#include "history/history_widget.h"
#include "history/history_message.h"
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
#include "history/view/history_view_service_message.h"
#include "history/view/history_view_element.h"
#include "lang/lang_keys.h"

View file

@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_document.h"
#include "data/data_session.h"
#include "data/data_media_types.h"
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
#include "history/history_item.h"
#include "history/view/history_view_element.h"
#include "media/audio/media_audio.h"

View file

@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_web_page.h"
#include "data/data_file_origin.h"
#include "history/history.h"
#include "history/media/history_media.h"
#include "history/view/media/history_view_media.h"
#include "ui/image/image.h"
#include "main/main_session.h"
#include "styles/style_mediaview.h"

View file

@ -13,8 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/radial_animation.h"
#include "styles/style_overview.h"
class HistoryMedia;
namespace style {
struct RoundCheckbox;
} // namespace style

View file

@ -274,40 +274,40 @@
<(src_loc)/history/admin_log/history_admin_log_section.h
//<(src_loc)/history/feed/history_feed_section.cpp
//<(src_loc)/history/feed/history_feed_section.h
<(src_loc)/history/media/history_media.h
<(src_loc)/history/media/history_media.cpp
<(src_loc)/history/media/history_media_call.h
<(src_loc)/history/media/history_media_call.cpp
<(src_loc)/history/media/history_media_common.h
<(src_loc)/history/media/history_media_common.cpp
<(src_loc)/history/media/history_media_contact.h
<(src_loc)/history/media/history_media_contact.cpp
<(src_loc)/history/media/history_media_document.h
<(src_loc)/history/media/history_media_document.cpp
<(src_loc)/history/media/history_media_file.h
<(src_loc)/history/media/history_media_file.cpp
<(src_loc)/history/media/history_media_game.h
<(src_loc)/history/media/history_media_game.cpp
<(src_loc)/history/media/history_media_gif.h
<(src_loc)/history/media/history_media_gif.cpp
<(src_loc)/history/media/history_media_grouped.h
<(src_loc)/history/media/history_media_grouped.cpp
<(src_loc)/history/media/history_media_invoice.h
<(src_loc)/history/media/history_media_invoice.cpp
<(src_loc)/history/media/history_media_location.h
<(src_loc)/history/media/history_media_location.cpp
<(src_loc)/history/media/history_media_photo.h
<(src_loc)/history/media/history_media_photo.cpp
<(src_loc)/history/media/history_media_poll.h
<(src_loc)/history/media/history_media_poll.cpp
<(src_loc)/history/media/history_media_sticker.h
<(src_loc)/history/media/history_media_sticker.cpp
<(src_loc)/history/media/history_media_video.h
<(src_loc)/history/media/history_media_video.cpp
<(src_loc)/history/media/history_media_wall_paper.h
<(src_loc)/history/media/history_media_wall_paper.cpp
<(src_loc)/history/media/history_media_web_page.h
<(src_loc)/history/media/history_media_web_page.cpp
<(src_loc)/history/view/media/history_view_call.h
<(src_loc)/history/view/media/history_view_call.cpp
<(src_loc)/history/view/media/history_view_contact.h
<(src_loc)/history/view/media/history_view_contact.cpp
<(src_loc)/history/view/media/history_view_document.h
<(src_loc)/history/view/media/history_view_document.cpp
<(src_loc)/history/view/media/history_view_file.h
<(src_loc)/history/view/media/history_view_file.cpp
<(src_loc)/history/view/media/history_view_game.h
<(src_loc)/history/view/media/history_view_game.cpp
<(src_loc)/history/view/media/history_view_gif.h
<(src_loc)/history/view/media/history_view_gif.cpp
<(src_loc)/history/view/media/history_view_invoice.h
<(src_loc)/history/view/media/history_view_invoice.cpp
<(src_loc)/history/view/media/history_view_location.h
<(src_loc)/history/view/media/history_view_location.cpp
<(src_loc)/history/view/media/history_view_media.h
<(src_loc)/history/view/media/history_view_media.cpp
<(src_loc)/history/view/media/history_view_media_common.h
<(src_loc)/history/view/media/history_view_media_common.cpp
<(src_loc)/history/view/media/history_view_media_grouped.h
<(src_loc)/history/view/media/history_view_media_grouped.cpp
<(src_loc)/history/view/media/history_view_photo.h
<(src_loc)/history/view/media/history_view_photo.cpp
<(src_loc)/history/view/media/history_view_poll.h
<(src_loc)/history/view/media/history_view_poll.cpp
<(src_loc)/history/view/media/history_view_sticker.h
<(src_loc)/history/view/media/history_view_sticker.cpp
<(src_loc)/history/view/media/history_view_video.h
<(src_loc)/history/view/media/history_view_video.cpp
<(src_loc)/history/view/media/history_view_wall_paper.h
<(src_loc)/history/view/media/history_view_wall_paper.cpp
<(src_loc)/history/view/media/history_view_web_page.h
<(src_loc)/history/view/media/history_view_web_page.cpp
<(src_loc)/history/view/history_view_contact_status.cpp
<(src_loc)/history/view/history_view_contact_status.h
<(src_loc)/history/view/history_view_context_menu.cpp