diff --git a/include/eepp/graphics/renderer/clippingmask.hpp b/include/eepp/graphics/renderer/clippingmask.hpp index 8e936253b..382971837 100644 --- a/include/eepp/graphics/renderer/clippingmask.hpp +++ b/include/eepp/graphics/renderer/clippingmask.hpp @@ -4,7 +4,6 @@ #include #include #include -#include namespace EE { namespace Graphics { @@ -44,17 +43,17 @@ class EE_API ClippingMask { void stencilMaskDisable( bool clearMasks = false ); - std::list getScissorsClipped() const; + const std::vector& getScissorsClipped() const; - void setScissorsClipped( const std::list& scissorsClipped ); + void setScissorsClipped( const std::vector& scissorsClipped ); - std::list getPlanesClipped() const; + const std::vector& getPlanesClipped() const; - void setPlanesClipped( const std::list& planesClipped ); + void setPlanesClipped( const std::vector& planesClipped ); protected: - std::list mScissorsClipped; - std::list mPlanesClipped; + std::vector mScissorsClipped; + std::vector mPlanesClipped; bool mPushScissorClip; bool mPushClip; diff --git a/include/eepp/graphics/text.hpp b/include/eepp/graphics/text.hpp index 62ed4a11a..793546b67 100644 --- a/include/eepp/graphics/text.hpp +++ b/include/eepp/graphics/text.hpp @@ -179,6 +179,8 @@ class EE_API Text { void setShadowOffset( const Vector2f& shadowOffset ); + bool hasSameFontStyleConfig( const FontStyleConfig& styleConfig ); + protected: struct VertexCoords { Vector2f texCoords; diff --git a/include/eepp/graphics/texturefactory.hpp b/include/eepp/graphics/texturefactory.hpp index 03879dd82..671ea299e 100644 --- a/include/eepp/graphics/texturefactory.hpp +++ b/include/eepp/graphics/texturefactory.hpp @@ -3,8 +3,6 @@ #include #include -#include - #include #include #include @@ -266,7 +264,7 @@ class EE_API TextureFactory : protected Mutex { unsigned int mMemSize; - std::list mVectorFreeSlots; + std::vector mVectorFreeSlots; Texture::CoordinateType mLastCoordinateType; diff --git a/include/eepp/graphics/texturepacker.hpp b/include/eepp/graphics/texturepacker.hpp index 8614d7070..8560dbd8a 100644 --- a/include/eepp/graphics/texturepacker.hpp +++ b/include/eepp/graphics/texturepacker.hpp @@ -31,7 +31,6 @@ #include #include #include -#include namespace EE { namespace Graphics { @@ -184,7 +183,7 @@ class EE_API TexturePacker { protected: enum PackStrategy { PackBig, PackTiny, PackFail }; - std::list mTextures; + std::vector mTextures; Int32 mTotalArea; TexturePackerNode* mFreeList; @@ -212,7 +211,7 @@ class EE_API TexturePacker { TexturePacker* getParent() const; - std::list* getTexturePackPtr(); + std::vector* getTexturePackPtr(); void childSave( const Image::SaveType& Format ); diff --git a/include/eepp/network/http.hpp b/include/eepp/network/http.hpp index 8589a7859..689e7cef8 100644 --- a/include/eepp/network/http.hpp +++ b/include/eepp/network/http.hpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include @@ -717,7 +716,7 @@ class EE_API Http : NonCopyable { IpAddress mHost; ///< Web host address std::string mHostName; ///< Web host name unsigned short mPort; ///< Port used for connection with host - std::list mThreads; + std::vector mThreads; Mutex mThreadsMutex; bool mIsSSL; bool mHostSolved; diff --git a/include/eepp/network/socketselector.hpp b/include/eepp/network/socketselector.hpp index 2bba4fef4..cebfe52e3 100644 --- a/include/eepp/network/socketselector.hpp +++ b/include/eepp/network/socketselector.hpp @@ -120,7 +120,7 @@ TcpListener listener; listener.listen(55001); // Create a list to store the future clients -std::list clients; +std::vector clients; // Create a selector SocketSelector selector; @@ -149,7 +149,7 @@ while (running) { } } else { // The listener socket is not ready, test all other sockets (the clients) - for (std::list::iterator it = clients.begin(); it != clients.end(); ++it) { + for (std::vector::iterator it = clients.begin(); it != clients.end(); ++it) { TcpSocket& client = **it; if (selector.isReady(client)) { // The client has sent some data, we can receive it diff --git a/include/eepp/scene/node.hpp b/include/eepp/scene/node.hpp index 69d137ed5..9a08417ea 100644 --- a/include/eepp/scene/node.hpp +++ b/include/eepp/scene/node.hpp @@ -191,9 +191,7 @@ class EE_API Node : public Transformable { Uint32 addEventListener( const Uint32& eventType, const EventCallback& callback ); - Uint32 on( const Uint32& eventType, const EventCallback& callback ) { - return addEventListener( eventType, callback ); - } + Uint32 on( const Uint32& eventType, const EventCallback& callback ); Uint32 onClick( const std::function& callback, const MouseButton& button = MouseButton::EE_BUTTON_LEFT ); diff --git a/include/eepp/system/log.hpp b/include/eepp/system/log.hpp index 1629fcf5f..e16560b99 100644 --- a/include/eepp/system/log.hpp +++ b/include/eepp/system/log.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include namespace EE { namespace System { @@ -192,7 +191,7 @@ class EE_API Log : protected Mutex { bool mKeepLog{ false }; LogLevel mLogLevelThreshold{ getDefaultLogLevel() }; IOStreamFile* mFS; - std::list mReaders; + std::vector mReaders; void openFS(); diff --git a/include/eepp/ui/uiconsole.hpp b/include/eepp/ui/uiconsole.hpp index c35838eb0..b0214400d 100644 --- a/include/eepp/ui/uiconsole.hpp +++ b/include/eepp/ui/uiconsole.hpp @@ -299,7 +299,7 @@ class EE_API UIConsole : public UIWidget, void printCommandsStartingWith( const String& start ); - String getLastCommonSubStr( std::list& cmds ); + String getLastCommonSubStr( std::vector& cmds ); void processLine(); diff --git a/include/eepp/ui/uilistbox.hpp b/include/eepp/ui/uilistbox.hpp index fd3e85ef8..a052ab1c2 100644 --- a/include/eepp/ui/uilistbox.hpp +++ b/include/eepp/ui/uilistbox.hpp @@ -63,9 +63,9 @@ class EE_API UIListBox : public UITouchDraggableWidget { bool hasSelection() const; - std::list getItemsSelectedIndex() const; + std::vector getItemsSelectedIndex() const; - std::list getItemsSelected(); + std::vector getItemsSelected(); Rectf getContainerPadding() const; @@ -134,7 +134,7 @@ class EE_API UIListBox : public UITouchDraggableWidget { bool mSmoothScroll; - std::list mSelected; + std::vector mSelected; std::vector mItems; std::vector mTexts; diff --git a/include/eepp/ui/uimenubar.hpp b/include/eepp/ui/uimenubar.hpp index 1c29d8d15..ea536c1d6 100644 --- a/include/eepp/ui/uimenubar.hpp +++ b/include/eepp/ui/uimenubar.hpp @@ -39,7 +39,7 @@ class EE_API UIMenuBar : public UIWidget { virtual void loadFromXmlNode( const pugi::xml_node& node ); protected: - typedef std::list> MenuBarList; + typedef std::vector> MenuBarList; Uint32 mMenuHeight; UIPopUpMenu* mCurrentMenu; diff --git a/include/eepp/ui/uiscenenode.hpp b/include/eepp/ui/uiscenenode.hpp index 3eb0b2bcb..2bd216408 100644 --- a/include/eepp/ui/uiscenenode.hpp +++ b/include/eepp/ui/uiscenenode.hpp @@ -6,7 +6,6 @@ #include #include #include -#include namespace EE { namespace Graphics { class Font; @@ -175,7 +174,7 @@ class EE_API UISceneNode : public SceneNode { Sizef mDpSize; Uint32 mFlags; Translator mTranslator; - std::list mWindowsList; + std::vector mWindowsList; CSS::StyleSheet mStyleSheet; bool mIsLoading; bool mVerbose; diff --git a/include/eepp/window/engine.hpp b/include/eepp/window/engine.hpp index f661fb26d..959b39c77 100644 --- a/include/eepp/window/engine.hpp +++ b/include/eepp/window/engine.hpp @@ -5,7 +5,6 @@ #include #include #include -#include namespace EE { namespace System { class IniFile; diff --git a/projects/linux/ee.files b/projects/linux/ee.files index 3550c633c..32c8baa15 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -1176,6 +1176,8 @@ ../../src/tools/ecode/filesystemlistener.hpp ../../src/tools/ecode/globalsearchcontroller.cpp ../../src/tools/ecode/globalsearchcontroller.hpp +../../src/tools/ecode/iconmanager.cpp +../../src/tools/ecode/iconmanager.hpp ../../src/tools/ecode/ignorematcher.cpp ../../src/tools/ecode/ignorematcher.hpp ../../src/tools/ecode/macos/macos.hpp diff --git a/src/eepp/graphics/framebuffer.cpp b/src/eepp/graphics/framebuffer.cpp index 7eea48c3e..32a066063 100644 --- a/src/eepp/graphics/framebuffer.cpp +++ b/src/eepp/graphics/framebuffer.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -10,7 +11,7 @@ using namespace EE::Graphics::Private; namespace EE { namespace Graphics { -static std::list sFBOActiveViews; +static std::vector sFBOActiveViews; FrameBuffer* FrameBuffer::New( const Uint32& Width, const Uint32& Height, bool StencilBuffer, bool DepthBuffer, bool useColorBuffer, const Uint32& channels, @@ -82,7 +83,9 @@ void FrameBuffer::setBufferView() { void FrameBuffer::recoverView() { GlobalBatchRenderer::instance()->draw(); - sFBOActiveViews.remove( &mView ); + auto found = std::find( sFBOActiveViews.begin(), sFBOActiveViews.end(), &mView ); + if ( found != sFBOActiveViews.end() ) + sFBOActiveViews.erase( found ); if ( sFBOActiveViews.empty() ) { mWindow->setView( mWindow->getView(), true ); diff --git a/src/eepp/graphics/renderer/clippingmask.cpp b/src/eepp/graphics/renderer/clippingmask.cpp index 45a4f2cf8..cff67adce 100644 --- a/src/eepp/graphics/renderer/clippingmask.cpp +++ b/src/eepp/graphics/renderer/clippingmask.cpp @@ -140,11 +140,11 @@ void ClippingMask::stencilMaskDisable( bool clearMasks ) { this->clearMasks(); } -std::list ClippingMask::getScissorsClipped() const { +const std::vector& ClippingMask::getScissorsClipped() const { return mScissorsClipped; } -void ClippingMask::setScissorsClipped( const std::list& scissorsClipped ) { +void ClippingMask::setScissorsClipped( const std::vector& scissorsClipped ) { mScissorsClipped = scissorsClipped; if ( !mScissorsClipped.empty() ) { @@ -155,11 +155,11 @@ void ClippingMask::setScissorsClipped( const std::list& scissorsClipped ) } } -std::list ClippingMask::getPlanesClipped() const { +const std::vector& ClippingMask::getPlanesClipped() const { return mPlanesClipped; } -void ClippingMask::setPlanesClipped( const std::list& planesClipped ) { +void ClippingMask::setPlanesClipped( const std::vector& planesClipped ) { mPlanesClipped = planesClipped; if ( !mPlanesClipped.empty() ) { diff --git a/src/eepp/graphics/text.cpp b/src/eepp/graphics/text.cpp index 0cfc1b858..314546d91 100644 --- a/src/eepp/graphics/text.cpp +++ b/src/eepp/graphics/text.cpp @@ -440,8 +440,8 @@ Float Text::getTextWidth( Font* font, const Uint32& fontSize, const String& stri } Vector2f Text::findCharacterPos( std::size_t index, Font* font, const Uint32& fontSize, - const String& string, const Uint32& style, const Uint32& tabWidth, - const Float& outlineThickness ) { + const String& string, const Uint32& style, const Uint32& tabWidth, + const Float& outlineThickness ) { // Make sure that we have a valid font if ( !font ) return Vector2f(); @@ -1176,6 +1176,14 @@ void Text::setStyleConfig( const FontStyleConfig& styleConfig ) { setShadowColor( styleConfig.ShadowColor ); } +bool Text::hasSameFontStyleConfig( const FontStyleConfig& styleConfig ) { + return styleConfig.Font == mFont && styleConfig.CharacterSize == mFontSize && + styleConfig.Style == mStyle && styleConfig.FontColor == mFillColor && + styleConfig.OutlineColor == mOutlineColor && styleConfig.ShadowColor == mShadowColor && + styleConfig.ShadowOffset == mShadowOffset && + styleConfig.OutlineThickness == mOutlineThickness; +} + void Text::setFillColor( const Color& color, Uint32 from, Uint32 to ) { if ( mString.empty() ) return; diff --git a/src/eepp/graphics/textureatlasmanager.cpp b/src/eepp/graphics/textureatlasmanager.cpp index aca263b4f..f56c1d722 100644 --- a/src/eepp/graphics/textureatlasmanager.cpp +++ b/src/eepp/graphics/textureatlasmanager.cpp @@ -52,8 +52,6 @@ TextureRegion* TextureAtlasManager::getTextureRegionByName( const std::string& N } TextureRegion* TextureAtlasManager::getTextureRegionById( const String::HashType& Id ) { - std::list::iterator it; - TextureAtlas* tSG = NULL; TextureRegion* tTextureRegion = NULL; diff --git a/src/eepp/graphics/texturefactory.cpp b/src/eepp/graphics/texturefactory.cpp index 1b6a9b8f7..febca3d49 100644 --- a/src/eepp/graphics/texturefactory.cpp +++ b/src/eepp/graphics/texturefactory.cpp @@ -133,10 +133,10 @@ Uint32 TextureFactory::pushTexture( const std::string& Filepath, const Uint32& T } Uint32 TextureFactory::findFreeSlot() { - if ( mVectorFreeSlots.size() ) { + if ( !mVectorFreeSlots.empty() ) { Uint32 Pos = mVectorFreeSlots.front(); - mVectorFreeSlots.pop_front(); + mVectorFreeSlots.erase( mVectorFreeSlots.begin() ); return Pos; } diff --git a/src/eepp/graphics/texturepacker.cpp b/src/eepp/graphics/texturepacker.cpp index 9359e3b1c..6817b5b7b 100644 --- a/src/eepp/graphics/texturepacker.cpp +++ b/src/eepp/graphics/texturepacker.cpp @@ -79,7 +79,7 @@ TexturePacker::~TexturePacker() { void TexturePacker::close() { reset(); - std::list::iterator it; + std::vector::iterator it; for ( it = mTextures.begin(); it != mTextures.end(); ++it ) { eeSAFE_DELETE( ( *it ) ); @@ -93,7 +93,7 @@ void TexturePacker::reset() { mCount = mTextures.size(); TexturePackerTex* t = NULL; - std::list::iterator it; + std::vector::iterator it; for ( it = mTextures.begin(); it != mTextures.end(); ++it ) { t = ( *it ); @@ -121,7 +121,7 @@ void TexturePacker::reset() { Uint32 TexturePacker::getAtlasNumChannels() { Uint32 maxChannels = 0; TexturePackerTex* t = NULL; - std::list::iterator it; + std::vector::iterator it; for ( it = mTextures.begin(); it != mTextures.end(); ++it ) { t = ( *it ); @@ -217,7 +217,7 @@ void TexturePacker::validate() { TexturePackerTex* TexturePacker::getLonguestEdge() { TexturePackerTex* t = NULL; - std::list::iterator it; + std::vector::iterator it; for ( it = mTextures.begin(); it != mTextures.end(); ++it ) { if ( !( *it )->placed() ) { @@ -231,7 +231,7 @@ TexturePackerTex* TexturePacker::getLonguestEdge() { TexturePackerTex* TexturePacker::getShortestEdge() { TexturePackerTex* t = NULL; - std::list::reverse_iterator it; + std::vector::reverse_iterator it; for ( it = mTextures.rbegin(); it != mTextures.rend(); ++it ) { if ( !( *it )->placed() ) { @@ -247,7 +247,7 @@ void TexturePacker::addBorderToTextures( const Int32& BorderSize ) { TexturePackerTex* t; if ( 0 != BorderSize ) { - std::list::iterator it; + std::vector::iterator it; for ( it = mTextures.begin(); it != mTextures.end(); ++it ) { t = ( *it ); @@ -404,8 +404,8 @@ void TexturePacker::createChild() { mChild = TexturePacker::New( mWidth, mHeight, mPixelDensity / 100.f, mForcePowOfTwo, mScalableSVG, mPixelBorder, mTextureFilter, mAllowFlipping ); - std::list::iterator it; - std::list::iterator> remove; + std::vector::iterator it; + std::vector::iterator> remove; TexturePackerTex* t = NULL; @@ -425,7 +425,7 @@ void TexturePacker::createChild() { } // Removes the non-placed textures from the pack - std::list::iterator>::iterator itit; + std::vector::iterator>::iterator itit; for ( itit = remove.begin(); itit != remove.end(); ++itit ) { mTextures.erase( *itit ); @@ -463,7 +463,7 @@ bool TexturePacker::addPackerTex( TexturePackerTex* TPack ) { mTotalArea += TPack->area(); // Insert ordered - std::list::iterator it; + std::vector::iterator it; bool Added = false; @@ -517,7 +517,7 @@ Int32 TexturePacker::packTextures() { mCount = (Int32)mTextures.size(); // We must place each texture - std::list::iterator it; + std::vector::iterator it; for ( it = mTextures.begin(); it != mTextures.end(); ++it ) { // For the texture with the longest edge we place it according to this criteria. // (1) If it is a perfect match, we always accept it as it causes the least amount of @@ -623,7 +623,7 @@ void TexturePacker::save( const std::string& Filepath, const Image::SaveType& Fo Img.fillWithColor( Color( 0, 0, 0, 0 ) ); TexturePackerTex* t = NULL; - std::list::iterator it; + std::vector::iterator it; for ( it = mTextures.begin(); it != mTextures.end(); ++it ) { t = ( *it ); @@ -738,8 +738,8 @@ void TexturePacker::createTextureRegionsHdr( TexturePacker* Packer, sTextureRegionHdr tTextureRegionHdr; Uint32 c = 0; - std::list tTextures = *( Packer->getTexturePackPtr() ); - std::list::iterator it; + std::vector tTextures = *( Packer->getTexturePackPtr() ); + std::vector::iterator it; TexturePackerTex* tTex; TextureRegions.resize( tTextures.size() ); @@ -833,7 +833,7 @@ TexturePacker* TexturePacker::getParent() const { return mParent; } -std::list* TexturePacker::getTexturePackPtr() { +std::vector* TexturePacker::getTexturePackPtr() { return &mTextures; } diff --git a/src/eepp/network/http.cpp b/src/eepp/network/http.cpp index ed6cdf572..1384d761f 100644 --- a/src/eepp/network/http.cpp +++ b/src/eepp/network/http.cpp @@ -946,7 +946,8 @@ Http::Response Http::downloadRequest( const Http::Request& request, IOStream& wr } if ( chunked ) { - IOStream& writeToStream = compressed ? *inflateStream : writeTo; + IOStream& writeToStream = + compressed ? *inflateStream : writeTo; chunkedStream = eeNew( HttpStreamChunked, ( writeToStream ) ); } @@ -1151,26 +1152,24 @@ void Http::AsyncRequest::run() { } void Http::removeOldThreads() { - std::list remove; + std::vector remove; - std::list::iterator it = mThreads.begin(); + for ( AsyncRequest* ar : mThreads ) { + if ( ar->mRunning ) + continue; + // We need to be sure, since the state is set in the thread, this will not block the + // thread anyway + ar->wait(); - for ( ; it != mThreads.end(); ++it ) { - AsyncRequest* ar = ( *it ); + eeDelete( ar ); - if ( !ar->mRunning ) { - // We need to be sure, since the state is set in the thread, this will not block the - // thread anyway - ar->wait(); - - eeDelete( ar ); - - remove.push_back( ar ); - } + remove.push_back( ar ); } - for ( it = remove.begin(); it != remove.end(); ++it ) { - mThreads.remove( ( *it ) ); + for ( auto rem : remove ) { + auto found = std::find( mThreads.begin(), mThreads.end(), rem ); + if ( found != mThreads.end() ) + mThreads.erase( found ); } } diff --git a/src/eepp/scene/node.cpp b/src/eepp/scene/node.cpp index cc21cf4b5..99039fca3 100644 --- a/src/eepp/scene/node.cpp +++ b/src/eepp/scene/node.cpp @@ -1120,14 +1120,18 @@ void Node::updateCenter() { } Uint32 Node::addEventListener( const Uint32& eventType, const EventCallback& callback ) { - mNumCallBacks++; - mEvents[eventType][mNumCallBacks] = callback; + mEvents[eventType][++mNumCallBacks] = callback; + return mNumCallBacks; +} + +Uint32 Node::on( const Uint32& eventType, const EventCallback& callback ) { + mEvents[eventType][++mNumCallBacks] = callback; return mNumCallBacks; } Uint32 Node::onClick( const std::function& callback, const MouseButton& button ) { - return addEventListener( Event::MouseClick, [callback, button]( const Event* event ) { + return on( Event::MouseClick, [callback, button]( const Event* event ) { if ( event->asMouseEvent()->getFlags() & ( EE_BUTTON_MASK( button ) ) ) { callback( event->asMouseEvent() ); } diff --git a/src/eepp/scene/scenenode.cpp b/src/eepp/scene/scenenode.cpp index 101e83235..acd78d918 100644 --- a/src/eepp/scene/scenenode.cpp +++ b/src/eepp/scene/scenenode.cpp @@ -98,7 +98,7 @@ void SceneNode::draw() { ClippingMask* clippingMask = GLi->getClippingMask(); - std::list clips = clippingMask->getPlanesClipped(); + const std::vector& clips = clippingMask->getPlanesClipped(); if ( !clips.empty() ) clippingMask->clipPlaneDisable(); diff --git a/src/eepp/system/filesystem.cpp b/src/eepp/system/filesystem.cpp index 63d68f7b6..16ccf93aa 100644 --- a/src/eepp/system/filesystem.cpp +++ b/src/eepp/system/filesystem.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #if EE_PLATFORM == EE_PLATFORM_WIN diff --git a/src/eepp/system/log.cpp b/src/eepp/system/log.cpp index f7bd8cde6..a74f4b9d6 100644 --- a/src/eepp/system/log.cpp +++ b/src/eepp/system/log.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -394,7 +395,9 @@ void Log::addLogReader( LogReaderInterface* reader ) { } void Log::removeLogReader( LogReaderInterface* reader ) { - mReaders.remove( reader ); + auto found = std::find( mReaders.begin(), mReaders.end(), reader ); + if ( found != mReaders.end() ) + mReaders.erase( found ); } void Log::writeToReaders( const std::string& text ) { diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index bc1e6a18c..86a0f84c4 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -3734,7 +3734,8 @@ const Vector2f& UICodeEditor::getScroll() const { Text& UICodeEditor::getLineText( const Int64& lineNumber ) const { auto it = mTextCache.find( lineNumber ); - if ( it == mTextCache.end() || it->second.hash != mDoc->line( lineNumber ).getHash() ) { + if ( it == mTextCache.end() || it->second.hash != mDoc->line( lineNumber ).getHash() || + !it->second.text.hasSameFontStyleConfig( mFontStyleConfig ) ) { Float fontSize = PixelDensity::pxToDp( getCharacterSize() ); Text txt( "", mFont, fontSize ); txt.setTabWidth( mTabWidth ); diff --git a/src/eepp/ui/uiconsole.cpp b/src/eepp/ui/uiconsole.cpp index 4bcf8abf8..28b11c6ca 100644 --- a/src/eepp/ui/uiconsole.cpp +++ b/src/eepp/ui/uiconsole.cpp @@ -995,11 +995,11 @@ void UIConsole::onSelectionChange() { invalidateDraw(); } -String UIConsole::getLastCommonSubStr( std::list& cmds ) { +String UIConsole::getLastCommonSubStr( std::vector& cmds ) { String lastCommon( mDoc.getCurrentLine().getTextWithoutNewLine() ); String strTry( lastCommon ); - std::list::iterator ite; + std::vector::iterator ite; bool found = false; @@ -1034,7 +1034,7 @@ String UIConsole::getLastCommonSubStr( std::list& cmds ) { } void UIConsole::printCommandsStartingWith( const String& start ) { - std::list cmds; + std::vector cmds; for ( auto it = mCallbacks.begin(); it != mCallbacks.end(); ++it ) { if ( String::startsWith( it->first, start ) ) { @@ -1045,7 +1045,7 @@ void UIConsole::printCommandsStartingWith( const String& start ) { if ( cmds.size() > 1 ) { privPushText( "> " + mDoc.getCurrentLine().getTextWithoutNewLine() ); - std::list::iterator ite; + std::vector::iterator ite; for ( ite = cmds.begin(); ite != cmds.end(); ++ite ) privPushText( ( *ite ) ); diff --git a/src/eepp/ui/uilistbox.cpp b/src/eepp/ui/uilistbox.cpp index c9c4ee0bd..9ab7c76ef 100644 --- a/src/eepp/ui/uilistbox.cpp +++ b/src/eepp/ui/uilistbox.cpp @@ -428,7 +428,7 @@ void UIListBox::createItemIndex( const Uint32& i ) { itemUpdateSize( mItems[i] ); - for ( std::list::iterator it = mSelected.begin(); it != mSelected.end(); ++it ) { + for ( auto it = mSelected.begin(); it != mSelected.end(); ++it ) { if ( *it == i ) { mItems[i]->select(); @@ -727,13 +727,13 @@ String UIListBox::getItemSelectedText() const { return tstr; } -std::list UIListBox::getItemsSelectedIndex() const { +std::vector UIListBox::getItemsSelectedIndex() const { return mSelected; } -std::list UIListBox::getItemsSelected() { - std::list tItems; - std::list::iterator it; +std::vector UIListBox::getItemsSelected() { + std::vector tItems; + std::vector::iterator it; for ( it = mSelected.begin(); it != mSelected.end(); ++it ) { if ( NULL == mItems[*it] ) @@ -810,8 +810,7 @@ void UIListBox::setSelected( Uint32 Index ) { if ( Index < mItems.size() ) { if ( isMultiSelect() ) { - for ( std::list::iterator it = mSelected.begin(); it != mSelected.end(); - ++it ) { + for ( auto it = mSelected.begin(); it != mSelected.end(); ++it ) { if ( *it == Index ) return; } diff --git a/src/eepp/ui/uilistboxitem.cpp b/src/eepp/ui/uilistboxitem.cpp index bdb8afe5c..75e6ee521 100644 --- a/src/eepp/ui/uilistboxitem.cpp +++ b/src/eepp/ui/uilistboxitem.cpp @@ -96,7 +96,10 @@ void UIListBoxItem::select() { mNodeFlags &= ~NODE_FLAG_SELECTED; - LBParent->mSelected.remove( LBParent->getItemIndex( this ) ); + auto found = std::find( LBParent->mSelected.begin(), LBParent->mSelected.end(), + LBParent->getItemIndex( this ) ); + if ( found != LBParent->mSelected.end() ) + LBParent->mSelected.erase( found ); LBParent->sendCommonEvent( Event::OnSelectionChanged ); } } else { diff --git a/src/eepp/ui/uiscenenode.cpp b/src/eepp/ui/uiscenenode.cpp index de06c6095..100e56774 100644 --- a/src/eepp/ui/uiscenenode.cpp +++ b/src/eepp/ui/uiscenenode.cpp @@ -231,13 +231,16 @@ void UISceneNode::setFocusLastWindow( UIWindow* window ) { void UISceneNode::windowAdd( UIWindow* win ) { if ( !windowExists( win ) ) { - mWindowsList.push_front( win ); + mWindowsList.insert( mWindowsList.begin(), win ); WindowEvent wevent( this, win, Event::OnWindowAdded ); sendEvent( &wevent ); } else { //! Send to front - mWindowsList.remove( win ); - mWindowsList.push_front( win ); + auto found = std::find( mWindowsList.begin(), mWindowsList.end(), win ); + if ( found != mWindowsList.end() ) { + mWindowsList.erase( found ); + mWindowsList.insert( mWindowsList.begin(), win ); + } } } @@ -245,7 +248,9 @@ void UISceneNode::windowRemove( UIWindow* win ) { if ( windowExists( win ) ) { WindowEvent wevent( this, win, Event::OnWindowRemoved ); sendEvent( &wevent ); - mWindowsList.remove( win ); + auto found = std::find( mWindowsList.begin(), mWindowsList.end(), win ); + if ( found != mWindowsList.end() ) + mWindowsList.erase( found ); } } diff --git a/src/eepp/ui/uitextedit.cpp b/src/eepp/ui/uitextedit.cpp index bbf94091c..9b345c81f 100644 --- a/src/eepp/ui/uitextedit.cpp +++ b/src/eepp/ui/uitextedit.cpp @@ -92,7 +92,10 @@ void UITextEdit::onDocumentLineChanged( const Int64& lineIndex ) { } void UITextEdit::drawLineText( const Int64& index, Vector2f position, const Float&, const Float& ) { + Color fontColor( mFontStyleConfig.FontColor ); + mFontStyleConfig.FontColor.blendAlpha( mAlpha ); getLineText( index ).draw( position.x, position.y ); + mFontStyleConfig.FontColor = fontColor; } bool UITextEdit::applyProperty( const StyleSheetProperty& attribute ) { diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index aa473e024..d39311a8c 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -1257,7 +1257,7 @@ void UIWindow::nodeDraw() { ClippingMask* clippingMask = GLi->getClippingMask(); - std::list clips = clippingMask->getPlanesClipped(); + const std::vector& clips = clippingMask->getPlanesClipped(); if ( !clips.empty() ) clippingMask->clipPlaneDisable(); diff --git a/src/eepp/window/engine.cpp b/src/eepp/window/engine.cpp index 270b0f830..b8ca5af5f 100644 --- a/src/eepp/window/engine.cpp +++ b/src/eepp/window/engine.cpp @@ -193,8 +193,6 @@ void Engine::destroyWindow( EE::Window::Window* window ) { } bool Engine::existsWindow( EE::Window::Window* window ) { - std::list::iterator it; - for ( auto& it : mWindows ) { if ( it.second == window ) return true; diff --git a/src/modules/maps/include/eepp/maps/mapeditor/mapeditor.hpp b/src/modules/maps/include/eepp/maps/mapeditor/mapeditor.hpp index 0d999dd37..340800d96 100644 --- a/src/modules/maps/include/eepp/maps/mapeditor/mapeditor.hpp +++ b/src/modules/maps/include/eepp/maps/mapeditor/mapeditor.hpp @@ -99,7 +99,7 @@ class EE_MAPS_API MapEditor { Int32 mLastSelButtonY; bool mMouseScrolling; - std::list mObjContButton; + std::vector mObjContButton; void onRedChange( const Event* Event ); diff --git a/src/modules/maps/include/eepp/maps/maplightmanager.hpp b/src/modules/maps/include/eepp/maps/maplightmanager.hpp index 51c9c1319..fde550cc3 100644 --- a/src/modules/maps/include/eepp/maps/maplightmanager.hpp +++ b/src/modules/maps/include/eepp/maps/maplightmanager.hpp @@ -3,7 +3,6 @@ #include #include -#include namespace EE { namespace Maps { @@ -11,7 +10,7 @@ class TileMap; class EE_MAPS_API MapLightManager { public: - typedef std::list LightsList; + typedef std::vector LightsList; MapLightManager( TileMap* Map, bool ByVertex ); diff --git a/src/modules/maps/include/eepp/maps/mapobjectlayer.hpp b/src/modules/maps/include/eepp/maps/mapobjectlayer.hpp index df04750db..5863645ba 100644 --- a/src/modules/maps/include/eepp/maps/mapobjectlayer.hpp +++ b/src/modules/maps/include/eepp/maps/mapobjectlayer.hpp @@ -3,7 +3,6 @@ #include #include -#include namespace EE { namespace Maps { @@ -13,7 +12,7 @@ class EE_MAPS_API MapObjectLayer : public MapLayer { public: enum SEARCH_TYPE { SEARCH_OBJECT = 1, SEARCH_POLY, SEARCH_ALL }; - typedef std::list ObjList; + typedef std::vector ObjList; virtual ~MapObjectLayer(); diff --git a/src/modules/maps/include/eepp/maps/tilemap.hpp b/src/modules/maps/include/eepp/maps/tilemap.hpp index 3036ae143..0c77b89e8 100644 --- a/src/modules/maps/include/eepp/maps/tilemap.hpp +++ b/src/modules/maps/include/eepp/maps/tilemap.hpp @@ -29,7 +29,7 @@ class UIMapNew; class EE_MAPS_API TileMap { public: typedef std::map PropertiesMap; - typedef std::list GOTypesList; //! Special object types used in this map + typedef std::vector GOTypesList; //! Special object types used in this map typedef std::function CreateGOCb; typedef std::function MapDrawCb; diff --git a/src/modules/maps/src/eepp/maps/mapeditor/mapeditor.cpp b/src/modules/maps/src/eepp/maps/mapeditor/mapeditor.cpp index 5fe72f542..8cea2afd6 100644 --- a/src/modules/maps/src/eepp/maps/mapeditor/mapeditor.cpp +++ b/src/modules/maps/src/eepp/maps/mapeditor/mapeditor.cpp @@ -652,8 +652,7 @@ void MapEditor::onObjectModeSel( const Event* Event ) { UISelectButton* Button = static_cast( Event->getNode() ); UISelectButton* ButtonT = NULL; - for ( std::list::iterator it = mObjContButton.begin(); - it != mObjContButton.end(); ++it ) { + for ( auto it = mObjContButton.begin(); it != mObjContButton.end(); ++it ) { ButtonT = *it; ButtonT->unselect(); diff --git a/src/modules/maps/src/eepp/maps/maplightmanager.cpp b/src/modules/maps/src/eepp/maps/maplightmanager.cpp index 763cd95ea..713a96883 100644 --- a/src/modules/maps/src/eepp/maps/maplightmanager.cpp +++ b/src/modules/maps/src/eepp/maps/maplightmanager.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -162,19 +163,28 @@ void MapLightManager::addLight( MapLight* Light ) { } void MapLightManager::removeLight( MapLight* Light ) { - mLights.remove( Light ); + auto found = std::find( mLights.begin(), mLights.end(), Light ); + if ( found != mLights.end() ) + mLights.erase( found ); } void MapLightManager::removeLight( const Vector2f& OverPos ) { + std::vector toRemove; for ( LightsList::reverse_iterator it = mLights.rbegin(); it != mLights.rend(); ++it ) { MapLight* Light = ( *it ); if ( Light->getAABB().contains( OverPos ) ) { - mLights.remove( Light ); + toRemove.push_back( Light ); eeSAFE_DELETE( Light ); break; } } + + for ( const auto& rem : toRemove ) { + auto found = std::find( mLights.begin(), mLights.end(), rem ); + if ( found != mLights.end() ) + mLights.erase( found ); + } } const Color* MapLightManager::getTileColor( const Vector2i& TilePos ) { diff --git a/src/modules/maps/src/eepp/maps/mapobjectlayer.cpp b/src/modules/maps/src/eepp/maps/mapobjectlayer.cpp index 477565e87..8cf969e06 100644 --- a/src/modules/maps/src/eepp/maps/mapobjectlayer.cpp +++ b/src/modules/maps/src/eepp/maps/mapobjectlayer.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -26,6 +27,9 @@ void MapObjectLayer::deallocateLayer() { } void MapObjectLayer::draw( const Vector2f& Offset ) { + if ( Offset != mOffset ) + mOffset = Offset; + GlobalBatchRenderer::instance()->draw(); ObjList::iterator it; @@ -72,8 +76,9 @@ void MapObjectLayer::addGameObject( GameObject* obj ) { } void MapObjectLayer::removeGameObject( GameObject* obj ) { - mObjects.remove( obj ); - + auto found = std::find( mObjects.begin(), mObjects.end(), obj ); + if ( found != mObjects.end() ) + mObjects.erase( found ); eeSAFE_DELETE( obj ); } diff --git a/src/modules/maps/src/eepp/maps/tilemap.cpp b/src/modules/maps/src/eepp/maps/tilemap.cpp index 5af687e4d..e083a4fcf 100644 --- a/src/modules/maps/src/eepp/maps/tilemap.cpp +++ b/src/modules/maps/src/eepp/maps/tilemap.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -786,12 +787,14 @@ TileMap::PropertiesMap& TileMap::getProperties() { } void TileMap::addVirtualObjectType( const std::string& name ) { - mObjTypes.push_back( name ); - mObjTypes.unique(); + if ( std::find( mObjTypes.begin(), mObjTypes.end(), name ) == mObjTypes.end() ) + mObjTypes.push_back( name ); } void TileMap::removeVirtualObjectType( const std::string& name ) { - mObjTypes.remove( name ); + auto found = std::find( mObjTypes.begin(), mObjTypes.end(), name ); + if ( found == mObjTypes.end() ) + mObjTypes.erase( found ); } void TileMap::clearVirtualObjectTypes() { diff --git a/src/tools/ecode/applayout.xml.hpp b/src/tools/ecode/applayout.xml.hpp new file mode 100644 index 000000000..d320583cd --- /dev/null +++ b/src/tools/ecode/applayout.xml.hpp @@ -0,0 +1,474 @@ +R"html( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + " + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +)html" diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index f3c308287..86064a6d6 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -1,5 +1,6 @@ #include "ecode.hpp" #include "featureshealth.hpp" +#include "iconmanager.hpp" #include "pathhelper.hpp" #include "plugins/autocomplete/autocompleteplugin.hpp" #include "plugins/formatter/formatterplugin.hpp" @@ -51,7 +52,7 @@ bool App::onCloseRequestCallback( EE::Window::Window* ) { i18n( "confirm_ecode_exit", "Do you really want to close the code editor?\nAll changes will be lost." ) .unescape() ); - msgBox->addEventListener( Event::OnConfirm, [this]( const Event* ) { + msgBox->on( Event::OnConfirm, [this]( const Event* ) { saveProject(); saveConfig(); mWindow->close(); @@ -106,12 +107,12 @@ void App::saveAllProcess() { mTmpDocs.erase( &editor->getDocument() ); } else { UIFileDialog* dialog = saveFileDialog( editor, false ); - dialog->addEventListener( Event::SaveFile, [&, editor]( const Event* ) { + dialog->on( Event::SaveFile, [&, editor]( const Event* ) { updateEditorTabTitle( editor ); if ( mSplitter->getCurEditor() == editor ) updateEditorTitle( editor ); } ); - dialog->addEventListener( Event::OnWindowClose, [&, editor]( const Event* ) { + dialog->on( Event::OnWindowClose, [&, editor]( const Event* ) { mTmpDocs.erase( &editor->getDocument() ); if ( !SceneManager::instance()->isShuttingDown() && !mTmpDocs.empty() ) saveAllProcess(); @@ -191,12 +192,12 @@ void App::openFileDialog() { dialog->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL ); dialog->setTitle( i18n( "open_file", "Open File" ) ); dialog->setCloseShortcut( KEY_ESCAPE ); - dialog->addEventListener( Event::OpenFile, [this]( const Event* event ) { + dialog->on( Event::OpenFile, [this]( const Event* event ) { auto file = event->getNode()->asType()->getFullPath(); mLastFileFolder = FileSystem::fileRemoveFileName( file ); loadFileFromPath( file ); } ); - dialog->addEventListener( Event::OnWindowClose, [this]( const Event* ) { + dialog->on( Event::OnWindowClose, [this]( const Event* ) { if ( mSplitter && mSplitter->getCurWidget() && !SceneManager::instance()->isShuttingDown() ) mSplitter->getCurWidget()->setFocus(); } ); @@ -235,12 +236,12 @@ void App::openFolderDialog() { dialog->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL ); dialog->setTitle( i18n( "open_folder", "Open Folder" ) ); dialog->setCloseShortcut( KEY_ESCAPE ); - dialog->addEventListener( Event::OpenFile, [this]( const Event* event ) { + dialog->on( Event::OpenFile, [this]( const Event* event ) { String path( event->getNode()->asType()->getFullPath() ); if ( FileSystem::isDirectory( path ) ) loadFolder( path ); } ); - dialog->addEventListener( Event::OnWindowClose, [this]( const Event* ) { + dialog->on( Event::OnWindowClose, [this]( const Event* ) { if ( mSplitter && mSplitter->getCurWidget() && !SceneManager::instance()->isShuttingDown() ) mSplitter->getCurWidget()->setFocus(); } ); @@ -263,11 +264,11 @@ void App::openFontDialog( std::string& fontPath, bool loadingMonoFont ) { dialog->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL ); dialog->setTitle( i18n( "select_font_file", "Select Font File" ) ); dialog->setCloseShortcut( KEY_ESCAPE ); - dialog->addEventListener( Event::OnWindowClose, [this]( const Event* ) { + dialog->on( Event::OnWindowClose, [this]( const Event* ) { if ( mSplitter && mSplitter->getCurWidget() && !SceneManager::instance()->isShuttingDown() ) mSplitter->getCurWidget()->setFocus(); } ); - dialog->addEventListener( Event::OpenFile, [&, loadingMonoFont]( const Event* event ) { + dialog->on( Event::OpenFile, [&, loadingMonoFont]( const Event* event ) { auto newPath = event->getNode()->asType()->getFullPath(); if ( String::startsWith( newPath, mResPath ) ) newPath = newPath.substr( mResPath.size() ); @@ -299,10 +300,10 @@ void App::openFontDialog( std::string& fontPath, bool loadingMonoFont ) { "flagged as monospace.\nDo you want to load it anyways?\nPerformance " "and memory usage will be awful without a monospaced font." ) .unescape() ); - msgBox->addEventListener( - Event::OnConfirm, - [&, loadMonoFont, fontMono]( const Event* ) { loadMonoFont( fontMono ); } ); - msgBox->addEventListener( Event::OnCancel, [fontMono]( const Event* ) { + msgBox->on( Event::OnConfirm, [&, loadMonoFont, fontMono]( const Event* ) { + loadMonoFont( fontMono ); + } ); + msgBox->on( Event::OnCancel, [fontMono]( const Event* ) { FontManager::instance()->remove( fontMono ); } ); msgBox->setTitle( i18n( "confirm_loading_font", "Font loading confirmation" ) ); @@ -326,7 +327,7 @@ void App::downloadFileWebDialog() { msgBox->getTextInput()->setHint( i18n( "any_https_or_http_url", "Any https or http URL" ) ); msgBox->setCloseShortcut( { KEY_ESCAPE, KEYMOD_NONE } ); msgBox->showWhenReady(); - msgBox->addEventListener( Event::OnConfirm, [&, msgBox]( const Event* ) { + msgBox->on( Event::OnConfirm, [&, msgBox]( const Event* ) { std::string url( msgBox->getTextInput()->getText().toUtf8() ); downloadFileWeb( url ); if ( mSplitter->getCurWidget() ) @@ -351,7 +352,7 @@ UIFileDialog* App::saveFileDialog( UICodeEditor* editor, bool focusOnClose ) { if ( FileSystem::fileExtension( editor->getDocument().getFilename() ).empty() ) filename += editor->getSyntaxDefinition().getFileExtension(); dialog->setFileName( filename ); - dialog->addEventListener( Event::SaveFile, [&, editor]( const Event* event ) { + dialog->on( Event::SaveFile, [&, editor]( const Event* event ) { if ( editor ) { std::string path( event->getNode()->asType()->getFullPath() ); if ( !path.empty() && !FileSystem::isDirectory( path ) && @@ -375,7 +376,7 @@ UIFileDialog* App::saveFileDialog( UICodeEditor* editor, bool focusOnClose ) { } } ); if ( focusOnClose ) { - dialog->addEventListener( Event::OnWindowClose, [&, editor]( const Event* ) { + dialog->on( Event::OnWindowClose, [&, editor]( const Event* ) { if ( editor && !SceneManager::instance()->isShuttingDown() ) editor->setFocus(); } ); @@ -659,7 +660,7 @@ void App::updateRecentFiles() { menu->add( file ); menu->addSeparator(); menu->add( i18n( "clear_menu", "Clear Menu" ) )->setId( "clear-menu" ); - menu->addEventListener( Event::OnItemClicked, [this]( const Event* event ) { + menu->on( Event::OnItemClicked, [this]( const Event* event ) { if ( !event->getNode()->isType( UI_TYPE_MENUITEM ) ) return; const std::string& id = event->getNode()->asType()->getId(); @@ -701,7 +702,7 @@ void App::updateRecentFolders() { i18n( "restore_last_session_at_startup", "Restart last session at startup" ) ) ->setActive( mConfig.workspace.restoreLastSession ) ->setId( "restore-last-session-at-startup" ); - menu->addEventListener( Event::OnItemClicked, [this]( const Event* event ) { + menu->on( Event::OnItemClicked, [this]( const Event* event ) { if ( !event->getNode()->isType( UI_TYPE_MENUITEM ) ) return; const std::string& id = event->getNode()->asType()->getId(); @@ -837,7 +838,7 @@ void App::checkForUpdatesResponse( Http::Response response, bool fromStartup ) { auto addStartUpCheckbox = [this]( UIMessageBox* msg ) { msg->setId( "check_for_updates" ); - msg->addEventListener( Event::OnWindowReady, [this, msg]( const Event* ) { + msg->on( Event::OnWindowReady, [this, msg]( const Event* ) { msg->setVisible( false ); UICheckBox* cbox = UICheckBox::New(); cbox->addClass( "check_at_startup" ); @@ -852,7 +853,7 @@ void App::checkForUpdatesResponse( Http::Response response, bool fromStartup ) { msg->center(); msg->show(); } ); - cbox->addEventListener( Event::OnValueChange, [this, cbox]( const Event* ) { + cbox->on( Event::OnValueChange, [this, cbox]( const Event* ) { mConfig.workspace.checkForUpdatesAtStartup = cbox->isChecked(); } ); } ); @@ -874,7 +875,7 @@ void App::checkForUpdatesResponse( Http::Response response, bool fromStartup ) { .unescape() ); auto url( j.value( "html_url", "https://github.com/SpartanJ/ecode/releases/" ) ); - msg->addEventListener( Event::OnConfirm, [&, url, msg]( const Event* ) { + msg->on( Event::OnConfirm, [&, url, msg]( const Event* ) { Engine::instance()->openURI( url ); msg->closeWindow(); } ); @@ -957,7 +958,7 @@ void App::setUIScaleFactor() { msgBox->getTextInput()->setText( String::format( "%.2f", mConfig.windowState.pixelDensity ) ); msgBox->setCloseShortcut( { KEY_ESCAPE, 0 } ); msgBox->showWhenReady(); - msgBox->addEventListener( Event::OnConfirm, [&, msgBox]( const Event* ) { + msgBox->on( Event::OnConfirm, [&, msgBox]( const Event* ) { msgBox->closeWindow(); Float val; if ( String::fromString( val, msgBox->getTextInput()->getText() ) && val >= 1 && @@ -992,7 +993,7 @@ void App::setEditorFontSize() { msgBox->getTextInput()->setText( mConfig.editor.fontSize.toString() ); msgBox->setCloseShortcut( { KEY_ESCAPE, 0 } ); msgBox->showWhenReady(); - msgBox->addEventListener( Event::OnConfirm, [&, msgBox]( const Event* ) { + msgBox->on( Event::OnConfirm, [&, msgBox]( const Event* ) { mConfig.editor.fontSize = StyleSheetLength( msgBox->getTextInput()->getText() ); mSplitter->forEachEditor( [this]( UICodeEditor* editor ) { editor->setFontSize( mConfig.editor.fontSize.asDp( 0, Sizef(), mDisplayDPI ) ); @@ -1008,7 +1009,7 @@ void App::setTerminalFontSize() { msgBox->getTextInput()->setText( mConfig.term.fontSize.toString() ); msgBox->setCloseShortcut( { KEY_ESCAPE, 0 } ); msgBox->showWhenReady(); - msgBox->addEventListener( Event::OnConfirm, [&, msgBox]( const Event* ) { + msgBox->on( Event::OnConfirm, [&, msgBox]( const Event* ) { mConfig.term.fontSize = StyleSheetLength( msgBox->getTextInput()->getText() ); mSplitter->forEachWidget( [this]( UIWidget* widget ) { if ( widget && widget->isType( UI_TYPE_TERMINAL ) ) @@ -1026,7 +1027,7 @@ void App::setUIFontSize() { msgBox->getTextInput()->setText( mConfig.ui.fontSize.toString() ); msgBox->setCloseShortcut( { KEY_ESCAPE, 0 } ); msgBox->showWhenReady(); - msgBox->addEventListener( Event::OnConfirm, [&, msgBox]( const Event* ) { + msgBox->on( Event::OnConfirm, [&, msgBox]( const Event* ) { mConfig.ui.fontSize = StyleSheetLength( msgBox->getTextInput()->getText() ); Float fontSize = mConfig.ui.fontSize.asDp( 0, Sizef(), mDisplayDPI ); UIThemeManager* manager = mUISceneNode->getUIThemeManager(); @@ -1054,7 +1055,7 @@ void App::setUIPanelFontSize() { msgBox->getTextInput()->setText( mConfig.ui.panelFontSize.toString() ); msgBox->setCloseShortcut( { KEY_ESCAPE, 0 } ); msgBox->showWhenReady(); - msgBox->addEventListener( Event::OnConfirm, [&, msgBox]( const Event* ) { + msgBox->on( Event::OnConfirm, [&, msgBox]( const Event* ) { mConfig.ui.panelFontSize = StyleSheetLength( msgBox->getTextInput()->getText() ); // Update the CSS @@ -1079,7 +1080,7 @@ void App::setUIPanelFontSize() { } void App::setFocusEditorOnClose( UIMessageBox* msgBox ) { - msgBox->addEventListener( Event::OnClose, [this]( const Event* ) { + msgBox->on( Event::OnClose, [this]( const Event* ) { if ( mSplitter && mSplitter->getCurWidget() ) mSplitter->getCurWidget()->setFocus(); } ); @@ -1142,7 +1143,7 @@ void App::setLineBreakingColumn() { msgBox->getTextInput()->setAllowOnlyNumbers( true, false ); msgBox->getTextInput()->setText( String::toString( mConfig.doc.lineBreakingColumn ) ); msgBox->showWhenReady(); - msgBox->addEventListener( Event::OnConfirm, [&, msgBox]( const Event* ) { + msgBox->on( Event::OnConfirm, [&, msgBox]( const Event* ) { int val; if ( String::fromString( val, msgBox->getTextInput()->getText() ) && val >= 0 ) { mConfig.doc.lineBreakingColumn = val; @@ -1162,7 +1163,7 @@ void App::setLineSpacing() { msgBox->setCloseShortcut( { KEY_ESCAPE, 0 } ); msgBox->getTextInput()->setText( mConfig.editor.lineSpacing.toString() ); msgBox->showWhenReady(); - msgBox->addEventListener( Event::OnConfirm, [&, msgBox]( const Event* ) { + msgBox->on( Event::OnConfirm, [&, msgBox]( const Event* ) { mConfig.editor.lineSpacing = StyleSheetLength( msgBox->getTextInput()->getText() ); mSplitter->forEachEditor( [this]( UICodeEditor* editor ) { editor->setLineSpacing( mConfig.editor.lineSpacing ); @@ -1180,7 +1181,7 @@ void App::setCursorBlinkingTime() { msgBox->setCloseShortcut( { KEY_ESCAPE, 0 } ); msgBox->getTextInput()->setText( mConfig.editor.cursorBlinkingTime.toString() ); msgBox->showWhenReady(); - msgBox->addEventListener( Event::OnConfirm, [&, msgBox]( const Event* ) { + msgBox->on( Event::OnConfirm, [&, msgBox]( const Event* ) { mConfig.editor.cursorBlinkingTime = Time::fromString( msgBox->getTextInput()->getText().toUtf8() ); mSplitter->forEachEditor( [this]( UICodeEditor* editor ) { @@ -1950,7 +1951,7 @@ void App::closeFolder() { UIMessageBox::OK_CANCEL, i18n( "confirm_close_folder", "Do you really want to close the folder?\nSome files haven't been saved." ) ); - msgBox->addEventListener( Event::OnConfirm, [this]( const Event* ) { closeEditors(); } ); + msgBox->on( Event::OnConfirm, [this]( const Event* ) { closeEditors(); } ); msgBox->setTitle( i18n( "close_folder_question", "Close Folder?" ) ); msgBox->center(); msgBox->showWhenReady(); @@ -1989,7 +1990,7 @@ void App::createDocAlert( UICodeEditor* editor ) { editor->enableReportSizeChangeToChilds(); docAlert->find( "file_reload" ) - ->addEventListener( Event::MouseClick, [editor, docAlert]( const Event* event ) { + ->on( Event::MouseClick, [editor, docAlert]( const Event* event ) { const MouseEvent* mouseEvent = static_cast( event ); if ( mouseEvent->getFlags() & EE_BUTTON_LMASK ) { editor->getDocument().reload(); @@ -2000,7 +2001,7 @@ void App::createDocAlert( UICodeEditor* editor ) { } ); docAlert->find( "file_overwrite" ) - ->addEventListener( Event::MouseClick, [editor, docAlert]( const Event* event ) { + ->on( Event::MouseClick, [editor, docAlert]( const Event* event ) { const MouseEvent* mouseEvent = static_cast( event ); if ( mouseEvent->getFlags() & EE_BUTTON_LMASK ) { editor->getDocument().save(); @@ -2011,7 +2012,7 @@ void App::createDocAlert( UICodeEditor* editor ) { } ); docAlert->find( "file_ignore" ) - ->addEventListener( Event::MouseClick, [docAlert, editor]( const Event* event ) { + ->on( Event::MouseClick, [docAlert, editor]( const Event* event ) { const MouseEvent* mouseEvent = static_cast( event ); if ( mouseEvent->getFlags() & EE_BUTTON_LMASK ) { editor->disableReportSizeChangeToChilds(); @@ -2213,7 +2214,7 @@ void App::onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) { doc.setCommand( "load-current-dir", [this] { loadCurrentDirectory(); } ); registerUnlockedCommands( doc ); - editor->addEventListener( Event::OnDocumentSave, [this]( const Event* event ) { + editor->on( Event::OnDocumentSave, [this]( const Event* event ) { UICodeEditor* editor = event->getNode()->asType(); updateEditorTabTitle( editor ); if ( mSplitter->curEditorExistsAndFocused() && mSplitter->getCurEditor() == editor ) @@ -2232,28 +2233,27 @@ void App::onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) { } } ); - editor->addEventListener( - Event::OnDocumentDirtyOnFileSysten, [&, editor]( const Event* event ) { - const DocEvent* docEvent = static_cast( event ); - FileInfo file( docEvent->getDoc()->getFileInfo().getFilepath() ); - TextDocument* doc = docEvent->getDoc(); - if ( doc->getFileInfo() != file ) { - if ( doc->isDirty() ) { - editor->runOnMainThread( [&, editor]() { createDocAlert( editor ); } ); - } else { - auto hash = String::hash( docEvent->getDoc()->getFilePath() ); - editor->removeActionsByTag( hash ); - editor->runOnMainThread( [doc]() { doc->reload(); }, Seconds( 0.5f ), hash ); - } + editor->on( Event::OnDocumentDirtyOnFileSysten, [&, editor]( const Event* event ) { + const DocEvent* docEvent = static_cast( event ); + FileInfo file( docEvent->getDoc()->getFileInfo().getFilepath() ); + TextDocument* doc = docEvent->getDoc(); + if ( doc->getFileInfo() != file ) { + if ( doc->isDirty() ) { + editor->runOnMainThread( [&, editor]() { createDocAlert( editor ); } ); + } else { + auto hash = String::hash( docEvent->getDoc()->getFilePath() ); + editor->removeActionsByTag( hash ); + editor->runOnMainThread( [doc]() { doc->reload(); }, Seconds( 0.5f ), hash ); } - } ); + } + } ); if ( !mKeybindings.empty() ) { editor->getKeyBindings().reset(); editor->getKeyBindings().addKeybindsStringUnordered( mKeybindings ); } - editor->addEventListener( Event::OnDocumentClosed, [this]( const Event* event ) { + editor->on( Event::OnDocumentClosed, [this]( const Event* event ) { if ( !appInstance ) return; const DocEvent* docEvent = static_cast( event ); @@ -2272,7 +2272,7 @@ void App::onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) { } } ); - editor->addEventListener( Event::OnDocumentMoved, [this]( const Event* event ) { + editor->on( Event::OnDocumentMoved, [this]( const Event* event ) { if ( !appInstance ) return; UICodeEditor* editor = event->getNode()->asType(); @@ -2302,7 +2302,7 @@ void App::onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) { editor->getDocument().setCommand( "show-image-preview", [this, editor]() { loadImageFromMemory( editor->getDocument().getText().toUtf8() ); } ); - editor->addEventListener( Event::OnCreateContextMenu, [this]( const Event* event ) { + editor->on( Event::OnCreateContextMenu, [this]( const Event* event ) { auto cevent = static_cast( event ); cevent->getMenu() ->add( i18n( "show_image_preview", "Show Image Preview" ), @@ -2314,12 +2314,12 @@ void App::onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) { docChanged( event ); }; - editor->addEventListener( Event::OnDocumentLoaded, docLoaded ); - editor->addEventListener( Event::OnDocumentChanged, docChanged ); - editor->addEventListener( Event::OnDocumentSave, docChanged ); - editor->addEventListener( Event::OnEditorTabReady, docChanged ); + editor->on( Event::OnDocumentLoaded, docLoaded ); + editor->on( Event::OnDocumentChanged, docChanged ); + editor->on( Event::OnDocumentSave, docChanged ); + editor->on( Event::OnEditorTabReady, docChanged ); - editor->addEventListener( Event::OnCursorPosChangeInteresting, [this, editor]( auto ) { + editor->on( Event::OnCursorPosChangeInteresting, [this, editor]( auto ) { mSplitter->addEditorPositionToNavigationHistory( editor ); } ); @@ -2507,7 +2507,7 @@ void App::renameFile( const FileInfo& file ) { newInputMsgBox( i18n( "rename_file", "Rename file" ) + " \"" + file.getFileName() + "\"", i18n( "enter_new_file_name", "Enter new file name:" ) ); msgBox->getTextInput()->setText( file.getFileName() ); - msgBox->addEventListener( Event::OnConfirm, [&, file, msgBox]( const Event* ) { + msgBox->on( Event::OnConfirm, [&, file, msgBox]( const Event* ) { auto newFilePath( getNewFilePath( file, msgBox, false ) ); if ( !FileSystem::fileExists( newFilePath ) || file.getFileName() != msgBox->getTextInput()->getText() ) { @@ -2545,7 +2545,7 @@ void App::toggleHiddenFiles() { void App::newFile( const FileInfo& file ) { UIMessageBox* msgBox = newInputMsgBox( i18n( "create_new_file", "Create new file" ), i18n( "enter_new_file_name", "Enter new file name:" ) ); - msgBox->addEventListener( Event::OnConfirm, [&, file, msgBox]( const Event* ) { + msgBox->on( Event::OnConfirm, [&, file, msgBox]( const Event* ) { auto newFilePath( getNewFilePath( file, msgBox ) ); if ( !FileSystem::fileExists( newFilePath ) ) { // Needs to create sub folders? @@ -2583,7 +2583,7 @@ void App::newFolder( const FileInfo& file ) { UIMessageBox* msgBox = newInputMsgBox( i18n( "create_new_folder", "Create new folder" ), i18n( "enter_new_folder_name", "Enter new folder name:" ) ); - msgBox->addEventListener( Event::OnConfirm, [&, file, msgBox]( const Event* ) { + msgBox->on( Event::OnConfirm, [&, file, msgBox]( const Event* ) { auto newFolderPath( getNewFilePath( file, msgBox ) ); if ( !FileSystem::fileExists( newFolderPath ) ) { if ( !FileSystem::makeDir( newFolderPath ) ) { @@ -2613,7 +2613,7 @@ void App::createAndShowRecentFolderPopUpMenu( Node* recentFolderBut ) { return; for ( const auto& file : mRecentFolders ) menu->add( file ); - menu->addEventListener( Event::OnItemClicked, [this]( const Event* event ) { + menu->on( Event::OnItemClicked, [this]( const Event* event ) { if ( !event->getNode()->isType( UI_TYPE_MENUITEM ) ) return; const String& txt = event->getNode()->asType()->getText(); @@ -2632,7 +2632,7 @@ void App::createAndShowRecentFilesPopUpMenu( Node* recentFilesBut ) { return; for ( const auto& file : mRecentFiles ) menu->add( file ); - menu->addEventListener( Event::OnItemClicked, [this]( const Event* event ) { + menu->on( Event::OnItemClicked, [this]( const Event* event ) { if ( !event->getNode()->isType( UI_TYPE_MENUITEM ) ) return; const String& txt = event->getNode()->asType()->getText(); @@ -2672,12 +2672,12 @@ void App::consoleToggle() { void App::initProjectTreeView( std::string path ) { mProjectViewEmptyCont = mUISceneNode->find( "project_view_empty" ); mProjectViewEmptyCont->find( "open_folder" ) - ->addEventListener( Event::MouseClick, [this]( const Event* event ) { + ->on( Event::MouseClick, [this]( const Event* event ) { if ( event->asMouseEvent()->getFlags() & EE_BUTTON_LMASK ) runCommand( "open-folder" ); } ); mProjectViewEmptyCont->find( "open_recent_folder" ) - ->addEventListener( Event::MouseClick, [this]( const Event* event ) { + ->on( Event::MouseClick, [this]( const Event* event ) { if ( event->asMouseEvent()->getFlags() & EE_BUTTON_LMASK ) createAndShowRecentFolderPopUpMenu( mProjectViewEmptyCont->find( "open_recent_folder" ) ); @@ -2695,7 +2695,7 @@ void App::initProjectTreeView( std::string path ) { mProjectTreeView->setHeadersVisible( false ); mProjectTreeView->setExpandersAsIcons( true ); mProjectTreeView->setSingleClickNavigation( mConfig.editor.singleClickTreeNavigation ); - mProjectTreeView->addEventListener( Event::OnModelEvent, [this]( const Event* event ) { + mProjectTreeView->on( Event::OnModelEvent, [this]( const Event* event ) { const ModelEvent* modelEvent = static_cast( event ); ModelEventType type = modelEvent->getModelEventType(); if ( type == ModelEventType::Open || type == ModelEventType::OpenMenu ) { @@ -2722,12 +2722,12 @@ void App::initProjectTreeView( std::string path ) { } } } ); - mProjectTreeView->addEventListener( Event::MouseClick, [this]( const Event* event ) { + mProjectTreeView->on( Event::MouseClick, [this]( const Event* event ) { const MouseEvent* mouseEvent = static_cast( event ); if ( mouseEvent->getFlags() & EE_BUTTON_RMASK ) mSettings->createProjectTreeMenu(); } ); - mProjectTreeView->addEventListener( Event::KeyDown, [this]( const Event* event ) { + mProjectTreeView->on( Event::KeyDown, [this]( const Event* event ) { if ( !mFileSystemModel ) return 0; const KeyEvent* keyEvent = static_cast( event ); @@ -3085,7 +3085,10 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe if ( mConfig.windowState.position != Vector2i( -1, -1 ) && mConfig.windowState.displayIndex < displayManager->getDisplayCount() ) { - mWindow->setPosition( mConfig.windowState.position.x, mConfig.windowState.position.y ); + // 1 px offset to avoid a bug in SDL2 2.28 when maximazing windows + mWindow->setPosition( mConfig.windowState.position.x + + ( mConfig.windowState.maximized ? -1 : 0 ), + mConfig.windowState.position.y ); } if ( mWindow->isWindowed() && mWindow->getSize() >= currentDisplay->getSize().asInt() ) { @@ -3097,8 +3100,11 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe PixelDensity::setPixelDensity( mConfig.windowState.pixelDensity ); - if ( mConfig.windowState.maximized ) - mWindow->maximize(); +#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN + if ( mConfig.windowState.maximized ) { + mThreadPool->run( [this] { mWindow->maximize(); } ); + } +#endif mWindow->setCloseRequestCallback( [this]( EE::Window::Window* win ) -> bool { return onCloseRequestCallback( win ); } ); @@ -3171,692 +3177,12 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe mConfig.ui.panelFontSize.toString().c_str() ) ); mUISceneNode->combineStyleSheet( panelUI, false ); - const auto baseUI = R"html( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - )html"; + const auto baseUI = ( +#include "applayout.xml.hpp" + ); mMenuIconSize = mConfig.ui.fontSize.asPixels( 0, Sizef(), mDisplayDPI ); - UIIconTheme* iconTheme = UIIconTheme::New( "ecode" ); - std::unordered_map icons = { { "document-new", 0xecc3 }, - { "document-open", 0xed70 }, - { "document-save", 0xf0b3 }, - { "document-save-as", 0xf0b3 }, - { "document-close", 0xeb99 }, - { "quit", 0xeb97 }, - { "undo", 0xea58 }, - { "redo", 0xea5a }, - { "cut", 0xf0c1 }, - { "copy", 0xecd5 }, - { "paste", 0xeb91 }, - { "edit", 0xec86 }, - { "split-horizontal", 0xf17a }, - { "split-vertical", 0xf17b }, - { "find-replace", 0xed2b }, - { "folder-add", 0xed5a }, - { "file-add", 0xecc9 }, - { "file-copy", 0xecd3 }, - { "file-code", 0xecd1 }, - { "file-edit", 0xecdb }, - { "font-size", 0xed8d }, - { "delete-bin", 0xec1e }, - { "delete-text", 0xec1e }, - { "zoom-in", 0xf2db }, - { "zoom-out", 0xf2dd }, - { "zoom-reset", 0xeb47 }, - { "fullscreen", 0xed9c }, - { "keybindings", 0xee75 }, - { "search", 0xf0d1 }, - { "go-up", 0xea78 }, - { "ok", 0xeb7a }, - { "cancel", 0xeb98 }, - { "color-picker", 0xf13d }, - { "pixel-density", 0xed8c }, - { "go-to-line", 0xf1f8 }, - { "table-view", 0xf1de }, - { "list-view", 0xecf1 }, - { "menu-unfold", 0xef40 }, - { "menu-fold", 0xef3d }, - { "download-cloud", 0xec58 }, - { "layout-left", 0xee94 }, - { "layout-right", 0xee9b }, - { "color-scheme", 0xebd4 }, - { "global-settings", 0xedcf }, - { "folder-user", 0xed84 }, - { "help", 0xf045 }, - { "terminal", 0xf1f6 }, - { "earth", 0xec7a }, - { "arrow-down", 0xea4c }, - { "arrow-up", 0xea76 }, - { "arrow-down-s", 0xea4e }, - { "arrow-up-s", 0xea78 }, - { "arrow-right-s", 0xea6e }, - { "match-case", 0xed8d }, - { "palette", 0xefc5 }, - { "file-code", 0xecd1 }, - { "cursor-pointer", 0xec09 }, - { "drive", 0xedf8 }, - { "refresh", 0xf064 }, - { "hearth-pulse", 0xee10 }, - { "add", 0xea12 }, - { "hammer", 0xedee }, - { "eraser", 0xec9e }, - { "file-search", 0xed05 } }; - - for ( const auto& icon : icons ) - iconTheme->add( UIGlyphIcon::New( icon.first, iconFont, icon.second ) ); - - if ( mimeIconFont && mimeIconFont->loaded() ) { - std::unordered_map mimeIcons = - - { { "filetype-lua", 61826 }, - { "filetype-c", 61718 }, - { "filetype-h", 61792 }, - { "filetype-cs", 61720 }, - { "filetype-cpp", 61719 }, - { "filetype-hpp", 61719 }, - { "filetype-css", 61743 }, - { "filetype-conf", 61781 }, - { "filetype-cfg", 61781 }, - { "filetype-desktop", 61781 }, - { "filetype-service", 61781 }, - { "filetype-env", 61781 }, - { "filetype-properties", 61781 }, - { "filetype-ini", 61781 }, - { "filetype-dart", 61744 }, - { "filetype-diff", 61752 }, - { "filetype-zip", 61775 }, - { "filetype-go", 61789 }, - { "filetype-htm", 61799 }, - { "filetype-html", 61799 }, - { "filetype-java", 61809 }, - { "filetype-js", 61810 }, - { "filetype-json", 61811 }, - { "filetype-kt", 61814 }, - { "filetype-md", 61829 }, - { "filetype-perl", 61853 }, - { "filetype-php", 61855 }, - { "filetype-py", 61863 }, - { "filetype-pyc", 61863 }, - { "filetype-pyd", 61863 }, - { "filetype-swift", 61906 }, - { "filetype-rb", 61880 }, - { "filetype-rs", 61881 }, - { "filetype-ts", 61923 }, - { "filetype-yaml", 61945 }, - { "filetype-yml", 61945 }, - { "filetype-jpg", 61801 }, - { "filetype-png", 61801 }, - { "filetype-jpeg", 61801 }, - { "filetype-bmp", 61801 }, - { "filetype-tga", 61801 }, - { "filetype-sh", 61911 }, - { "filetype-bash", 61911 }, - { "filetype-fish", 61911 }, - { "filetype-scala", 61882 }, - { "filetype-r", 61866 }, - { "filetype-rake", 61880 }, - { "filetype-rss", 61879 }, - { "filetype-sql", 61746 }, - { "filetype-elm", 61763 }, - { "filetype-ex", 61971 }, - { "filetype-exs", 61971 }, - { "filetype-awk", 61971 }, - { "filetype-nim", 61734 }, - { "filetype-xml", 61769 }, - { "filetype-dockerfile", 61758 }, - { "filetype-ruby", 61880 }, - { "filetype-scala", 61882 }, - { "filetype-perl", 61853 }, - { "file", 61766 }, - { "file-symlink", 61774 }, - { "folder", 0xF23B }, - { "folder-open", 0xF23C }, - { "tree-expanded", 0xF11E }, - { "tree-contracted", 0xF120 }, - { "github", 0xF184 }, - { "package", 61846 }, - { "tab-close", 61944 } }; - - for ( const auto& icon : mimeIcons ) - iconTheme->add( UIGlyphIcon::New( icon.first, mimeIconFont, icon.second ) ); - } - - if ( codIconFont && codIconFont->loaded() ) { - std::unordered_map codIcons = { - { "symbol-text", 0xea93 }, - { "symbol-method", 0xea8c }, - { "symbol-function", 0xea8c }, - { "symbol-constructor", 0xea8c }, - { "symbol-field", 0xeb5f }, - { "symbol-variable", 0xea88 }, - { "symbol-class", 0xeb5b }, - { "symbol-interface", 0xeb61 }, - { "symbol-module", 0xea8b }, - { "symbol-property", 0xeb65 }, - { "symbol-unit", 0xea96 }, - { "symbol-value", 0xea95 }, - { "symbol-enum", 0xea95 }, - { "symbol-keyword", 0xeb62 }, - { "symbol-snippet", 0xeb66 }, - { "symbol-color", 0xeb5c }, - { "symbol-file", 0xeb60 }, - { "symbol-reference", 0xea94 }, - { "symbol-folder", 0xea83 }, - { "symbol-enum-member", 0xeb5e }, - { "symbol-constant", 0xeb5d }, - { "symbol-struct", 0xea91 }, - { "symbol-event", 0xea86 }, - { "symbol-operator", 0xeb64 }, - { "symbol-type-parameter", 0xea92 }, - { "expand-all", 0xeb95 }, - { "symbol-namespace", 0xea8b }, - { "symbol-package", 0xea8b }, - { "symbol-string", 0xeb8d }, - { "symbol-number", 0xea90 }, - { "symbol-boolean", 0xea8f }, - { "symbol-array", 0xea8a }, - { "symbol-object", 0xea8b }, - { "symbol-key", 0xea93 }, - { "symbol-null", 0xea8f }, - { "collapse-all", 0xeac5 }, - { "chevron-right", 0xeab6 }, - { "lightbulb-autofix", 0xeb13 }, - { "layout-sidebar-left-off", 0xec02 }, - { "layout-sidebar-left", 0xebf3 }, - { "warning", 0xea6c }, - { "error", 0xea87 }, - { "search-fuzzy", 0xec0d } }; - - for ( const auto& icon : codIcons ) - iconTheme->add( UIGlyphIcon::New( icon.first, codIconFont, icon.second ) ); - } - - iconTheme->add( UISVGIcon::New( - "ecode", - "" ) ); - - mUISceneNode->getUIIconThemeManager()->setCurrentTheme( iconTheme ); + IconManager::init( mUISceneNode, iconFont, mimeIconFont, codIconFont ); Clock defClock; SyntaxDefinitionManager::createSingleton(); @@ -3876,7 +3202,7 @@ Anchor.error:hover { mUISceneNode->bind( "doc_info", mDocInfo ); mUISceneNode->bind( "panel", mSidePanel ); mUISceneNode->bind( "project_splitter", mProjectSplitter ); - mUISceneNode->addEventListener( Event::KeyDown, [this]( const Event* event ) { + mUISceneNode->on( Event::KeyDown, [this]( const Event* event ) { trySendUnlockedCmd( *static_cast( event ) ); } ); if ( logLevel == LogLevel::Debug ) diff --git a/src/tools/ecode/iconmanager.cpp b/src/tools/ecode/iconmanager.cpp new file mode 100644 index 000000000..723a4240a --- /dev/null +++ b/src/tools/ecode/iconmanager.cpp @@ -0,0 +1,225 @@ +#include "iconmanager.hpp" +#include +#include + +namespace ecode { + +void IconManager::init( UISceneNode* sceneNode, FontTrueType* iconFont, FontTrueType* mimeIconFont, + FontTrueType* codIconFont ) { + + UIIconTheme* iconTheme = UIIconTheme::New( "ecode" ); + std::unordered_map icons = { + + { "document-new", 0xecc3 }, + { "document-open", 0xed70 }, + { "document-save", 0xf0b3 }, + { "document-save-as", 0xf0b3 }, + { "document-close", 0xeb99 }, + { "quit", 0xeb97 }, + { "undo", 0xea58 }, + { "redo", 0xea5a }, + { "cut", 0xf0c1 }, + { "copy", 0xecd5 }, + { "paste", 0xeb91 }, + { "edit", 0xec86 }, + { "split-horizontal", 0xf17a }, + { "split-vertical", 0xf17b }, + { "find-replace", 0xed2b }, + { "folder-add", 0xed5a }, + { "file-add", 0xecc9 }, + { "file-copy", 0xecd3 }, + { "file-code", 0xecd1 }, + { "file-edit", 0xecdb }, + { "font-size", 0xed8d }, + { "delete-bin", 0xec1e }, + { "delete-text", 0xec1e }, + { "zoom-in", 0xf2db }, + { "zoom-out", 0xf2dd }, + { "zoom-reset", 0xeb47 }, + { "fullscreen", 0xed9c }, + { "keybindings", 0xee75 }, + { "search", 0xf0d1 }, + { "go-up", 0xea78 }, + { "ok", 0xeb7a }, + { "cancel", 0xeb98 }, + { "color-picker", 0xf13d }, + { "pixel-density", 0xed8c }, + { "go-to-line", 0xf1f8 }, + { "table-view", 0xf1de }, + { "list-view", 0xecf1 }, + { "menu-unfold", 0xef40 }, + { "menu-fold", 0xef3d }, + { "download-cloud", 0xec58 }, + { "layout-left", 0xee94 }, + { "layout-right", 0xee9b }, + { "color-scheme", 0xebd4 }, + { "global-settings", 0xedcf }, + { "folder-user", 0xed84 }, + { "help", 0xf045 }, + { "terminal", 0xf1f6 }, + { "earth", 0xec7a }, + { "arrow-down", 0xea4c }, + { "arrow-up", 0xea76 }, + { "arrow-down-s", 0xea4e }, + { "arrow-up-s", 0xea78 }, + { "arrow-right-s", 0xea6e }, + { "match-case", 0xed8d }, + { "palette", 0xefc5 }, + { "file-code", 0xecd1 }, + { "cursor-pointer", 0xec09 }, + { "drive", 0xedf8 }, + { "refresh", 0xf064 }, + { "hearth-pulse", 0xee10 }, + { "add", 0xea12 }, + { "hammer", 0xedee }, + { "eraser", 0xec9e }, + { "file-search", 0xed05 } }; + + for ( const auto& icon : icons ) + iconTheme->add( UIGlyphIcon::New( icon.first, iconFont, icon.second ) ); + + if ( mimeIconFont && mimeIconFont->loaded() ) { + std::unordered_map mimeIcons = + + { { "filetype-lua", 61826 }, + { "filetype-c", 61718 }, + { "filetype-h", 61792 }, + { "filetype-cs", 61720 }, + { "filetype-cpp", 61719 }, + { "filetype-hpp", 61719 }, + { "filetype-css", 61743 }, + { "filetype-conf", 61781 }, + { "filetype-cfg", 61781 }, + { "filetype-desktop", 61781 }, + { "filetype-service", 61781 }, + { "filetype-env", 61781 }, + { "filetype-properties", 61781 }, + { "filetype-ini", 61781 }, + { "filetype-dart", 61744 }, + { "filetype-diff", 61752 }, + { "filetype-zip", 61775 }, + { "filetype-go", 61789 }, + { "filetype-htm", 61799 }, + { "filetype-html", 61799 }, + { "filetype-java", 61809 }, + { "filetype-js", 61810 }, + { "filetype-json", 61811 }, + { "filetype-kt", 61814 }, + { "filetype-md", 61829 }, + { "filetype-perl", 61853 }, + { "filetype-php", 61855 }, + { "filetype-py", 61863 }, + { "filetype-pyc", 61863 }, + { "filetype-pyd", 61863 }, + { "filetype-swift", 61906 }, + { "filetype-rb", 61880 }, + { "filetype-rs", 61881 }, + { "filetype-ts", 61923 }, + { "filetype-yaml", 61945 }, + { "filetype-yml", 61945 }, + { "filetype-jpg", 61801 }, + { "filetype-png", 61801 }, + { "filetype-jpeg", 61801 }, + { "filetype-bmp", 61801 }, + { "filetype-tga", 61801 }, + { "filetype-sh", 61911 }, + { "filetype-bash", 61911 }, + { "filetype-fish", 61911 }, + { "filetype-scala", 61882 }, + { "filetype-r", 61866 }, + { "filetype-rake", 61880 }, + { "filetype-rss", 61879 }, + { "filetype-sql", 61746 }, + { "filetype-elm", 61763 }, + { "filetype-ex", 61971 }, + { "filetype-exs", 61971 }, + { "filetype-awk", 61971 }, + { "filetype-nim", 61734 }, + { "filetype-xml", 61769 }, + { "filetype-dockerfile", 61758 }, + { "filetype-ruby", 61880 }, + { "filetype-scala", 61882 }, + { "filetype-perl", 61853 }, + { "file", 61766 }, + { "file-symlink", 61774 }, + { "folder", 0xF23B }, + { "folder-open", 0xF23C }, + { "tree-expanded", 0xF11E }, + { "tree-contracted", 0xF120 }, + { "github", 0xF184 }, + { "package", 61846 }, + { "tab-close", 61944 } }; + + for ( const auto& icon : mimeIcons ) + iconTheme->add( UIGlyphIcon::New( icon.first, mimeIconFont, icon.second ) ); + } + + if ( codIconFont && codIconFont->loaded() ) { + std::unordered_map codIcons = { + + { "symbol-text", 0xea93 }, + { "symbol-method", 0xea8c }, + { "symbol-function", 0xea8c }, + { "symbol-constructor", 0xea8c }, + { "symbol-field", 0xeb5f }, + { "symbol-variable", 0xea88 }, + { "symbol-class", 0xeb5b }, + { "symbol-interface", 0xeb61 }, + { "symbol-module", 0xea8b }, + { "symbol-property", 0xeb65 }, + { "symbol-unit", 0xea96 }, + { "symbol-value", 0xea95 }, + { "symbol-enum", 0xea95 }, + { "symbol-keyword", 0xeb62 }, + { "symbol-snippet", 0xeb66 }, + { "symbol-color", 0xeb5c }, + { "symbol-file", 0xeb60 }, + { "symbol-reference", 0xea94 }, + { "symbol-folder", 0xea83 }, + { "symbol-enum-member", 0xeb5e }, + { "symbol-constant", 0xeb5d }, + { "symbol-struct", 0xea91 }, + { "symbol-event", 0xea86 }, + { "symbol-operator", 0xeb64 }, + { "symbol-type-parameter", 0xea92 }, + { "expand-all", 0xeb95 }, + { "symbol-namespace", 0xea8b }, + { "symbol-package", 0xea8b }, + { "symbol-string", 0xeb8d }, + { "symbol-number", 0xea90 }, + { "symbol-boolean", 0xea8f }, + { "symbol-array", 0xea8a }, + { "symbol-object", 0xea8b }, + { "symbol-key", 0xea93 }, + { "symbol-null", 0xea8f }, + { "collapse-all", 0xeac5 }, + { "chevron-right", 0xeab6 }, + { "lightbulb-autofix", 0xeb13 }, + { "layout-sidebar-left-off", 0xec02 }, + { "layout-sidebar-left", 0xebf3 }, + { "warning", 0xea6c }, + { "error", 0xea87 }, + { "search-fuzzy", 0xec0d } }; + + for ( const auto& icon : codIcons ) + iconTheme->add( UIGlyphIcon::New( icon.first, codIconFont, icon.second ) ); + } + + iconTheme->add( UISVGIcon::New( + "ecode", + "" ) ); + + sceneNode->getUIIconThemeManager()->setCurrentTheme( iconTheme ); +} + +} // namespace ecode diff --git a/src/tools/ecode/iconmanager.hpp b/src/tools/ecode/iconmanager.hpp new file mode 100644 index 000000000..4abe59c1f --- /dev/null +++ b/src/tools/ecode/iconmanager.hpp @@ -0,0 +1,21 @@ +#ifndef ECODE_ICONMANAGER_HPP +#define ECODE_ICONMANAGER_HPP + +#include +#include + +using namespace EE; +using namespace EE::Graphics; +using namespace EE::UI; + +namespace ecode { + +class IconManager { + public: + static void init( UISceneNode* sceneNode, FontTrueType* iconFont, FontTrueType* mimeIconFont, + FontTrueType* codIconFont ); +}; + +} // namespace ecode + +#endif // ECODE_ICONMANAGER_HPP diff --git a/src/tools/ecode/plugins/lsp/lspclientserver.cpp b/src/tools/ecode/plugins/lsp/lspclientserver.cpp index 35131bb14..136a4e443 100644 --- a/src/tools/ecode/plugins/lsp/lspclientserver.cpp +++ b/src/tools/ecode/plugins/lsp/lspclientserver.cpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace ecode {