mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add a small scale for stories siblings.
This commit is contained in:
parent
5aa6102903
commit
0f2e8d9a79
6 changed files with 30 additions and 4 deletions
|
@ -32,6 +32,7 @@ constexpr auto kSiblingFade = 0.5;
|
||||||
constexpr auto kSiblingFadeOver = 0.4;
|
constexpr auto kSiblingFadeOver = 0.4;
|
||||||
constexpr auto kSiblingNameOpacity = 0.8;
|
constexpr auto kSiblingNameOpacity = 0.8;
|
||||||
constexpr auto kSiblingNameOpacityOver = 1.;
|
constexpr auto kSiblingNameOpacityOver = 1.;
|
||||||
|
constexpr auto kSiblingScaleOver = 0.05;
|
||||||
|
|
||||||
[[nodiscard]] StoryId LookupShownId(
|
[[nodiscard]] StoryId LookupShownId(
|
||||||
const Data::StoriesSource &source,
|
const Data::StoriesSource &source,
|
||||||
|
@ -325,6 +326,7 @@ SiblingView Sibling::view(const SiblingLayout &layout, float64 over) {
|
||||||
.namePosition = namePosition(layout, name),
|
.namePosition = namePosition(layout, name),
|
||||||
.nameOpacity = (kSiblingNameOpacity * (1 - over)
|
.nameOpacity = (kSiblingNameOpacity * (1 - over)
|
||||||
+ kSiblingNameOpacityOver * over),
|
+ kSiblingNameOpacityOver * over),
|
||||||
|
.scale = 1. + (over * kSiblingScaleOver),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ class Controller;
|
||||||
struct ContentLayout {
|
struct ContentLayout {
|
||||||
QRect geometry;
|
QRect geometry;
|
||||||
float64 fade = 0.;
|
float64 fade = 0.;
|
||||||
|
float64 scale = 1.;
|
||||||
int radius = 0;
|
int radius = 0;
|
||||||
bool headerOutside = false;
|
bool headerOutside = false;
|
||||||
};
|
};
|
||||||
|
@ -39,6 +40,7 @@ struct SiblingView {
|
||||||
QImage name;
|
QImage name;
|
||||||
QPoint namePosition;
|
QPoint namePosition;
|
||||||
float64 nameOpacity = 0.;
|
float64 nameOpacity = 0.;
|
||||||
|
float64 scale = 1.;
|
||||||
|
|
||||||
[[nodiscard]] bool valid() const {
|
[[nodiscard]] bool valid() const {
|
||||||
return !image.isNull();
|
return !image.isNull();
|
||||||
|
|
|
@ -488,7 +488,9 @@ void OverlayWidget::RendererGL::paintTransformedContent(
|
||||||
not_null<QOpenGLShaderProgram*> program,
|
not_null<QOpenGLShaderProgram*> program,
|
||||||
ContentGeometry geometry,
|
ContentGeometry geometry,
|
||||||
bool fillTransparentBackground) {
|
bool fillTransparentBackground) {
|
||||||
const auto rect = transformRect(geometry.rect);
|
const auto rect = scaleRect(
|
||||||
|
transformRect(geometry.rect),
|
||||||
|
geometry.scale);
|
||||||
const auto centerx = rect.x() + rect.width() / 2;
|
const auto centerx = rect.x() + rect.width() / 2;
|
||||||
const auto centery = rect.y() + rect.height() / 2;
|
const auto centery = rect.y() + rect.height() / 2;
|
||||||
const auto rsin = float(std::sin(geometry.rotation * M_PI / 180.));
|
const auto rsin = float(std::sin(geometry.rotation * M_PI / 180.));
|
||||||
|
@ -1066,4 +1068,17 @@ Rect OverlayWidget::RendererGL::transformRect(const QRect &raster) const {
|
||||||
return TransformRect(Rect(raster), _viewport, _factor);
|
return TransformRect(Rect(raster), _viewport, _factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rect OverlayWidget::RendererGL::scaleRect(
|
||||||
|
const Rect &unscaled,
|
||||||
|
float64 scale) const {
|
||||||
|
const auto added = scale - 1.;
|
||||||
|
const auto addw = unscaled.width() * added;
|
||||||
|
const auto addh = unscaled.height() * added;
|
||||||
|
return Rect(
|
||||||
|
unscaled.x() - addw / 2,
|
||||||
|
unscaled.y() - addh / 2,
|
||||||
|
unscaled.width() + addw,
|
||||||
|
unscaled.height() + addh);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Media::View
|
} // namespace Media::View
|
||||||
|
|
|
@ -97,6 +97,9 @@ private:
|
||||||
[[nodiscard]] Ui::GL::Rect transformRect(const QRectF &raster) const;
|
[[nodiscard]] Ui::GL::Rect transformRect(const QRectF &raster) const;
|
||||||
[[nodiscard]] Ui::GL::Rect transformRect(
|
[[nodiscard]] Ui::GL::Rect transformRect(
|
||||||
const Ui::GL::Rect &raster) const;
|
const Ui::GL::Rect &raster) const;
|
||||||
|
[[nodiscard]] Ui::GL::Rect scaleRect(
|
||||||
|
const Ui::GL::Rect &unscaled,
|
||||||
|
float64 scale) const;
|
||||||
|
|
||||||
void uploadTexture(
|
void uploadTexture(
|
||||||
GLint internalformat,
|
GLint internalformat,
|
||||||
|
|
|
@ -1795,11 +1795,13 @@ OverlayWidget::ContentGeometry OverlayWidget::contentGeometry() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
OverlayWidget::ContentGeometry OverlayWidget::storiesContentGeometry(
|
OverlayWidget::ContentGeometry OverlayWidget::storiesContentGeometry(
|
||||||
const Stories::ContentLayout &layout) const {
|
const Stories::ContentLayout &layout,
|
||||||
|
float64 scale) const {
|
||||||
return {
|
return {
|
||||||
.rect = QRectF(layout.geometry),
|
.rect = QRectF(layout.geometry),
|
||||||
.controlsOpacity = kStoriesControlsOpacity,
|
.controlsOpacity = kStoriesControlsOpacity,
|
||||||
.fade = layout.fade,
|
.fade = layout.fade,
|
||||||
|
.scale = scale,
|
||||||
.roundRadius = layout.radius,
|
.roundRadius = layout.radius,
|
||||||
.topShadowShown = !layout.headerOutside,
|
.topShadowShown = !layout.headerOutside,
|
||||||
};
|
};
|
||||||
|
@ -4458,7 +4460,7 @@ void OverlayWidget::paint(not_null<Renderer*> renderer) {
|
||||||
const auto paint = [&](const SiblingView &view, int index) {
|
const auto paint = [&](const SiblingView &view, int index) {
|
||||||
renderer->paintTransformedStaticContent(
|
renderer->paintTransformedStaticContent(
|
||||||
view.image,
|
view.image,
|
||||||
storiesContentGeometry(view.layout),
|
storiesContentGeometry(view.layout, view.scale),
|
||||||
false, // semi-transparent
|
false, // semi-transparent
|
||||||
false, // fill transparent background
|
false, // fill transparent background
|
||||||
index);
|
index);
|
||||||
|
|
|
@ -180,6 +180,7 @@ private:
|
||||||
|
|
||||||
// Stories.
|
// Stories.
|
||||||
qreal fade = 0.;
|
qreal fade = 0.;
|
||||||
|
qreal scale = 1.;
|
||||||
int bottomShadowSkip = 0;
|
int bottomShadowSkip = 0;
|
||||||
int roundRadius = 0;
|
int roundRadius = 0;
|
||||||
bool topShadowShown = false;
|
bool topShadowShown = false;
|
||||||
|
@ -421,7 +422,8 @@ private:
|
||||||
[[nodiscard]] QRect finalContentRect() const;
|
[[nodiscard]] QRect finalContentRect() const;
|
||||||
[[nodiscard]] ContentGeometry contentGeometry() const;
|
[[nodiscard]] ContentGeometry contentGeometry() const;
|
||||||
[[nodiscard]] ContentGeometry storiesContentGeometry(
|
[[nodiscard]] ContentGeometry storiesContentGeometry(
|
||||||
const Stories::ContentLayout &layout) const;
|
const Stories::ContentLayout &layout,
|
||||||
|
float64 scale = 1.) const;
|
||||||
void updateContentRect();
|
void updateContentRect();
|
||||||
void contentSizeChanged();
|
void contentSizeChanged();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue