Native file dialogs support WIP (SpartanJ/ecode#653).

This commit is contained in:
Martín Lucas Golini
2025-09-18 23:20:16 -03:00
parent aa3eea5810
commit dfd47dd1e3
13 changed files with 2205 additions and 39 deletions

View File

@@ -112,6 +112,7 @@
#if EE_PLATFORM == EE_PLATFORM_ANDROID || EE_PLATFORM == EE_PLATFORM_IOS || \
( EE_PLATFORM == EE_PLATFORM_WIN && defined( EE_COMPILER_MSVC ) )
#define EE_OVERRIDES_MAIN
#if defined( EE_BACKEND_SDL_ACTIVE )
#if EE_PLATFORM == EE_PLATFORM_WIN && defined( EE_COMPILER_MSVC )
#define main SDL_main
@@ -121,7 +122,7 @@
#endif
#endif
#ifdef __cplusplus
#if defined( __cplusplus ) && defined( EE_OVERRIDES_MAIN )
#define EE_MAIN_FUNC extern "C"
#else
#define EE_MAIN_FUNC

View File

@@ -15,6 +15,8 @@
namespace EE { namespace UI {
struct NativeFileDialogHandler;
class EE_API UIFileDialog : public UIWindow {
public:
enum Flags {
@@ -25,6 +27,8 @@ class EE_API UIFileDialog : public UIWindow {
ShowOnlyFolders = ( 1 << 4 ),
ShowHidden = ( 1 << 5 ),
AllowMultiFileSelection = ( 1 << 6 ),
UseNativeFileDialog =
( 1 << 7 ), //< Uses the OS native file dialog if exists and it's available
};
static const Uint32 DefaultFlags = UIFileDialog::Flags::FoldersFirst |
@@ -107,18 +111,6 @@ class EE_API UIFileDialog : public UIWindow {
void setCloseShortcut( const KeyBindings::Shortcut& closeWithKey );
UIIcon* getIconNewFolder() const;
void setIconNewFolder( UIIcon* iconNewFolder );
UIIcon* getIconListView() const;
void setIconListView( UIIcon* iconListView );
UIIcon* getIconTableView() const;
void setIconTableView( UIIcon* iconTableView );
void setViewMode( const UIMultiModelView::ViewMode& viewMode );
const UIMultiModelView::ViewMode& getViewMode() const;
@@ -129,8 +121,17 @@ class EE_API UIFileDialog : public UIWindow {
void setSingleClickNavigation( bool singleClickNavigation );
virtual bool show();
virtual bool hide();
bool usingNativeFileDialog() const;
virtual void scheduledUpdate( const Time& time );
protected:
std::string mCurPath;
std::string mFilePatterns;
UIPushButton* mButtonOpen;
UIPushButton* mButtonCancel;
UIPushButton* mButtonUp;
@@ -140,6 +141,7 @@ class EE_API UIFileDialog : public UIWindow {
UIMultiModelView* mMultiView;
UITextInput* mPath;
UITextInput* mFile;
std::string mFileName;
UIDropDownList* mFiletype;
Uint32 mDialogFlags;
KeyBindings::Shortcut mCloseShortcut;
@@ -147,6 +149,8 @@ class EE_API UIFileDialog : public UIWindow {
std::shared_ptr<FileSystemModel> mModel;
std::shared_ptr<DiskDrivesModel> mDiskDrivesModel;
bool mDisplayingDrives{ false };
NativeFileDialogHandler* mHandler{ nullptr };
std::vector<std::string> mRes;
UIFileDialog( Uint32 dialogFlags = UIFileDialog::DefaultFlags,
const std::string& defaultFilePattern = "*",