diff options
author | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2016-02-17 14:59:46 +0300 |
---|---|---|
committer | Sergey Yershov <yershov@corp.mail.ru> | 2016-03-23 16:21:22 +0300 |
commit | 02d375be30f95b48577c6ce6affbf4ea46d7284a (patch) | |
tree | 0f47ac1c94b8bae67b3c3b51868e028b76f6c588 /drape_frontend/gui | |
parent | 324fcd155afae83d5d84929deda8140b30e25649 (diff) |
Choose position mark rendering and taps blocking.
Diffstat (limited to 'drape_frontend/gui')
-rw-r--r-- | drape_frontend/gui/choose_position_mark.cpp | 98 | ||||
-rw-r--r-- | drape_frontend/gui/choose_position_mark.hpp | 18 | ||||
-rw-r--r-- | drape_frontend/gui/compass.cpp | 2 | ||||
-rw-r--r-- | drape_frontend/gui/layer_render.cpp | 18 | ||||
-rw-r--r-- | drape_frontend/gui/layer_render.hpp | 3 | ||||
-rw-r--r-- | drape_frontend/gui/skin.hpp | 6 |
6 files changed, 140 insertions, 5 deletions
diff --git a/drape_frontend/gui/choose_position_mark.cpp b/drape_frontend/gui/choose_position_mark.cpp new file mode 100644 index 0000000000..3f33aa6239 --- /dev/null +++ b/drape_frontend/gui/choose_position_mark.cpp @@ -0,0 +1,98 @@ +#include "choose_position_mark.hpp" +#include "drape_gui.hpp" + +#include "drape/shader_def.hpp" + +#include "drape/utils/vertex_decl.hpp" + +#include "std/bind.hpp" + +namespace gui +{ + +namespace +{ + +struct ChoosePositionMarkVertex +{ + ChoosePositionMarkVertex(glsl::vec2 const & position, glsl::vec2 const & texCoord) + : m_position(position) + , m_texCoord(texCoord) + {} + + glsl::vec2 m_position; + glsl::vec2 m_texCoord; +}; + +class ChoosePositionMarkHandle : public Handle +{ + using TBase = Handle; + +public: + ChoosePositionMarkHandle(uint32_t id, m2::PointF const & pivot, m2::PointF const & size) + : Handle(id, dp::Center, pivot, size) + { + SetIsVisible(true); + } + + bool Update(ScreenBase const & screen) override + { + SetPivot(glsl::ToVec2(m2::PointF(screen.PixelRect().Center()))); + return TBase::Update(screen); + } +}; + +} + +drape_ptr<ShapeRenderer> ChoosePositionMark::Draw(ref_ptr<dp::TextureManager> tex) const +{ + dp::TextureManager::SymbolRegion region; + tex->GetSymbolRegion("cross_geoposition", region); + glsl::vec2 halfSize = glsl::ToVec2(m2::PointD(region.GetPixelSize()) * 0.5); + m2::RectF texRect = region.GetTexRect(); + + ASSERT_EQUAL(m_position.m_anchor, dp::Center, ()); + ChoosePositionMarkVertex vertexes[] = + { + ChoosePositionMarkVertex(glsl::vec2(-halfSize.x, halfSize.y), glsl::ToVec2(texRect.LeftTop())), + ChoosePositionMarkVertex(glsl::vec2(-halfSize.x, -halfSize.y), glsl::ToVec2(texRect.LeftBottom())), + ChoosePositionMarkVertex(glsl::vec2(halfSize.x, halfSize.y), glsl::ToVec2(texRect.RightTop())), + ChoosePositionMarkVertex(glsl::vec2(halfSize.x, -halfSize.y), glsl::ToVec2(texRect.RightBottom())) + }; + + dp::GLState state(gpu::TEXTURING_GUI_PROGRAM, dp::GLState::Gui); + state.SetColorTexture(region.GetTexture()); + + dp::AttributeProvider provider(1 /*streamCount*/, 4 /*vertexCount*/); + dp::BindingInfo info(2 /*count*/); + + dp::BindingDecl & posDecl = info.GetBindingDecl(0); + posDecl.m_attributeName = "a_position"; + posDecl.m_componentCount = 2; + posDecl.m_componentType = gl_const::GLFloatType; + posDecl.m_offset = 0; + posDecl.m_stride = sizeof(ChoosePositionMarkVertex); + + dp::BindingDecl & texDecl = info.GetBindingDecl(1); + texDecl.m_attributeName = "a_colorTexCoords"; + texDecl.m_componentCount = 2; + texDecl.m_componentType = gl_const::GLFloatType; + texDecl.m_offset = sizeof(glsl::vec2); + texDecl.m_stride = posDecl.m_stride; + + provider.InitStream(0, info, make_ref(&vertexes)); + + m2::PointF const markSize = region.GetPixelSize(); + drape_ptr<dp::OverlayHandle> handle = make_unique_dp<ChoosePositionMarkHandle>(EGuiHandle::GuiHandleChoosePositionMark, + m_position.m_pixelPivot, + markSize); + + drape_ptr<ShapeRenderer> renderer = make_unique_dp<ShapeRenderer>(); + dp::Batcher batcher(dp::Batcher::IndexPerQuad, dp::Batcher::VertexPerQuad); + dp::SessionGuard guard(batcher, bind(&ShapeRenderer::AddShape, renderer.get(), _1, _2)); + batcher.InsertTriangleStrip(state, make_ref(&provider), move(handle)); + + return renderer; +} + +} // namespace gui diff --git a/drape_frontend/gui/choose_position_mark.hpp b/drape_frontend/gui/choose_position_mark.hpp new file mode 100644 index 0000000000..6696df7df0 --- /dev/null +++ b/drape_frontend/gui/choose_position_mark.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "shape.hpp" + +namespace gui +{ + +class ChoosePositionMark : public Shape +{ +public: + ChoosePositionMark(gui::Position const & position) + : Shape(position) + {} + + drape_ptr<ShapeRenderer> Draw(ref_ptr<dp::TextureManager> tex) const; +}; + +} // namespace gui diff --git a/drape_frontend/gui/compass.cpp b/drape_frontend/gui/compass.cpp index 8accaae6ee..2ff4222656 100644 --- a/drape_frontend/gui/compass.cpp +++ b/drape_frontend/gui/compass.cpp @@ -104,7 +104,7 @@ drape_ptr<ShapeRenderer> Compass::Draw(m2::PointF & compassSize, ref_ptr<dp::Tex CompassVertex(glsl::vec2(halfSize.x, -halfSize.y), glsl::ToVec2(texRect.RightBottom())) }; - dp::GLState state(gpu::COMPASS_PROGRAM, dp::GLState::Gui); + dp::GLState state(gpu::TEXTURING_GUI_PROGRAM, dp::GLState::Gui); state.SetColorTexture(region.GetTexture()); dp::AttributeProvider provider(1, 4); diff --git a/drape_frontend/gui/layer_render.cpp b/drape_frontend/gui/layer_render.cpp index 9fe84225fc..866b690651 100644 --- a/drape_frontend/gui/layer_render.cpp +++ b/drape_frontend/gui/layer_render.cpp @@ -1,3 +1,4 @@ +#include "choose_position_mark.hpp" #include "compass.hpp" #include "copyright_label.hpp" #include "country_status.hpp" @@ -203,7 +204,7 @@ drape_ptr<LayerRenderer> LayerCacher::RecacheCountryStatus(ref_ptr<dp::TextureMa { m2::PointF surfSize = DrapeGui::Instance().GetSurfaceSize(); drape_ptr<LayerRenderer> renderer = make_unique_dp<LayerRenderer>(); - CountryStatus countryStatus = CountryStatus(Position(surfSize * 0.5, dp::Center)); + CountryStatus countryStatus = CountryStatus(Position(surfSize * 0.5f, dp::Center)); CountryStatus::TButtonHandlers handlers; RegisterButtonHandler(handlers, CountryStatusHelper::BUTTON_TYPE_MAP); @@ -218,6 +219,21 @@ drape_ptr<LayerRenderer> LayerCacher::RecacheCountryStatus(ref_ptr<dp::TextureMa return renderer; } +drape_ptr<LayerRenderer> LayerCacher::RecacheChoosePositionMark(ref_ptr<dp::TextureManager> textures) +{ + m2::PointF surfSize = DrapeGui::Instance().GetSurfaceSize(); + drape_ptr<LayerRenderer> renderer = make_unique_dp<LayerRenderer>(); + + ChoosePositionMark positionMark = ChoosePositionMark(Position(surfSize * 0.5f, dp::Center)); + renderer->AddShapeRenderer(WIDGET_CHOOSE_POSITION_MARK, positionMark.Draw(textures)); + + // Flush gui geometry. + GLFunctions::glFlush(); + + return renderer; +} + + m2::PointF LayerCacher::CacheCompass(Position const & position, ref_ptr<LayerRenderer> renderer, ref_ptr<dp::TextureManager> textures) { diff --git a/drape_frontend/gui/layer_render.hpp b/drape_frontend/gui/layer_render.hpp index 4126f77c2a..b3703be9b7 100644 --- a/drape_frontend/gui/layer_render.hpp +++ b/drape_frontend/gui/layer_render.hpp @@ -55,7 +55,8 @@ public: drape_ptr<LayerRenderer> RecacheWidgets(TWidgetsInitInfo const & initInfo, TWidgetsSizeInfo & sizeInfo, ref_ptr<dp::TextureManager> textures); - drape_ptr<LayerRenderer> RecacheCountryStatus(ref_ptr<dp::TextureManager> texMng); + drape_ptr<LayerRenderer> RecacheCountryStatus(ref_ptr<dp::TextureManager> textures); + drape_ptr<LayerRenderer> RecacheChoosePositionMark(ref_ptr<dp::TextureManager> textures); private: m2::PointF CacheCompass(Position const & position, ref_ptr<LayerRenderer> renderer, ref_ptr<dp::TextureManager> textures); diff --git a/drape_frontend/gui/skin.hpp b/drape_frontend/gui/skin.hpp index b756863c95..60bf6750f4 100644 --- a/drape_frontend/gui/skin.hpp +++ b/drape_frontend/gui/skin.hpp @@ -16,7 +16,8 @@ enum EWidget WIDGET_COPYRIGHT = 0x4, WIDGET_SCALE_LABEL = 0x8, /// WIDGET_COUNTRY_STATUS - controlled by rendering kernel. Don't use it in platform code - WIDGET_COUNTRY_STATUS = 0x8000 + WIDGET_COUNTRY_STATUS = 0x8000, + WIDGET_CHOOSE_POSITION_MARK = 0x8001 }; enum EGuiHandle @@ -33,7 +34,8 @@ enum EGuiHandle GuiHandleRetryButton, GuiHandleRetryButtonLabel, GuiHandleCancelButton, - GuiHandleCancelButtonLabel + GuiHandleCancelButtonLabel, + GuiHandleChoosePositionMark }; struct Position |