mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 00:40:06 +00:00 
			
		
		
		
	Fix display scaling for custom map widgets
This commit is contained in:
		
							parent
							
								
									fceb5c33f7
								
							
						
					
					
						commit
						53c2f29785
					
				
					 5 changed files with 26 additions and 5 deletions
				
			
		|  | @ -13,6 +13,7 @@ public: | |||
|    explicit Impl(std::shared_ptr<view::RadarProductView> radarProductView) : | ||||
|        map_ {}, | ||||
|        settings_ {}, | ||||
|        pixelRatio_ {1.0f}, | ||||
|        radarProductView_ {radarProductView}, | ||||
|        radarProductGroup_ {common::RadarProductGroup::Unknown}, | ||||
|        radarProduct_ {"???"}, | ||||
|  | @ -24,6 +25,7 @@ public: | |||
| 
 | ||||
|    std::weak_ptr<QMapLibreGL::Map>         map_; | ||||
|    MapSettings                             settings_; | ||||
|    float                                   pixelRatio_; | ||||
|    std::shared_ptr<view::RadarProductView> radarProductView_; | ||||
|    common::RadarProductGroup               radarProductGroup_; | ||||
|    std::string                             radarProduct_; | ||||
|  | @ -50,6 +52,11 @@ MapSettings& MapContext::settings() | |||
|    return p->settings_; | ||||
| } | ||||
| 
 | ||||
| float MapContext::pixel_ratio() const | ||||
| { | ||||
|    return p->pixelRatio_; | ||||
| } | ||||
| 
 | ||||
| std::shared_ptr<view::RadarProductView> MapContext::radar_product_view() const | ||||
| { | ||||
|    return p->radarProductView_; | ||||
|  | @ -75,6 +82,11 @@ void MapContext::set_map(std::shared_ptr<QMapLibreGL::Map> map) | |||
|    p->map_ = map; | ||||
| } | ||||
| 
 | ||||
| void MapContext::set_pixel_ratio(float pixelRatio) | ||||
| { | ||||
|    p->pixelRatio_ = pixelRatio; | ||||
| } | ||||
| 
 | ||||
| void MapContext::set_radar_product_view( | ||||
|    std::shared_ptr<view::RadarProductView> radarProductView) | ||||
| { | ||||
|  |  | |||
|  | @ -28,12 +28,14 @@ public: | |||
| 
 | ||||
|    std::weak_ptr<QMapLibreGL::Map>         map() const; | ||||
|    MapSettings&                            settings(); | ||||
|    float                                   pixel_ratio() const; | ||||
|    std::shared_ptr<view::RadarProductView> radar_product_view() const; | ||||
|    common::RadarProductGroup               radar_product_group() const; | ||||
|    std::string                             radar_product() const; | ||||
|    int16_t                                 radar_product_code() const; | ||||
| 
 | ||||
|    void set_map(std::shared_ptr<QMapLibreGL::Map> map); | ||||
|    void set_pixel_ratio(float pixelRatio); | ||||
|    void set_radar_product_view( | ||||
|       std::shared_ptr<view::RadarProductView> radarProductView); | ||||
|    void set_radar_product_group(common::RadarProductGroup radarProductGroup); | ||||
|  |  | |||
|  | @ -811,6 +811,9 @@ void MapWidget::paintGL() | |||
|    ImGui_ImplOpenGL3_NewFrame(); | ||||
|    ImGui::NewFrame(); | ||||
| 
 | ||||
|    // Update pixel ratio
 | ||||
|    p->context_->set_pixel_ratio(pixelRatio()); | ||||
| 
 | ||||
|    // Render QMapLibreGL Map
 | ||||
|    p->map_->resize(size()); | ||||
|    p->map_->setFramebufferObject(defaultFramebufferObject(), | ||||
|  |  | |||
|  | @ -66,9 +66,6 @@ OverlayLayer::OverlayLayer(std::shared_ptr<MapContext> context) : | |||
|    AddDrawItem(p->activeBoxInner_); | ||||
| 
 | ||||
|    p->activeBoxOuter_->SetPosition(0.0f, 0.0f); | ||||
|    p->activeBoxOuter_->SetBorder(1.0f, {0, 0, 0, 255}); | ||||
|    p->activeBoxInner_->SetBorder(1.0f, {255, 255, 255, 255}); | ||||
|    p->activeBoxInner_->SetPosition(1.0f, 1.0f); | ||||
| } | ||||
| 
 | ||||
| OverlayLayer::~OverlayLayer() = default; | ||||
|  | @ -96,6 +93,7 @@ void OverlayLayer::Render( | |||
|    gl::OpenGLFunctions& gl               = context()->gl(); | ||||
|    auto                 radarProductView = context()->radar_product_view(); | ||||
|    auto&                settings         = context()->settings(); | ||||
|    const float          pixelRatio       = context()->pixel_ratio(); | ||||
| 
 | ||||
|    if (p->sweepTimeNeedsUpdate_ && radarProductView != nullptr) | ||||
|    { | ||||
|  | @ -118,7 +116,13 @@ void OverlayLayer::Render( | |||
|    if (settings.isActive_) | ||||
|    { | ||||
|       p->activeBoxOuter_->SetSize(params.width, params.height); | ||||
|       p->activeBoxInner_->SetSize(params.width - 2.0f, params.height - 2.0f); | ||||
|       p->activeBoxInner_->SetSize(params.width - (2.0f * pixelRatio), | ||||
|                                   params.height - (2.0f * pixelRatio)); | ||||
| 
 | ||||
|       p->activeBoxInner_->SetPosition(1.0f * pixelRatio, 1.0f * pixelRatio); | ||||
| 
 | ||||
|       p->activeBoxOuter_->SetBorder(1.0f * pixelRatio, {0, 0, 0, 255}); | ||||
|       p->activeBoxInner_->SetBorder(1.0f * pixelRatio, {255, 255, 255, 255}); | ||||
|    } | ||||
| 
 | ||||
|    DrawLayer::Render(params); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat