mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-30 21:30:05 +00:00 
			
		
		
		
	Add map center icon to overlay layer
This commit is contained in:
		
							parent
							
								
									5beb16271a
								
							
						
					
					
						commit
						fcf6ef800b
					
				
					 1 changed files with 23 additions and 1 deletions
				
			
		|  | @ -69,6 +69,9 @@ public: | ||||||
|       showMapAttributionCallbackUuid_ = |       showMapAttributionCallbackUuid_ = | ||||||
|          generalSettings.show_map_attribution().RegisterValueChangedCallback( |          generalSettings.show_map_attribution().RegisterValueChangedCallback( | ||||||
|             [this](const bool&) { Q_EMIT self_->NeedsRendering(); }); |             [this](const bool&) { Q_EMIT self_->NeedsRendering(); }); | ||||||
|  |       showMapCenterCallbackUuid_ = | ||||||
|  |          generalSettings.show_map_center().RegisterValueChangedCallback( | ||||||
|  |             [this](const bool&) { Q_EMIT self_->NeedsRendering(); }); | ||||||
|       showMapLogoCallbackUuid_ = |       showMapLogoCallbackUuid_ = | ||||||
|          generalSettings.show_map_logo().RegisterValueChangedCallback( |          generalSettings.show_map_logo().RegisterValueChangedCallback( | ||||||
|             [this](const bool&) { Q_EMIT self_->NeedsRendering(); }); |             [this](const bool&) { Q_EMIT self_->NeedsRendering(); }); | ||||||
|  | @ -84,6 +87,8 @@ public: | ||||||
|          defaultTimeZoneCallbackUuid_); |          defaultTimeZoneCallbackUuid_); | ||||||
|       generalSettings.show_map_attribution().UnregisterValueChangedCallback( |       generalSettings.show_map_attribution().UnregisterValueChangedCallback( | ||||||
|          showMapAttributionCallbackUuid_); |          showMapAttributionCallbackUuid_); | ||||||
|  |       generalSettings.show_map_center().UnregisterValueChangedCallback( | ||||||
|  |          showMapCenterCallbackUuid_); | ||||||
|       generalSettings.show_map_logo().UnregisterValueChangedCallback( |       generalSettings.show_map_logo().UnregisterValueChangedCallback( | ||||||
|          showMapLogoCallbackUuid_); |          showMapLogoCallbackUuid_); | ||||||
|    } |    } | ||||||
|  | @ -93,6 +98,7 @@ public: | ||||||
|    boost::uuids::uuid clockFormatCallbackUuid_; |    boost::uuids::uuid clockFormatCallbackUuid_; | ||||||
|    boost::uuids::uuid defaultTimeZoneCallbackUuid_; |    boost::uuids::uuid defaultTimeZoneCallbackUuid_; | ||||||
|    boost::uuids::uuid showMapAttributionCallbackUuid_; |    boost::uuids::uuid showMapAttributionCallbackUuid_; | ||||||
|  |    boost::uuids::uuid showMapCenterCallbackUuid_; | ||||||
|    boost::uuids::uuid showMapLogoCallbackUuid_; |    boost::uuids::uuid showMapLogoCallbackUuid_; | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<manager::PositionManager> positionManager_ { |    std::shared_ptr<manager::PositionManager> positionManager_ { | ||||||
|  | @ -112,6 +118,8 @@ public: | ||||||
|       types::GetTextureName(types::ImageTexture::CardinalPoint24)}; |       types::GetTextureName(types::ImageTexture::CardinalPoint24)}; | ||||||
|    const std::string& compassIconName_ { |    const std::string& compassIconName_ { | ||||||
|       types::GetTextureName(types::ImageTexture::Compass24)}; |       types::GetTextureName(types::ImageTexture::Compass24)}; | ||||||
|  |    const std::string& mapCenterIconName_ { | ||||||
|  |       types::GetTextureName(types::ImageTexture::Cursor17)}; | ||||||
| 
 | 
 | ||||||
|    const std::string& mapboxLogoImageName_ { |    const std::string& mapboxLogoImageName_ { | ||||||
|       types::GetTextureName(types::ImageTexture::MapboxLogo)}; |       types::GetTextureName(types::ImageTexture::MapboxLogo)}; | ||||||
|  | @ -119,6 +127,7 @@ public: | ||||||
|       types::GetTextureName(types::ImageTexture::MapTilerLogo)}; |       types::GetTextureName(types::ImageTexture::MapTilerLogo)}; | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<gl::draw::IconDrawItem> compassIcon_ {}; |    std::shared_ptr<gl::draw::IconDrawItem> compassIcon_ {}; | ||||||
|  |    std::shared_ptr<gl::draw::IconDrawItem> mapCenterIcon_ {}; | ||||||
|    double                                  lastBearing_ {0.0}; |    double                                  lastBearing_ {0.0}; | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<gl::draw::IconDrawItem> mapLogoIcon_ {}; |    std::shared_ptr<gl::draw::IconDrawItem> mapLogoIcon_ {}; | ||||||
|  | @ -185,6 +194,7 @@ void OverlayLayer::Initialize() | ||||||
|    p->icons_->StartIconSheets(); |    p->icons_->StartIconSheets(); | ||||||
|    p->icons_->AddIconSheet(p->cardinalPointIconName_); |    p->icons_->AddIconSheet(p->cardinalPointIconName_); | ||||||
|    p->icons_->AddIconSheet(p->compassIconName_); |    p->icons_->AddIconSheet(p->compassIconName_); | ||||||
|  |    p->icons_->AddIconSheet(p->mapCenterIconName_); | ||||||
|    p->icons_->AddIconSheet(p->mapboxLogoImageName_)->SetAnchor(0.0f, 1.0f); |    p->icons_->AddIconSheet(p->mapboxLogoImageName_)->SetAnchor(0.0f, 1.0f); | ||||||
|    p->icons_->AddIconSheet(p->mapTilerLogoImageName_)->SetAnchor(0.0f, 1.0f); |    p->icons_->AddIconSheet(p->mapTilerLogoImageName_)->SetAnchor(0.0f, 1.0f); | ||||||
|    p->icons_->FinishIconSheets(); |    p->icons_->FinishIconSheets(); | ||||||
|  | @ -234,6 +244,9 @@ void OverlayLayer::Initialize() | ||||||
|          } |          } | ||||||
|       }); |       }); | ||||||
| 
 | 
 | ||||||
|  |    p->mapCenterIcon_ = p->icons_->AddIcon(); | ||||||
|  |    p->icons_->SetIconTexture(p->mapCenterIcon_, p->mapCenterIconName_, 0); | ||||||
|  | 
 | ||||||
|    p->mapLogoIcon_ = p->icons_->AddIcon(); |    p->mapLogoIcon_ = p->icons_->AddIcon(); | ||||||
|    if (context()->map_provider() == MapProvider::Mapbox) |    if (context()->map_provider() == MapProvider::Mapbox) | ||||||
|    { |    { | ||||||
|  | @ -411,6 +424,16 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) | ||||||
| 
 | 
 | ||||||
|    auto& generalSettings = settings::GeneralSettings::Instance(); |    auto& generalSettings = settings::GeneralSettings::Instance(); | ||||||
| 
 | 
 | ||||||
|  |    // Map Center Icon
 | ||||||
|  |    if (params.width != p->lastWidth_ || params.height != p->lastHeight_) | ||||||
|  |    { | ||||||
|  |       // Draw the icon in the center of the widget
 | ||||||
|  |       p->icons_->SetIconLocation( | ||||||
|  |          p->mapCenterIcon_, params.width / 2.0, params.height / 2.0); | ||||||
|  |    } | ||||||
|  |    p->icons_->SetIconVisible(p->mapCenterIcon_, | ||||||
|  |                              generalSettings.show_map_center().GetValue()); | ||||||
|  | 
 | ||||||
|    QMargins colorTableMargins = context()->color_table_margins(); |    QMargins colorTableMargins = context()->color_table_margins(); | ||||||
|    if (colorTableMargins != p->lastColorTableMargins_ || p->firstRender_) |    if (colorTableMargins != p->lastColorTableMargins_ || p->firstRender_) | ||||||
|    { |    { | ||||||
|  | @ -418,7 +441,6 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) | ||||||
|       p->icons_->SetIconLocation(p->mapLogoIcon_, |       p->icons_->SetIconLocation(p->mapLogoIcon_, | ||||||
|                                  10 + colorTableMargins.left(), |                                  10 + colorTableMargins.left(), | ||||||
|                                  10 + colorTableMargins.bottom()); |                                  10 + colorTableMargins.bottom()); | ||||||
|       p->icons_->FinishIcons(); |  | ||||||
|    } |    } | ||||||
|    p->icons_->SetIconVisible(p->mapLogoIcon_, |    p->icons_->SetIconVisible(p->mapLogoIcon_, | ||||||
|                              generalSettings.show_map_logo().GetValue()); |                              generalSettings.show_map_logo().GetValue()); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat