mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 08:50:05 +00:00 
			
		
		
		
	Add map logo to map
This commit is contained in:
		
							parent
							
								
									f6ac027725
								
							
						
					
					
						commit
						074a39d224
					
				
					 1 changed files with 49 additions and 13 deletions
				
			
		|  | @ -67,13 +67,23 @@ 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& mapboxLogoImageName_ { | ||||||
|  |       types::GetTextureName(types::ImageTexture::MapboxLogo)}; | ||||||
|  |    const std::string& mapTilerLogoImageName_ { | ||||||
|  |       types::GetTextureName(types::ImageTexture::MapTilerLogo)}; | ||||||
|  | 
 | ||||||
|    std::shared_ptr<gl::draw::IconDrawItem> compassIcon_ {}; |    std::shared_ptr<gl::draw::IconDrawItem> compassIcon_ {}; | ||||||
|    bool                                    compassIconDirty_ {false}; |    bool                                    compassIconDirty_ {false}; | ||||||
|    double                                  lastBearing_ {0.0}; |    double                                  lastBearing_ {0.0}; | ||||||
| 
 | 
 | ||||||
|  |    std::shared_ptr<gl::draw::IconDrawItem> mapLogoIcon_ {}; | ||||||
|  | 
 | ||||||
|  |    bool     firstRender_ {true}; | ||||||
|    double   lastWidth_ {0.0}; |    double   lastWidth_ {0.0}; | ||||||
|    double   lastHeight_ {0.0}; |    double   lastHeight_ {0.0}; | ||||||
|    float    lastFontSize_ {0.0f}; |    float    lastFontSize_ {0.0f}; | ||||||
|  |    QMargins lastColorTableMargins_ {}; | ||||||
| 
 | 
 | ||||||
|    std::string sweepTimeString_ {}; |    std::string sweepTimeString_ {}; | ||||||
|    bool        sweepTimeNeedsUpdate_ {true}; |    bool        sweepTimeNeedsUpdate_ {true}; | ||||||
|  | @ -131,6 +141,8 @@ 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->mapboxLogoImageName_)->SetAnchor(0.0f, 1.0f); | ||||||
|  |    p->icons_->AddIconSheet(p->mapTilerLogoImageName_)->SetAnchor(0.0f, 1.0f); | ||||||
|    p->icons_->FinishIconSheets(); |    p->icons_->FinishIconSheets(); | ||||||
| 
 | 
 | ||||||
|    p->icons_->StartIcons(); |    p->icons_->StartIcons(); | ||||||
|  | @ -180,6 +192,19 @@ void OverlayLayer::Initialize() | ||||||
|             break; |             break; | ||||||
|          } |          } | ||||||
|       }); |       }); | ||||||
|  | 
 | ||||||
|  |    p->mapLogoIcon_ = p->icons_->AddIcon(); | ||||||
|  |    if (context()->map_provider() == MapProvider::Mapbox) | ||||||
|  |    { | ||||||
|  |       gl::draw::Icons::SetIconTexture( | ||||||
|  |          p->mapLogoIcon_, p->mapboxLogoImageName_, 0); | ||||||
|  |    } | ||||||
|  |    else if (context()->map_provider() == MapProvider::MapTiler) | ||||||
|  |    { | ||||||
|  |       gl::draw::Icons::SetIconTexture( | ||||||
|  |          p->mapLogoIcon_, p->mapTilerLogoImageName_, 0); | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|    p->icons_->FinishIcons(); |    p->icons_->FinishIcons(); | ||||||
| 
 | 
 | ||||||
|    connect(p->positionManager_.get(), |    connect(p->positionManager_.get(), | ||||||
|  | @ -356,16 +381,25 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) | ||||||
|       ImGui::End(); |       ImGui::End(); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  |    QMargins colorTableMargins = context()->color_table_margins(); | ||||||
|  |    if (colorTableMargins != p->lastColorTableMargins_ || p->firstRender_) | ||||||
|  |    { | ||||||
|  |       // Draw map logo with a 10x10 indent from the bottom left
 | ||||||
|  |       gl::draw::Icons::SetIconLocation(p->mapLogoIcon_, | ||||||
|  |                                        10 + colorTableMargins.left(), | ||||||
|  |                                        10 + colorTableMargins.bottom()); | ||||||
|  |       p->icons_->FinishIcons(); | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|    auto mapCopyrights = context()->map_copyrights(); |    auto mapCopyrights = context()->map_copyrights(); | ||||||
|    if (mapCopyrights.length() > 0) |    if (mapCopyrights.length() > 0) | ||||||
|    { |    { | ||||||
|       auto attributionFont = manager::FontManager::Instance().GetImGuiFont( |       auto attributionFont = manager::FontManager::Instance().GetImGuiFont( | ||||||
|          types::FontCategory::Attribution); |          types::FontCategory::Attribution); | ||||||
| 
 | 
 | ||||||
|       ImGui::SetNextWindowPos( |       ImGui::SetNextWindowPos(ImVec2 {static_cast<float>(params.width), | ||||||
|          ImVec2 {static_cast<float>(params.width), |  | ||||||
|                                       static_cast<float>(params.height) - |                                       static_cast<float>(params.height) - | ||||||
|                     context()->color_table_margins().bottom()}, |                                          colorTableMargins.bottom()}, | ||||||
|                               ImGuiCond_Always, |                               ImGuiCond_Always, | ||||||
|                               ImVec2 {1.0f, 1.0f}); |                               ImVec2 {1.0f, 1.0f}); | ||||||
|       ImGui::SetNextWindowBgAlpha(0.5f); |       ImGui::SetNextWindowBgAlpha(0.5f); | ||||||
|  | @ -381,10 +415,12 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) | ||||||
|       ImGui::PopStyleVar(); |       ImGui::PopStyleVar(); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  |    p->firstRender_           = false; | ||||||
|    p->lastWidth_             = params.width; |    p->lastWidth_             = params.width; | ||||||
|    p->lastHeight_            = params.height; |    p->lastHeight_            = params.height; | ||||||
|    p->lastBearing_           = params.bearing; |    p->lastBearing_           = params.bearing; | ||||||
|    p->lastFontSize_          = ImGui::GetFontSize(); |    p->lastFontSize_          = ImGui::GetFontSize(); | ||||||
|  |    p->lastColorTableMargins_ = colorTableMargins; | ||||||
| 
 | 
 | ||||||
|    SCWX_GL_CHECK_ERROR(); |    SCWX_GL_CHECK_ERROR(); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat