mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 00:10:06 +00:00 
			
		
		
		
	Display mouse cursor icon on maps when Ctrl is held
This commit is contained in:
		
							parent
							
								
									9cb29c6b9a
								
							
						
					
					
						commit
						f4bc2572d2
					
				
					 7 changed files with 68 additions and 5 deletions
				
			
		|  | @ -43,8 +43,8 @@ vec2 latLngToScreenCoordinate(in vec2 latLng) | |||
| 
 | ||||
| void main() | ||||
| { | ||||
|    // Always set displayed to true | ||||
|    vsOut.displayed = 1; | ||||
|    // Pass displayed to the geometry shader | ||||
|    vsOut.displayed = aDisplayed; | ||||
| 
 | ||||
|    // Pass the threshold and time range to the geometry shader | ||||
|    vsOut.threshold = aThreshold; | ||||
|  |  | |||
|  | @ -824,6 +824,11 @@ void MainWindowImpl::ConnectMapSignals() | |||
|             coordinateLabel_->setText( | ||||
|                QString("%1, %2").arg(latitude).arg(longitude)); | ||||
|             coordinateLabel_->setVisible(true); | ||||
| 
 | ||||
|             for (auto& map : maps_) | ||||
|             { | ||||
|                map->UpdateMouseCoordinate(coordinate); | ||||
|             } | ||||
|          }, | ||||
|          Qt::QueuedConnection); | ||||
| 
 | ||||
|  |  | |||
|  | @ -32,7 +32,8 @@ public: | |||
|    MapProvider mapProvider_ {MapProvider::Unknown}; | ||||
|    std::string mapCopyrights_ {}; | ||||
| 
 | ||||
|    QMargins colorTableMargins_ {}; | ||||
|    QMargins           colorTableMargins_ {}; | ||||
|    common::Coordinate mouseCoordinate_ {}; | ||||
| 
 | ||||
|    std::shared_ptr<view::OverlayProductView> overlayProductView_ {nullptr}; | ||||
|    std::shared_ptr<view::RadarProductView>   radarProductView_; | ||||
|  | @ -78,6 +79,11 @@ float MapContext::pixel_ratio() const | |||
|    return p->pixelRatio_; | ||||
| } | ||||
| 
 | ||||
| common::Coordinate MapContext::mouse_coordinate() const | ||||
| { | ||||
|    return p->mouseCoordinate_; | ||||
| } | ||||
| 
 | ||||
| std::shared_ptr<view::OverlayProductView> | ||||
| MapContext::overlay_product_view() const | ||||
| { | ||||
|  | @ -129,6 +135,11 @@ void MapContext::set_color_table_margins(const QMargins& margins) | |||
|    p->colorTableMargins_ = margins; | ||||
| } | ||||
| 
 | ||||
| void MapContext::set_mouse_coordinate(const common::Coordinate& coordinate) | ||||
| { | ||||
|    p->mouseCoordinate_ = coordinate; | ||||
| } | ||||
| 
 | ||||
| void MapContext::set_overlay_product_view( | ||||
|    const std::shared_ptr<view::OverlayProductView>& overlayProductView) | ||||
| { | ||||
|  |  | |||
|  | @ -2,6 +2,7 @@ | |||
| 
 | ||||
| #include <scwx/qt/gl/gl_context.hpp> | ||||
| #include <scwx/qt/map/map_provider.hpp> | ||||
| #include <scwx/common/geographic.hpp> | ||||
| #include <scwx/common/products.hpp> | ||||
| 
 | ||||
| #include <qmaplibre.hpp> | ||||
|  | @ -43,6 +44,7 @@ public: | |||
|    MapSettings&                              settings(); | ||||
|    QMargins                                  color_table_margins() const; | ||||
|    float                                     pixel_ratio() const; | ||||
|    common::Coordinate                        mouse_coordinate() const; | ||||
|    std::shared_ptr<view::OverlayProductView> overlay_product_view() const; | ||||
|    std::shared_ptr<view::RadarProductView>   radar_product_view() const; | ||||
|    common::RadarProductGroup                 radar_product_group() const; | ||||
|  | @ -54,6 +56,7 @@ public: | |||
|    void set_map_copyrights(const std::string& copyrights); | ||||
|    void set_map_provider(MapProvider provider); | ||||
|    void set_color_table_margins(const QMargins& margins); | ||||
|    void set_mouse_coordinate(const common::Coordinate& coordinate); | ||||
|    void set_overlay_product_view( | ||||
|       const std::shared_ptr<view::OverlayProductView>& overlayProductView); | ||||
|    void set_pixel_ratio(float pixelRatio); | ||||
|  |  | |||
|  | @ -940,6 +940,20 @@ void MapWidget::SetMapStyle(const std::string& styleName) | |||
|    } | ||||
| } | ||||
| 
 | ||||
| void MapWidget::UpdateMouseCoordinate(const common::Coordinate& coordinate) | ||||
| { | ||||
|    if (p->context_->mouse_coordinate() != coordinate) | ||||
|    { | ||||
|       p->context_->set_mouse_coordinate(coordinate); | ||||
| 
 | ||||
|       if (QGuiApplication::keyboardModifiers() != | ||||
|           Qt::KeyboardModifier::NoModifier) | ||||
|       { | ||||
|          update(); | ||||
|       } | ||||
|    } | ||||
| } | ||||
| 
 | ||||
