ecode: WIP Build settings fixes.

This commit is contained in:
Martín Lucas Golini
2023-06-02 01:56:22 -03:00
parent 84c9fe4e6b
commit ac416fab20
7 changed files with 77 additions and 26 deletions
@@ -136,6 +136,9 @@ class EE_API UICodeEditorSplitter {
void applyColorScheme( const SyntaxColorScheme& colorScheme );
void forEachWidgetClass( const std::string& className,
std::function<void( UIWidget* )> run ) const;
void forEachWidgetType( const UINodeType& nodeType,
std::function<void( UIWidget* )> run ) const;
+2
View File
@@ -40,6 +40,8 @@ class EE_API UITab : public UISelectButton {
virtual UIWidget* getExtraInnerWidget() const;
void removeTab( bool destroyOwnedNode = true, bool immediateClose = false );
protected:
friend class UITabWidget;
@@ -681,6 +681,22 @@ void UICodeEditorSplitter::applyColorScheme( const SyntaxColorScheme& colorSchem
mClient->onColorSchemeChanged( mCurrentColorScheme );
}
void UICodeEditorSplitter::forEachWidgetClass( const std::string& className,
std::function<void( UIWidget* )> run ) const {
Node* node;
UIWidget* widget;
for ( auto tabWidget : mTabWidgets ) {
for ( size_t i = 0; i < tabWidget->getTabCount(); i++ ) {
node = tabWidget->getTab( i )->getOwnedWidget();
if ( node && node->isWidget() ) {
widget = node->asType<UIWidget>();
if ( widget->hasClass( className ) )
run( widget );
}
}
}
}
void UICodeEditorSplitter::forEachWidgetType( const UINodeType& nodeType,
std::function<void( UIWidget* )> run ) const {
Node* node;
+4
View File
@@ -163,6 +163,10 @@ UIWidget* UITab::getExtraInnerWidget() const {
return mCloseButton;
}
void UITab::removeTab( bool destroyOwnedNode, bool immediateClose ) {
getTabWidget()->removeTab( this, destroyOwnedNode, immediateClose );
}
void UITab::setTheme( UITheme* Theme ) {
UIWidget::setTheme( Theme );
+26 -22
View File
@@ -5,6 +5,7 @@
#include "plugins/linter/linterplugin.hpp"
#include "plugins/lsp/lspclientplugin.hpp"
#include "settingsmenu.hpp"
#include "uibuildsettings.hpp"
#include "uiwelcomescreen.hpp"
#include "version.hpp"
#include <algorithm>
@@ -1653,7 +1654,8 @@ void App::onRealDocumentLoaded( UICodeEditor* editor, const std::string& path )
( !mDirTree || !mDirTree->isDirInTree( doc.getFileInfo().getFilepath() ) ) ) {
std::string dir( FileSystem::fileRemoveFileName( doc.getFileInfo().getFilepath() ) );
Lock l( mWatchesLock );
mFilesFolderWatches[dir] = mFileWatcher->addWatch( dir, mFileSystemListener );
if ( mFileWatcher )
mFilesFolderWatches[dir] = mFileWatcher->addWatch( dir, mFileSystemListener );
}
}
@@ -1820,6 +1822,10 @@ void App::closeEditors() {
tabWidget->removeTab( (UITab*)terminal->getData(), true, true );
}
mSplitter->forEachWidgetClass( "build_settings", []( UIWidget* widget ) {
widget->asType<UIBuildSettings>()->getTab()->removeTab( true, true );
} );
mCurrentProject = "";
mDirTree = nullptr;
if ( mFileSystemListener )
@@ -2265,23 +2271,22 @@ void App::updateEditorState() {
}
void App::removeFolderWatches() {
if ( mFileWatcher ) {
std::unordered_set<efsw::WatchID> folderWatches;
std::unordered_map<std::string, efsw::WatchID> filesFolderWatches;
{
Lock l( mWatchesLock );
folderWatches = mFolderWatches;
filesFolderWatches = mFilesFolderWatches;
mFolderWatches.clear();
mFilesFolderWatches.clear();
}
std::unordered_set<efsw::WatchID> folderWatches;
std::unordered_map<std::string, efsw::WatchID> filesFolderWatches;
for ( const auto& dir : folderWatches )
mFileWatcher->removeWatch( dir );
Lock l( mWatchesLock );
if ( !mFileWatcher )
return;
folderWatches = mFolderWatches;
filesFolderWatches = mFilesFolderWatches;
mFolderWatches.clear();
mFilesFolderWatches.clear();
for ( const auto& fileFolder : filesFolderWatches )
mFileWatcher->removeWatch( fileFolder.second );
}
for ( const auto& dir : folderWatches )
mFileWatcher->removeWatch( dir );
for ( const auto& fileFolder : filesFolderWatches )
mFileWatcher->removeWatch( fileFolder.second );
}
void App::loadDirTree( const std::string& path ) {
@@ -2300,15 +2305,14 @@ void App::loadDirTree( const std::string& path ) {
if ( mSplitter->curEditorExistsAndFocused() )
syncProjectTreeWithEditor( mSplitter->getCurEditor() );
} );
if ( mFileWatcher ) {
removeFolderWatches();
{
Lock l( mWatchesLock );
removeFolderWatches();
{
Lock l( mWatchesLock );
if ( mFileWatcher )
mFolderWatches.insert(
mFileWatcher->addWatch( dirTree.getPath(), mFileSystemListener, true ) );
}
mFileSystemListener->setDirTree( mDirTree );
}
mFileSystemListener->setDirTree( mDirTree );
},
SyntaxDefinitionManager::instance()->getExtensionsPatternsSupported() );
}
+21 -4
View File
@@ -202,8 +202,16 @@ UIBuildSettings* UIBuildSettings::New( ProjectBuild& build, ProjectBuildConfigur
return eeNew( UIBuildSettings, ( build, config ) );
}
UIBuildSettings::~UIBuildSettings() {
for ( const auto& cbs : mCbs ) {
for ( const auto& cb : cbs.second )
cbs.first->removeEventListener( cb );
}
}
UIBuildSettings::UIBuildSettings( ProjectBuild& build, ProjectBuildConfiguration& config ) :
mBuild( build ), mConfig( config ), mOldName( mBuild.getName() ) {
addClass( "build_settings" );
mUISceneNode->loadLayoutFromString( SETTINGS_PANEL_XML, this,
String::hash( "build_settings" ) );
auto buildNameInput = find<UITextInput>( "build_name" );
@@ -265,7 +273,7 @@ UIBuildSettings::UIBuildSettings( ProjectBuild& build, ProjectBuildConfiguration
auto buildTypeDropDown = find<UIDropDownList>( "build_type_list" );
auto panelBuildTypeDDL = getUISceneNode()
->getRoot()
->querySelector( " #build_tab #build_type_list" )
->querySelector( "#build_tab #build_type_list" )
->asType<UIDropDownList>();
std::vector<String> buildTypes;
@@ -279,13 +287,18 @@ UIBuildSettings::UIBuildSettings( ProjectBuild& build, ProjectBuildConfiguration
if ( panelBuildTypeDDL )
panelBuildTypeDDL->getListBox()->setSelected( mConfig.buildType );
} );
if ( panelBuildTypeDDL )
panelBuildTypeDDL->on(
if ( panelBuildTypeDDL ) {
mCbs[panelBuildTypeDDL].push_back( panelBuildTypeDDL->on(
Event::OnItemSelected, [this, buildTypeDropDown, panelBuildTypeDDL]( const Event* ) {
mConfig.buildType = panelBuildTypeDDL->getListBox()->getItemSelectedText().toUtf8();
if ( buildTypeDropDown )
buildTypeDropDown->getListBox()->setSelected( mConfig.buildType );
} );
} ) );
mCbs[panelBuildTypeDDL].push_back(
panelBuildTypeDDL->on( Event::OnClose, [this, panelBuildTypeDDL]( auto ) {
mCbs.erase( panelBuildTypeDDL );
} ) );
}
auto advTitle = querySelector( ".settings_panel > .advanced_options > .title" );
advTitle->onClick( [this]( const MouseEvent* event ) {
@@ -377,6 +390,10 @@ void UIBuildSettings::setTab( UITab* tab ) {
}
}
UITab* UIBuildSettings::getTab() const {
return mTab;
}
void UIBuildSettings::refreshTab() {
if ( !mTab )
return;
+5
View File
@@ -13,8 +13,12 @@ class UIBuildSettings : public UIRelativeLayout {
public:
static UIBuildSettings* New( ProjectBuild& build, ProjectBuildConfiguration& config );
virtual ~UIBuildSettings();
void setTab( UITab* tab );
UITab* getTab() const;
protected:
friend class UIBuildStep;
@@ -23,6 +27,7 @@ class UIBuildSettings : public UIRelativeLayout {
UIDataBindHolder mDataBindHolder;
UITab* mTab{ nullptr };
String mOldName;
std::unordered_map<UIWidget*, std::vector<Uint32>> mCbs;
explicit UIBuildSettings( ProjectBuild& build, ProjectBuildConfiguration& config );