Moved InterpolatedRect util to separated file.
This commit is contained in:
parent
d6cdc810c4
commit
27d3b68ff4
3 changed files with 29 additions and 16 deletions
|
|
@ -38,6 +38,7 @@ PRIVATE
|
|||
|
||||
ui/effects/animation_value.cpp
|
||||
ui/effects/animation_value.h
|
||||
ui/effects/animation_value_f.h
|
||||
ui/effects/animations.cpp
|
||||
ui/effects/animations.h
|
||||
ui/effects/cross_animation.cpp
|
||||
|
|
|
|||
26
ui/effects/animation_value_f.h
Normal file
26
ui/effects/animation_value_f.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// This file is part of Desktop App Toolkit,
|
||||
// a set of libraries for developing nice desktop applications.
|
||||
//
|
||||
// For license and copyright information please follow this link:
|
||||
// https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||
//
|
||||
#pragma once
|
||||
|
||||
namespace anim {
|
||||
|
||||
TG_FORCE_INLINE float64 interpolateF(float a, float b, float64 b_ratio) {
|
||||
return a + float64(b - a) * b_ratio;
|
||||
};
|
||||
|
||||
TG_FORCE_INLINE QRectF interpolatedRectF(
|
||||
const QRectF &r1,
|
||||
const QRectF &r2,
|
||||
float64 ratio) {
|
||||
return QRectF(
|
||||
interpolateF(r1.x(), r2.x(), ratio),
|
||||
interpolateF(r1.y(), r2.y(), ratio),
|
||||
interpolateF(r1.width(), r2.width(), ratio),
|
||||
interpolateF(r1.height(), r2.height(), ratio));
|
||||
}
|
||||
|
||||
} // namespace anim
|
||||
|
|
@ -7,24 +7,10 @@
|
|||
#include "ui/paint/arcs.h"
|
||||
|
||||
#include "ui/effects/animation_value.h"
|
||||
#include "ui/effects/animation_value_f.h"
|
||||
#include "ui/painter.h"
|
||||
|
||||
namespace Ui::Paint {
|
||||
namespace {
|
||||
|
||||
inline float64 InterpolateF(float a, float b, float64 b_ratio) {
|
||||
return a + float64(b - a) * b_ratio;
|
||||
};
|
||||
|
||||
QRectF InterpolatedRect(const QRectF &r1, const QRectF &r2, float64 ratio) {
|
||||
return QRectF(
|
||||
InterpolateF(r1.x(), r2.x(), ratio),
|
||||
InterpolateF(r1.y(), r2.y(), ratio),
|
||||
InterpolateF(r1.width(), r2.width(), ratio),
|
||||
InterpolateF(r1.height(), r2.height(), ratio));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ArcsAnimation::ArcsAnimation(
|
||||
const style::ArcsAnimation &st,
|
||||
|
|
@ -221,7 +207,7 @@ void ArcsAnimation::paint(Painter &p, std::optional<QColor> colorOverride) {
|
|||
? arc.rect
|
||||
: (progress == 1.)
|
||||
? previousRect
|
||||
: InterpolatedRect(arc.rect, previousRect, progress);
|
||||
: anim::interpolatedRectF(arc.rect, previousRect, progress);
|
||||
p.drawArc(rect, _startAngle, _spanAngle);
|
||||
}
|
||||
p.setOpacity(1.);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue