@@ -25,7 +25,7 @@ void Planner::createPlan(const Diag::Diagram &source,
2525
2626 Morph::StyleMorphFactory (source.getStyle (), target.getStyle (),
2727 actual.getStyle (), *this ,
28- options.get (SectionId::style, :: Anim::Options (500ms)));
28+ options.get (SectionId::style, defOptions (500ms)));
2929
3030 if (source.getOptions ()->title .get () != target.getOptions ()->title .get ())
3131 addElement (
@@ -34,60 +34,62 @@ void Planner::createPlan(const Diag::Diagram &source,
3434 source.getOptions ()->title .ref (),
3535 target.getOptions ()->title .ref (),
3636 actual.getOptions ()->title .ref ()),
37- options.get (SectionId::title, :: Anim::Options (500ms)));
37+ options.get (SectionId::title, defOptions (500ms)));
3838
3939 if (anyMarker (
4040 [&](const auto &source, const auto &target) -> bool {
4141 return (bool )(source.enabled && !target.enabled );
4242 }))
43- addMorph (SectionId::enable, :: Anim::Options (1s));
43+ addMorph (SectionId::enable, defOptions (1s));
4444
45- if (needColor ()) addMorph (SectionId::color, :: Anim::Options (500ms));
45+ if (needColor ()) addMorph (SectionId::color, defOptions (500ms));
4646
4747 if (source.getOptions ()->polar .get ()
4848 != target.getOptions ()->polar .get ()
4949 || source.getOptions ()->angle .get ()
5050 != target.getOptions ()->angle .get ())
51- addMorph (SectionId::coordSystem, :: Anim::Options (1s));
51+ addMorph (SectionId::coordSystem, defOptions (1s));
5252
5353 const auto &src = source.getOptions ()->shapeType .get ();
5454 const auto &trg = target.getOptions ()->shapeType .get ();
5555 if ((bool )src.getFactor (Diag::ShapeType::Circle) && src != trg)
56- addMorph (SectionId::shape, :: Anim::Options (1s));
56+ addMorph (SectionId::shape, defOptions (1s));
5757
5858 if (positionMorphNeeded ())
5959 {
60- addMorph (SectionId::y, :: Anim::Options (1s));
61- addMorph (SectionId::x, :: Anim::Options (1s));
60+ addMorph (SectionId::y, defOptions (1s));
61+ addMorph (SectionId::x, defOptions (1s));
6262 }
6363 else
6464 {
6565 if (verticalBeforeHorizontal ())
6666 {
67- if (needVertical ()) addMorph (SectionId::y, ::Anim::Options (750ms));
67+ if (needVertical ()) addMorph (SectionId::y,
68+ defOptions (1500ms, 0 , 0.5 ));
6869 if (needHorizontal ()) addMorph (SectionId::x,
69- ::Anim::Options (750ms, 750ms ));
70+ defOptions (1500ms, 0.5 , 0.5 ));
7071 }
7172 else
7273 {
73- if (needHorizontal ()) addMorph (SectionId::x, ::Anim::Options (750ms));
74+ if (needHorizontal ()) addMorph (SectionId::x,
75+ defOptions (1500ms, 0 , 0.5 ));
7476 if (needVertical ()) addMorph (SectionId::y,
75- ::Anim::Options (750ms, 750ms ));
77+ defOptions (1500ms, 0.5 , 0.5 ));
7678 }
7779 }
7880
7981 if (!(bool )src.getFactor (Diag::ShapeType::Circle) && src != trg)
80- addMorph (SectionId::shape, :: Anim::Options (1s));
82+ addMorph (SectionId::shape, defOptions (1s));
8183
8284 if (anyMarker (
8385 [&](const auto &source, const auto &target) {
8486 return (bool )(!source.enabled && target.enabled );
8587 }))
86- addMorph (SectionId::enable, :: Anim::Options (1s));
88+ addMorph (SectionId::enable, defOptions (1s));
8789
8890 if (!source.getOptions ()->polar .get ()
8991 && target.getOptions ()->polar .get ())
90- addMorph (SectionId::coordSystem, :: Anim::Options (1s));
92+ addMorph (SectionId::coordSystem, defOptions (1s));
9193}
9294
9395void Planner::addMorph (SectionId sectionId, const ::Anim::Options &autoOptions)
@@ -199,3 +201,17 @@ bool Planner::needHorizontal() const
199201 || source.size .x != target.size .x );
200202 });
201203}
204+
205+ ::Anim::Options Planner::defOptions (
206+ ::Anim::Duration wholeDuration,
207+ double delayFactor,
208+ double durationFactor) const
209+ {
210+ ::Anim::Options res (wholeDuration);
211+ options->all .writeOver (res);
212+ if (delayFactor > 0 )
213+ res.delay = res.delay + res.duration * delayFactor;
214+ if (durationFactor != 1 )
215+ res.duration = res.duration * durationFactor;
216+ return res;
217+ }
0 commit comments