mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-30 23: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
				
			
		
							
								
								
									
										2
									
								
								external/imgui-backend-qt
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								external/imgui-backend-qt
									
										
									
									
										vendored
									
									
								
							|  | @ -1 +1 @@ | ||||||
| Subproject commit daef19109c763e6eb0e4339837596616fe9dc492 | Subproject commit 0fe974ebd037844c9f23d6325dbcc128e9973749 | ||||||
|  | @ -13,6 +13,7 @@ public: | ||||||
|    explicit Impl(std::shared_ptr<view::RadarProductView> radarProductView) : |    explicit Impl(std::shared_ptr<view::RadarProductView> radarProductView) : | ||||||
|        map_ {}, |        map_ {}, | ||||||
|        settings_ {}, |        settings_ {}, | ||||||
|  |        pixelRatio_ {1.0f}, | ||||||
|        radarProductView_ {radarProductView}, |        radarProductView_ {radarProductView}, | ||||||
|        radarProductGroup_ {common::RadarProductGroup::Unknown}, |        radarProductGroup_ {common::RadarProductGroup::Unknown}, | ||||||
|        radarProduct_ {"???"}, |        radarProduct_ {"???"}, | ||||||
|  | @ -24,6 +25,7 @@ public: | ||||||
| 
 | 
 | ||||||
|    std::weak_ptr<QMapLibreGL::Map>         map_; |    std::weak_ptr<QMapLibreGL::Map>         map_; | ||||||
|    MapSettings                             settings_; |    MapSettings                             settings_; | ||||||
|  |    float                                   pixelRatio_; | ||||||
|    std::shared_ptr<view::RadarProductView> radarProductView_; |    std::shared_ptr<view::RadarProductView> radarProductView_; | ||||||
|    common::RadarProductGroup               radarProductGroup_; |    common::RadarProductGroup               radarProductGroup_; | ||||||
|    std::string                             radarProduct_; |    std::string                             radarProduct_; | ||||||
|  | @ -50,6 +52,11 @@ MapSettings& MapContext::settings() | ||||||
|    return p->settings_; |    return p->settings_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | float MapContext::pixel_ratio() const | ||||||
|  | { | ||||||
|  |    return p->pixelRatio_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| std::shared_ptr<view::RadarProductView> MapContext::radar_product_view() const | std::shared_ptr<view::RadarProductView> MapContext::radar_product_view() const | ||||||
| { | { | ||||||
|    return p->radarProductView_; |    return p->radarProductView_; | ||||||
|  | @ -75,6 +82,11 @@ void MapContext::set_map(std::shared_ptr<QMapLibreGL::Map> map) | ||||||
|    p->map_ = map; |    p->map_ = map; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void MapContext::set_pixel_ratio(float pixelRatio) | ||||||
|  | { | ||||||
|  |    p->pixelRatio_ = pixelRatio; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void MapContext::set_radar_product_view( | void MapContext::set_radar_product_view( | ||||||
|    std::shared_ptr<view::RadarProductView> radarProductView) |    std::shared_ptr<view::RadarProductView> radarProductView) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -28,12 +28,14 @@ public: | ||||||
| 
 | 
 | ||||||
|    std::weak_ptr<QMapLibreGL::Map>         map() const; |    std::weak_ptr<QMapLibreGL::Map>         map() const; | ||||||
|    MapSettings&                            settings(); |    MapSettings&                            settings(); | ||||||
|  |    float                                   pixel_ratio() const; | ||||||
|    std::shared_ptr<view::RadarProductView> radar_product_view() const; |    std::shared_ptr<view::RadarProductView> radar_product_view() const; | ||||||
|    common::RadarProductGroup               radar_product_group() const; |    common::RadarProductGroup               radar_product_group() const; | ||||||
|    std::string                             radar_product() const; |    std::string                             radar_product() const; | ||||||
|    int16_t                                 radar_product_code() const; |    int16_t                                 radar_product_code() const; | ||||||
| 
 | 
 | ||||||
|    void set_map(std::shared_ptr<QMapLibreGL::Map> map); |    void set_map(std::shared_ptr<QMapLibreGL::Map> map); | ||||||
|  |    void set_pixel_ratio(float pixelRatio); | ||||||
|    void set_radar_product_view( |    void set_radar_product_view( | ||||||
|       std::shared_ptr<view::RadarProductView> radarProductView); |       std::shared_ptr<view::RadarProductView> radarProductView); | ||||||
|    void set_radar_product_group(common::RadarProductGroup radarProductGroup); |    void set_radar_product_group(common::RadarProductGroup radarProductGroup); | ||||||
|  |  | ||||||
|  | @ -811,6 +811,9 @@ void MapWidget::paintGL() | ||||||
|    ImGui_ImplOpenGL3_NewFrame(); |    ImGui_ImplOpenGL3_NewFrame(); | ||||||
|    ImGui::NewFrame(); |    ImGui::NewFrame(); | ||||||
| 
 | 
 | ||||||
|  |    // Update pixel ratio
 | ||||||
|  |    p->context_->set_pixel_ratio(pixelRatio()); | ||||||
|  | 
 | ||||||
|    // Render QMapLibreGL Map
 |    // Render QMapLibreGL Map
 | ||||||
|    p->map_->resize(size()); |    p->map_->resize(size()); | ||||||
|    p->map_->setFramebufferObject(defaultFramebufferObject(), |    p->map_->setFramebufferObject(defaultFramebufferObject(), | ||||||
|  |  | ||||||
|  | @ -66,9 +66,6 @@ OverlayLayer::OverlayLayer(std::shared_ptr<MapContext> context) : | ||||||
|    AddDrawItem(p->activeBoxInner_); |    AddDrawItem(p->activeBoxInner_); | ||||||
| 
 | 
 | ||||||
|    p->activeBoxOuter_->SetPosition(0.0f, 0.0f); |    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; | OverlayLayer::~OverlayLayer() = default; | ||||||
|  | @ -96,6 +93,7 @@ void OverlayLayer::Render( | ||||||
|    gl::OpenGLFunctions& gl               = context()->gl(); |    gl::OpenGLFunctions& gl               = context()->gl(); | ||||||
|    auto                 radarProductView = context()->radar_product_view(); |    auto                 radarProductView = context()->radar_product_view(); | ||||||
|    auto&                settings         = context()->settings(); |    auto&                settings         = context()->settings(); | ||||||
|  |    const float          pixelRatio       = context()->pixel_ratio(); | ||||||
| 
 | 
 | ||||||
|    if (p->sweepTimeNeedsUpdate_ && radarProductView != nullptr) |    if (p->sweepTimeNeedsUpdate_ && radarProductView != nullptr) | ||||||
|    { |    { | ||||||
|  | @ -118,7 +116,13 @@ void OverlayLayer::Render( | ||||||
|    if (settings.isActive_) |    if (settings.isActive_) | ||||||
|    { |    { | ||||||
|       p->activeBoxOuter_->SetSize(params.width, params.height); |       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); |    DrawLayer::Render(params); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat