[drape] selection object small refactoring. Empty state added

This commit is contained in:
ExMix 2015-06-15 18:55:17 +03:00 committed by r.kuznetsov
parent d4abadc910
commit c1ec502bf8
7 changed files with 32 additions and 31 deletions

View file

@ -288,10 +288,10 @@ FeatureID DrapeEngine::GetVisiblePOI(m2::PointD const & glbPoint)
return result;
}
void DrapeEngine::SelectObject(SelectionShape::ESelectedObject obj, m2::PointD const & pt)
void DrapeEngine::SelectObject(SelectionShape::ESelectedObject obj, m2::PointD const & pt, bool isAnim)
{
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
make_unique_dp<SelectObjectMessage>(obj, pt),
make_unique_dp<SelectObjectMessage>(obj, pt, isAnim),
MessagePriority::High);
}

View file

@ -94,7 +94,7 @@ public:
void SetUserPositionListener(TUserPositionChangedFn const & fn);
FeatureID GetVisiblePOI(m2::PointD const & glbPoint);
void SelectObject(SelectionShape::ESelectedObject obj, m2::PointD const & pt);
void SelectObject(SelectionShape::ESelectedObject obj, m2::PointD const & pt, bool isAnim);
void DeselectObject();
bool GetMyPosition(m2::PointD & myPosition);

View file

@ -262,16 +262,9 @@ void FrontendRenderer::AcceptMessage(ref_ptr<Message> message)
ref_ptr<SelectObjectMessage> msg = message;
ASSERT(m_selectionShape != nullptr, ());
if (msg->IsDismiss())
{
m_selectionShape->Hide();
}
else
{
m_selectionShape->SetPosition(msg->GetPosition());
m_selectionShape->SetSelectedObject(msg->GetSelectedObject());
m_selectionShape->Hide();
m_selectionShape->Show();
}
m_selectionShape->Show(msg->GetSelectedObject(), msg->GetPosition(), msg->IsAnim());
break;
}

View file

@ -439,25 +439,35 @@ class SelectObjectMessage : public Message
public:
struct DismissTag {};
SelectObjectMessage(DismissTag)
: m_isDismiss(true)
: SelectObjectMessage(SelectionShape::OBJECT_EMPTY, m2::PointD::Zero(), false, true)
{
}
SelectObjectMessage(SelectionShape::ESelectedObject selectedObject, m2::PointD const & glbPoint)
: m_selected(selectedObject)
, m_glbPoint(glbPoint)
, m_isDismiss(false)
SelectObjectMessage(SelectionShape::ESelectedObject selectedObject, m2::PointD const & glbPoint, bool isAnim)
: SelectObjectMessage(selectedObject, glbPoint, isAnim, false)
{
}
Type GetType() const override { return SelectObject; }
m2::PointD const & GetPosition() const { return m_glbPoint; }
SelectionShape::ESelectedObject GetSelectedObject() const { return m_selected; }
bool IsAnim() const { return m_isAnim; }
bool IsDismiss() const { return m_isDismiss; }
private:
SelectObjectMessage(SelectionShape::ESelectedObject obj, m2::PointD const & pt, bool isAnim, bool isDismiss)
: m_selected(obj)
, m_glbPoint(pt)
, m_isAnim(isAnim)
, m_isDismiss(isDismiss)
{
}
private:
SelectionShape::ESelectedObject m_selected;
m2::PointD m_glbPoint;
bool m_isAnim;
bool m_isDismiss;
};

View file

@ -55,6 +55,7 @@ dp::BindingInfo GetBindingInfo()
SelectionShape::SelectionShape(ref_ptr<dp::TextureManager> mng)
: m_position(m2::PointD::Zero())
, m_animation(false, 0.25)
, m_selectedObject(OBJECT_EMPTY)
{
int const TriangleCount = 40;
int const VertexCount = 3 * TriangleCount;
@ -102,19 +103,21 @@ SelectionShape::SelectionShape(ref_ptr<dp::TextureManager> mng)
m_mapping.AddRangePoint(1.0, r);
}
void SelectionShape::SetPosition(m2::PointD const & position)
void SelectionShape::Show(ESelectedObject obj, m2::PointD const & position, bool isAnimate)
{
m_animation.Hide();
m_position = position;
}
void SelectionShape::Show()
{
m_animation.ShowAnimated();
m_selectedObject = obj;
if (isAnimate)
m_animation.ShowAnimated();
else
m_animation.Show();
}
void SelectionShape::Hide()
{
m_animation.Hide();
m_selectedObject = OBJECT_EMPTY;
}
void SelectionShape::Render(ScreenBase const & screen, ref_ptr<dp::GpuProgramManager> mng,
@ -133,11 +136,6 @@ void SelectionShape::Render(ScreenBase const & screen, ref_ptr<dp::GpuProgramMan
}
}
void SelectionShape::SetSelectedObject(SelectionShape::ESelectedObject obj)
{
m_selectedObject = obj;
}
SelectionShape::ESelectedObject SelectionShape::GetSelectedObject() const
{
return m_selectedObject;

View file

@ -24,6 +24,7 @@ class SelectionShape
public:
enum ESelectedObject
{
OBJECT_EMPTY,
OBJECT_POI,
OBJECT_USER_MARK,
OBJECT_MY_POSITION
@ -31,14 +32,13 @@ public:
SelectionShape(ref_ptr<dp::TextureManager> mng);
void SetPosition(m2::PointD const & position);
void Show();
void SetPosition(m2::PointD const & position) { m_position = position; }
void Show(ESelectedObject obj, m2::PointD const & position, bool isAnimate);
void Hide();
void Render(ScreenBase const & screen,
ref_ptr<dp::GpuProgramManager> mng,
dp::UniformValuesStorage const & commonUniforms);
void SetSelectedObject(ESelectedObject obj);
ESelectedObject GetSelectedObject() const;
private:

View file

@ -1655,7 +1655,7 @@ void Framework::ActivateUserMark(UserMark const * mark, bool needAnim)
else if (type == UserMark::Type::POI)
object = df::SelectionShape::OBJECT_POI;
CallDrapeFunction(bind(&df::DrapeEngine::SelectObject, _1, object, pt));
CallDrapeFunction(bind(&df::DrapeEngine::SelectObject, _1, object, pt, needAnim));
}
else
{