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
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
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
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
85
Telegram/lib_ui/ui/paint/arcs.h
Normal file
85
Telegram/lib_ui/ui/paint/arcs.h
Normal file
@@ -0,0 +1,85 @@
|
||||
// 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
|
||||
|
||||
#include "styles/style_widgets.h"
|
||||
|
||||
class Painter;
|
||||
|
||||
namespace Ui::Paint {
|
||||
|
||||
class ArcsAnimation {
|
||||
public:
|
||||
|
||||
enum class Direction {
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right,
|
||||
};
|
||||
|
||||
ArcsAnimation(
|
||||
const style::ArcsAnimation &st,
|
||||
std::vector<float> thresholds,
|
||||
float64 startValue,
|
||||
Direction direction);
|
||||
|
||||
void paint(
|
||||
QPainter &p,
|
||||
std::optional<QColor> colorOverride = std::nullopt);
|
||||
|
||||
void setValue(float64 value);
|
||||
|
||||
rpl::producer<> startUpdateRequests();
|
||||
rpl::producer<> stopUpdateRequests();
|
||||
|
||||
void update(crl::time now);
|
||||
|
||||
bool isFinished() const;
|
||||
|
||||
float width() const;
|
||||
float maxWidth() const;
|
||||
float finishedWidth() const;
|
||||
float height() const;
|
||||
|
||||
void setStrokeRatio(float ratio);
|
||||
|
||||
private:
|
||||
struct Arc {
|
||||
QRectF rect;
|
||||
float threshold;
|
||||
crl::time startTime = 0;
|
||||
float64 progress = 0.;
|
||||
};
|
||||
|
||||
void initArcs(std::vector<float> thresholds);
|
||||
QRectF computeArcRect(int index) const;
|
||||
bool isHorizontal() const;
|
||||
|
||||
bool isArcFinished(const Arc &arc) const;
|
||||
void updateArcStartTime(
|
||||
Arc &arc,
|
||||
float64 previousValue,
|
||||
crl::time now);
|
||||
|
||||
const style::ArcsAnimation &_st;
|
||||
const Direction _direction;
|
||||
const int _startAngle;
|
||||
const int _spanAngle;
|
||||
const QRectF _emptyRect;
|
||||
|
||||
float64 _currentValue = 0.;
|
||||
float _strokeRatio = 0.;
|
||||
|
||||
rpl::event_stream<> _startUpdateRequests;
|
||||
rpl::event_stream<> _stopUpdateRequests;
|
||||
|
||||
std::vector<Arc> _arcs;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Ui::Paint
|
||||
Reference in New Issue
Block a user