| qreal MapWidget::pixelRatio() | ||||
| { | ||||
|    return devicePixelRatioF(); | ||||
|  |  | |||
|  | @ -117,6 +117,13 @@ public: | |||
|    void SetInitialMapStyle(const std::string& styleName); | ||||
|    void SetMapStyle(const std::string& styleName); | ||||
| 
 | ||||
|    /**
 | ||||
|     * Updates the coordinates associated with mouse movement from another map. | ||||
|     * | ||||
|     * @param [in] coordinate Coordinate of the mouse | ||||
|     */ | ||||
|    void UpdateMouseCoordinate(const common::Coordinate& coordinate); | ||||
| 
 | ||||
| private: | ||||
|    void  changeStyle(); | ||||
|    qreal pixelRatio(); | ||||
|  |  | |||
|  | @ -19,6 +19,7 @@ | |||
| 
 | ||||
| #include <imgui.h> | ||||
| #include <QGeoPositionInfo> | ||||
| #include <QGuiApplication> | ||||
| #include <QMouseEvent> | ||||
| 
 | ||||
| #if !defined(_MSC_VER) | ||||
|  | @ -114,10 +115,14 @@ public: | |||
|       types::GetTextureName(types::ImageTexture::Crosshairs24)}; | ||||
|    std::shared_ptr<gl::draw::GeoIconDrawItem> locationIcon_ {}; | ||||
| 
 | ||||
|    std::shared_ptr<gl::draw::GeoIconDrawItem> cursorIcon_ {}; | ||||
| 
 | ||||
|    const std::string& cardinalPointIconName_ { | ||||
|       types::GetTextureName(types::ImageTexture::CardinalPoint24)}; | ||||
|    const std::string& compassIconName_ { | ||||
|       types::GetTextureName(types::ImageTexture::Compass24)}; | ||||
|    const std::string& cursorIconName_ { | ||||
|       types::GetTextureName(types::ImageTexture::Dot3)}; | ||||
|    const std::string& mapCenterIconName_ { | ||||
|       types::GetTextureName(types::ImageTexture::Cursor17)}; | ||||
| 
 | ||||
|  | @ -177,16 +182,22 @@ void OverlayLayer::Initialize() | |||
| 
 | ||||
|    // Geo Icons
 | ||||
|    p->geoIcons_->StartIconSheets(); | ||||
|    p->geoIcons_->AddIconSheet(p->cursorIconName_); | ||||
|    p->geoIcons_->AddIconSheet(p->locationIconName_); | ||||
|    p->geoIcons_->FinishIconSheets(); | ||||
| 
 | ||||
|    p->geoIcons_->StartIcons(); | ||||
| 
 | ||||
|    p->cursorIcon_ = p->geoIcons_->AddIcon(); | ||||
|    p->geoIcons_->SetIconTexture(p->cursorIcon_, p->cursorIconName_, 0); | ||||
| 
 | ||||
|    p->locationIcon_ = p->geoIcons_->AddIcon(); | ||||
|    p->geoIcons_->SetIconTexture(p->locationIcon_, p->locationIconName_, 0); | ||||
|    p->geoIcons_->SetIconAngle(p->locationIcon_, | ||||
|                               units::angle::degrees<double> {45.0}); | ||||
|    p->geoIcons_->SetIconLocation( | ||||
|       p->locationIcon_, coordinate.latitude(), coordinate.longitude()); | ||||
| 
 | ||||
|    p->geoIcons_->FinishIcons(); | ||||
| 
 | ||||
|    // Icons
 | ||||
|  | @ -326,9 +337,21 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params) | |||
|       p->activeBoxInner_->SetBorder(1.0f * pixelRatio, {255, 255, 255, 255}); | ||||
|    } | ||||
| 
 | ||||
|    // Cursor Icon
 | ||||
|    bool cursorIconVisible = QGuiApplication::keyboardModifiers() & | ||||
|                             Qt::KeyboardModifier::ControlModifier; | ||||
|    p->geoIcons_->SetIconVisible(p->cursorIcon_, cursorIconVisible); | ||||
|    if (cursorIconVisible) | ||||
|    { | ||||
|       common::Coordinate mouseCoordinate = context()->mouse_coordinate(); | ||||
|       p->geoIcons_->SetIconLocation( | ||||
|          p->cursorIcon_, mouseCoordinate.latitude_, mouseCoordinate.longitude_); | ||||
|    } | ||||
| 
 | ||||
|    // Location Icon
 | ||||
|    p->geoIcons_->SetVisible(p->currentPosition_.isValid() && | ||||
|                             p->positionManager_->IsLocationTracked()); | ||||
|    p->geoIcons_->SetIconVisible(p->locationIcon_, | ||||
|                                 p->currentPosition_.isValid() && | ||||
|                                    p->positionManager_->IsLocationTracked()); | ||||
| 
 | ||||
|    // Compass Icon
 | ||||
|    if (params.width != p->lastWidth_ || params.height != p->lastHeight_ || | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat