forked from organicmaps/organicmaps
[drape] compass tap and angle animation
This commit is contained in:
parent
ba09d1e7c2
commit
e07bc8269d
8 changed files with 53 additions and 2 deletions
|
@ -14,11 +14,13 @@ namespace
|
|||
Tester() = default;
|
||||
};
|
||||
|
||||
#if defined(TRACK_POINTERS)
|
||||
bool g_assertRaised = false;
|
||||
void OnAssertRaised(my::SrcPoint const & srcPoint, string const & msg)
|
||||
void OnAssertRaised(my::SrcPoint const & /*srcPoint*/, string const & /*msg*/)
|
||||
{
|
||||
g_assertRaised = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
UNIT_TEST(PointersTrackingTest)
|
||||
|
|
|
@ -3,6 +3,13 @@
|
|||
namespace df
|
||||
{
|
||||
|
||||
ModelViewAngleAnimation::ModelViewAngleAnimation(double startAngle, double endAngle)
|
||||
: BaseModeViewAnimation(GetStandardDuration(startAngle, endAngle))
|
||||
, m_angle(startAngle, endAngle)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ModelViewAngleAnimation::ModelViewAngleAnimation(double startAngle, double endAngle, double duration)
|
||||
: BaseModeViewAnimation(duration)
|
||||
, m_angle(startAngle, endAngle)
|
||||
|
@ -17,4 +24,9 @@ void ModelViewAngleAnimation::Apply(Navigator & navigator)
|
|||
navigator.SetFromRect(r);
|
||||
}
|
||||
|
||||
double ModelViewAngleAnimation::GetStandardDuration(double startAngle, double endAngle)
|
||||
{
|
||||
return fabs(ang::GetShortestDistance(startAngle, endAngle) / math::twicePi * 2.0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,9 +9,12 @@ namespace df
|
|||
class ModelViewAngleAnimation : public BaseModeViewAnimation
|
||||
{
|
||||
public:
|
||||
ModelViewAngleAnimation(double startAngle, double endAngle);
|
||||
ModelViewAngleAnimation(double startAngle, double endAngle, double duration);
|
||||
void Apply(Navigator & navigator) override;
|
||||
|
||||
static double GetStandardDuration(double startAngle, double endAngle);
|
||||
|
||||
private:
|
||||
InerpolateAngle m_angle;
|
||||
};
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "drape_frontend/visual_params.hpp"
|
||||
#include "drape_frontend/user_mark_shapes.hpp"
|
||||
|
||||
#include "drape_gui/drape_gui.hpp"
|
||||
|
||||
#include "drape/utils/glyph_usage_tracker.hpp"
|
||||
#include "drape/utils/gpu_mem_tracker.hpp"
|
||||
#include "drape/utils/projection.hpp"
|
||||
|
@ -257,6 +259,11 @@ void FrontendRenderer::OnRemoveTile(TileKey const & tileKey)
|
|||
m_deferredRenderGroups.end());
|
||||
}
|
||||
|
||||
void FrontendRenderer::OnCompassTapped()
|
||||
{
|
||||
m_userEventStream.AddEvent(RotateEvent(0.0));
|
||||
}
|
||||
|
||||
void FrontendRenderer::RenderScene(ScreenBase const & modelView)
|
||||
{
|
||||
#ifdef DRAW_INFO
|
||||
|
@ -446,6 +453,8 @@ FrontendRenderer::Routine::Routine(FrontendRenderer & renderer) : m_renderer(ren
|
|||
|
||||
void FrontendRenderer::Routine::Do()
|
||||
{
|
||||
gui::DrapeGui::Instance().ConnectOnCompassTappedHandler(bind(&FrontendRenderer::OnCompassTapped, &m_renderer));
|
||||
|
||||
m_renderer.m_tileTree->SetHandlers(bind(&FrontendRenderer::OnAddRenderGroup, &m_renderer, _1, _2, _3),
|
||||
bind(&FrontendRenderer::OnDeferRenderGroup, &m_renderer, _1, _2, _3),
|
||||
bind(&FrontendRenderer::OnActivateTile, &m_renderer, _1),
|
||||
|
|
|
@ -128,6 +128,8 @@ private:
|
|||
void OnActivateTile(TileKey const & tileKey);
|
||||
void OnRemoveTile(TileKey const & tileKey);
|
||||
|
||||
void OnCompassTapped();
|
||||
|
||||
private:
|
||||
drape_ptr<dp::GpuProgramManager> m_gpuProgramManager;
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "drape_frontend/animation/modelview_angle_animation.hpp"
|
||||
#include "drape_frontend/user_event_stream.hpp"
|
||||
#include "drape_frontend/visual_params.hpp"
|
||||
|
||||
|
@ -91,6 +92,9 @@ ScreenBase const & UserEventStream::ProcessEvents(bool & modelViewChange, bool &
|
|||
case UserEvent::EVENT_TOUCH:
|
||||
ProcessTouch(e.m_touchEvent);
|
||||
break;
|
||||
case UserEvent::EVENT_ROTATE:
|
||||
m_animation.reset(new ModelViewAngleAnimation(m_navigator.Screen().GetAngle(), e.m_rotate.m_targetAzimut));
|
||||
break;
|
||||
default:
|
||||
ASSERT(false, ());
|
||||
break;
|
||||
|
|
|
@ -88,6 +88,13 @@ struct SetAnyRectEvent
|
|||
m2::AnyRectD m_rect; // destination mercator rect
|
||||
};
|
||||
|
||||
struct RotateEvent
|
||||
{
|
||||
RotateEvent(double targetAzimut) : m_targetAzimut(targetAzimut) {}
|
||||
|
||||
double m_targetAzimut;
|
||||
};
|
||||
|
||||
struct ResizeEvent
|
||||
{
|
||||
ResizeEvent(uint32_t w, uint32_t h) : m_width(w), m_height(h) {}
|
||||
|
@ -105,7 +112,8 @@ struct UserEvent
|
|||
EVENT_SET_CENTER,
|
||||
EVENT_SET_RECT,
|
||||
EVENT_SET_ANY_RECT,
|
||||
EVENT_RESIZE
|
||||
EVENT_RESIZE,
|
||||
EVENT_ROTATE
|
||||
};
|
||||
|
||||
UserEvent(TouchEvent const & e) : m_type(EVENT_TOUCH) { m_touchEvent = e; }
|
||||
|
@ -114,6 +122,7 @@ struct UserEvent
|
|||
UserEvent(SetRectEvent const & e) : m_type(EVENT_SET_RECT) { m_rectEvent = e; }
|
||||
UserEvent(SetAnyRectEvent const & e) : m_type(EVENT_SET_ANY_RECT) { m_anyRect = e; }
|
||||
UserEvent(ResizeEvent const & e) : m_type(EVENT_RESIZE) { m_resize = e; }
|
||||
UserEvent(RotateEvent const & e) : m_type(EVENT_ROTATE) { m_rotate = e; }
|
||||
|
||||
EEventType m_type;
|
||||
union
|
||||
|
@ -124,6 +133,7 @@ struct UserEvent
|
|||
SetRectEvent m_rectEvent;
|
||||
SetAnyRectEvent m_anyRect;
|
||||
ResizeEvent m_resize;
|
||||
RotateEvent m_rotate;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -34,16 +34,25 @@ public:
|
|||
void OnTouchUp(m2::PointD const & pt);
|
||||
void OnTouchCancel(m2::PointD const & pt);
|
||||
|
||||
using TCompassTapedFn = function<void ()>;
|
||||
int ConnectOnCompassTap(TCompassTapedFn const & fn);
|
||||
void DisconnectOnCompassTap(int slotID);
|
||||
|
||||
private:
|
||||
void DestroyRenderers();
|
||||
|
||||
friend class LayerCacher;
|
||||
void AddShapeRenderer(Skin::ElementName name, drape_ptr<ShapeRenderer> && shape);
|
||||
|
||||
void OnCompassTap();
|
||||
|
||||
private:
|
||||
typedef map<Skin::ElementName, drape_ptr<ShapeRenderer> > TRenderers;
|
||||
TRenderers m_renderers;
|
||||
|
||||
using TCompassSlotMap = map<int, TCompassTapedFn>;
|
||||
TCompassSlotMap m_compasSlot;
|
||||
|
||||
ref_ptr<gui::Handle> m_activeOverlay;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue