2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-29 21:57:42 +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( void HistoryWidget::enqueueMessageHighlight(
not_null<HistoryView::Element*> view) { not_null<HistoryView::Element*> view) {
const auto originalItem = view->data();
if (const auto group = session().data().groups().find(view->data())) { if (const auto group = session().data().groups().find(view->data())) {
if (const auto leader = group->items.back()->mainView()) { if (const auto leader = group->items.back()->mainView()) {
view = leader; view = leader;
} }
} }
auto enqueueMessageId = [this](MsgId universalId) { auto enqueueMessageId = [this](MsgId universalId, MsgId originalId) {
if (_highlightQueue.empty() && !_highlightTimer.isActive()) { if (_highlightQueue.empty() && !_highlightTimer.isActive()) {
highlightMessage(universalId); highlightMessage(universalId, originalId);
} else if (_highlightedMessageId != universalId } else if (_highlightedMessageId != universalId
&& !base::contains(_highlightQueue, universalId)) { && !base::contains(_highlightQueue, universalId)) {
_highlightQueue.push_back(universalId); _highlightQueue.push_back(universalId);
_highlightOriginalQueue.push_back(originalId);
checkNextHighlight(); checkNextHighlight();
} }
}; };
const auto item = view->data(); const auto item = view->data();
if (item->history() == _history) { if (item->history() == _history) {
enqueueMessageId(item->id); enqueueMessageId(item->id, originalItem->id);
} else if (item->history() == _migrated) { } 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(); _highlightStart = crl::now();
_highlightedMessageId = universalMessageId; _highlightedMessageId = universalMessageId;
_highlightedOriginalMessageId = originalMessageId;
_highlightTimer.callEach(AnimationTimerDelta); _highlightTimer.callEach(AnimationTimerDelta);
} }
@ -938,10 +941,21 @@ void HistoryWidget::checkNextHighlight() {
} }
return 0; 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; return;
} }
highlightMessage(nextHighlight); highlightMessage(nextHighlight, nextOriginalHighlight);
} }
void HistoryWidget::updateHighlightedMessage() { void HistoryWidget::updateHighlightedMessage() {
@ -975,11 +989,13 @@ crl::time HistoryWidget::highlightStartTime(not_null<const HistoryItem*> item) c
void HistoryWidget::stopMessageHighlight() { void HistoryWidget::stopMessageHighlight() {
_highlightTimer.cancel(); _highlightTimer.cancel();
_highlightedMessageId = 0; _highlightedMessageId = 0;
_highlightedOriginalMessageId = 0;
checkNextHighlight(); checkNextHighlight();
} }
void HistoryWidget::clearHighlightMessages() { void HistoryWidget::clearHighlightMessages() {
_highlightQueue.clear(); _highlightQueue.clear();
_highlightOriginalQueue.clear();
stopMessageHighlight(); stopMessageHighlight();
} }
@ -3145,6 +3161,11 @@ MsgId HistoryWidget::msgId() const {
return _showAtMsgId; return _showAtMsgId;
} }
MsgId HistoryWidget::highlightOrigId() const {
return _highlightedOriginalMessageId;
}
void HistoryWidget::showAnimated( void HistoryWidget::showAnimated(
Window::SlideDirection direction, Window::SlideDirection direction,
const Window::SectionSlideParams &params) { const Window::SectionSlideParams &params) {

View File

@ -147,6 +147,7 @@ public:
PeerData *peer() const; PeerData *peer() const;
void setMsgId(MsgId showAtMsgId); void setMsgId(MsgId showAtMsgId);
MsgId msgId() const; MsgId msgId() const;
MsgId highlightOrigId() const;
bool hasTopBarShadow() const { bool hasTopBarShadow() const {
return peer() != nullptr; return peer() != nullptr;
@ -402,7 +403,7 @@ private:
void supportInsertText(const QString &text); void supportInsertText(const QString &text);
void supportShareContact(Support::Contact contact); void supportShareContact(Support::Contact contact);
void highlightMessage(MsgId universalMessageId); void highlightMessage(MsgId universalMessageId, MsgId originalMessageId);
void checkNextHighlight(); void checkNextHighlight();
void updateHighlightedMessage(); void updateHighlightedMessage();
void clearHighlightMessages(); void clearHighlightMessages();
@ -791,6 +792,8 @@ private:
MsgId _highlightedMessageId = 0; MsgId _highlightedMessageId = 0;
std::deque<MsgId> _highlightQueue; std::deque<MsgId> _highlightQueue;
MsgId _highlightedOriginalMessageId = 0;
std::deque<MsgId> _highlightOriginalQueue;
base::Timer _highlightTimer; base::Timer _highlightTimer;
crl::time _highlightStart = 0; 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_session.h"
#include "data/data_photo.h" #include "data/data_photo.h"
#include "data/data_file_origin.h" #include "data/data_file_origin.h"
#include "mainwidget.h"
#include "app.h" #include "app.h"
#include "styles/style_history.h" #include "styles/style_history.h"
@ -368,7 +369,25 @@ void Photo::drawGrouped(
if (!bubble) { if (!bubble) {
// App::roundShadow(p, 0, 0, paintw, painth, selected ? st::msgInShadowSelected : st::msgInShadow, selected ? InSelectedShadowCorners : InShadowCorners); // 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) { if (selected) {
const auto roundRadius = ImageRoundRadius::Large; const auto roundRadius = ImageRoundRadius::Large;
App::complexOverlayRect(p, geometry, roundRadius, corners); 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_session.h"
#include "data/data_document.h" #include "data/data_document.h"
#include "data/data_file_origin.h" #include "data/data_file_origin.h"
#include "mainwidget.h"
#include "app.h" #include "app.h"
#include "styles/style_history.h" #include "styles/style_history.h"
@ -410,7 +411,24 @@ void Video::drawGrouped(
if (!bubble) { if (!bubble) {
// App::roundShadow(p, 0, 0, paintw, painth, selected ? st::msgInShadowSelected : st::msgInShadow, selected ? InSelectedShadowCorners : InShadowCorners); // 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) { if (selected) {
const auto roundRadius = ImageRoundRadius::Large; const auto roundRadius = ImageRoundRadius::Large;
App::complexOverlayRect(p, geometry, roundRadius, corners); App::complexOverlayRect(p, geometry, roundRadius, corners);

View File

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

View File

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