From d05bc5c67d9dd133eedd68bbb3c8b3cb2a7b1d96 Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Mon, 4 Jan 2016 10:09:51 +0300 Subject: [PATCH] Changing constant colors on map style changing --- drape_frontend/color_constants.cpp | 4 ++++ drape_frontend/color_constants.hpp | 2 ++ drape_frontend/drape_engine.cpp | 3 ++- drape_frontend/drape_engine.hpp | 4 +++- drape_frontend/gui/country_status.cpp | 10 ++++++---- drape_frontend/message_subclasses.hpp | 7 ++++--- drape_frontend/route_builder.cpp | 2 +- drape_frontend/route_builder.hpp | 3 ++- drape_frontend/route_renderer.cpp | 4 +++- drape_frontend/route_shape.hpp | 3 ++- map/framework.cpp | 8 ++------ 11 files changed, 31 insertions(+), 19 deletions(-) diff --git a/drape_frontend/color_constants.cpp b/drape_frontend/color_constants.cpp index 6fd3d0abe4..6a8ef68c34 100644 --- a/drape_frontend/color_constants.cpp +++ b/drape_frontend/color_constants.cpp @@ -16,6 +16,8 @@ unordered_map> kColorConstants = { DownloadButtonRouting, dp::Color(32, 152, 82, 255) }, { DownloadButtonPressed, dp::Color(0, 0, 0, 0.72 * 255) }, { DownloadButtonRoutingPressed, dp::Color(24, 128, 68, 255) }, + { DownloadButtonText, dp::Color(255, 255, 255, 255) }, + { CountryStatusText, dp::Color(0, 0, 0, 255) }, { GuiText, dp::Color(0x4D, 0x4D, 0x4D, 0xDD) }, { MyPositionAccuracy, dp::Color(30, 150, 240, 20) }, { Selection, dp::Color(0x17, 0xBF, 0x8E, 0x6F) }, @@ -29,6 +31,8 @@ unordered_map> kColorConstants = { DownloadButtonRouting, dp::Color(32, 152, 82, 255) }, { DownloadButtonPressed, dp::Color(0, 0, 0, 0.72 * 255) }, { DownloadButtonRoutingPressed, dp::Color(24, 128, 68, 255) }, + { DownloadButtonText, dp::Color(255, 255, 255, 255) }, + { CountryStatusText, dp::Color(0, 0, 0, 255) }, { GuiText, dp::Color(0x4D, 0x4D, 0x4D, 0xDD) }, { MyPositionAccuracy, dp::Color(30, 150, 240, 20) }, { Selection, dp::Color(0x17, 0xBF, 0x8E, 0x6F) }, diff --git a/drape_frontend/color_constants.hpp b/drape_frontend/color_constants.hpp index 1d2ad01082..3c64acc39e 100644 --- a/drape_frontend/color_constants.hpp +++ b/drape_frontend/color_constants.hpp @@ -13,6 +13,8 @@ enum ColorConstant DownloadButtonRouting, DownloadButtonPressed, DownloadButtonRoutingPressed, + DownloadButtonText, + CountryStatusText, GuiText, MyPositionAccuracy, Selection, diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp index eab573c9a3..54a1395b95 100644 --- a/drape_frontend/drape_engine.cpp +++ b/drape_frontend/drape_engine.cpp @@ -389,7 +389,8 @@ bool DrapeEngine::GetMyPosition(m2::PointD & myPosition) return hasPosition; } -void DrapeEngine::AddRoute(m2::PolylineD const & routePolyline, vector const & turns, dp::Color const & color) +void DrapeEngine::AddRoute(m2::PolylineD const & routePolyline, vector const & turns, + df::ColorConstant color) { m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, make_unique_dp(routePolyline, turns, color), diff --git a/drape_frontend/drape_engine.hpp b/drape_frontend/drape_engine.hpp index 38b364e760..05691ce3a7 100644 --- a/drape_frontend/drape_engine.hpp +++ b/drape_frontend/drape_engine.hpp @@ -1,6 +1,7 @@ #pragma once #include "drape_frontend/backend_renderer.hpp" +#include "drape_frontend/color_constants.hpp" #include "drape_frontend/frontend_renderer.hpp" #include "drape_frontend/threads_commutator.hpp" #include "drape_frontend/selection_shape.hpp" @@ -108,7 +109,8 @@ public: bool GetMyPosition(m2::PointD & myPosition); SelectionShape::ESelectedObject GetSelectedObject(); - void AddRoute(m2::PolylineD const & routePolyline, vector const & turns, dp::Color const & color); + void AddRoute(m2::PolylineD const & routePolyline, vector const & turns, + df::ColorConstant color); void RemoveRoute(bool deactivateFollowing); void FollowRoute(int preferredZoomLevel, int preferredZoomLevel3d, double rotationAngle, double angleFOV); void DeactivateRouteFollowing(); diff --git a/drape_frontend/gui/country_status.cpp b/drape_frontend/gui/country_status.cpp index 1b5e1ca936..70c2527a1d 100644 --- a/drape_frontend/gui/country_status.cpp +++ b/drape_frontend/gui/country_status.cpp @@ -117,8 +117,8 @@ void DrawLabelControl(string const & text, dp::Anchor anchor, dp::Batcher::TFlus ref_ptr mng, CountryStatusHelper::ECountryState state) { StaticLabel::LabelResult result; - StaticLabel::CacheStaticText(text, "\n", anchor, dp::FontDecl(dp::Color::Black(), 18), mng, - result); + dp::Color const textColor = df::GetColorConstant(GetStyleReader().GetCurrentStyle(), df::CountryStatusText); + StaticLabel::CacheStaticText(text, "\n", anchor, dp::FontDecl(textColor, 18), mng, result); size_t vertexCount = result.m_buffer.size(); ASSERT(vertexCount % dp::Batcher::VertexPerQuad == 0, ()); size_t indexCount = dp::Batcher::IndexPerQuad * vertexCount / dp::Batcher::VertexPerQuad; @@ -141,10 +141,11 @@ void DrawProgressControl(dp::Anchor anchor, dp::Batcher::TFlushFn const & flushF MutableLabelDrawer::Params params; CountryStatusHelper & helper = DrapeGui::GetCountryStatusHelper(); helper.GetProgressInfo(params.m_alphabet, params.m_maxLength); + dp::Color const textColor = df::GetColorConstant(GetStyleReader().GetCurrentStyle(), df::CountryStatusText); params.m_anchor = anchor; params.m_pivot = m2::PointF::Zero(); - params.m_font = dp::FontDecl(dp::Color::Black(), 18); + params.m_font = dp::FontDecl(textColor, 18); params.m_handleCreator = [state, mng](dp::Anchor anchor, m2::PointF const & /*pivot*/) { return make_unique_dp(anchor, state, mng); @@ -206,11 +207,12 @@ drape_ptr CountryStatus::Draw(ref_ptr tex, &maxButtonWidth](CountryStatusHelper::Control const & control) { float const visualScale = df::VisualParams::Instance().GetVisualScale(); + dp::Color const textColor = df::GetColorConstant(GetStyleReader().GetCurrentStyle(), df::DownloadButtonText); Button::Params params; params.m_anchor = m_position.m_anchor; params.m_label = control.m_label; - params.m_labelFont = dp::FontDecl(dp::Color::White(), 18); + params.m_labelFont = dp::FontDecl(textColor, 18); params.m_margin = 5.0f * visualScale; params.m_facet = 8.0f * visualScale; diff --git a/drape_frontend/message_subclasses.hpp b/drape_frontend/message_subclasses.hpp index 16351d0540..bfd1dbcab3 100644 --- a/drape_frontend/message_subclasses.hpp +++ b/drape_frontend/message_subclasses.hpp @@ -4,6 +4,7 @@ #include "drape_frontend/gui/layer_render.hpp" #include "drape_frontend/gui/skin.hpp" +#include "drape_frontend/color_constants.hpp" #include "drape_frontend/gps_track_point.hpp" #include "drape_frontend/gps_track_shape.hpp" #include "drape_frontend/route_builder.hpp" @@ -514,7 +515,7 @@ private: class AddRouteMessage : public Message { public: - AddRouteMessage(m2::PolylineD const & routePolyline, vector const & turns, dp::Color const & color) + AddRouteMessage(m2::PolylineD const & routePolyline, vector const & turns, df::ColorConstant color) : m_routePolyline(routePolyline) , m_color(color) , m_turns(turns) @@ -523,12 +524,12 @@ public: Type GetType() const override { return Message::AddRoute; } m2::PolylineD const & GetRoutePolyline() { return m_routePolyline; } - dp::Color const & GetColor() const { return m_color; } + df::ColorConstant GetColor() const { return m_color; } vector const & GetTurns() const { return m_turns; } private: m2::PolylineD m_routePolyline; - dp::Color m_color; + df::ColorConstant m_color; vector m_turns; }; diff --git a/drape_frontend/route_builder.cpp b/drape_frontend/route_builder.cpp index 3161d8fb75..1051b4ddda 100644 --- a/drape_frontend/route_builder.cpp +++ b/drape_frontend/route_builder.cpp @@ -12,7 +12,7 @@ RouteBuilder::RouteBuilder(TFlushRouteFn const & flushRouteFn, {} void RouteBuilder::Build(m2::PolylineD const & routePolyline, vector const & turns, - dp::Color const & color, ref_ptr textures) + df::ColorConstant color, ref_ptr textures) { CommonViewParams params; params.m_minVisibleScale = 1; diff --git a/drape_frontend/route_builder.hpp b/drape_frontend/route_builder.hpp index 0a6bedd78f..e6a34dab44 100644 --- a/drape_frontend/route_builder.hpp +++ b/drape_frontend/route_builder.hpp @@ -1,5 +1,6 @@ #pragma once +#include "drape_frontend/color_constants.hpp" #include "drape_frontend/route_shape.hpp" #include "drape/pointers.hpp" @@ -22,7 +23,7 @@ public: TFlushRouteSignFn const & flushRouteSignFn); void Build(m2::PolylineD const & routePolyline, vector const & turns, - dp::Color const & color, ref_ptr textures); + df::ColorConstant color, ref_ptr textures); void BuildSign(m2::PointD const & pos, bool isStart, bool isValid, ref_ptr textures); diff --git a/drape_frontend/route_renderer.cpp b/drape_frontend/route_renderer.cpp index 883f5d20c7..eadb63ff81 100644 --- a/drape_frontend/route_renderer.cpp +++ b/drape_frontend/route_renderer.cpp @@ -5,6 +5,7 @@ #include "drape/utils/projection.hpp" #include "drape/vertex_array_buffer.hpp" +#include "indexer/map_style_reader.hpp" #include "indexer/scales.hpp" #include "base/logging.hpp" @@ -179,7 +180,8 @@ void RouteRenderer::RenderRoute(ScreenBase const & screen, ref_ptrm_color); + glsl::vec4 const color = glsl::ToVec4(df::GetColorConstant(GetStyleReader().GetCurrentStyle(), + m_routeData->m_color)); uniforms.SetFloatValue("u_color", color.r, color.g, color.b, alpha); uniforms.SetFloatValue("u_routeParams", halfWidth, halfWidth * screen.GetScale(), m_distanceFromBegin); diff --git a/drape_frontend/route_shape.hpp b/drape_frontend/route_shape.hpp index ad806642f6..77f8b598cb 100644 --- a/drape_frontend/route_shape.hpp +++ b/drape_frontend/route_shape.hpp @@ -1,5 +1,6 @@ #pragma once +#include "drape_frontend/color_constants.hpp" #include "drape_frontend/map_shape.hpp" #include "drape_frontend/shape_view_params.hpp" @@ -44,7 +45,7 @@ struct RouteData { m2::PolylineD m_sourcePolyline; vector m_sourceTurns; - dp::Color m_color; + df::ColorConstant m_color; m2::RectF m_arrowTextureRect; double m_length; RouteRenderProperty m_route; diff --git a/map/framework.cpp b/map/framework.cpp index 4d8b687a8f..2a232feb7a 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2043,12 +2043,8 @@ void Framework::InsertRoute(Route const & route) if (m_currentRouterType == RouterType::Vehicle) route.GetTurnsDistances(turns); - dp::Color routeColor; - if (m_currentRouterType == RouterType::Pedestrian) - routeColor = df::GetColorConstant(GetMapStyle(), df::RoutePedestrian); - else - routeColor = df::GetColorConstant(GetMapStyle(), df::Route); - + df::ColorConstant const routeColor = (m_currentRouterType == RouterType::Pedestrian) ? + df::RoutePedestrian : df::Route; m_drapeEngine->AddRoute(route.GetPoly(), turns, routeColor); }