init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
This commit is contained in:
104
Telegram/SourceFiles/ui/effects/outline_segments.cpp
Normal file
104
Telegram/SourceFiles/ui/effects/outline_segments.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
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 "ui/effects/outline_segments.h"
|
||||
|
||||
namespace Ui {
|
||||
|
||||
void PaintOutlineSegments(
|
||||
QPainter &p,
|
||||
QRectF ellipse,
|
||||
const std::vector<OutlineSegment> &segments,
|
||||
float64 fromFullProgress) {
|
||||
Expects(!segments.empty());
|
||||
|
||||
p.setBrush(Qt::NoBrush);
|
||||
const auto count = std::min(int(segments.size()), kOutlineSegmentsMax);
|
||||
if (count == 1) {
|
||||
p.setPen(QPen(segments.front().brush, segments.front().width));
|
||||
p.drawEllipse(ellipse);
|
||||
return;
|
||||
}
|
||||
const auto small = 160;
|
||||
const auto full = arc::kFullLength;
|
||||
const auto separator = (full > 1.1 * small * count)
|
||||
? small
|
||||
: (full / (count * 1.1));
|
||||
const auto left = full - (separator * count);
|
||||
const auto length = left / float64(count);
|
||||
const auto spin = separator * (1. - fromFullProgress);
|
||||
|
||||
auto start = 0. + (arc::kQuarterLength + (separator / 2)) + (3. * spin);
|
||||
auto pen = QPen(
|
||||
segments.back().brush,
|
||||
segments.back().width,
|
||||
Qt::SolidLine,
|
||||
Qt::RoundCap);
|
||||
p.setPen(pen);
|
||||
for (auto i = 0; i != count;) {
|
||||
const auto &segment = segments[count - (++i)];
|
||||
if (!segment.width) {
|
||||
start += length + separator;
|
||||
continue;
|
||||
} else if (pen.brush() != segment.brush
|
||||
|| pen.widthF() != segment.width) {
|
||||
pen = QPen(
|
||||
segment.brush,
|
||||
segment.width,
|
||||
Qt::SolidLine,
|
||||
Qt::RoundCap);
|
||||
p.setPen(pen);
|
||||
}
|
||||
const auto from = int(base::SafeRound(start));
|
||||
const auto till = start + length;
|
||||
auto added = spin;
|
||||
for (; i != count;) {
|
||||
start += length + separator;
|
||||
const auto &next = segments[count - (++i)];
|
||||
if (next.width) {
|
||||
--i;
|
||||
break;
|
||||
}
|
||||
added += (separator + length) * (1. - fromFullProgress);
|
||||
}
|
||||
p.drawArc(ellipse, from, int(base::SafeRound(till + added)) - from);
|
||||
}
|
||||
}
|
||||
|
||||
void PaintOutlineSegments(
|
||||
QPainter &p,
|
||||
QRectF rect,
|
||||
float64 radius,
|
||||
const std::vector<OutlineSegment> &segments) {
|
||||
Expects(!segments.empty());
|
||||
|
||||
p.setBrush(Qt::NoBrush);
|
||||
const auto count = std::min(int(segments.size()), kOutlineSegmentsMax);
|
||||
if (count == 1 || true) {
|
||||
p.setPen(QPen(segments.back().brush, segments.back().width));
|
||||
p.drawRoundedRect(rect, radius, radius);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QLinearGradient UnreadStoryOutlineGradient(
|
||||
QRectF rect,
|
||||
const QColor &c1,
|
||||
const QColor &c2) {
|
||||
auto result = QLinearGradient(rect.topRight(), rect.bottomLeft());
|
||||
result.setStops({ { 0., c1 }, { 1., c2 } });
|
||||
return result;
|
||||
}
|
||||
|
||||
QLinearGradient UnreadStoryOutlineGradient(QRectF rect) {
|
||||
return UnreadStoryOutlineGradient(
|
||||
std::move(rect),
|
||||
st::groupCallLive1->c,
|
||||
st::groupCallMuted1->c);
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
Reference in New Issue
Block a user