diff --git a/include/eepp/maps/mapeditor/mapeditor.hpp b/include/eepp/maps/mapeditor/mapeditor.hpp index cc2c68bda..0187f6679 100644 --- a/include/eepp/maps/mapeditor/mapeditor.hpp +++ b/include/eepp/maps/mapeditor/mapeditor.hpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/eepp/ui.hpp b/include/eepp/ui.hpp index 7ee26a579..f937cd843 100644 --- a/include/eepp/ui.hpp +++ b/include/eepp/ui.hpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/eepp/ui/uicommondialog.hpp b/include/eepp/ui/uifiledialog.hpp similarity index 71% rename from include/eepp/ui/uicommondialog.hpp rename to include/eepp/ui/uifiledialog.hpp index 5ae1dd129..79d1d2c0e 100644 --- a/include/eepp/ui/uicommondialog.hpp +++ b/include/eepp/ui/uifiledialog.hpp @@ -1,5 +1,5 @@ -#ifndef EE_UICUICOMMONDIALOG_HPP -#define EE_UICUICOMMONDIALOG_HPP +#ifndef EE_UI_UIFILEDIALOG_HPP +#define EE_UI_UIFILEDIALOG_HPP #include #include @@ -11,25 +11,25 @@ namespace EE { namespace UI { -enum UICommonDialogFlags { - CDL_FLAG_SAVE_DIALOG = ( 1 << 0 ), - CDL_FLAG_FOLDERS_FISRT = ( 1 << 1 ), - CDL_FLAG_SORT_ALPHABETICALLY = ( 1 << 2 ), - CDL_FLAG_ALLOW_FOLDER_SELECT = ( 1 << 3 ) -}; - -static const Uint32 UI_CDL_DEFAULT_FLAGS = CDL_FLAG_FOLDERS_FISRT | CDL_FLAG_SORT_ALPHABETICALLY; - -class EE_API UICommonDialog : public UIWindow { +class EE_API UIFileDialog : public UIWindow { public: - static UICommonDialog* New( Uint32 CDLFlags = UI_CDL_DEFAULT_FLAGS, - std::string DefaultFilePattern = "*", - std::string DefaultDirectory = Sys::getProcessPath() ); + enum Flags { + SaveDialog = ( 1 << 0 ), + FoldersFirst = ( 1 << 1 ), + SortAlphabetically = ( 1 << 2 ), + AllowFolderSelect = ( 1 << 3 ) + }; - UICommonDialog( Uint32 CDLFlags = UI_CDL_DEFAULT_FLAGS, std::string DefaultFilePattern = "*", - std::string DefaultDirectory = Sys::getProcessPath() ); + static const Uint32 DefaultFlags = FoldersFirst | SortAlphabetically; - virtual ~UICommonDialog(); + static UIFileDialog* New( Uint32 dialogFlags = DefaultFlags, + std::string defaultFilePattern = "*", + std::string defaultDirectory = Sys::getProcessPath() ); + + UIFileDialog( Uint32 dialogFlags = DefaultFlags, std::string defaultFilePattern = "*", + std::string defaultDirectory = Sys::getProcessPath() ); + + virtual ~UIFileDialog(); virtual Uint32 getType() const; @@ -94,7 +94,7 @@ class EE_API UICommonDialog : public UIWindow { UITextInput* mPath; UITextInput* mFile; UIDropDownList* mFiletype; - Uint32 mCDLFlags; + Uint32 mDialogFlags; Uint32 mCloseWithKey; virtual void onWindowReady(); diff --git a/include/eepp/ui/uihelper.hpp b/include/eepp/ui/uihelper.hpp index da1d53f18..4490f606d 100644 --- a/include/eepp/ui/uihelper.hpp +++ b/include/eepp/ui/uihelper.hpp @@ -75,7 +75,7 @@ enum UINodeType { UI_TYPE_MENUBAR, UI_TYPE_SELECTBUTTON, UI_TYPE_POPUPMENU, - UI_TYPE_COMMONDIALOG, + UI_TYPE_FILEDIALOG, UI_TYPE_TAB, UI_TYPE_TABWIDGET, UI_TYPE_LOADER, diff --git a/projects/linux/ee.files b/projects/linux/ee.files index 6d5371f79..4ed3e8187 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -335,9 +335,9 @@ ../../include/eepp/ui/uicheckbox.hpp ../../include/eepp/ui/uicodeeditor.hpp ../../include/eepp/ui/uicombobox.hpp -../../include/eepp/ui/uicommondialog.hpp ../../include/eepp/ui/uidropdownlist.hpp ../../include/eepp/ui/uieventdispatcher.hpp +../../include/eepp/ui/uifiledialog.hpp ../../include/eepp/ui/uifontstyleconfig.hpp ../../include/eepp/ui/uigridlayout.hpp ../../include/eepp/ui/uihelper.hpp @@ -787,9 +787,9 @@ ../../src/eepp/ui/uicheckbox.cpp ../../src/eepp/ui/uicodeeditor.cpp ../../src/eepp/ui/uicombobox.cpp -../../src/eepp/ui/uicommondialog.cpp ../../src/eepp/ui/uidropdownlist.cpp ../../src/eepp/ui/uieventdispatcher.cpp +../../src/eepp/ui/uifiledialog.cpp ../../src/eepp/ui/uigridlayout.cpp ../../src/eepp/ui/uiimage.cpp ../../src/eepp/ui/uilayout.cpp diff --git a/src/eepp/maps/mapeditor/mapeditor.cpp b/src/eepp/maps/mapeditor/mapeditor.cpp index 03f73c52f..25ed769f3 100644 --- a/src/eepp/maps/mapeditor/mapeditor.cpp +++ b/src/eepp/maps/mapeditor/mapeditor.cpp @@ -1083,7 +1083,7 @@ void MapEditor::updateScroll() { } void MapEditor::mapOpen( const Event* Event ) { - UICommonDialog* CDL = Event->getNode()->asType(); + UIFileDialog* CDL = Event->getNode()->asType(); if ( mUIMap->Map()->loadFromFile( CDL->getFullPath() ) ) { onMapLoad(); @@ -1103,7 +1103,7 @@ void MapEditor::onMapLoad() { } void MapEditor::mapSave( const Event* Event ) { - UICommonDialog* CDL = Event->getNode()->asType(); + UIFileDialog* CDL = Event->getNode()->asType(); std::string path( CDL->getFullPath() ); @@ -1123,15 +1123,15 @@ void MapEditor::fileMenuClick( const Event* Event ) { if ( "New..." == txt ) { createNewMap(); } else if ( "Open..." == txt ) { - UICommonDialog* TGDialog = UICommonDialog::New( UI_CDL_DEFAULT_FLAGS, "*.eem" ); + UIFileDialog* TGDialog = UIFileDialog::New( UIFileDialog::DefaultFlags, "*.eem" ); TGDialog->setWinFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL ); TGDialog->setTitle( "Open Map" ); TGDialog->addEventListener( Event::OpenFile, cb::Make1( this, &MapEditor::mapOpen ) ); TGDialog->center(); TGDialog->show(); } else if ( "Save As..." == txt ) { - UICommonDialog* TGDialog = - UICommonDialog::New( UI_CDL_DEFAULT_FLAGS | CDL_FLAG_SAVE_DIALOG, "*.eem" ); + UIFileDialog* TGDialog = + UIFileDialog::New( UIFileDialog::DefaultFlags | UIFileDialog::SaveDialog, "*.eem" ); TGDialog->setWinFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL ); TGDialog->setTitle( "Save Map" ); TGDialog->addEventListener( Event::SaveFile, cb::Make1( this, &MapEditor::mapSave ) ); @@ -1265,8 +1265,8 @@ void MapEditor::mapMenuClick( const Event* Event ) { tWin->center(); tWin->show(); } else if ( "Add External Texture Atlas..." == txt ) { - UICommonDialog* TGDialog = UICommonDialog::New( - UI_CDL_DEFAULT_FLAGS, std::string( "*" ) + EE_TEXTURE_ATLAS_EXTENSION ); + UIFileDialog* TGDialog = UIFileDialog::New( + UIFileDialog::DefaultFlags, std::string( "*" ) + EE_TEXTURE_ATLAS_EXTENSION ); TGDialog->setWinFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL ); TGDialog->setTitle( "Load Texture Atlas..." ); TGDialog->addEventListener( Event::OpenFile, @@ -1380,7 +1380,7 @@ void MapEditor::refreshLayersList() { } void MapEditor::cextureAtlasOpen( const Event* Event ) { - UICommonDialog* CDL = Event->getNode()->asType(); + UIFileDialog* CDL = Event->getNode()->asType(); std::string sgname = FileSystem::fileRemoveExtension( FileSystem::fileNameFromPath( CDL->getFullPath() ) ); diff --git a/src/eepp/ui/tools/textureatlaseditor.cpp b/src/eepp/ui/tools/textureatlaseditor.cpp index 09fddb885..a6987d7e3 100644 --- a/src/eepp/ui/tools/textureatlaseditor.cpp +++ b/src/eepp/ui/tools/textureatlaseditor.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -293,8 +293,8 @@ void TextureAtlasEditor::fileMenuClick( const Event* Event ) { if ( "New..." == txt ) { eeNew( TextureAtlasNew, ( cb::Make1( this, &TextureAtlasEditor::onTextureAtlasCreate ) ) ); } else if ( "Open..." == txt ) { - UICommonDialog* TGDialog = UICommonDialog::New( - UI_CDL_DEFAULT_FLAGS, std::string( "*" ) + EE_TEXTURE_ATLAS_EXTENSION ); + UIFileDialog* TGDialog = UIFileDialog::New( + UIFileDialog::DefaultFlags, std::string( "*" ) + EE_TEXTURE_ATLAS_EXTENSION ); TGDialog->setWinFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL ); TGDialog->setTitle( "Open Texture Atlas" ); TGDialog->addEventListener( Event::OpenFile, @@ -448,7 +448,7 @@ void TextureAtlasEditor::openTextureAtlas( const Event* Event ) { eeSAFE_DELETE( mTextureAtlasLoader ); mTextureAtlasLoader = TextureAtlasLoader::New( - Event->getNode()->asType()->getFullPath(), Engine::instance()->isThreaded(), + Event->getNode()->asType()->getFullPath(), Engine::instance()->isThreaded(), cb::Make1( this, &TextureAtlasEditor::onTextureAtlasLoaded ) ); } diff --git a/src/eepp/ui/tools/textureatlasnew.cpp b/src/eepp/ui/tools/textureatlasnew.cpp index da9066c74..dda953fb5 100644 --- a/src/eepp/ui/tools/textureatlasnew.cpp +++ b/src/eepp/ui/tools/textureatlasnew.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include @@ -128,8 +128,8 @@ void TextureAtlasNew::okClick( const Event* event ) { std::string ext( mSaveFileType->getText() ); String::toLowerInPlace( ext ); - UICommonDialog* TGDialog = - UICommonDialog::New( UI_CDL_DEFAULT_FLAGS | CDL_FLAG_SAVE_DIALOG, "*." + ext ); + UIFileDialog* TGDialog = + UIFileDialog::New( UIFileDialog::DefaultFlags | UIFileDialog::SaveDialog, "*." + ext ); TGDialog->setWinFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL ); TGDialog->setTitle( "Save Texture Atlas" ); TGDialog->addEventListener( Event::SaveFile, @@ -156,7 +156,7 @@ static bool isValidExtension( const std::string& ext ) { } void TextureAtlasNew::textureAtlasSave( const Event* Event ) { - std::string FPath( Event->getNode()->asType()->getFullPath() ); + std::string FPath( Event->getNode()->asType()->getFullPath() ); if ( !FileSystem::isDirectory( FPath ) ) { Int32 w = 0, h = 0, b; @@ -206,8 +206,8 @@ void TextureAtlasNew::onDialogFolderSelect( const Event* event ) { const MouseEvent* mouseEvent = reinterpret_cast( event ); if ( mouseEvent->getFlags() & EE_BUTTON_LMASK ) { - UICommonDialog* TGDialog = - UICommonDialog::New( UI_CDL_DEFAULT_FLAGS | CDL_FLAG_ALLOW_FOLDER_SELECT, "*" ); + UIFileDialog* TGDialog = + UIFileDialog::New( UIFileDialog::DefaultFlags | UIFileDialog::AllowFolderSelect, "*" ); TGDialog->setWinFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL ); TGDialog->setTitle( "Create Texture Atlas ( Select Folder Containing Textures )" ); TGDialog->addEventListener( Event::OpenFile, @@ -218,7 +218,7 @@ void TextureAtlasNew::onDialogFolderSelect( const Event* event ) { } void TextureAtlasNew::onSelectFolder( const Event* Event ) { - UICommonDialog* CDL = Event->getNode()->asType(); + UIFileDialog* CDL = Event->getNode()->asType(); UIMessageBox* MsgBox; std::string FPath( CDL->getFullPath() ); FileSystem::dirPathAddSlashAtEnd( FPath ); diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index 91ca734ee..49d50cdb5 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -1248,6 +1248,7 @@ void UICodeEditor::drawSelectionMatch( const std::pair& lineRange, const Vector2f& startScroll, const Float& lineHeight ) { if ( !mDoc.hasSelection() ) return; + Primitives primitives; primitives.setForceDraw( false ); primitives.setColor( Color( mSelectionMatchColor ).blendAlpha( mAlpha ) ); @@ -1257,6 +1258,11 @@ void UICodeEditor::drawSelectionMatch( const std::pair& lineRange, String text( selectionLine.substr( selection.start().column(), selection.end().column() - selection.start().column() ) ); + if ( ( text[0] == '\t' && text.countChar( '\t' ) == text.size() ) || + ( text[0] == ' ' && text.countChar( ' ' ) == text.size() ) ) { + return; + } + for ( auto ln = lineRange.first; ln <= lineRange.second; ln++ ) { const String& line = mDoc.line( ln ).getText(); size_t pos = 0; diff --git a/src/eepp/ui/uicommondialog.cpp b/src/eepp/ui/uifiledialog.cpp similarity index 71% rename from src/eepp/ui/uicommondialog.cpp rename to src/eepp/ui/uifiledialog.cpp index fce07e4fd..d361027e0 100644 --- a/src/eepp/ui/uicommondialog.cpp +++ b/src/eepp/ui/uifiledialog.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include @@ -9,32 +9,35 @@ namespace EE { namespace UI { -#define CDLG_MIN_WIDTH 420 -#define CDLG_MIN_HEIGHT 320 +#define FDLG_MIN_WIDTH 420 +#define FDLG_MIN_HEIGHT 320 -UICommonDialog* UICommonDialog::New( Uint32 CDLFlags, std::string DefaultFilePattern, - std::string DefaultDirectory ) { - return eeNew( UICommonDialog, ( CDLFlags, DefaultFilePattern, DefaultDirectory ) ); +UIFileDialog* UIFileDialog::New( Uint32 dialogFlags, std::string defaultFilePattern, + std::string defaultDirectory ) { + return eeNew( UIFileDialog, ( dialogFlags, defaultFilePattern, defaultDirectory ) ); } -UICommonDialog::UICommonDialog( Uint32 CDLFlags, std::string DefaultFilePattern, - std::string DefaultDirectory ) : - UIWindow(), mCurPath( DefaultDirectory ), mCDLFlags( CDLFlags ), mCloseWithKey( KEY_UNKNOWN ) { - if ( getSize().getWidth() < CDLG_MIN_WIDTH ) { - mDpSize.x = CDLG_MIN_WIDTH; - mSize.x = PixelDensity::dpToPxI( CDLG_MIN_WIDTH ); +UIFileDialog::UIFileDialog( Uint32 dialogFlags, std::string defaultFilePattern, + std::string defaultDirectory ) : + UIWindow(), + mCurPath( defaultDirectory ), + mDialogFlags( dialogFlags ), + mCloseWithKey( KEY_UNKNOWN ) { + if ( getSize().getWidth() < FDLG_MIN_WIDTH ) { + mDpSize.x = FDLG_MIN_WIDTH; + mSize.x = PixelDensity::dpToPxI( FDLG_MIN_WIDTH ); } - if ( getSize().getHeight() < CDLG_MIN_HEIGHT ) { - mDpSize.y = CDLG_MIN_HEIGHT; - mSize.y = PixelDensity::dpToPxI( CDLG_MIN_HEIGHT ); + if ( getSize().getHeight() < FDLG_MIN_HEIGHT ) { + mDpSize.y = FDLG_MIN_HEIGHT; + mSize.y = PixelDensity::dpToPxI( FDLG_MIN_HEIGHT ); } - if ( mStyleConfig.MinWindowSize.getWidth() < CDLG_MIN_WIDTH ) - mStyleConfig.MinWindowSize.setWidth( CDLG_MIN_WIDTH ); + if ( mStyleConfig.MinWindowSize.getWidth() < FDLG_MIN_WIDTH ) + mStyleConfig.MinWindowSize.setWidth( FDLG_MIN_WIDTH ); - if ( mStyleConfig.MinWindowSize.getHeight() < CDLG_MIN_HEIGHT ) - mStyleConfig.MinWindowSize.setHeight( CDLG_MIN_HEIGHT ); + if ( mStyleConfig.MinWindowSize.getHeight() < FDLG_MIN_HEIGHT ) + mStyleConfig.MinWindowSize.setHeight( FDLG_MIN_HEIGHT ); bool loading = isSceneNodeLoading(); mUISceneNode->setIsLoading( true ); @@ -70,8 +73,7 @@ UICommonDialog::UICommonDialog( Uint32 CDLFlags, std::string DefaultFilePattern, ->setLayoutSizePolicy( SizePolicy::WrapContent, SizePolicy::WrapContent ) ->setLayoutWeight( 1 ) ->setParent( hLayout ); - mPath->addEventListener( Event::OnPressEnter, - cb::Make1( this, &UICommonDialog::onPressEnter ) ); + mPath->addEventListener( Event::OnPressEnter, cb::Make1( this, &UIFileDialog::onPressEnter ) ); mButtonUp = UIPushButton::New(); mButtonUp->setText( "Up" ) @@ -116,7 +118,7 @@ UICommonDialog::UICommonDialog( Uint32 CDLFlags, std::string DefaultFilePattern, ->setParent( hLayout ); mFile->setLayoutMargin( Rect( 0, 0, 4, 0 ) ); mFile->addEventListener( Event::OnPressEnter, - cb::Make1( this, &UICommonDialog::onPressFileEnter ) ); + cb::Make1( this, &UIFileDialog::onPressFileEnter ) ); mButtonOpen = UIPushButton::New(); mButtonOpen->setText( isSaveDialog() ? "Save" : "Open" ) @@ -140,7 +142,7 @@ UICommonDialog::UICommonDialog( Uint32 CDLFlags, std::string DefaultFilePattern, ->setLayoutWeight( 1 ) ->setParent( hLayout ); mFiletype->setPopUpToRoot( true ); - mFiletype->getListBox()->addListBoxItem( DefaultFilePattern ); + mFiletype->getListBox()->addListBoxItem( defaultFilePattern ); mFiletype->getListBox()->setSelected( 0 ); mFiletype->setLayoutMargin( Rect( 0, 0, 4, 0 ) ); @@ -155,21 +157,21 @@ UICommonDialog::UICommonDialog( Uint32 CDLFlags, std::string DefaultFilePattern, mUISceneNode->setIsLoading( loading ); } -UICommonDialog::~UICommonDialog() {} +UIFileDialog::~UIFileDialog() {} -void UICommonDialog::onWindowReady() { +void UIFileDialog::onWindowReady() { updateClickStep(); } -Uint32 UICommonDialog::getType() const { - return UI_TYPE_COMMONDIALOG; +Uint32 UIFileDialog::getType() const { + return UI_TYPE_FILEDIALOG; } -bool UICommonDialog::isType( const Uint32& type ) const { - return UICommonDialog::getType() == type ? true : UIWindow::isType( type ); +bool UIFileDialog::isType( const Uint32& type ) const { + return UIFileDialog::getType() == type ? true : UIWindow::isType( type ); } -void UICommonDialog::setTheme( UITheme* Theme ) { +void UIFileDialog::setTheme( UITheme* Theme ) { UIWindow::setTheme( Theme ); mButtonOpen->setTheme( Theme ); @@ -190,7 +192,7 @@ void UICommonDialog::setTheme( UITheme* Theme ) { onThemeLoaded(); } -void UICommonDialog::refreshFolder() { +void UIFileDialog::refreshFolder() { std::vector flist = FileSystem::filesGetInPath( String( mCurPath ) ); std::vector files; std::vector folders; @@ -245,7 +247,7 @@ void UICommonDialog::refreshFolder() { mList->setFocus(); } -void UICommonDialog::updateClickStep() { +void UIFileDialog::updateClickStep() { if ( NULL != mList->getVerticalScrollBar() ) { mList->getVerticalScrollBar()->setClickStep( 1.f / ( ( mList->getCount() * mList->getRowHeight() ) / @@ -253,7 +255,7 @@ void UICommonDialog::updateClickStep() { } } -void UICommonDialog::openSaveClick() { +void UIFileDialog::openSaveClick() { if ( isSaveDialog() ) { save(); } else { @@ -261,11 +263,11 @@ void UICommonDialog::openSaveClick() { } } -void UICommonDialog::onPressFileEnter( const Event* ) { +void UIFileDialog::onPressFileEnter( const Event* ) { openSaveClick(); } -void UICommonDialog::disableButtons() { +void UIFileDialog::disableButtons() { mButtonOpen->setEnabled( false ); mButtonCancel->setEnabled( false ); mButtonUp->setEnabled( false ); @@ -280,7 +282,7 @@ void UICommonDialog::disableButtons() { mButtonMaximize->setEnabled( false ); } -void UICommonDialog::openFileOrFolder() { +void UIFileDialog::openFileOrFolder() { std::string newPath = mCurPath + mList->getItemSelectedText(); if ( FileSystem::isDirectory( newPath ) ) { @@ -292,13 +294,13 @@ void UICommonDialog::openFileOrFolder() { } } -void UICommonDialog::goFolderUp() { +void UIFileDialog::goFolderUp() { mCurPath = FileSystem::removeLastFolderFromPath( mCurPath ); mPath->setText( mCurPath ); refreshFolder(); } -Uint32 UICommonDialog::onMessage( const NodeMessage* Msg ) { +Uint32 UIFileDialog::onMessage( const NodeMessage* Msg ) { switch ( Msg->getMsg() ) { case NodeMessage::Click: { if ( Msg->getFlags() & EE_BUTTON_LMASK ) { @@ -350,7 +352,7 @@ Uint32 UICommonDialog::onMessage( const NodeMessage* Msg ) { return UIWindow::onMessage( Msg ); } -void UICommonDialog::save() { +void UIFileDialog::save() { sendCommonEvent( Event::SaveFile ); disableButtons(); @@ -358,7 +360,7 @@ void UICommonDialog::save() { closeWindow(); } -void UICommonDialog::open() { +void UIFileDialog::open() { if ( "" != mList->getItemSelectedText() || getAllowFolderSelect() ) { if ( !getAllowFolderSelect() ) { if ( FileSystem::isDirectory( getFullPath() ) ) @@ -377,7 +379,7 @@ void UICommonDialog::open() { } } -void UICommonDialog::onPressEnter( const Event* ) { +void UIFileDialog::onPressEnter( const Event* ) { if ( FileSystem::isDirectory( mPath->getText() ) ) { std::string tpath = mPath->getText(); FileSystem::dirPathAddSlashAtEnd( tpath ); @@ -387,7 +389,7 @@ void UICommonDialog::onPressEnter( const Event* ) { } } -void UICommonDialog::addFilePattern( std::string pattern, bool select ) { +void UIFileDialog::addFilePattern( std::string pattern, bool select ) { Uint32 index = mFiletype->getListBox()->addListBoxItem( pattern ); if ( select ) { @@ -397,37 +399,37 @@ void UICommonDialog::addFilePattern( std::string pattern, bool select ) { } } -bool UICommonDialog::isSaveDialog() { - return 0 != ( mCDLFlags & CDL_FLAG_SAVE_DIALOG ); +bool UIFileDialog::isSaveDialog() { + return 0 != ( mDialogFlags & SaveDialog ); } -bool UICommonDialog::getSortAlphabetically() { - return 0 != ( mCDLFlags & CDL_FLAG_SORT_ALPHABETICALLY ); +bool UIFileDialog::getSortAlphabetically() { + return 0 != ( mDialogFlags & SortAlphabetically ); } -bool UICommonDialog::getFoldersFirst() { - return 0 != ( mCDLFlags & CDL_FLAG_FOLDERS_FISRT ); +bool UIFileDialog::getFoldersFirst() { + return 0 != ( mDialogFlags & FoldersFirst ); } -bool UICommonDialog::getAllowFolderSelect() { - return 0 != ( mCDLFlags & CDL_FLAG_ALLOW_FOLDER_SELECT ); +bool UIFileDialog::getAllowFolderSelect() { + return 0 != ( mDialogFlags & AllowFolderSelect ); } -void UICommonDialog::setSortAlphabetically( const bool& sortAlphabetically ) { - BitOp::setBitFlagValue( &mCDLFlags, CDL_FLAG_SORT_ALPHABETICALLY, sortAlphabetically ? 1 : 0 ); +void UIFileDialog::setSortAlphabetically( const bool& sortAlphabetically ) { + BitOp::setBitFlagValue( &mDialogFlags, SortAlphabetically, sortAlphabetically ? 1 : 0 ); refreshFolder(); } -void UICommonDialog::setFoldersFirst( const bool& foldersFirst ) { - BitOp::setBitFlagValue( &mCDLFlags, CDL_FLAG_FOLDERS_FISRT, foldersFirst ? 1 : 0 ); +void UIFileDialog::setFoldersFirst( const bool& foldersFirst ) { + BitOp::setBitFlagValue( &mDialogFlags, FoldersFirst, foldersFirst ? 1 : 0 ); refreshFolder(); } -void UICommonDialog::setAllowFolderSelect( const bool& allowFolderSelect ) { - BitOp::setBitFlagValue( &mCDLFlags, CDL_FLAG_ALLOW_FOLDER_SELECT, allowFolderSelect ? 1 : 0 ); +void UIFileDialog::setAllowFolderSelect( const bool& allowFolderSelect ) { + BitOp::setBitFlagValue( &mDialogFlags, AllowFolderSelect, allowFolderSelect ? 1 : 0 ); } -std::string UICommonDialog::getFullPath() { +std::string UIFileDialog::getFullPath() { std::string tPath = mCurPath; FileSystem::dirPathAddSlashAtEnd( tPath ); @@ -437,7 +439,7 @@ std::string UICommonDialog::getFullPath() { return tPath; } -std::string UICommonDialog::getTempFullPath() { +std::string UIFileDialog::getTempFullPath() { std::string tPath = mCurPath; FileSystem::dirPathAddSlashAtEnd( tPath ); @@ -447,46 +449,46 @@ std::string UICommonDialog::getTempFullPath() { return tPath; } -std::string UICommonDialog::getCurPath() const { +std::string UIFileDialog::getCurPath() const { return mCurPath; } -std::string UICommonDialog::getCurFile() const { - if ( mCDLFlags & CDL_FLAG_SAVE_DIALOG ) +std::string UIFileDialog::getCurFile() const { + if ( mDialogFlags & SaveDialog ) return mFile->getText(); return mList->getItemSelectedText().toUtf8(); } -UIPushButton* UICommonDialog::getButtonOpen() const { +UIPushButton* UIFileDialog::getButtonOpen() const { return mButtonOpen; } -UIPushButton* UICommonDialog::getButtonCancel() const { +UIPushButton* UIFileDialog::getButtonCancel() const { return mButtonCancel; } -UIPushButton* UICommonDialog::getButtonUp() const { +UIPushButton* UIFileDialog::getButtonUp() const { return mButtonUp; } -UIListBox* UICommonDialog::getList() const { +UIListBox* UIFileDialog::getList() const { return mList; } -UITextInput* UICommonDialog::getPathInput() const { +UITextInput* UIFileDialog::getPathInput() const { return mPath; } -UITextInput* UICommonDialog::getFileInput() const { +UITextInput* UIFileDialog::getFileInput() const { return mFile; } -UIDropDownList* UICommonDialog::getFiletypeList() const { +UIDropDownList* UIFileDialog::getFiletypeList() const { return mFiletype; } -Uint32 UICommonDialog::onKeyUp( const KeyEvent& Event ) { +Uint32 UIFileDialog::onKeyUp( const KeyEvent& Event ) { if ( mCloseWithKey && Event.getKeyCode() == mCloseWithKey ) { disableButtons(); @@ -496,11 +498,11 @@ Uint32 UICommonDialog::onKeyUp( const KeyEvent& Event ) { return 1; } -const Uint32& UICommonDialog::getCloseWithKey() const { +const Uint32& UIFileDialog::getCloseWithKey() const { return mCloseWithKey; } -void UICommonDialog::setCloseWithKey( const Uint32& closeWithKey ) { +void UIFileDialog::setCloseWithKey( const Uint32& closeWithKey ) { mCloseWithKey = closeWithKey; } diff --git a/src/tests/test_all/test.cpp b/src/tests/test_all/test.cpp index 69cbc51f6..ce9f64bd1 100644 --- a/src/tests/test_all/test.cpp +++ b/src/tests/test_all/test.cpp @@ -1038,8 +1038,8 @@ void EETest::createColorPicker( Node* node ) { // mColorPicker->getUIWindow()->center(); } -void EETest::createCommonDialog() { - UICommonDialog* CDialog = UICommonDialog::New(); +void EETest::createFileDialog() { + UIFileDialog* CDialog = UIFileDialog::New(); CDialog->setWinFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON ); CDialog->addFilePattern( "*.hpp;*.cpp", true ); CDialog->center(); @@ -1237,7 +1237,7 @@ void EETest::onItemClick( const Event* event ) { } else if ( "Multi Viewport" == txt ) { MultiViewportMode = !MultiViewportMode; } else if ( "Open..." == txt ) { - createCommonDialog(); + createFileDialog(); } else if ( "New" == txt ) { if ( 0 == Screen ) { changeDemo( 0 ); diff --git a/src/tests/test_all/test.hpp b/src/tests/test_all/test.hpp index 433479ed6..9bfe66fca 100644 --- a/src/tests/test_all/test.hpp +++ b/src/tests/test_all/test.hpp @@ -143,7 +143,7 @@ class EETest : private Thread { Clock mFTE; Translator mTranslator; - void createCommonDialog(); + void createFileDialog(); void onItemClick( const Event* Event ); void onMainClick( const Event* Event ); void onQuitClick( const Event* Event ); diff --git a/src/tools/codeeditor/codeeditor.cpp b/src/tools/codeeditor/codeeditor.cpp index a1ea332ed..2f966730a 100644 --- a/src/tools/codeeditor/codeeditor.cpp +++ b/src/tools/codeeditor/codeeditor.cpp @@ -486,7 +486,7 @@ void App::loadFileFromPath( const std::string& path, UICodeEditor* codeEditor ) } void App::openFileDialog() { - UICommonDialog* TGDialog = UICommonDialog::New( UI_CDL_DEFAULT_FLAGS, "*" ); + UIFileDialog* TGDialog = UIFileDialog::New(); TGDialog->setWinFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL ); TGDialog->setTitle( "Open layout..." ); TGDialog->setCloseWithKey( KEY_ESCAPE ); @@ -494,7 +494,7 @@ void App::openFileDialog() { auto d = createCodeEditorInTabWidget( tabWidgetFromEditor( mCurEditor ) ); UITabWidget* tabWidget = d.first->getTabWidget(); UITab* addedTab = d.first; - loadFileFromPath( event->getNode()->asType()->getFullPath(), d.second ); + loadFileFromPath( event->getNode()->asType()->getFullPath(), d.second ); tabWidget->setTabSelected( addedTab ); UITab* firstTab = tabWidget->getTab( 0 ); if ( addedTab != firstTab ) { @@ -871,7 +871,7 @@ void App::init( const std::string& file ) { mUISceneNode->getRoot()->addClass( "appbackground" ); - std::string baseUI = R"xml( + const std::string baseUI = R"xml(