mirror of
				https://github.com/TES3MP/openmw-tes3mp.git
				synced 2025-11-04 01:26:41 +00:00 
			
		
		
		
	properly abort drags from outside the worldspace widget (code was leaving unclean dragging flags behind)
This commit is contained in:
		
							parent
							
								
									70745487f3
								
							
						
					
					
						commit
						51a4e3fa7d
					
				
					 3 changed files with 20 additions and 13 deletions
				
			
		| 
						 | 
					@ -97,10 +97,7 @@ void CSVRender::InstanceMode::setEditLock (bool locked)
 | 
				
			||||||
    mLocked = locked;
 | 
					    mLocked = locked;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (mLocked)
 | 
					    if (mLocked)
 | 
				
			||||||
    {
 | 
					        getWorldspaceWidget().abortDrag();
 | 
				
			||||||
        mDragMode = DragMode_None;
 | 
					 | 
				
			||||||
        getWorldspaceWidget().reset (Mask_Reference);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void CSVRender::InstanceMode::primaryEditPressed (osg::ref_ptr<TagBase> tag)
 | 
					void CSVRender::InstanceMode::primaryEditPressed (osg::ref_ptr<TagBase> tag)
 | 
				
			||||||
| 
						 | 
					@ -457,7 +454,6 @@ int CSVRender::InstanceMode::getSubMode() const
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void CSVRender::InstanceMode::subModeChanged (const std::string& id)
 | 
					void CSVRender::InstanceMode::subModeChanged (const std::string& id)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    mDragMode = DragMode_None;
 | 
					    getWorldspaceWidget().abortDrag();
 | 
				
			||||||
    getWorldspaceWidget().reset (Mask_Reference);
 | 
					 | 
				
			||||||
    getWorldspaceWidget().setSubMode (getSubModeFromId (id), Mask_Reference);
 | 
					    getWorldspaceWidget().setSubMode (getSubModeFromId (id), Mask_Reference);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -364,6 +364,17 @@ osg::Vec3f CSVRender::WorldspaceWidget::getIntersectionPoint (const QPoint& loca
 | 
				
			||||||
    return start + direction * CSMPrefs::get()["Scene Drops"]["distance"].toInt();
 | 
					    return start + direction * CSMPrefs::get()["Scene Drops"]["distance"].toInt();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void CSVRender::WorldspaceWidget::abortDrag()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (mDragging)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        EditMode& editMode = dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        editMode.dragAborted();
 | 
				
			||||||
 | 
					        mDragging = false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void CSVRender::WorldspaceWidget::dragEnterEvent (QDragEnterEvent* event)
 | 
					void CSVRender::WorldspaceWidget::dragEnterEvent (QDragEnterEvent* event)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
 | 
					    const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
 | 
				
			||||||
| 
						 | 
					@ -736,13 +747,7 @@ void CSVRender::WorldspaceWidget::keyPressEvent (QKeyEvent *event)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if(event->key() == Qt::Key_Escape)
 | 
					    if(event->key() == Qt::Key_Escape)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (mDragging)
 | 
					        abortDrag();
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            EditMode& editMode = dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            editMode.dragAborted();
 | 
					 | 
				
			||||||
            mDragging = false;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        RenderWidget::keyPressEvent(event);
 | 
					        RenderWidget::keyPressEvent(event);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -161,6 +161,12 @@ namespace CSVRender
 | 
				
			||||||
            /// Erase all overrides and restore the visual representation to its true state.
 | 
					            /// Erase all overrides and restore the visual representation to its true state.
 | 
				
			||||||
            virtual void reset (unsigned int elementMask) = 0;
 | 
					            virtual void reset (unsigned int elementMask) = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            /// \note Drags will be automatically aborted when the aborting is triggered
 | 
				
			||||||
 | 
					            /// (either explicitly or implicitly) from within this class. This function only
 | 
				
			||||||
 | 
					            /// needs to be called, when the drag abort is triggered externally (e.g. from
 | 
				
			||||||
 | 
					            /// an edit mode).
 | 
				
			||||||
 | 
					            void abortDrag();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        protected:
 | 
					        protected:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            /// Visual elements in a scene
 | 
					            /// Visual elements in a scene
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue