2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-29 13:47:47 +00:00

Highlight specific media in album

This commit is contained in:
RadRussianRus 2019-10-20 08:34:20 +03:00
parent 8b1a42bbb1
commit eddf7e3553
6 changed files with 77 additions and 10 deletions

View File

@ -895,31 +895,34 @@ void HistoryWidget::scrollToAnimationCallback(
void HistoryWidget::enqueueMessageHighlight(
not_null<HistoryView::Element*> view) {
const auto originalItem = view->data();
if (const auto group = session().data().groups().find(view->data())) {
if (const auto leader = group->items.back()->mainView()) {
view = leader;
}
}
auto enqueueMessageId = [this](MsgId universalId) {
auto enqueueMessageId = [this](MsgId universalId, MsgId originalId) {
if (_highlightQueue.empty() && !_highlightTimer.isActive()) {
highlightMessage(universalId);
highlightMessage(universalId, originalId);
} else if (_highlightedMessageId != universalId
&& !base::contains(_highlightQueue, universalId)) {
_highlightQueue.push_back(universalId);
_highlightOriginalQueue.push_back(originalId);
checkNextHighlight();
}
};
const auto item = view->data();
if (item->history() == _history) {
enqueueMessageId(item->id);
enqueueMessageId(item->id, originalItem->id);
} else if (item->history() == _migrated) {
enqueueMessageId(-item->id);
enqueueMessageId(-item->id, -originalItem->id);
}
}
void HistoryWidget::highlightMessage(MsgId universalMessageId) {
void HistoryWidget::highlightMessage(MsgId universalMessageId, MsgId originalMessageId) {
_highlightStart = crl::now();
_highlightedMessageId = universalMessageId;
_highlightedOriginalMessageId = originalMessageId;
_highlightTimer.callEach(AnimationTimerDelta);
}
@ -938,10 +941,21 @@ void HistoryWidget::checkNextHighlight() {
}
return 0;
}();
if (!nextHighlight) {
auto nextOriginalHighlight = [this] {
while (!_highlightOriginalQueue.empty()) {
auto msgId = _highlightOriginalQueue.front();
_highlightOriginalQueue.pop_front();
auto item = getItemFromHistoryOrMigrated(msgId);
if (item && item->mainView()) {
return msgId;
}
}
return 0;
}();
if (!nextHighlight || !nextOriginalHighlight) {
return;
}
highlightMessage(nextHighlight);
highlightMessage(nextHighlight, nextOriginalHighlight);
}
void HistoryWidget::updateHighlightedMessage() {
@ -975,11 +989,13 @@ crl::time HistoryWidget::highlightStartTime(not_null<const HistoryItem*> item) c
void HistoryWidget::stopMessageHighlight() {
_highlightTimer.cancel();
_highlightedMessageId = 0;
_highlightedOriginalMessageId = 0;
checkNextHighlight();
}
void HistoryWidget::clearHighlightMessages() {
_highlightQueue.clear();
_highlightOriginalQueue.clear();
stopMessageHighlight();
}
@ -3145,6 +3161,11 @@ MsgId HistoryWidget::msgId() const {
return _showAtMsgId;
}
MsgId HistoryWidget::highlightOrigId() const {
return _highlightedOriginalMessageId;
}
void HistoryWidget::showAnimated(
Window::SlideDirection direction,
const Window::SectionSlideParams &params) {

View File

@ -147,6 +147,7 @@ public:
PeerData *peer() const;
void setMsgId(MsgId showAtMsgId);
MsgId msgId() const;
MsgId highlightOrigId() const;
bool hasTopBarShadow() const {
return peer() != nullptr;
@ -402,7 +403,7 @@ private:
void supportInsertText(const QString &text);
void supportShareContact(Support::Contact contact);
void highlightMessage(MsgId universalMessageId);
void highlightMessage(MsgId universalMessageId, MsgId originalMessageId);
void checkNextHighlight();
void updateHighlightedMessage();
void clearHighlightMessages();
@ -791,6 +792,8 @@ private:
MsgId _highlightedMessageId = 0;
std::deque<MsgId> _highlightQueue;
MsgId _highlightedOriginalMessageId = 0;
std::deque<MsgId> _highlightOriginalQueue;
base::Timer _highlightTimer;
crl::time _highlightStart = 0;

View File

@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h"
#include "data/data_photo.h"
#include "data/data_file_origin.h"
#include "mainwidget.h"
#include "app.h"
#include "styles/style_history.h"
@ -368,7 +369,25 @@ void Photo::drawGrouped(
if (!bubble) {
// App::roundShadow(p, 0, 0, paintw, painth, selected ? st::msgInShadowSelected : st::msgInShadow, selected ? InSelectedShadowCorners : InShadowCorners);
}
p.drawPixmap(geometry.topLeft(), *cache);
const auto animms = _parent->delegate()->elementHighlightTime(_parent);
const auto realId = _realParent->id;
const auto mainWidget = App::main();
const auto highlightedRealId = mainWidget->highlightedOriginalId();
if (realId != highlightedRealId
&& animms
&& animms < st::activeFadeInDuration + st::activeFadeOutDuration) {
const auto dt = (animms <= st::activeFadeInDuration)
? ((animms / float64(st::activeFadeInDuration)))
: (1. - (animms - st::activeFadeInDuration)
/ float64(st::activeFadeOutDuration));
const auto o = p.opacity();
p.setOpacity(o - dt * 0.8);
p.drawPixmap(geometry.topLeft(), *cache);
p.setOpacity(o);
} else {
p.drawPixmap(geometry.topLeft(), *cache);
}
if (selected) {
const auto roundRadius = ImageRoundRadius::Large;
App::complexOverlayRect(p, geometry, roundRadius, corners);

View File

@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h"
#include "data/data_document.h"
#include "data/data_file_origin.h"
#include "mainwidget.h"
#include "app.h"
#include "styles/style_history.h"
@ -410,7 +411,24 @@ void Video::drawGrouped(
if (!bubble) {
// App::roundShadow(p, 0, 0, paintw, painth, selected ? st::msgInShadowSelected : st::msgInShadow, selected ? InSelectedShadowCorners : InShadowCorners);
}
p.drawPixmap(geometry.topLeft(), *cache);
const auto animms = _parent->delegate()->elementHighlightTime(_parent);
const auto realId = _realParent->id;
const auto mainWidget = App::main();
const auto highlightedRealId = mainWidget->highlightedOriginalId();
if (realId != highlightedRealId
&& animms
&& animms < st::activeFadeInDuration + st::activeFadeOutDuration) {
const auto dt = (animms <= st::activeFadeInDuration)
? ((animms / float64(st::activeFadeInDuration)))
: (1. - (animms - st::activeFadeInDuration)
/ float64(st::activeFadeOutDuration));
const auto o = p.opacity();
p.setOpacity(o - dt * 0.8);
p.drawPixmap(geometry.topLeft(), *cache);
p.setOpacity(o);
} else {
p.drawPixmap(geometry.topLeft(), *cache);
}
if (selected) {
const auto roundRadius = ImageRoundRadius::Large;
App::complexOverlayRect(p, geometry, roundRadius, corners);

View File

@ -778,6 +778,10 @@ void MainWidget::notify_historyMuteUpdated(History *history) {
_dialogs->notify_historyMuteUpdated(history);
}
MsgId MainWidget::highlightedOriginalId() const {
return _history->highlightOrigId();
}
void MainWidget::clearHider(not_null<Window::HistoryHider*> instance) {
if (_hider != instance) {
return;

View File

@ -292,6 +292,8 @@ public:
void notify_showScheduledButtonChanged();
void notify_historyMuteUpdated(History *history);
MsgId highlightedOriginalId() const;
void closeBothPlayers();
bool isQuitPrevent();