mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Create nice camera init effect.
This commit is contained in:
parent
6287d306c2
commit
9ce6636c6a
2 changed files with 51 additions and 2 deletions
|
@ -1031,6 +1031,12 @@ void RoundVideoRecorder::Private::updateResultDuration(
|
||||||
RoundVideoRecorder::RoundVideoRecorder(
|
RoundVideoRecorder::RoundVideoRecorder(
|
||||||
RoundVideoRecorderDescriptor &&descriptor)
|
RoundVideoRecorderDescriptor &&descriptor)
|
||||||
: _descriptor(std::move(descriptor))
|
: _descriptor(std::move(descriptor))
|
||||||
|
, _gradientBg(QColor(255, 255, 255, 0))
|
||||||
|
, _gradientFg(QColor(255, 255, 255, 48))
|
||||||
|
, _gradient(
|
||||||
|
_gradientBg.color(),
|
||||||
|
_gradientFg.color(),
|
||||||
|
[=] { _preview->update(); })
|
||||||
, _preview(std::make_unique<RpWidget>(_descriptor.container))
|
, _preview(std::make_unique<RpWidget>(_descriptor.container))
|
||||||
, _private(MinithumbSize()) {
|
, _private(MinithumbSize()) {
|
||||||
setup();
|
setup();
|
||||||
|
@ -1192,6 +1198,43 @@ void RoundVideoRecorder::setup() {
|
||||||
QRect(0, 0, side, side)));
|
QRect(0, 0, side, side)));
|
||||||
}, raw->lifetime());
|
}, raw->lifetime());
|
||||||
|
|
||||||
|
const auto paintPlaceholder = [=](QPainter &p, QRect inner) {
|
||||||
|
p.drawImage(inner, _framePlaceholder);
|
||||||
|
if (_paused) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_gradient.startFrame(
|
||||||
|
0,
|
||||||
|
raw->width(),
|
||||||
|
raw->width() * 2 / 3);
|
||||||
|
_gradient.paint([&](const Ui::PathShiftGradient::Background &b) {
|
||||||
|
if (!v::is<QLinearGradient*>(b)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
|
const auto gradient = v::get<QLinearGradient*>(b);
|
||||||
|
|
||||||
|
auto copy = *gradient;
|
||||||
|
auto stops = copy.stops();
|
||||||
|
for (auto &pair : stops) {
|
||||||
|
if (pair.second.alpha() > 0) {
|
||||||
|
pair.second.setAlpha(255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
copy.setStops(stops);
|
||||||
|
|
||||||
|
const auto stroke = style::ConvertScaleExact(1.);
|
||||||
|
const auto sub = stroke / 2.;
|
||||||
|
p.setPen(QPen(QBrush(copy), stroke));
|
||||||
|
|
||||||
|
p.setBrush(*gradient);
|
||||||
|
const auto innerf = QRectF(inner);
|
||||||
|
p.drawEllipse(innerf.marginsRemoved({ sub, sub, sub, sub }));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
raw->paintRequest() | rpl::start_with_next([=] {
|
raw->paintRequest() | rpl::start_with_next([=] {
|
||||||
prepareFrame();
|
prepareFrame();
|
||||||
|
|
||||||
|
@ -1202,14 +1245,16 @@ void RoundVideoRecorder::setup() {
|
||||||
} else if (!_visible) {
|
} else if (!_visible) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.drawImage(raw->rect(), _shadow);
|
p.drawImage(raw->rect(), _shadow);
|
||||||
const auto inner = QRect(_extent, _extent, _side, _side);
|
const auto inner = QRect(_extent, _extent, _side, _side);
|
||||||
const auto fading = _fadeContentAnimation.animating();
|
const auto fading = _fadeContentAnimation.animating();
|
||||||
if (!_progressReceived && !fading) {
|
if (!_progressReceived && !fading) {
|
||||||
p.drawImage(inner, _framePlaceholder);
|
paintPlaceholder(p, inner);
|
||||||
} else {
|
} else {
|
||||||
if (fading) {
|
if (fading) {
|
||||||
p.drawImage(inner, _framePlaceholder);
|
paintPlaceholder(p, inner);
|
||||||
|
|
||||||
const auto to = _progressReceived ? 1. : 0.;
|
const auto to = _progressReceived ? 1. : 0.;
|
||||||
p.setOpacity(opacity * _fadeContentAnimation.value(to));
|
p.setOpacity(opacity * _fadeContentAnimation.value(to));
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "base/weak_ptr.h"
|
#include "base/weak_ptr.h"
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
|
#include "ui/effects/path_shift_gradient.h"
|
||||||
|
|
||||||
#include <crl/crl_object_on_queue.h>
|
#include <crl/crl_object_on_queue.h>
|
||||||
|
|
||||||
|
@ -91,6 +92,9 @@ private:
|
||||||
[[nodiscard]] PreviewFrame lookupPreviewFrame() const;
|
[[nodiscard]] PreviewFrame lookupPreviewFrame() const;
|
||||||
|
|
||||||
const RoundVideoRecorderDescriptor _descriptor;
|
const RoundVideoRecorderDescriptor _descriptor;
|
||||||
|
style::owned_color _gradientBg;
|
||||||
|
style::owned_color _gradientFg;
|
||||||
|
PathShiftGradient _gradient;
|
||||||
std::unique_ptr<RpWidget> _preview;
|
std::unique_ptr<RpWidget> _preview;
|
||||||
crl::object_on_queue<Private> _private;
|
crl::object_on_queue<Private> _private;
|
||||||
Ui::Animations::Simple _progressAnimation;
|
Ui::Animations::Simple _progressAnimation;
|
||||||
|
|
Loading…
Add table
Reference in a new issue