mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 15:50:05 +00:00 
			
		
		
		
	Add ability to install event handlers from mouse picking
This commit is contained in:
		
							parent
							
								
									ff882f5c06
								
							
						
					
					
						commit
						b3e035c53d
					
				
					 26 changed files with 222 additions and 76 deletions
				
			
		|  | @ -32,7 +32,7 @@ static constexpr std::size_t kIconBufferLength = | |||
| static constexpr std::size_t kTextureBufferLength = | ||||
|    kNumTriangles * kVerticesPerTriangle * kPointsPerTexCoord; | ||||
| 
 | ||||
| struct IconDrawItem | ||||
| struct IconDrawItem : types::EventHandler | ||||
| { | ||||
|    boost::gil::rgba32f_pixel_t modulate_ {1.0f, 1.0f, 1.0f, 1.0f}; | ||||
|    double                      x_ {}; | ||||
|  | @ -424,7 +424,7 @@ void Icons::Impl::UpdateBuffers() | |||
|                                x, y, lx, ty, mc0, mc1, mc2, mc3, a  // TL
 | ||||
|                             }); | ||||
| 
 | ||||
|       if (!di->hoverText_.empty()) | ||||
|       if (!di->hoverText_.empty() || di->event_ != nullptr) | ||||
|       { | ||||
|          const units::angle::radians<double> radians = angle; | ||||
| 
 | ||||
|  | @ -579,7 +579,8 @@ bool Icons::RunMousePicking( | |||
|    const QPointF&                                  mouseLocalPos, | ||||
|    const QPointF&                                  mouseGlobalPos, | ||||
|    const glm::vec2& /* mouseCoords */, | ||||
|    const common::Coordinate& /* mouseGeoCoords */) | ||||
|    const common::Coordinate& /* mouseGeoCoords */, | ||||
|    std::shared_ptr<types::EventHandler>& eventHandler) | ||||
| { | ||||
|    std::unique_lock lock {p->iconMutex_}; | ||||
| 
 | ||||
|  | @ -617,12 +618,29 @@ bool Icons::RunMousePicking( | |||
|    if (it != p->currentHoverIcons_.crend()) | ||||
|    { | ||||
|       itemPicked = true; | ||||
|       util::tooltip::Show(it->di_->hoverText_, mouseGlobalPos); | ||||
| 
 | ||||
|       if (!it->di_->hoverText_.empty()) | ||||
|       { | ||||
|          // Show tooltip
 | ||||
|          util::tooltip::Show(it->di_->hoverText_, mouseGlobalPos); | ||||
|       } | ||||
|       if (it->di_->event_ != nullptr) | ||||
|       { | ||||
|          // Register event handler
 | ||||
|          eventHandler = it->di_; | ||||
|       } | ||||
|    } | ||||
| 
 | ||||
|    return itemPicked; | ||||
| } | ||||
| 
 | ||||
| void Icons::RegisterEventHandler( | ||||
|    const std::shared_ptr<IconDrawItem>& di, | ||||
|    const std::function<void(QEvent*)>&  eventHandler) | ||||
| { | ||||
|    di->event_ = eventHandler; | ||||
| } | ||||
| 
 | ||||
| } // namespace draw
 | ||||
| } // namespace gl
 | ||||
| } // namespace qt
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat