mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-03 11:23:48 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -6,7 +6,8 @@ namespace df
|
||||
{
|
||||
|
||||
// static
|
||||
bool Animation::GetCachedProperty(TPropertyCache const & properties, Object object, ObjectProperty property, PropertyValue & value)
|
||||
bool Animation::GetCachedProperty(TPropertyCache const & properties, Object object, ObjectProperty property,
|
||||
PropertyValue & value)
|
||||
{
|
||||
auto const it = properties.find(std::make_pair(object, property));
|
||||
if (it != properties.end())
|
||||
@@ -18,7 +19,8 @@ bool Animation::GetCachedProperty(TPropertyCache const & properties, Object obje
|
||||
}
|
||||
|
||||
// static
|
||||
void Animation::GetCurrentScreen(TPropertyCache const & properties, ScreenBase const & screen, ScreenBase & currentScreen)
|
||||
void Animation::GetCurrentScreen(TPropertyCache const & properties, ScreenBase const & screen,
|
||||
ScreenBase & currentScreen)
|
||||
{
|
||||
currentScreen = screen;
|
||||
|
||||
@@ -46,10 +48,8 @@ bool Animation::HasSameObjects(Animation const & animation) const
|
||||
{
|
||||
TAnimObjects const & objects = animation.GetObjects();
|
||||
for (auto const & object : objects)
|
||||
{
|
||||
if (HasObject(object))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -129,4 +129,4 @@ std::string DebugPrint(Animation::ObjectProperty const & property)
|
||||
return "Unknown property";
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -52,18 +52,11 @@ public:
|
||||
ValuePointD
|
||||
};
|
||||
|
||||
PropertyValue()
|
||||
{}
|
||||
PropertyValue() {}
|
||||
|
||||
explicit PropertyValue(double value)
|
||||
: m_type(Type::ValueD)
|
||||
, m_valueD(value)
|
||||
{}
|
||||
explicit PropertyValue(double value) : m_type(Type::ValueD), m_valueD(value) {}
|
||||
|
||||
explicit PropertyValue(m2::PointD const & value)
|
||||
: m_type(Type::ValuePointD)
|
||||
, m_valuePointD(value)
|
||||
{}
|
||||
explicit PropertyValue(m2::PointD const & value) : m_type(Type::ValuePointD), m_valuePointD(value) {}
|
||||
|
||||
Type m_type;
|
||||
union
|
||||
@@ -88,9 +81,21 @@ public:
|
||||
virtual ~Animation() = default;
|
||||
|
||||
virtual void Init(ScreenBase const & screen, TPropertyCache const & properties) {}
|
||||
virtual void OnStart() { if (m_onStartAction != nullptr) m_onStartAction(this); }
|
||||
virtual void OnFinish() { if (m_onFinishAction != nullptr) m_onFinishAction(this); }
|
||||
virtual void Interrupt() { if (m_onInterruptAction != nullptr) m_onInterruptAction(this); }
|
||||
virtual void OnStart()
|
||||
{
|
||||
if (m_onStartAction != nullptr)
|
||||
m_onStartAction(this);
|
||||
}
|
||||
virtual void OnFinish()
|
||||
{
|
||||
if (m_onFinishAction != nullptr)
|
||||
m_onFinishAction(this);
|
||||
}
|
||||
virtual void Interrupt()
|
||||
{
|
||||
if (m_onInterruptAction != nullptr)
|
||||
m_onInterruptAction(this);
|
||||
}
|
||||
|
||||
virtual Type GetType() const = 0;
|
||||
virtual std::string GetCustomType() const { return std::string(); }
|
||||
@@ -130,13 +135,15 @@ public:
|
||||
|
||||
void SetCouldBeInterrupted(bool enable) { m_couldBeInterrupted = enable; }
|
||||
void SetCouldBeBlended(bool enable) { m_couldBeBlended = enable; }
|
||||
|
||||
|
||||
void SetCouldBeRewinded(bool enable) { m_couldBeRewinded = enable; }
|
||||
bool CouldBeRewinded() const { return m_couldBeRewinded; }
|
||||
|
||||
protected:
|
||||
static void GetCurrentScreen(TPropertyCache const & properties, ScreenBase const & screen, ScreenBase & currentScreen);
|
||||
static bool GetCachedProperty(TPropertyCache const & properties, Object object, ObjectProperty property, PropertyValue & value);
|
||||
static void GetCurrentScreen(TPropertyCache const & properties, ScreenBase const & screen,
|
||||
ScreenBase & currentScreen);
|
||||
static bool GetCachedProperty(TPropertyCache const & properties, Object object, ObjectProperty property,
|
||||
PropertyValue & value);
|
||||
|
||||
static bool GetMinDuration(Interpolator const & interpolator, double & minDuration);
|
||||
static bool GetMaxDuration(Interpolator const & interpolator, double & maxDuration);
|
||||
@@ -159,5 +166,4 @@ std::string DebugPrint(Animation::Type const & type);
|
||||
std::string DebugPrint(Animation::Object const & object);
|
||||
std::string DebugPrint(Animation::ObjectProperty const & property);
|
||||
|
||||
} // namespace df
|
||||
|
||||
} // namespace df
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace df
|
||||
namespace df
|
||||
{
|
||||
|
||||
ArrowAnimation::ArrowAnimation(m2::PointD const & startPos, m2::PointD const & endPos, double moveDuration,
|
||||
double startAngle, double endAngle)
|
||||
double startAngle, double endAngle)
|
||||
: Animation(true /* couldBeInterrupted */, true /* couldBeBlended */)
|
||||
, m_positionInterpolator(moveDuration, 0.0 /* delay */, startPos, endPos)
|
||||
, m_angleInterpolator(startAngle, endAngle)
|
||||
@@ -28,10 +28,8 @@ void ArrowAnimation::Init(ScreenBase const & screen, TPropertyCache const & prop
|
||||
minDuration = m_positionInterpolator.GetMinDuration();
|
||||
maxDuration = m_positionInterpolator.GetMaxDuration();
|
||||
|
||||
m_positionInterpolator = PositionInterpolator(m_positionInterpolator.GetDuration(),
|
||||
0.0 /* delay */,
|
||||
value.m_valuePointD,
|
||||
m_positionInterpolator.GetTargetPosition());
|
||||
m_positionInterpolator = PositionInterpolator(m_positionInterpolator.GetDuration(), 0.0 /* delay */,
|
||||
value.m_valuePointD, m_positionInterpolator.GetTargetPosition());
|
||||
|
||||
m_positionInterpolator.SetMinDuration(minDuration);
|
||||
m_positionInterpolator.SetMaxDuration(maxDuration);
|
||||
@@ -56,7 +54,7 @@ void ArrowAnimation::Init(ScreenBase const & screen, TPropertyCache const & prop
|
||||
|
||||
Animation::TAnimObjects const & ArrowAnimation::GetObjects() const
|
||||
{
|
||||
return m_objects;
|
||||
return m_objects;
|
||||
}
|
||||
|
||||
bool ArrowAnimation::HasObject(Object object) const
|
||||
@@ -166,7 +164,8 @@ bool ArrowAnimation::GetProperty(Object object, ObjectProperty property, bool ta
|
||||
case Animation::ObjectProperty::Position:
|
||||
if (m_positionInterpolator.IsActive())
|
||||
{
|
||||
value = PropertyValue(targetValue ? m_positionInterpolator.GetTargetPosition() : m_positionInterpolator.GetPosition());
|
||||
value = PropertyValue(targetValue ? m_positionInterpolator.GetTargetPosition()
|
||||
: m_positionInterpolator.GetPosition());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -177,12 +176,10 @@ bool ArrowAnimation::GetProperty(Object object, ObjectProperty property, bool ta
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
ASSERT(false, ("Wrong property:", static_cast<int>(property)));
|
||||
default: ASSERT(false, ("Wrong property:", static_cast<int>(property)));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace df
|
||||
class ArrowAnimation : public Animation
|
||||
{
|
||||
public:
|
||||
ArrowAnimation(m2::PointD const & startPos, m2::PointD const & endPos, double moveDuration,
|
||||
double startAngle, double endAngle);
|
||||
ArrowAnimation(m2::PointD const & startPos, m2::PointD const & endPos, double moveDuration, double startAngle,
|
||||
double endAngle);
|
||||
|
||||
void Init(ScreenBase const & screen, TPropertyCache const & properties) override;
|
||||
|
||||
@@ -43,4 +43,4 @@ private:
|
||||
AngleInterpolator m_angleInterpolator;
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
namespace df
|
||||
{
|
||||
|
||||
MapFollowAnimation::MapFollowAnimation(ScreenBase const & screen,
|
||||
m2::PointD const & globalUserPosition,
|
||||
m2::PointD const & endPixelPosition,
|
||||
double endScale, double endAngle,
|
||||
MapFollowAnimation::MapFollowAnimation(ScreenBase const & screen, m2::PointD const & globalUserPosition,
|
||||
m2::PointD const & endPixelPosition, double endScale, double endAngle,
|
||||
bool isAutoZoom)
|
||||
: Animation(true /* couldBeInterrupted */, true /* couldBeBlended */)
|
||||
, m_isAutoZoom(isAutoZoom)
|
||||
@@ -37,7 +35,8 @@ void MapFollowAnimation::Init(ScreenBase const & screen, TPropertyCache const &
|
||||
|
||||
m_offset = currentScreen.PtoG(currentScreen.P3dtoP(m_endPixelPosition)) - m_globalPosition;
|
||||
double const averageScale = m_isAutoZoom ? currentScreen.GetScale() : (currentScreen.GetScale() + m_endScale) / 2.0;
|
||||
double const moveDuration = PositionInterpolator::GetMoveDuration(m_offset.Length(), screen.PixelRectIn3d(), averageScale);
|
||||
double const moveDuration =
|
||||
PositionInterpolator::GetMoveDuration(m_offset.Length(), screen.PixelRectIn3d(), averageScale);
|
||||
m_offsetInterpolator = PositionInterpolator(moveDuration, 0.0, m_offset, m2::PointD(0.0, 0.0));
|
||||
|
||||
m_offsetInterpolator.SetMinDuration(minDuration);
|
||||
@@ -156,7 +155,6 @@ double MapFollowAnimation::GetMinDuration() const
|
||||
return minDuration;
|
||||
}
|
||||
|
||||
|
||||
double MapFollowAnimation::CalculateDuration() const
|
||||
{
|
||||
double duration = std::max(m_angleInterpolator.GetDuration(), m_offsetInterpolator.GetDuration());
|
||||
@@ -180,15 +178,16 @@ bool MapFollowAnimation::GetTargetProperty(Object object, ObjectProperty propert
|
||||
return GetProperty(object, property, true /* targetValue */, value);
|
||||
}
|
||||
|
||||
bool MapFollowAnimation::GetProperty(Object object, ObjectProperty property, bool targetValue, PropertyValue & value) const
|
||||
bool MapFollowAnimation::GetProperty(Object object, ObjectProperty property, bool targetValue,
|
||||
PropertyValue & value) const
|
||||
{
|
||||
if (property == Animation::ObjectProperty::Position)
|
||||
{
|
||||
ScreenBase tmp = AnimationSystem::Instance().GetLastScreen();
|
||||
if (targetValue)
|
||||
{
|
||||
tmp.SetFromParams(m_globalPosition, m_angleInterpolator.GetTargetAngle(), m_isAutoZoom ? m_scaleInterpolator.GetScale()
|
||||
: m_scaleInterpolator.GetTargetScale());
|
||||
tmp.SetFromParams(m_globalPosition, m_angleInterpolator.GetTargetAngle(),
|
||||
m_isAutoZoom ? m_scaleInterpolator.GetScale() : m_scaleInterpolator.GetTargetScale());
|
||||
tmp.MatchGandP3d(m_globalPosition, m_endPixelPosition);
|
||||
}
|
||||
else
|
||||
@@ -230,4 +229,4 @@ bool MapFollowAnimation::HasPixelOffset() const
|
||||
return m_offsetInterpolator.IsActive();
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -9,25 +9,16 @@ namespace df
|
||||
class MapFollowAnimation : public Animation
|
||||
{
|
||||
public:
|
||||
MapFollowAnimation(ScreenBase const & screen,
|
||||
m2::PointD const & globalUserPosition,
|
||||
m2::PointD const & endPixelPosition,
|
||||
double endScale, double endAngle,
|
||||
bool isAutoZoom);
|
||||
MapFollowAnimation(ScreenBase const & screen, m2::PointD const & globalUserPosition,
|
||||
m2::PointD const & endPixelPosition, double endScale, double endAngle, bool isAutoZoom);
|
||||
|
||||
void Init(ScreenBase const & screen, TPropertyCache const & properties) override;
|
||||
|
||||
Animation::Type GetType() const override { return Animation::Type::MapFollow; }
|
||||
|
||||
TAnimObjects const & GetObjects() const override
|
||||
{
|
||||
return m_objects;
|
||||
}
|
||||
TAnimObjects const & GetObjects() const override { return m_objects; }
|
||||
|
||||
bool HasObject(Object object) const override
|
||||
{
|
||||
return object == Animation::Object::MapPlane;
|
||||
}
|
||||
bool HasObject(Object object) const override { return object == Animation::Object::MapPlane; }
|
||||
|
||||
TObjectProperties const & GetProperties(Object object) const override;
|
||||
bool HasProperty(Object object, ObjectProperty property) const override;
|
||||
@@ -70,4 +61,4 @@ private:
|
||||
TAnimObjects m_objects;
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "drape_frontend/animation/base_interpolator.hpp"
|
||||
#include "drape_frontend/animation/interpolation_holder.hpp"
|
||||
#include "drape_frontend/animation/base_interpolator.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
|
||||
@@ -23,4 +23,4 @@ double InterpolateAngle(double startAngle, double endAngle, double t)
|
||||
return startAngle + ang::GetShortestDistance(startAngle, endAngle) * t;
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "geometry/any_rect2d.hpp"
|
||||
#include "geometry/point2d.hpp"
|
||||
#include "geometry/rect2d.hpp"
|
||||
#include "geometry/any_rect2d.hpp"
|
||||
|
||||
namespace df
|
||||
{
|
||||
@@ -11,4 +11,4 @@ double InterpolateDouble(double startV, double endV, double t);
|
||||
m2::PointD InterpolatePoint(m2::PointD const & startPt, m2::PointD const & endPt, double t);
|
||||
double InterpolateAngle(double startAngle, double endAngle, double t);
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -103,8 +103,8 @@ PositionInterpolator::PositionInterpolator()
|
||||
: PositionInterpolator(0.0 /* duration */, 0.0 /* delay */, m2::PointD(), m2::PointD())
|
||||
{}
|
||||
|
||||
PositionInterpolator::PositionInterpolator(double duration, double delay,
|
||||
m2::PointD const & startPosition, m2::PointD const & endPosition)
|
||||
PositionInterpolator::PositionInterpolator(double duration, double delay, m2::PointD const & startPosition,
|
||||
m2::PointD const & endPosition)
|
||||
: Interpolator(duration, delay)
|
||||
, m_startPosition(startPosition)
|
||||
, m_endPosition(endPosition)
|
||||
@@ -118,9 +118,8 @@ PositionInterpolator::PositionInterpolator(m2::PointD const & startPosition, m2:
|
||||
: PositionInterpolator(0.0 /* delay */, startPosition, endPosition, convertor)
|
||||
{}
|
||||
|
||||
PositionInterpolator::PositionInterpolator(double delay,
|
||||
m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
ScreenBase const & convertor)
|
||||
PositionInterpolator::PositionInterpolator(double delay, m2::PointD const & startPosition,
|
||||
m2::PointD const & endPosition, ScreenBase const & convertor)
|
||||
: Interpolator(PositionInterpolator::GetMoveDuration(startPosition, endPosition, convertor), delay)
|
||||
, m_startPosition(startPosition)
|
||||
, m_endPosition(endPosition)
|
||||
@@ -134,9 +133,8 @@ PositionInterpolator::PositionInterpolator(m2::PointD const & startPosition, m2:
|
||||
: PositionInterpolator(0.0 /* delay */, startPosition, endPosition, viewportRect, scale)
|
||||
{}
|
||||
|
||||
PositionInterpolator::PositionInterpolator(double delay,
|
||||
m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
m2::RectD const & viewportRect, double scale)
|
||||
PositionInterpolator::PositionInterpolator(double delay, m2::PointD const & startPosition,
|
||||
m2::PointD const & endPosition, m2::RectD const & viewportRect, double scale)
|
||||
: Interpolator(PositionInterpolator::GetMoveDuration(startPosition, endPosition, viewportRect, scale), delay)
|
||||
, m_startPosition(startPosition)
|
||||
, m_endPosition(endPosition)
|
||||
@@ -145,7 +143,7 @@ PositionInterpolator::PositionInterpolator(double delay,
|
||||
SetActive((GetDuration() > 0.0) && (m_startPosition != m_endPosition));
|
||||
}
|
||||
|
||||
//static
|
||||
// static
|
||||
double PositionInterpolator::GetMoveDuration(double globalDistance, m2::RectD const & viewportRect, double scale)
|
||||
{
|
||||
double constexpr kMinMoveDuration = 0.2;
|
||||
@@ -166,22 +164,20 @@ double PositionInterpolator::GetMoveDuration(double globalDistance, m2::RectD co
|
||||
return CalcAnimSpeedDuration(pixelLength, pixelSpeed);
|
||||
}
|
||||
|
||||
//static
|
||||
// static
|
||||
double PositionInterpolator::GetMoveDuration(m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
m2::RectD const & viewportRect, double scale)
|
||||
m2::RectD const & viewportRect, double scale)
|
||||
{
|
||||
return GetMoveDuration(endPosition.Length(startPosition), viewportRect, scale);
|
||||
}
|
||||
|
||||
//static
|
||||
double PositionInterpolator::GetMoveDuration(m2::PointD const & startPosition,
|
||||
m2::PointD const & endPosition,
|
||||
// static
|
||||
double PositionInterpolator::GetMoveDuration(m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
ScreenBase const & convertor)
|
||||
{
|
||||
return GetMoveDuration(startPosition, endPosition, convertor.PixelRectIn3d(), convertor.GetScale());
|
||||
}
|
||||
|
||||
|
||||
void PositionInterpolator::Advance(double elapsedSeconds)
|
||||
{
|
||||
TBase::Advance(elapsedSeconds);
|
||||
@@ -235,9 +231,7 @@ void ScaleInterpolator::Finish()
|
||||
m_scale = m_endScale;
|
||||
}
|
||||
|
||||
AngleInterpolator::AngleInterpolator()
|
||||
: AngleInterpolator(0.0 /* startAngle */, 0.0 /* endAngle */)
|
||||
{}
|
||||
AngleInterpolator::AngleInterpolator() : AngleInterpolator(0.0 /* startAngle */, 0.0 /* endAngle */) {}
|
||||
|
||||
AngleInterpolator::AngleInterpolator(double startAngle, double endAngle)
|
||||
: AngleInterpolator(0.0 /* delay */, startAngle, endAngle)
|
||||
@@ -282,4 +276,4 @@ void AngleInterpolator::Finish()
|
||||
m_angle = m_endAngle;
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
static double constexpr kInvalidDuration = -1.0;
|
||||
void SetMaxDuration(double maxDuration);
|
||||
void SetMinDuration(double minDuration);
|
||||
void SetMinDuration(double minDuration);
|
||||
double GetMaxDuration() const;
|
||||
double GetMinDuration() const;
|
||||
|
||||
@@ -41,27 +41,23 @@ private:
|
||||
bool m_isActive;
|
||||
};
|
||||
|
||||
class PositionInterpolator: public Interpolator
|
||||
class PositionInterpolator : public Interpolator
|
||||
{
|
||||
using TBase = Interpolator;
|
||||
|
||||
public:
|
||||
PositionInterpolator();
|
||||
PositionInterpolator(double duration, double delay,
|
||||
m2::PointD const & startPosition, m2::PointD const & endPosition);
|
||||
PositionInterpolator(double duration, double delay, m2::PointD const & startPosition, m2::PointD const & endPosition);
|
||||
|
||||
PositionInterpolator(m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
PositionInterpolator(m2::PointD const & startPosition, m2::PointD const & endPosition, ScreenBase const & convertor);
|
||||
|
||||
PositionInterpolator(double delay, m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
ScreenBase const & convertor);
|
||||
|
||||
PositionInterpolator(double delay,
|
||||
m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
ScreenBase const & convertor);
|
||||
PositionInterpolator(m2::PointD const & startPosition, m2::PointD const & endPosition, m2::RectD const & viewportRect,
|
||||
double scale);
|
||||
|
||||
PositionInterpolator(m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
m2::RectD const & viewportRect, double scale);
|
||||
|
||||
PositionInterpolator(double delay,
|
||||
m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
PositionInterpolator(double delay, m2::PointD const & startPosition, m2::PointD const & endPosition,
|
||||
m2::RectD const & viewportRect, double scale);
|
||||
|
||||
static double GetMoveDuration(double globalDistance, m2::RectD const & viewportRect, double scale);
|
||||
@@ -85,7 +81,7 @@ private:
|
||||
m2::PointD m_position;
|
||||
};
|
||||
|
||||
class ScaleInterpolator: public Interpolator
|
||||
class ScaleInterpolator : public Interpolator
|
||||
{
|
||||
using TBase = Interpolator;
|
||||
|
||||
@@ -110,7 +106,7 @@ private:
|
||||
double m_scale;
|
||||
};
|
||||
|
||||
class AngleInterpolator: public Interpolator
|
||||
class AngleInterpolator : public Interpolator
|
||||
{
|
||||
using TBase = Interpolator;
|
||||
|
||||
@@ -136,4 +132,4 @@ private:
|
||||
double m_angle;
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
namespace df
|
||||
{
|
||||
|
||||
MapLinearAnimation::MapLinearAnimation(m2::PointD const & startPos, m2::PointD const & endPos,
|
||||
double startAngle, double endAngle,
|
||||
double startScale, double endScale, ScreenBase const & convertor)
|
||||
MapLinearAnimation::MapLinearAnimation(m2::PointD const & startPos, m2::PointD const & endPos, double startAngle,
|
||||
double endAngle, double startScale, double endScale,
|
||||
ScreenBase const & convertor)
|
||||
: Animation(true /* couldBeInterrupted */, false /* couldBeBlended */)
|
||||
, m_angleInterpolator(startAngle, endAngle)
|
||||
, m_positionInterpolator(startPos, endPos, convertor)
|
||||
@@ -27,8 +27,7 @@ MapLinearAnimation::MapLinearAnimation(m2::PointD const & startPos, m2::PointD c
|
||||
m_properties.insert(Animation::ObjectProperty::Scale);
|
||||
}
|
||||
|
||||
MapLinearAnimation::MapLinearAnimation()
|
||||
: Animation(true /* couldBeInterrupted */, false /* couldBeBlended */)
|
||||
MapLinearAnimation::MapLinearAnimation() : Animation(true /* couldBeInterrupted */, false /* couldBeBlended */)
|
||||
{
|
||||
m_objects.insert(Animation::Object::MapPlane);
|
||||
}
|
||||
@@ -60,16 +59,15 @@ void MapLinearAnimation::Init(ScreenBase const & screen, TPropertyCache const &
|
||||
m_angleInterpolator.SetMaxDuration(maxDuration);
|
||||
}
|
||||
|
||||
void MapLinearAnimation::SetMove(m2::PointD const & startPos, m2::PointD const & endPos,
|
||||
ScreenBase const & convertor)
|
||||
void MapLinearAnimation::SetMove(m2::PointD const & startPos, m2::PointD const & endPos, ScreenBase const & convertor)
|
||||
{
|
||||
m_positionInterpolator = PositionInterpolator(startPos, endPos, convertor);
|
||||
if (m_positionInterpolator.IsActive())
|
||||
m_properties.insert(Animation::ObjectProperty::Position);
|
||||
}
|
||||
|
||||
void MapLinearAnimation::SetMove(m2::PointD const & startPos, m2::PointD const & endPos,
|
||||
m2::RectD const & viewportRect, double scale)
|
||||
void MapLinearAnimation::SetMove(m2::PointD const & startPos, m2::PointD const & endPos, m2::RectD const & viewportRect,
|
||||
double scale)
|
||||
{
|
||||
m_positionInterpolator = PositionInterpolator(startPos, endPos, viewportRect, scale);
|
||||
if (m_positionInterpolator.IsActive())
|
||||
@@ -194,8 +192,7 @@ double MapLinearAnimation::GetMinDuration() const
|
||||
|
||||
bool MapLinearAnimation::IsFinished() const
|
||||
{
|
||||
return m_angleInterpolator.IsFinished() && m_scaleInterpolator.IsFinished() &&
|
||||
m_positionInterpolator.IsFinished();
|
||||
return m_angleInterpolator.IsFinished() && m_scaleInterpolator.IsFinished() && m_positionInterpolator.IsFinished();
|
||||
}
|
||||
|
||||
bool MapLinearAnimation::GetProperty(Object object, ObjectProperty property, PropertyValue & value) const
|
||||
@@ -208,7 +205,8 @@ bool MapLinearAnimation::GetTargetProperty(Object object, ObjectProperty propert
|
||||
return GetProperty(object, property, true /* targetValue */, value);
|
||||
}
|
||||
|
||||
bool MapLinearAnimation::GetProperty(Object object, ObjectProperty property, bool targetValue, PropertyValue & value) const
|
||||
bool MapLinearAnimation::GetProperty(Object object, ObjectProperty property, bool targetValue,
|
||||
PropertyValue & value) const
|
||||
{
|
||||
ASSERT_EQUAL(static_cast<int>(object), static_cast<int>(Animation::Object::MapPlane), ());
|
||||
|
||||
@@ -217,7 +215,8 @@ bool MapLinearAnimation::GetProperty(Object object, ObjectProperty property, boo
|
||||
case Animation::ObjectProperty::Position:
|
||||
if (m_positionInterpolator.IsActive())
|
||||
{
|
||||
value = PropertyValue(targetValue ? m_positionInterpolator.GetTargetPosition() : m_positionInterpolator.GetPosition());
|
||||
value = PropertyValue(targetValue ? m_positionInterpolator.GetTargetPosition()
|
||||
: m_positionInterpolator.GetPosition());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -235,11 +234,10 @@ bool MapLinearAnimation::GetProperty(Object object, ObjectProperty property, boo
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
ASSERT(false, ("Wrong property:", static_cast<int>(property)));
|
||||
default: ASSERT(false, ("Wrong property:", static_cast<int>(property)));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -8,8 +8,7 @@ namespace df
|
||||
class MapLinearAnimation : public Animation
|
||||
{
|
||||
public:
|
||||
MapLinearAnimation(m2::PointD const & startPos, m2::PointD const & endPos,
|
||||
double startAngle, double endAngle,
|
||||
MapLinearAnimation(m2::PointD const & startPos, m2::PointD const & endPos, double startAngle, double endAngle,
|
||||
double startScale, double endScale, ScreenBase const & convertor);
|
||||
MapLinearAnimation();
|
||||
|
||||
@@ -22,15 +21,9 @@ public:
|
||||
|
||||
Animation::Type GetType() const override { return Animation::Type::MapLinear; }
|
||||
|
||||
TAnimObjects const & GetObjects() const override
|
||||
{
|
||||
return m_objects;
|
||||
}
|
||||
TAnimObjects const & GetObjects() const override { return m_objects; }
|
||||
|
||||
bool HasObject(Object object) const override
|
||||
{
|
||||
return object == Animation::Object::MapPlane;
|
||||
}
|
||||
bool HasObject(Object object) const override { return object == Animation::Object::MapPlane; }
|
||||
|
||||
TObjectProperties const & GetProperties(Object object) const override;
|
||||
bool HasProperty(Object object, ObjectProperty property) const override;
|
||||
|
||||
@@ -6,16 +6,14 @@ namespace df
|
||||
|
||||
OpacityAnimation::OpacityAnimation(double duration, double startOpacity, double endOpacity)
|
||||
: OpacityAnimation(duration, 0.0, startOpacity, endOpacity)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
OpacityAnimation::OpacityAnimation(double duration, double delay, double startOpacity, double endOpacity)
|
||||
: BaseInterpolator(duration, delay)
|
||||
, m_startOpacity(startOpacity)
|
||||
, m_endOpacity(endOpacity)
|
||||
, m_opacity(startOpacity)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void OpacityAnimation::Advance(double elapsedSeconds)
|
||||
{
|
||||
@@ -23,4 +21,4 @@ void OpacityAnimation::Advance(double elapsedSeconds)
|
||||
m_opacity = InterpolateDouble(m_startOpacity, m_endOpacity, GetT());
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace df
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
namespace df
|
||||
{
|
||||
|
||||
ParallelAnimation::ParallelAnimation()
|
||||
: Animation(true /* couldBeInterrupted */, true /* couldBeBlended */)
|
||||
{}
|
||||
ParallelAnimation::ParallelAnimation() : Animation(true /* couldBeInterrupted */, true /* couldBeBlended */) {}
|
||||
|
||||
void ParallelAnimation::Init(ScreenBase const & screen, TPropertyCache const & properties)
|
||||
{
|
||||
@@ -55,10 +53,8 @@ bool ParallelAnimation::HasTargetProperty(Object object, ObjectProperty property
|
||||
{
|
||||
ASSERT(!m_animations.empty(), ());
|
||||
for (auto const & anim : m_animations)
|
||||
{
|
||||
if (anim->HasTargetProperty(object, property))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -119,10 +115,8 @@ bool ParallelAnimation::GetProperty(Object object, ObjectProperty property, Prop
|
||||
{
|
||||
ASSERT(!m_animations.empty(), ());
|
||||
for (auto const & anim : m_animations)
|
||||
{
|
||||
if (anim->HasProperty(object, property))
|
||||
return anim->GetProperty(object, property, value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -130,10 +124,8 @@ bool ParallelAnimation::GetTargetProperty(Object object, ObjectProperty property
|
||||
{
|
||||
ASSERT(!m_animations.empty(), ());
|
||||
for (auto const & anim : m_animations)
|
||||
{
|
||||
if (anim->HasProperty(object, property))
|
||||
return anim->GetTargetProperty(object, property, value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -211,4 +203,4 @@ void ParallelAnimation::ObtainObjectProperties()
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -47,12 +47,12 @@ public:
|
||||
bool GetProperty(Object object, ObjectProperty property, PropertyValue & value) const override;
|
||||
bool GetTargetProperty(Object object, ObjectProperty property, PropertyValue & value) const override;
|
||||
|
||||
template<typename T> T const * FindAnimation(Animation::Type type, char const * customType = nullptr) const
|
||||
template <typename T>
|
||||
T const * FindAnimation(Animation::Type type, char const * customType = nullptr) const
|
||||
{
|
||||
for (auto const & anim : m_animations)
|
||||
{
|
||||
if ((anim->GetType() == type) &&
|
||||
(customType == nullptr || anim->GetCustomType() == customType))
|
||||
if ((anim->GetType() == type) && (customType == nullptr || anim->GetCustomType() == customType))
|
||||
{
|
||||
ASSERT(dynamic_cast<T const *>(anim.get()) != nullptr, ());
|
||||
return static_cast<T const *>(anim.get());
|
||||
@@ -71,4 +71,4 @@ private:
|
||||
std::string m_customType;
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -27,7 +27,8 @@ void MapScaleAnimation::Init(ScreenBase const & screen, TPropertyCache const & p
|
||||
double const minDuration = m_scaleInterpolator.GetMinDuration();
|
||||
double const maxDuration = m_scaleInterpolator.GetMaxDuration();
|
||||
|
||||
m_scaleInterpolator = ScaleInterpolator(currentScreen.GetScale(), m_scaleInterpolator.GetTargetScale(), false /* isAutoZoom */);
|
||||
m_scaleInterpolator =
|
||||
ScaleInterpolator(currentScreen.GetScale(), m_scaleInterpolator.GetTargetScale(), false /* isAutoZoom */);
|
||||
|
||||
m_scaleInterpolator.SetMinDuration(minDuration);
|
||||
m_scaleInterpolator.SetMaxDuration(maxDuration);
|
||||
@@ -85,7 +86,8 @@ bool MapScaleAnimation::IsFinished() const
|
||||
return m_scaleInterpolator.IsFinished();
|
||||
}
|
||||
|
||||
bool MapScaleAnimation::GetProperty(Object object, ObjectProperty property, bool targetValue, PropertyValue & value) const
|
||||
bool MapScaleAnimation::GetProperty(Object object, ObjectProperty property, bool targetValue,
|
||||
PropertyValue & value) const
|
||||
{
|
||||
ASSERT_EQUAL(static_cast<int>(object), static_cast<int>(Animation::Object::MapPlane), ());
|
||||
|
||||
@@ -116,4 +118,4 @@ bool MapScaleAnimation::GetProperty(Object object, ObjectProperty property, Prop
|
||||
return GetProperty(object, property, false /* targetValue */, value);
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -9,22 +9,16 @@ namespace df
|
||||
class MapScaleAnimation : public Animation
|
||||
{
|
||||
public:
|
||||
MapScaleAnimation(double startScale, double endScale,
|
||||
m2::PointD const & globalScaleCenter, m2::PointD const & pxScaleCenter);
|
||||
MapScaleAnimation(double startScale, double endScale, m2::PointD const & globalScaleCenter,
|
||||
m2::PointD const & pxScaleCenter);
|
||||
|
||||
void Init(ScreenBase const & screen, TPropertyCache const & properties) override;
|
||||
|
||||
Animation::Type GetType() const override { return Animation::Type::MapScale; }
|
||||
|
||||
TAnimObjects const & GetObjects() const override
|
||||
{
|
||||
return m_objects;
|
||||
}
|
||||
TAnimObjects const & GetObjects() const override { return m_objects; }
|
||||
|
||||
bool HasObject(Object object) const override
|
||||
{
|
||||
return object == Animation::Object::MapPlane;
|
||||
}
|
||||
bool HasObject(Object object) const override { return object == Animation::Object::MapPlane; }
|
||||
|
||||
TObjectProperties const & GetProperties(Object object) const override;
|
||||
bool HasProperty(Object object, ObjectProperty property) const override;
|
||||
@@ -52,5 +46,4 @@ private:
|
||||
TAnimObjects m_objects;
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
|
||||
} // namespace df
|
||||
|
||||
@@ -7,10 +7,7 @@
|
||||
namespace df
|
||||
{
|
||||
|
||||
SequenceAnimation::SequenceAnimation()
|
||||
: Animation(true /* couldBeInterrupted */, true /* couldBeBlended */)
|
||||
{
|
||||
}
|
||||
SequenceAnimation::SequenceAnimation() : Animation(true /* couldBeInterrupted */, true /* couldBeBlended */) {}
|
||||
|
||||
void SequenceAnimation::Init(ScreenBase const & screen, TPropertyCache const & properties)
|
||||
{
|
||||
@@ -18,9 +15,15 @@ void SequenceAnimation::Init(ScreenBase const & screen, TPropertyCache const & p
|
||||
m_animations.front()->Init(screen, properties);
|
||||
}
|
||||
|
||||
std::string SequenceAnimation::GetCustomType() const { return m_customType; }
|
||||
std::string SequenceAnimation::GetCustomType() const
|
||||
{
|
||||
return m_customType;
|
||||
}
|
||||
|
||||
void SequenceAnimation::SetCustomType(std::string const & type) { m_customType = type; }
|
||||
void SequenceAnimation::SetCustomType(std::string const & type)
|
||||
{
|
||||
m_customType = type;
|
||||
}
|
||||
|
||||
Animation::TAnimObjects const & SequenceAnimation::GetObjects() const
|
||||
{
|
||||
@@ -51,10 +54,8 @@ bool SequenceAnimation::HasTargetProperty(Object object, ObjectProperty property
|
||||
{
|
||||
ASSERT(!m_animations.empty(), ());
|
||||
for (auto const & anim : m_animations)
|
||||
{
|
||||
if (anim->HasTargetProperty(object, property))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -192,4 +193,4 @@ void SequenceAnimation::ObtainObjectProperties()
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace df
|
||||
} // namespace df
|
||||
|
||||
@@ -35,8 +35,8 @@ public:
|
||||
double GetMinDuration() const override;
|
||||
bool IsFinished() const override;
|
||||
|
||||
bool GetProperty(Object object, ObjectProperty property, PropertyValue &value) const override;
|
||||
bool GetTargetProperty(Object object, ObjectProperty property, PropertyValue &value) const override;
|
||||
bool GetProperty(Object object, ObjectProperty property, PropertyValue & value) const override;
|
||||
bool GetTargetProperty(Object object, ObjectProperty property, PropertyValue & value) const override;
|
||||
|
||||
void AddAnimation(drape_ptr<Animation> && animation);
|
||||
|
||||
@@ -56,5 +56,4 @@ private:
|
||||
std::string m_customType;
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
|
||||
} // namespace df
|
||||
|
||||
@@ -9,22 +9,20 @@ namespace df
|
||||
class ShowHideAnimation::ShowHideInterpolator : public BaseInterpolator
|
||||
{
|
||||
public:
|
||||
ShowHideInterpolator(ShowHideAnimation::EState & state, double startT, double endT,
|
||||
double duration)
|
||||
: BaseInterpolator(duration), m_state(state), m_startT(startT), m_endT(endT)
|
||||
ShowHideInterpolator(ShowHideAnimation::EState & state, double startT, double endT, double duration)
|
||||
: BaseInterpolator(duration)
|
||||
, m_state(state)
|
||||
, m_startT(startT)
|
||||
, m_endT(endT)
|
||||
{
|
||||
m_state = m_endT > m_startT ? ShowHideAnimation::STATE_SHOW_DIRECTION
|
||||
: ShowHideAnimation::STATE_HIDE_DIRECTION;
|
||||
m_state = m_endT > m_startT ? ShowHideAnimation::STATE_SHOW_DIRECTION : ShowHideAnimation::STATE_HIDE_DIRECTION;
|
||||
}
|
||||
|
||||
void Advance(double elapsedSeconds) override
|
||||
{
|
||||
BaseInterpolator::Advance(elapsedSeconds);
|
||||
if (IsFinished())
|
||||
{
|
||||
m_state = m_endT > m_startT ? ShowHideAnimation::STATE_VISIBLE
|
||||
: ShowHideAnimation::STATE_INVISIBLE;
|
||||
}
|
||||
m_state = m_endT > m_startT ? ShowHideAnimation::STATE_VISIBLE : ShowHideAnimation::STATE_INVISIBLE;
|
||||
}
|
||||
|
||||
double GetCurrentT() const { return m_startT + (m_endT - m_startT) * GetT(); }
|
||||
@@ -57,7 +55,7 @@ void ShowHideAnimation::Show()
|
||||
|
||||
void ShowHideAnimation::ShowAnimated()
|
||||
{
|
||||
RefreshInterpolator({{ STATE_VISIBLE, STATE_SHOW_DIRECTION }}, 1.0);
|
||||
RefreshInterpolator({{STATE_VISIBLE, STATE_SHOW_DIRECTION}}, 1.0);
|
||||
}
|
||||
|
||||
void ShowHideAnimation::Hide()
|
||||
@@ -72,7 +70,7 @@ void ShowHideAnimation::Hide()
|
||||
|
||||
void ShowHideAnimation::HideAnimated()
|
||||
{
|
||||
RefreshInterpolator({{ STATE_INVISIBLE, STATE_HIDE_DIRECTION }}, 0.0);
|
||||
RefreshInterpolator({{STATE_INVISIBLE, STATE_HIDE_DIRECTION}}, 0.0);
|
||||
}
|
||||
|
||||
ShowHideAnimation::EState ShowHideAnimation::GetState() const
|
||||
|
||||
@@ -16,6 +16,7 @@ class ValueMapping
|
||||
using TRangePoint = std::pair<double, TValue>;
|
||||
using TRangeVector = buffer_vector<TRangePoint, 8>;
|
||||
using TRangeIter = typename TRangeVector::const_iterator;
|
||||
|
||||
public:
|
||||
ValueMapping() = default;
|
||||
|
||||
@@ -71,4 +72,4 @@ private:
|
||||
TRangeVector m_ranges;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace df
|
||||
|
||||
Reference in New Issue
Block a user