diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 46d4e1702..a21a090b2 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -1684,6 +1684,9 @@ void App::closeFolder() { } else { closeEditors(); } + + mProjectViewEmptyCont->setVisible( true ); + mFileSystemModel->setRootPath( "" ); } void App::createDocAlert( UICodeEditor* editor ) { @@ -2256,6 +2259,25 @@ void App::newFolder( const FileInfo& file ) { } ); } +void App::createAndShowRecentFolderPopUpMenu() { + UIPopUpMenu* menu = UIPopUpMenu::New(); + if ( mRecentFolders.empty() ) + return; + for ( const auto& file : mRecentFolders ) + menu->add( file ); + menu->addEventListener( Event::OnItemClicked, [&]( const Event* event ) { + if ( !event->getNode()->isType( UI_TYPE_MENUITEM ) ) + return; + const String& txt = event->getNode()->asType()->getText(); + loadFolder( txt ); + } ); + auto recentFolderBut = mProjectViewEmptyCont->find( "open_recent_folder" ); + auto pos = recentFolderBut->getScreenPos(); + pos.y += recentFolderBut->getPixelsSize().getHeight(); + menu->setPixelsPosition( pos ); + menu->show(); +} + void App::consoleToggle() { mConsole->toggle(); bool lock = mConsole->isActive(); @@ -2265,6 +2287,17 @@ void App::consoleToggle() { } void App::initProjectTreeView( std::string path ) { + mProjectViewEmptyCont = mUISceneNode->find( "project_view_empty" ); + mProjectViewEmptyCont->find( "open_folder" ) + ->addEventListener( Event::MouseClick, [&]( const Event* event ) { + if ( event->asMouseEvent()->getFlags() & EE_BUTTON_LMASK ) + runCommand( "open-folder" ); + } ); + mProjectViewEmptyCont->find( "open_recent_folder" ) + ->addEventListener( Event::MouseClick, [&]( const Event* event ) { + if ( event->asMouseEvent()->getFlags() & EE_BUTTON_LMASK ) + createAndShowRecentFolderPopUpMenu(); + } ); mProjectTreeView = mUISceneNode->find( "project_view" ); mProjectTreeView->setColumnsHidden( { FileSystemModel::Icon, FileSystemModel::Size, FileSystemModel::Group, @@ -2393,8 +2426,6 @@ void App::initProjectTreeView( std::string path ) { } } else if ( mConfig.workspace.restoreLastSession && !mRecentFolders.empty() ) { loadFolder( mRecentFolders[0] ); - } else if ( !mIsBundledApp ) { - loadFolder( "." ); } mProjectTreeView->setAutoExpandOnSingleColumn( true ); @@ -2532,6 +2563,8 @@ void App::loadFolder( const std::string& path ) { if ( !mCurrentProject.empty() ) closeEditors(); + mProjectViewEmptyCont->setVisible( false ); + std::string rpath( FileSystem::getRealPath( path ) ); FileSystem::dirAddSlashAtEnd( rpath ); @@ -2596,15 +2629,9 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe mBenchmarkMode = benchmarkMode; mResPath = Sys::getProcessPath(); -#if EE_PLATFORM == EE_PLATFORM_MACOSX - if ( String::contains( mResPath, "ecode.app" ) ) { - mIsBundledApp = true; - } -#elif EE_PLATFORM == EE_PLATFORM_LINUX - if ( String::contains( mResPath, ".mount_" ) ) { +#if EE_PLATFORM == EE_PLATFORM_LINUX + if ( String::contains( mResPath, ".mount_" ) ) FileSystem::dirAddSlashAtEnd( mResPath ); - mIsBundledApp = true; - } #elif EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN mResPath += "ecode/"; #endif @@ -2877,12 +2904,26 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe #check_for_updates .check_at_startup { margin: 6dp 0dp 6p 0dp; } + #project_view_empty { + padding-top: 8dp; + } + #project_view_empty > * { + margin-left: 8dp; + margin-right: 8dp; + } - - + + + + + + + + + @@ -2933,7 +2974,7 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe - + diff --git a/src/tools/ecode/ecode.hpp b/src/tools/ecode/ecode.hpp index 09afb39e5..fa8aa4cc7 100644 --- a/src/tools/ecode/ecode.hpp +++ b/src/tools/ecode/ecode.hpp @@ -314,6 +314,8 @@ class App : public UICodeEditorSplitter::Client { void loadFileDelayed(); + const std::vector& getRecentFolders() const; + protected: std::vector mArgs; EE::Window::Window* mWindow{ nullptr }; @@ -347,11 +349,11 @@ class App : public UICodeEditorSplitter::Client { std::shared_ptr mThreadPool; std::shared_ptr mDirTree; UITreeView* mProjectTreeView{ nullptr }; + UILinearLayout* mProjectViewEmptyCont{ nullptr }; std::shared_ptr mFileSystemModel; std::shared_ptr mFileSystemMatcher; size_t mMenuIconSize{ 16 }; bool mDirTreeReady{ false }; - bool mIsBundledApp{ false }; bool mUseFrameBuffer{ false }; bool mBenchmarkMode{ false }; Time mFrameTime{ Time::Zero }; @@ -460,6 +462,8 @@ class App : public UICodeEditorSplitter::Client { void cleanUpRecentFolders(); void cleanUpRecentFiles(); + + void createAndShowRecentFolderPopUpMenu(); }; } // namespace ecode