diff --git a/include/eepp/scene/eventdispatcher.hpp b/include/eepp/scene/eventdispatcher.hpp index db1cffcf5..fb7492e29 100644 --- a/include/eepp/scene/eventdispatcher.hpp +++ b/include/eepp/scene/eventdispatcher.hpp @@ -70,6 +70,10 @@ class EE_API EventDispatcher { bool isNodeDragging() const; + bool wasNodeDragging() const; + + bool isOrWasNodeDragging() const; + Vector2i getMousePos(); Vector2f getMousePosf(); @@ -82,6 +86,10 @@ class EE_API EventDispatcher { const Time& getLastFrameTime() const; + Node* getNodeDragging() const; + + Node* getNodeWasDragging() const; + protected: EE::Window::Window* mWindow; Input* mInput; @@ -97,6 +105,7 @@ class EE_API EventDispatcher { Vector2i mClickPos; Int32 mCbId; bool mFirstPress; + Node* mNodeWasDragging; Node* mNodeDragging; Time mElapsed; diff --git a/include/eepp/ui/uicommondialog.hpp b/include/eepp/ui/uicommondialog.hpp index 97dfe287e..c6a676ba4 100644 --- a/include/eepp/ui/uicommondialog.hpp +++ b/include/eepp/ui/uicommondialog.hpp @@ -92,6 +92,8 @@ class EE_API UICommonDialog : public UIWindow { UIDropDownList* mFiletype; Uint32 mCDLFlags; + virtual void onWindowReady(); + void onPressEnter( const Event* Event ); void onPressFileEnter( const Event* Event ); diff --git a/premake5.lua b/premake5.lua index 10add26f9..c0fe237f0 100644 --- a/premake5.lua +++ b/premake5.lua @@ -86,9 +86,9 @@ os_links = { } backends = { } static_backends = { } backend_selected = false -remote_sdl2_version = "SDL2-2.0.10" -remote_sdl2_devel_src_url = "https://libsdl.org/release/SDL2-2.0.10.zip" -remote_sdl2_devel_vc_url = "https://www.libsdl.org/release/SDL2-devel-2.0.10-VC.zip" +remote_sdl2_version = "SDL2-2.0.12" +remote_sdl2_devel_src_url = "https://libsdl.org/release/SDL2-2.0.12.zip" +remote_sdl2_devel_vc_url = "https://www.libsdl.org/release/SDL2-devel-2.0.12-VC.zip" function incdirs( dirs ) if is_xcode() then diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 168a32995..ed26a2da4 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/src/eepp/graphics/vertexbufferogl.cpp b/src/eepp/graphics/vertexbufferogl.cpp index d03e5af2c..17df7eaca 100644 --- a/src/eepp/graphics/vertexbufferogl.cpp +++ b/src/eepp/graphics/vertexbufferogl.cpp @@ -40,11 +40,14 @@ void VertexBufferOGL::setVertexStates() { if ( GLi->isExtension( EEGL_ARB_multitexture ) ) { for ( Int32 i = 0; i < EE_MAX_TEXTURE_UNITS; i++ ) { if ( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 + i ) ) { + if ( mVertexArray[VERTEX_FLAG_TEXTURE0 + i].empty() ) + return; GLi->clientActiveTexture( GL_TEXTURE0 + i ); GLi->enableClientState( GL_TEXTURE_COORD_ARRAY ); GLi->texCoordPointer( VertexElementCount[VERTEX_FLAG_TEXTURE0 + i], GL_FP, - sizeof( Float ) * VertexElementCount[VERTEX_FLAG_TEXTURE0 + i], + sizeof( Float ) * + VertexElementCount[VERTEX_FLAG_TEXTURE0 + i], &mVertexArray[VERTEX_FLAG_TEXTURE0 + i][0], alloc ); } else { if ( 0 == i ) { @@ -56,6 +59,8 @@ void VertexBufferOGL::setVertexStates() { } } else { if ( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 ) ) { + if ( mVertexArray[VERTEX_FLAG_TEXTURE0].empty() ) + return; GLi->enableClientState( GL_TEXTURE_COORD_ARRAY ); GLi->texCoordPointer( VertexElementCount[VERTEX_FLAG_TEXTURE0], GL_FP, sizeof( Float ) * VertexElementCount[VERTEX_FLAG_TEXTURE0], @@ -68,6 +73,8 @@ void VertexBufferOGL::setVertexStates() { /// POSITION if ( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_POSITION ) ) { + if ( mVertexArray[VERTEX_FLAG_POSITION].empty() ) + return; GLi->enableClientState( GL_VERTEX_ARRAY ); GLi->vertexPointer( VertexElementCount[VERTEX_FLAG_POSITION], GL_FP, sizeof( Float ) * VertexElementCount[VERTEX_FLAG_POSITION], @@ -78,6 +85,8 @@ void VertexBufferOGL::setVertexStates() { /// COLOR if ( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_COLOR ) ) { + if ( mColorArray.empty() ) + return; GLi->enableClientState( GL_COLOR_ARRAY ); GLi->colorPointer( VertexElementCount[VERTEX_FLAG_COLOR], GL_UNSIGNED_BYTE, sizeof( Uint8 ) * VertexElementCount[VERTEX_FLAG_COLOR], &mColorArray[0], @@ -104,7 +113,7 @@ void VertexBufferOGL::unbind() { } } -void VertexBufferOGL::update( const Uint32& Types, bool Indices ) {} +void VertexBufferOGL::update( const Uint32&, bool ) {} void VertexBufferOGL::reload() {} diff --git a/src/eepp/graphics/vertexbuffervbo.cpp b/src/eepp/graphics/vertexbuffervbo.cpp index 3ca4eb8e7..6b22be762 100644 --- a/src/eepp/graphics/vertexbuffervbo.cpp +++ b/src/eepp/graphics/vertexbuffervbo.cpp @@ -94,7 +94,7 @@ bool VertexBufferVBO::compile() { } // Create the VBO index array - if ( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_USE_INDICES ) ) { + if ( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_USE_INDICES ) && !mIndexArray.empty() ) { glGenBuffersARB( 1, (unsigned int*)&mElementHandle ); glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER, mElementHandle ); @@ -193,7 +193,8 @@ void VertexBufferVBO::setVertexStates() { EEGL_TEXTURE_COORD_ARRAY ) ); if ( -1 != index ) - glVertexAttribPointerARB( index, VertexElementCount[VERTEX_FLAG_TEXTURE0 + i], + glVertexAttribPointerARB( index, + VertexElementCount[VERTEX_FLAG_TEXTURE0 + i], GL_FP, GL_FALSE, 0, 0 ); } else #endif @@ -228,13 +229,13 @@ void VertexBufferVBO::setVertexStates() { EEGL_TEXTURE_COORD_ARRAY ) ); if ( -1 != index ) - glVertexAttribPointerARB( index, VertexElementCount[VERTEX_FLAG_TEXTURE0], GL_FP, - GL_FALSE, 0, 0 ); + glVertexAttribPointerARB( index, VertexElementCount[VERTEX_FLAG_TEXTURE0], + GL_FP, GL_FALSE, 0, 0 ); } else #endif { - GLi->texCoordPointer( VertexElementCount[VERTEX_FLAG_TEXTURE0], GL_FP, 0, (char*)NULL, - 0 ); + GLi->texCoordPointer( VertexElementCount[VERTEX_FLAG_TEXTURE0], GL_FP, 0, + (char*)NULL, 0 ); } mTextured = true; @@ -265,7 +266,8 @@ void VertexBufferVBO::setVertexStates() { } else #endif { - GLi->vertexPointer( VertexElementCount[VERTEX_FLAG_POSITION], GL_FP, 0, (char*)NULL, 0 ); + GLi->vertexPointer( VertexElementCount[VERTEX_FLAG_POSITION], GL_FP, 0, (char*)NULL, + 0 ); } } else { GLi->disableClientState( GL_VERTEX_ARRAY ); diff --git a/src/eepp/scene/eventdispatcher.cpp b/src/eepp/scene/eventdispatcher.cpp index 834941a56..75f28c0f7 100644 --- a/src/eepp/scene/eventdispatcher.cpp +++ b/src/eepp/scene/eventdispatcher.cpp @@ -22,6 +22,7 @@ EventDispatcher::EventDispatcher( SceneNode* sceneNode ) : mLossFocusNode( NULL ), mCbId( 0 ), mFirstPress( false ), + mNodeWasDragging( NULL ), mNodeDragging( NULL ) { mCbId = mInput->pushCallback( cb::Make1( this, &EventDispatcher::inputCallback ) ); } @@ -60,7 +61,8 @@ void EventDispatcher::inputCallback( InputEvent* event ) { } void EventDispatcher::update( const Time& time ) { - bool wasDraggingNode = mNodeDragging; + mNodeWasDragging = mNodeDragging; + bool nodeWasDragging = mNodeDragging; mElapsed = time; mMousePos = mInput->getMousePosFromView( mWindow->getDefaultView() ); @@ -108,7 +110,7 @@ void EventDispatcher::update( const Time& time ) { if ( mInput->getReleaseTrigger() ) { if ( NULL != mFocusNode ) { - if ( !wasDraggingNode || mMousePos == mLastMousePos ) { + if ( !nodeWasDragging || mMousePos == mLastMousePos ) { if ( mOverNode != mFocusNode && mInput->getReleaseTrigger() & ( EE_BUTTON_LMASK | EE_BUTTON_RMASK ) ) setFocusNode( mOverNode ); @@ -150,9 +152,9 @@ void EventDispatcher::update( const Time& time ) { // While dragging and object we want to be able to continue dragging even if the mouse cursor // moves outside the window. Capturing the mouse allows this. - if ( !wasDraggingNode && isNodeDragging() ) { + if ( !nodeWasDragging && isNodeDragging() ) { mInput->captureMouse( true ); - } else if ( wasDraggingNode && !isNodeDragging() ) { + } else if ( nodeWasDragging && !isNodeDragging() ) { mInput->captureMouse( false ); } } @@ -277,6 +279,14 @@ bool EventDispatcher::isNodeDragging() const { return NULL != mNodeDragging; } +bool EventDispatcher::wasNodeDragging() const { + return NULL != mNodeWasDragging; +} + +bool EventDispatcher::isOrWasNodeDragging() const { + return mNodeWasDragging || isNodeDragging(); +} + Vector2i EventDispatcher::getMousePos() { return mMousePosi; } @@ -301,4 +311,12 @@ const Time& EventDispatcher::getLastFrameTime() const { return mElapsed; } +Node* EventDispatcher::getNodeDragging() const { + return mNodeDragging; +} + +Node* EventDispatcher::getNodeWasDragging() const { + return mNodeWasDragging; +} + }} // namespace EE::Scene diff --git a/src/eepp/ui/doc/syntaxhighlighter.cpp b/src/eepp/ui/doc/syntaxhighlighter.cpp index ea808e934..17b244af0 100644 --- a/src/eepp/ui/doc/syntaxhighlighter.cpp +++ b/src/eepp/ui/doc/syntaxhighlighter.cpp @@ -15,9 +15,10 @@ TokenizedLine SyntaxHighlighter::tokenizeLine( const size_t& line, const int& st TokenizedLine tokenizedLine; tokenizedLine.initState = state; tokenizedLine.text = mDoc->line( line ); - auto res = SyntaxTokenizer::tokenize( mDoc->getSyntaxDefinition(), tokenizedLine.text.toUtf8(), state ); - tokenizedLine.tokens = res.first; - tokenizedLine.state = res.second; + std::pair, int> res = SyntaxTokenizer::tokenize( + mDoc->getSyntaxDefinition(), tokenizedLine.text.toUtf8(), state ); + tokenizedLine.tokens = std::move( res.first ); + tokenizedLine.state = std::move( res.second ); return tokenizedLine; } diff --git a/src/eepp/ui/doc/undostack.cpp b/src/eepp/ui/doc/undostack.cpp index e73fcd01f..ca3c5b2d6 100644 --- a/src/eepp/ui/doc/undostack.cpp +++ b/src/eepp/ui/doc/undostack.cpp @@ -94,14 +94,13 @@ void UndoStack::pushUndo( UndoStackContainer& undoStack, TextUndoCommand* cmd ) void UndoStack::pushInsert( UndoStackContainer& undoStack, const String& string, const TextPosition& position, const Time& time ) { - pushUndo( undoStack, eeNew( TextUndoCommandInsert, ( ++mChangeIdCounter, string, - position, time ) ) ); + pushUndo( undoStack, + eeNew( TextUndoCommandInsert, ( ++mChangeIdCounter, string, position, time ) ) ); } void UndoStack::pushRemove( UndoStackContainer& undoStack, const TextRange& range, const Time& time ) { - pushUndo( undoStack, - eeNew( TextUndoCommandRemove, ( ++mChangeIdCounter, range, time ) ) ); + pushUndo( undoStack, eeNew( TextUndoCommandRemove, ( ++mChangeIdCounter, range, time ) ) ); } void UndoStack::pushSelection( UndoStackContainer& undoStack, const TextRange& selection, @@ -131,8 +130,7 @@ void UndoStack::popUndo( UndoStackContainer& undoStack, UndoStackContainer& redo break; } case TextUndoCommandType::Selection: { - TextUndoCommandSelection* selection = - static_cast( cmd ); + TextUndoCommandSelection* selection = static_cast( cmd ); mDoc->setSelection( selection->getSelection() ); break; } diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index 96fe9e0e5..d7580a482 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -769,11 +769,12 @@ int UICodeEditor::getVisibleLinesCount() { void UICodeEditor::scrollToMakeVisible( const TextPosition& position ) { // Vertical Scroll Float lineHeight = getLineHeight(); - Float min = lineHeight * ( eemax( 0, position.line() - 1 ) ); - Float max = lineHeight * ( position.line() + 2 ) - mSize.getHeight(); - Float scrollY = eemin( mScroll.y, min ); - scrollY = eefloor( eemax( mScroll.y, max ) ); - setScrollY( scrollY ); + Float min = eefloor( lineHeight * ( eemax( 0, position.line() - 1 ) ) ); + Float max = eefloor( lineHeight * ( position.line() + 2 ) - mSize.getHeight() ); + if ( min < mScroll.y ) + setScrollY( min ); + else if ( max > mScroll.y ) + setScrollY( max ); // Horizontal Scroll Float offsetX = getXOffsetCol( position ); diff --git a/src/eepp/ui/uicommondialog.cpp b/src/eepp/ui/uicommondialog.cpp index 0f45e9ca9..de143ee14 100644 --- a/src/eepp/ui/uicommondialog.cpp +++ b/src/eepp/ui/uicommondialog.cpp @@ -138,13 +138,15 @@ UICommonDialog::UICommonDialog( Uint32 CDLFlags, std::string DefaultFilePattern, applyDefaultTheme(); - refreshFolder(); - mUISceneNode->setIsLoading( loading ); } UICommonDialog::~UICommonDialog() {} +void UICommonDialog::onWindowReady() { + refreshFolder(); +} + Uint32 UICommonDialog::getType() const { return UI_TYPE_COMMONDIALOG; } diff --git a/src/eepp/ui/uislider.cpp b/src/eepp/ui/uislider.cpp index 5d71d40cb..461d9d120 100644 --- a/src/eepp/ui/uislider.cpp +++ b/src/eepp/ui/uislider.cpp @@ -431,7 +431,8 @@ void UISlider::manageClick( const Uint32& Flags ) { Vector2f controlPos = getEventDispatcher()->getMousePosf(); mSlider->worldToNode( controlPos ); - if ( Flags & EE_BUTTON_LMASK && !mSlider->isMouseOver() ) { + if ( Flags & EE_BUTTON_LMASK && !mSlider->isMouseOver() && !mSlider->isDragging() && + getUISceneNode()->getEventDispatcher()->getNodeWasDragging() != mSlider ) { if ( UIOrientation::Horizontal == mOrientation ) { if ( controlPos.x < 0 ) setValue( mValue - mClickStep ); diff --git a/src/tools/codeeditor/codeeditor.cpp b/src/tools/codeeditor/codeeditor.cpp index edf255ccf..cf5c87aea 100644 --- a/src/tools/codeeditor/codeeditor.cpp +++ b/src/tools/codeeditor/codeeditor.cpp @@ -36,7 +36,7 @@ void loadFileFromPath( const std::string& path ) { } void openFileDialog() { - UICommonDialog* TGDialog = UICommonDialog::New( UI_CDL_DEFAULT_FLAGS, "*.xml;*.css;*.svg" ); + UICommonDialog* TGDialog = UICommonDialog::New( UI_CDL_DEFAULT_FLAGS, "*" ); TGDialog->setWinFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL ); TGDialog->setTitle( "Open layout..." ); TGDialog->addEventListener( Event::OpenFile, []( const Event* event ) {