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,
|
const style::ArcsAnimation &st,
|
||||||
std::vector<float> thresholds,
|
std::vector<float> thresholds,
|
||||||
float64 startValue,
|
float64 startValue,
|
||||||
VerticalDirection direction,
|
VerticalDirection direction)
|
||||||
int centerX,
|
|
||||||
int startY)
|
|
||||||
: _st(st)
|
: _st(st)
|
||||||
, _center(centerX)
|
|
||||||
, _start(startY)
|
|
||||||
, _horizontalDirection(HorizontalDirection::None)
|
, _horizontalDirection(HorizontalDirection::None)
|
||||||
, _verticalDirection(direction)
|
, _verticalDirection(direction)
|
||||||
, _startAngle((st.deltaAngle
|
, _startAngle((st.deltaAngle
|
||||||
|
|
@ -50,12 +46,8 @@ ArcsAnimation::ArcsAnimation(
|
||||||
const style::ArcsAnimation &st,
|
const style::ArcsAnimation &st,
|
||||||
std::vector<float> thresholds,
|
std::vector<float> thresholds,
|
||||||
float64 startValue,
|
float64 startValue,
|
||||||
HorizontalDirection direction,
|
HorizontalDirection direction)
|
||||||
int startX,
|
|
||||||
int centerY)
|
|
||||||
: _st(st)
|
: _st(st)
|
||||||
, _center(centerY)
|
|
||||||
, _start(startX)
|
|
||||||
, _horizontalDirection(direction)
|
, _horizontalDirection(direction)
|
||||||
, _verticalDirection(VerticalDirection::None)
|
, _verticalDirection(VerticalDirection::None)
|
||||||
, _startAngle((st.deltaAngle
|
, _startAngle((st.deltaAngle
|
||||||
|
|
@ -86,19 +78,19 @@ QRectF ArcsAnimation::computeArcRect(int index) const {
|
||||||
const auto w = _st.startWidth + _st.deltaWidth * index;
|
const auto w = _st.startWidth + _st.deltaWidth * index;
|
||||||
const auto h = _st.startHeight + _st.deltaHeight * index;
|
const auto h = _st.startHeight + _st.deltaHeight * index;
|
||||||
if (_horizontalDirection != HorizontalDirection::None) {
|
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) {
|
if (_horizontalDirection == HorizontalDirection::Right) {
|
||||||
rect.moveRight(_start + index * _st.space);
|
rect.moveRight(index * _st.space);
|
||||||
} else {
|
} else {
|
||||||
rect.moveLeft(_start - index * _st.space);
|
rect.moveLeft(-index * _st.space);
|
||||||
}
|
}
|
||||||
return rect;
|
return rect;
|
||||||
} else if (_verticalDirection != VerticalDirection::None) {
|
} 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) {
|
if (_verticalDirection == VerticalDirection::Up) {
|
||||||
rect.moveTop(_start - index * _st.space);
|
rect.moveTop(-index * _st.space);
|
||||||
} else {
|
} else {
|
||||||
rect.moveBottom(_start + index * _st.space);
|
rect.moveBottom(index * _st.space);
|
||||||
}
|
}
|
||||||
return rect;
|
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() {
|
rpl::producer<> ArcsAnimation::startUpdateRequests() {
|
||||||
return _startUpdateRequests.events();
|
return _startUpdateRequests.events();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,17 +31,13 @@ public:
|
||||||
const style::ArcsAnimation &st,
|
const style::ArcsAnimation &st,
|
||||||
std::vector<float> thresholds,
|
std::vector<float> thresholds,
|
||||||
float64 startValue,
|
float64 startValue,
|
||||||
VerticalDirection direction,
|
VerticalDirection direction);
|
||||||
int centerX,
|
|
||||||
int startY);
|
|
||||||
|
|
||||||
ArcsAnimation(
|
ArcsAnimation(
|
||||||
const style::ArcsAnimation &st,
|
const style::ArcsAnimation &st,
|
||||||
std::vector<float> thresholds,
|
std::vector<float> thresholds,
|
||||||
float64 startValue,
|
float64 startValue,
|
||||||
HorizontalDirection direction,
|
HorizontalDirection direction);
|
||||||
int startX,
|
|
||||||
int centerY);
|
|
||||||
|
|
||||||
void paint(
|
void paint(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
|
|
@ -56,6 +52,9 @@ public:
|
||||||
|
|
||||||
bool isFinished() const;
|
bool isFinished() const;
|
||||||
|
|
||||||
|
float width() const;
|
||||||
|
float height() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Arc {
|
struct Arc {
|
||||||
QRectF rect;
|
QRectF rect;
|
||||||
|
|
@ -74,8 +73,6 @@ private:
|
||||||
crl::time now);
|
crl::time now);
|
||||||
|
|
||||||
const style::ArcsAnimation &_st;
|
const style::ArcsAnimation &_st;
|
||||||
const int _center;
|
|
||||||
const int _start;
|
|
||||||
const HorizontalDirection _horizontalDirection;
|
const HorizontalDirection _horizontalDirection;
|
||||||
const VerticalDirection _verticalDirection;
|
const VerticalDirection _verticalDirection;
|
||||||
const int _startAngle;
|
const int _startAngle;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue