Delegated responsibility for position of arc painter to parent.
This commit is contained in:
parent
ddda92c777
commit
3bd07cf837
2 changed files with 27 additions and 24 deletions
|
|
@ -30,12 +30,8 @@ ArcsAnimation::ArcsAnimation(
|
|||
const style::ArcsAnimation &st,
|
||||
std::vector<float> thresholds,
|
||||
float64 startValue,
|
||||
VerticalDirection direction,
|
||||
int centerX,
|
||||
int startY)
|
||||
VerticalDirection direction)
|
||||
: _st(st)
|
||||
, _center(centerX)
|
||||
, _start(startY)
|
||||
, _horizontalDirection(HorizontalDirection::None)
|
||||
, _verticalDirection(direction)
|
||||
, _startAngle((st.deltaAngle
|
||||
|
|
@ -50,12 +46,8 @@ ArcsAnimation::ArcsAnimation(
|
|||
const style::ArcsAnimation &st,
|
||||
std::vector<float> thresholds,
|
||||
float64 startValue,
|
||||
HorizontalDirection direction,
|
||||
int startX,
|
||||
int centerY)
|
||||
HorizontalDirection direction)
|
||||
: _st(st)
|
||||
, _center(centerY)
|
||||
, _start(startX)
|
||||
, _horizontalDirection(direction)
|
||||
, _verticalDirection(VerticalDirection::None)
|
||||
, _startAngle((st.deltaAngle
|
||||
|
|
@ -86,19 +78,19 @@ QRectF ArcsAnimation::computeArcRect(int index) const {
|
|||
const auto w = _st.startWidth + _st.deltaWidth * index;
|
||||
const auto h = _st.startHeight + _st.deltaHeight * index;
|
||||
if (_horizontalDirection != HorizontalDirection::None) {
|
||||
auto rect = QRectF(0, _center - h / 2.0, w, h);
|
||||
auto rect = QRectF(0, -h / 2.0, w, h);
|
||||
if (_horizontalDirection == HorizontalDirection::Right) {
|
||||
rect.moveRight(_start + index * _st.space);
|
||||
rect.moveRight(index * _st.space);
|
||||
} else {
|
||||
rect.moveLeft(_start - index * _st.space);
|
||||
rect.moveLeft(-index * _st.space);
|
||||
}
|
||||
return rect;
|
||||
} else if (_verticalDirection != VerticalDirection::None) {
|
||||
auto rect = QRectF(_center - w / 2.0, 0, w, h);
|
||||
auto rect = QRectF(-w / 2.0, 0, w, h);
|
||||
if (_verticalDirection == VerticalDirection::Up) {
|
||||
rect.moveTop(_start - index * _st.space);
|
||||
rect.moveTop(-index * _st.space);
|
||||
} else {
|
||||
rect.moveBottom(_start + index * _st.space);
|
||||
rect.moveBottom(index * _st.space);
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
|
@ -157,6 +149,20 @@ void ArcsAnimation::updateArcStartTime(
|
|||
}
|
||||
}
|
||||
|
||||
float ArcsAnimation::width() const {
|
||||
if (_arcs.empty()) {
|
||||
return 0;
|
||||
}
|
||||
const auto &r = _arcs.back().rect;
|
||||
return r.x() + r.width();
|
||||
}
|
||||
|
||||
float ArcsAnimation::height() const {
|
||||
return _arcs.empty()
|
||||
? 0
|
||||
: _arcs.back().rect.height();
|
||||
}
|
||||
|
||||
rpl::producer<> ArcsAnimation::startUpdateRequests() {
|
||||
return _startUpdateRequests.events();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,17 +31,13 @@ public:
|
|||
const style::ArcsAnimation &st,
|
||||
std::vector<float> thresholds,
|
||||
float64 startValue,
|
||||
VerticalDirection direction,
|
||||
int centerX,
|
||||
int startY);
|
||||
VerticalDirection direction);
|
||||
|
||||
ArcsAnimation(
|
||||
const style::ArcsAnimation &st,
|
||||
std::vector<float> thresholds,
|
||||
float64 startValue,
|
||||
HorizontalDirection direction,
|
||||
int startX,
|
||||
int centerY);
|
||||
HorizontalDirection direction);
|
||||
|
||||
void paint(
|
||||
Painter &p,
|
||||
|
|
@ -56,6 +52,9 @@ public:
|
|||
|
||||
bool isFinished() const;
|
||||
|
||||
float width() const;
|
||||
float height() const;
|
||||
|
||||
private:
|
||||
struct Arc {
|
||||
QRectF rect;
|
||||
|
|
@ -74,8 +73,6 @@ private:
|
|||
crl::time now);
|
||||
|
||||
const style::ArcsAnimation &_st;
|
||||
const int _center;
|
||||
const int _start;
|
||||
const HorizontalDirection _horizontalDirection;
|
||||
const VerticalDirection _verticalDirection;
|
||||
const int _startAngle;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue