mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Support text-color-ed emoji in userpic editor.
This commit is contained in:
parent
ed9ba07a32
commit
fec80c0c64
5 changed files with 11 additions and 60 deletions
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "base/random.h"
|
#include "base/random.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
|
#include "data/stickers/data_stickers.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
|
@ -125,7 +126,11 @@ constexpr auto kSharedMediaLimit = 100;
|
||||||
colors,
|
colors,
|
||||||
ranges::back_inserter(mtpColors),
|
ranges::back_inserter(mtpColors),
|
||||||
[&](const QColor &c) { return MTP_int(serializeColor(c)); });
|
[&](const QColor &c) { return MTP_int(serializeColor(c)); });
|
||||||
if (sticker->set.id && sticker->set.accessHash) {
|
if (sticker->setType == Data::StickersType::Emoji) {
|
||||||
|
return MTP_videoSizeEmojiMarkup(
|
||||||
|
MTP_long(document->id),
|
||||||
|
MTP_vector(mtpColors));
|
||||||
|
} else if (sticker->set.id && sticker->set.accessHash) {
|
||||||
return MTP_videoSizeStickerMarkup(
|
return MTP_videoSizeStickerMarkup(
|
||||||
MTP_inputStickerSetID(
|
MTP_inputStickerSetID(
|
||||||
MTP_long(sticker->set.id),
|
MTP_long(sticker->set.id),
|
||||||
|
|
|
@ -425,10 +425,6 @@ CustomEmojiManager::CustomEmojiManager(not_null<Session*> owner)
|
||||||
QString()).toULongLong();
|
QString()).toULongLong();
|
||||||
if (setId) {
|
if (setId) {
|
||||||
_coloredSetId = setId;
|
_coloredSetId = setId;
|
||||||
auto pending = base::take(_coloredSetPending);
|
|
||||||
for (const auto &instance : pending[setId]) {
|
|
||||||
instance->setColored();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
@ -460,12 +456,6 @@ std::unique_ptr<Ui::Text::CustomEmoji> CustomEmojiManager::create(
|
||||||
}, std::move(repaint))).first;
|
}, std::move(repaint))).first;
|
||||||
if (colored) {
|
if (colored) {
|
||||||
i->second->setColored();
|
i->second->setColored();
|
||||||
} else if (_coloredSetId) {
|
|
||||||
if (_coloredSetId == setId) {
|
|
||||||
i->second->setColored();
|
|
||||||
}
|
|
||||||
} else if (setId) {
|
|
||||||
_coloredSetPending[setId].emplace(i->second.get());
|
|
||||||
}
|
}
|
||||||
} else if (!i->second->hasImagePreview()) {
|
} else if (!i->second->hasImagePreview()) {
|
||||||
auto preview = prepareNonExactPreview(documentId, tag, sizeOverride);
|
auto preview = prepareNonExactPreview(documentId, tag, sizeOverride);
|
||||||
|
@ -693,32 +683,14 @@ void CustomEmojiManager::request() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomEmojiManager::fillColoredFlags(not_null<DocumentData*> document) {
|
void CustomEmojiManager::fillColoredFlags(not_null<DocumentData*> document) {
|
||||||
const auto id = document->id;
|
if (document->emojiUsesTextColor()) {
|
||||||
const auto setColored = [&] {
|
const auto id = document->id;
|
||||||
for (auto &instances : _instances) {
|
for (auto &instances : _instances) {
|
||||||
const auto i = instances.find(id);
|
const auto i = instances.find(id);
|
||||||
if (i != end(instances)) {
|
if (i != end(instances)) {
|
||||||
i->second->setColored();
|
i->second->setColored();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
if (document->emojiUsesTextColor()) {
|
|
||||||
setColored();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto sticker = document->sticker();
|
|
||||||
const auto setId = sticker ? sticker->set.id : uint64();
|
|
||||||
if (!setId || (_coloredSetId && setId != _coloredSetId)) {
|
|
||||||
return;
|
|
||||||
} else if (setId == _coloredSetId) {
|
|
||||||
setColored();
|
|
||||||
} else {
|
|
||||||
for (auto &instances : _instances) {
|
|
||||||
const auto i = instances.find(id);
|
|
||||||
if (i != end(instances)) {
|
|
||||||
_coloredSetPending[setId].emplace(i->second.get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,10 +152,6 @@ private:
|
||||||
not_null<Listener*>,
|
not_null<Listener*>,
|
||||||
base::flat_set<DocumentId>> _listeners;
|
base::flat_set<DocumentId>> _listeners;
|
||||||
base::flat_set<DocumentId> _pendingForRequest;
|
base::flat_set<DocumentId> _pendingForRequest;
|
||||||
base::flat_map<
|
|
||||||
uint64,
|
|
||||||
base::flat_set<
|
|
||||||
not_null<Ui::CustomEmoji::Instance*>>> _coloredSetPending;
|
|
||||||
|
|
||||||
mtpRequestId _requestId = 0;
|
mtpRequestId _requestId = 0;
|
||||||
|
|
||||||
|
|
|
@ -118,12 +118,10 @@ void PreviewPainter::paintBackground(QPainter &p, const QImage &image) {
|
||||||
|
|
||||||
bool PreviewPainter::paintForeground(QPainter &p) {
|
bool PreviewPainter::paintForeground(QPainter &p) {
|
||||||
if (_player && _player->ready()) {
|
if (_player && _player->ready()) {
|
||||||
// resolveIsColored();
|
const auto c = _media->owner()->emojiUsesTextColor() ? 255 : 0;
|
||||||
auto frame = _player->frame(
|
auto frame = _player->frame(
|
||||||
Size(_emojiSize),
|
Size(_emojiSize),
|
||||||
(/*_isColored
|
QColor(c, c, c, c),
|
||||||
? st::profileVerifiedCheckBg->c
|
|
||||||
: */QColor(0, 0, 0, 0)),
|
|
||||||
false,
|
false,
|
||||||
crl::now(),
|
crl::now(),
|
||||||
_paused);
|
_paused);
|
||||||
|
|
|
@ -489,14 +489,10 @@ public:
|
||||||
void paint(QPainter &p);
|
void paint(QPainter &p);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resolveIsColored();
|
|
||||||
|
|
||||||
QRectF _rect;
|
QRectF _rect;
|
||||||
std::shared_ptr<Data::DocumentMedia> _media;
|
std::shared_ptr<Data::DocumentMedia> _media;
|
||||||
std::unique_ptr<HistoryView::StickerPlayer> _player;
|
std::unique_ptr<HistoryView::StickerPlayer> _player;
|
||||||
bool _paused = false;
|
bool _paused = false;
|
||||||
bool _isColored = false;
|
|
||||||
bool _isColoredResolved = false;
|
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -555,27 +551,11 @@ void EmojiStatusTopBar::setPaused(bool paused) {
|
||||||
_paused = paused;
|
_paused = paused;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiStatusTopBar::resolveIsColored() {
|
|
||||||
if (_isColoredResolved) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto document = _media->owner();
|
|
||||||
const auto manager = &document->owner().customEmojiManager();
|
|
||||||
const auto coloredSetId = manager->coloredSetId();
|
|
||||||
if (!coloredSetId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_isColoredResolved = true;
|
|
||||||
const auto sticker = document->sticker();
|
|
||||||
_isColored = sticker && (sticker->set.id == coloredSetId);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmojiStatusTopBar::paint(QPainter &p) {
|
void EmojiStatusTopBar::paint(QPainter &p) {
|
||||||
if (_player && _player->ready()) {
|
if (_player && _player->ready()) {
|
||||||
resolveIsColored();
|
|
||||||
const auto frame = _player->frame(
|
const auto frame = _player->frame(
|
||||||
_rect.size().toSize(),
|
_rect.size().toSize(),
|
||||||
(_isColored
|
(_media->owner()->emojiUsesTextColor()
|
||||||
? st::profileVerifiedCheckBg->c
|
? st::profileVerifiedCheckBg->c
|
||||||
: QColor(0, 0, 0, 0)),
|
: QColor(0, 0, 0, 0)),
|
||||||
false,
|
false,
|
||||||
|
|
Loading…
Add table
Reference in a new issue