mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Use a single Ui::UnreadStoryOutlineGradient.
This commit is contained in:
parent
04f1a7be02
commit
734c5c6740
7 changed files with 53 additions and 32 deletions
|
@ -84,14 +84,8 @@ constexpr auto kSearchPerPage = 50;
|
|||
const auto &st = st::contactsWithStories.item;
|
||||
const auto left = st.photoPosition.x();
|
||||
const auto top = st.photoPosition.y();
|
||||
auto gradient = QLinearGradient(
|
||||
QPoint(left + st.photoSize, top),
|
||||
QPoint(left, top + st.photoSize));
|
||||
gradient.setStops({
|
||||
{ 0., st::groupCallLive1->c },
|
||||
{ 1., st::groupCallMuted1->c },
|
||||
});
|
||||
return QBrush(gradient);
|
||||
const auto size = st.photoSize;
|
||||
return Ui::UnreadStoryOutlineGradient(QRectF(left, top, size, size));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -531,11 +531,37 @@ void Stories::loadMore(StorySourcesList list) {
|
|||
}
|
||||
}, [](const MTPDstories_allStoriesNotModified &) {
|
||||
});
|
||||
|
||||
preloadListsMore();
|
||||
}).fail([=] {
|
||||
_loadMoreRequestId[index] = 0;
|
||||
}).send();
|
||||
}
|
||||
|
||||
void Stories::preloadListsMore() {
|
||||
if (_loadMoreRequestId[static_cast<int>(StorySourcesList::NotHidden)]
|
||||
|| _loadMoreRequestId[static_cast<int>(StorySourcesList::Hidden)]) {
|
||||
return;
|
||||
}
|
||||
const auto loading = [&](StorySourcesList list) {
|
||||
return _loadMoreRequestId[static_cast<int>(list)] != 0;
|
||||
};
|
||||
const auto countLoaded = [&](StorySourcesList list) {
|
||||
const auto index = static_cast<int>(list);
|
||||
return _sourcesLoaded[index] || !_sourcesStates[index].isEmpty();
|
||||
};
|
||||
if (loading(StorySourcesList::NotHidden)
|
||||
|| loading(StorySourcesList::Hidden)) {
|
||||
return;
|
||||
} else if (!countLoaded(StorySourcesList::NotHidden)) {
|
||||
loadMore(StorySourcesList::NotHidden);
|
||||
} else if (!countLoaded(StorySourcesList::Hidden)) {
|
||||
loadMore(StorySourcesList::Hidden);
|
||||
} else if (!archiveCountKnown()) {
|
||||
archiveLoadMore();
|
||||
}
|
||||
}
|
||||
|
||||
void Stories::sendResolveRequests() {
|
||||
if (!_resolveSent.empty()) {
|
||||
return;
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "ui/chat/chat_theme.h" // CountAverageColor.
|
||||
#include "ui/color_contrast.h"
|
||||
#include "ui/effects/outline_segments.h"
|
||||
#include "ui/effects/ripple_animation.h"
|
||||
#include "ui/image/image_prepare.h"
|
||||
#include "ui/text/format_values.h"
|
||||
|
@ -372,13 +373,11 @@ void Row::PaintCornerBadgeFrame(
|
|||
}
|
||||
const auto left = st->padding.left();
|
||||
const auto top = st->padding.top();
|
||||
auto gradient = QLinearGradient(
|
||||
QPoint(left + st->photoSize, top),
|
||||
QPoint(left, top + st->photoSize));
|
||||
gradient.setStops({
|
||||
{ 0., st::groupCallLive1->c },
|
||||
{ 1., st::groupCallMuted1->c },
|
||||
});
|
||||
auto gradient = Ui::UnreadStoryOutlineGradient(QRectF(
|
||||
st->padding.left(),
|
||||
st->padding.top(),
|
||||
st->photoSize,
|
||||
st->photoSize));
|
||||
return QBrush(gradient);
|
||||
};
|
||||
const auto storiesBrush = data->storiesUnread
|
||||
|
|
|
@ -394,11 +394,7 @@ void List::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
}
|
||||
};
|
||||
auto gradient = QLinearGradient();
|
||||
gradient.setStops({
|
||||
{ 0., st::groupCallLive1->c },
|
||||
{ 1., st::groupCallMuted1->c },
|
||||
});
|
||||
auto gradient = Ui::UnreadStoryOutlineGradient();
|
||||
enumerate([&](Single single) {
|
||||
// Name.
|
||||
if (const auto full = single.itemFull) {
|
||||
|
@ -495,7 +491,8 @@ void List::paintEvent(QPaintEvent *e) {
|
|||
Ui::PaintOutlineSegments(
|
||||
p,
|
||||
rect,
|
||||
itemFull->segments);
|
||||
itemFull->segments,
|
||||
layout.segmentsSpinProgress);
|
||||
}
|
||||
|
||||
// Userpic.
|
||||
|
|
|
@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "window/window_session_controller.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/chat/chat_style.h"
|
||||
#include "ui/effects/outline_segments.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/painter.h"
|
||||
|
@ -124,23 +125,16 @@ void StoryMention::draw(
|
|||
geometry.topLeft() + QPoint(padding, padding),
|
||||
_thumbnail->image(size));
|
||||
|
||||
const auto thumbnail = geometry.marginsRemoved(
|
||||
QMargins(padding, padding, padding, padding));
|
||||
const auto thumbnail = QRectF(geometry.marginsRemoved(
|
||||
QMargins(padding, padding, padding, padding)));
|
||||
const auto added = 0.5 * (_unread
|
||||
? st::storyMentionUnreadSkipTwice
|
||||
: st::storyMentionReadSkipTwice);
|
||||
const auto outline = thumbnail.marginsAdded(
|
||||
QMargins(added, added, added, added));
|
||||
QMarginsF(added, added, added, added));
|
||||
if (_unread && _paletteVersion != style::PaletteVersion()) {
|
||||
_paletteVersion = style::PaletteVersion();
|
||||
auto gradient = QLinearGradient(
|
||||
outline.topRight(),
|
||||
outline.bottomLeft());
|
||||
gradient.setStops({
|
||||
{ 0., st::groupCallLive1->c },
|
||||
{ 1., st::groupCallMuted1->c },
|
||||
});
|
||||
_unreadBrush = QBrush(gradient);
|
||||
_unreadBrush = QBrush(Ui::UnreadStoryOutlineGradient(outline));
|
||||
}
|
||||
auto readColor = context.st->msgServiceFg()->c;
|
||||
readColor.setAlphaF(std::min(1. * readColor.alphaF(), kReadOutlineAlpha));
|
||||
|
|
|
@ -70,4 +70,13 @@ void PaintOutlineSegments(
|
|||
}
|
||||
}
|
||||
|
||||
QLinearGradient UnreadStoryOutlineGradient(QRectF rect) {
|
||||
auto result = QLinearGradient(rect.topRight(), rect.bottomLeft());
|
||||
result.setStops({
|
||||
{ 0., st::groupCallLive1->c },
|
||||
{ 1., st::groupCallMuted1->c },
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
|
|
|
@ -20,4 +20,6 @@ void PaintOutlineSegments(
|
|||
const std::vector<OutlineSegment> &segments,
|
||||
float64 fromFullProgress = 1.);
|
||||
|
||||
[[nodiscard]] QLinearGradient UnreadStoryOutlineGradient(QRectF rect = {});
|
||||
|
||||
} // namespace Ui
|
||||
|
|
Loading…
Add table
Reference in a new issue