diff --git a/include/eepp/window/input.hpp b/include/eepp/window/input.hpp index b9e0e9fde..1825bc65e 100644 --- a/include/eepp/window/input.hpp +++ b/include/eepp/window/input.hpp @@ -173,9 +173,6 @@ class EE_API Input { /** @return The Mouse position vector */ Vector2i getMousePos() const; - /** @return The position vector converted to float */ - Vector2f getMousePosf(); - /** This will change the value of the mouse pos, will not REALLY move the mouse ( for that is * InjectMousePos ). */ void setMousePos( const Vector2i& Pos ); diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index cbdbce184..b4ff011a5 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -422,7 +422,8 @@ void UICodeEditor::scheduledUpdate( const Time& ) { if ( mMouseDown ) { if ( !( getUISceneNode()->getWindow()->getInput()->getPressTrigger() & EE_BUTTON_LMASK ) ) { - stopMinimapDragging( getUISceneNode()->getWindow()->getInput()->getMousePosf() ); + stopMinimapDragging( + getUISceneNode()->getWindow()->getInput()->getMousePos().asFloat() ); mMouseDown = false; getUISceneNode()->getWindow()->getInput()->captureMouse( false ); } else if ( !isMouseOverMeOrChilds() || mMinimapDragging ) { @@ -1009,7 +1010,7 @@ Uint32 UICodeEditor::onFocus( NodeFocusReason reason ) { Uint32 UICodeEditor::onFocusLoss() { if ( mMouseDown ) getUISceneNode()->getWindow()->getInput()->captureMouse( false ); - stopMinimapDragging( getUISceneNode()->getWindow()->getInput()->getMousePosf() ); + stopMinimapDragging( getUISceneNode()->getWindow()->getInput()->getMousePos().asFloat() ); mMouseDown = false; mCursorVisible = false; getSceneNode()->getWindow()->stopTextInput(); @@ -1474,8 +1475,8 @@ Uint32 UICodeEditor::onMouseMove( const Vector2i& position, const Uint32& flags Vector2f localPos( convertToNodeSpace( position.asFloat() ) ); if ( !minimapHover && isTextSelectionEnabled() && - !getUISceneNode()->getEventDispatcher()->isNodeDragging() && NULL != mFont && mMouseDown && - ( flags & EE_BUTTON_LMASK ) && ( localPos.y <= 0 || localPos.y >= mPluginsTopSpace ) ) { + !getUISceneNode()->getEventDispatcher()->isNodeDragging() && NULL != mFont && + mMouseDown ) { TextRange selection = mDoc->getSelection(); selection.setStart( resolveScreenPosition( position.asFloat() ) ); mDoc->setSelection( selection ); diff --git a/src/eepp/ui/uipopupmenu.cpp b/src/eepp/ui/uipopupmenu.cpp index cf650627b..77deb83ef 100644 --- a/src/eepp/ui/uipopupmenu.cpp +++ b/src/eepp/ui/uipopupmenu.cpp @@ -68,7 +68,7 @@ void UIPopUpMenu::showAtScreenPosition( Vector2f pos ) { } void UIPopUpMenu::showOverMouseCursor() { - showAtScreenPosition( getUISceneNode()->getWindow()->getInput()->getMousePosf() ); + showAtScreenPosition( getUISceneNode()->getWindow()->getInput()->getMousePos().asFloat() ); } bool UIPopUpMenu::hide() { diff --git a/src/eepp/window/input.cpp b/src/eepp/window/input.cpp index dedece434..75cbb2746 100644 --- a/src/eepp/window/input.cpp +++ b/src/eepp/window/input.cpp @@ -312,10 +312,6 @@ void Input::setMousePos( const Vector2i& Pos ) { mMousePos = Pos; } -Vector2f Input::getMousePosf() { - return Vector2f( (Float)mMousePos.x, (Float)mMousePos.y ); -} - Vector2f Input::getMousePosFromView( const View& View ) { return mWindow->mapPixelToCoords( getMousePos(), View ); } diff --git a/src/examples/external_shader/external_shader.cpp b/src/examples/external_shader/external_shader.cpp index 670be3e46..01aee8ebb 100644 --- a/src/examples/external_shader/external_shader.cpp +++ b/src/examples/external_shader/external_shader.cpp @@ -107,7 +107,7 @@ void mainLoop() { } Float p; - Vector2f mf = imp->getMousePosf(); + Vector2f mf = imp->getMousePos().asFloat(); Float tratio = tw / th; Float touchX = ( mf.x / tw - 1 ) * tratio; Float touchY = -( mf.y / th - 1 ); diff --git a/src/examples/physics/physics.cpp b/src/examples/physics/physics.cpp index afe473842..c98db43e4 100644 --- a/src/examples/physics/physics.cpp +++ b/src/examples/physics/physics.cpp @@ -597,7 +597,8 @@ void physicsCreate() { void physicsUpdate() { // Creates a joint to drag any grabable object on the scene - mMousePoint = cVectNew( KM->getMousePosf().x, KM->getMousePosf().y ); + const Vector2f mousePos( KM->getMousePos().asFloat() ); + mMousePoint = cVectNew( mousePos.x, mousePos.y ); cVect newPoint = tovect( cpvlerp( tocpv( mMousePoint_last ), tocpv( mMousePoint ), 0.25 ) ); mMouseBody->setPos( newPoint ); mMouseBody->setVel( ( newPoint - mMousePoint_last ) * (cpFloat)mWindow->getFPS() ); @@ -605,7 +606,7 @@ void physicsUpdate() { if ( KM->isMouseLeftPressed() ) { if ( NULL == mMouseJoint ) { - cVect point = cVectNew( KM->getMousePosf().x, KM->getMousePosf().y ); + cVect point = cVectNew( mousePos.x, mousePos.y ); Shape* shape = mSpace->pointQueryFirst( point, GRABABLE_MASK_BIT, CP_NO_GROUP ); diff --git a/src/tests/test_all/test.cpp b/src/tests/test_all/test.cpp index 4719c7daa..40bbb24bc 100644 --- a/src/tests/test_all/test.cpp +++ b/src/tests/test_all/test.cpp @@ -1272,7 +1272,7 @@ void EETest::onQuitClick( const Event* event ) { void EETest::showMenu() { if ( NULL != Menu && Menu->show() ) { - Vector2f Pos = KM->getMousePosf(); + Vector2f Pos = KM->getMousePos().asFloat(); UIMenu::findBestMenuPos( Pos, Menu ); Menu->setPixelsPosition( Pos ); } @@ -2470,7 +2470,8 @@ void EETest::physicsCreate() { void EETest::physicsUpdate() { #ifndef EE_PLATFORM_TOUCH - mMousePoint = cVectNew( KM->getMousePosf().x, KM->getMousePosf().y ); + const Vector2f mousePos( KM->getMousePos().asFloat() ); + mMousePoint = cVectNew( mousePos.x, mousePos.y ); cVect newPoint = tovect( cpvlerp( tocpv( mMousePoint_last ), tocpv( mMousePoint ), 0.25 ) ); mMouseBody->setPos( newPoint ); mMouseBody->setVel( ( newPoint - mMousePoint_last ) * (cpFloat)mWindow->getFPS() ); @@ -2478,7 +2479,7 @@ void EETest::physicsUpdate() { if ( KM->isMouseLeftPressed() ) { if ( NULL == mMouseJoint ) { - cVect point = cVectNew( KM->getMousePosf().x, KM->getMousePosf().y ); + cVect point = cVectNew( mousePos.x, mousePos.y ); Shape* shape = mSpace->pointQueryFirst( point, GRABABLE_MASK_BIT, CP_NO_GROUP ); diff --git a/src/tools/ecode/plugins/lsp/lspclientplugin.cpp b/src/tools/ecode/plugins/lsp/lspclientplugin.cpp index a9b9cad24..14eb4c9b1 100644 --- a/src/tools/ecode/plugins/lsp/lspclientplugin.cpp +++ b/src/tools/ecode/plugins/lsp/lspclientplugin.cpp @@ -605,14 +605,18 @@ TextDocument* LSPClientPlugin::getDocumentFromURI( const URI& uri ) { bool LSPClientPlugin::onMouseClick( UICodeEditor* editor, const Vector2i& pos, const Uint32& flags ) { - const Vector2f localPos( mBreadcrumb && ( flags & EE_BUTTON_LMASK ) - ? editor->convertToNodeSpace( pos.asFloat() ) - : Vector2f::Zero ); - - if ( mBreadcrumb && ( flags & EE_BUTTON_LMASK ) && localPos.y < mPluginTopSpace && + const bool breadcrumbClick = mBreadcrumb && ( flags & EE_BUTTON_LMASK ); + const Vector2f localPos( breadcrumbClick ? editor->convertToNodeSpace( pos.asFloat() ) + : Vector2f::Zero ); + if ( breadcrumbClick && localPos.y < mPluginTopSpace && localPos.x < editor->getPixelsSize().getWidth() - editor->getMinimapWidth() ) { - editor->getDocument().execute( "lsp-show-document-symbols", editor ); - return true; + const Vector2f downLocalPos( editor->convertToNodeSpace( + editor->getEventDispatcher()->getMouseDownPos().asFloat() ) ); + if ( downLocalPos.y < mPluginTopSpace && + downLocalPos.x < editor->getPixelsSize().getWidth() - editor->getMinimapWidth() ) { + editor->getDocument().execute( "lsp-show-document-symbols", editor ); + return true; + } } Input* input = editor->getUISceneNode()->getWindow()->getInput(); @@ -1714,7 +1718,7 @@ void LSPClientPlugin::hideTooltip( UICodeEditor* editor ) { TextPosition currentMouseTextPosition( UICodeEditor* editor ) { return editor->resolveScreenPosition( - editor->getUISceneNode()->getWindow()->getInput()->getMousePosf() ); + editor->getUISceneNode()->getWindow()->getInput()->getMousePos().asFloat() ); } void LSPClientPlugin::tryHideTooltip( UICodeEditor* editor, const Vector2i& position ) { @@ -1830,7 +1834,8 @@ bool LSPClientPlugin::onMouseMove( UICodeEditor* editor, const Vector2i& positio if ( !editor->getScreenRect().contains( editor->getUISceneNode() ->getWindow() ->getInput() - ->getMousePosf() ) ) + ->getMousePos() + .asFloat() ) ) return; tryDisplayTooltip( editor, resp, position ); } ); diff --git a/src/tools/ecode/statusbuildoutputcontroller.cpp b/src/tools/ecode/statusbuildoutputcontroller.cpp index 4a017b223..417c6d6e4 100644 --- a/src/tools/ecode/statusbuildoutputcontroller.cpp +++ b/src/tools/ecode/statusbuildoutputcontroller.cpp @@ -504,7 +504,7 @@ void StatusBuildOutputController::createContainer() { UITableCell* cell = mTableIssues->getCellFromIndex( idx ); if ( modelEvent->getTriggerEvent()->getType() == Event::MouseClick || cell == nullptr ) { - Vector2f pos( mApp->getWindow()->getInput()->getMousePosf() ); + Vector2f pos( mApp->getWindow()->getInput()->getMousePos().asFloat() ); menu->nodeToWorldTranslation( pos ); UIMenu::findBestMenuPos( pos, menu ); menu->setPixelsPosition( pos );