1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Report if file selector can be displayed.

This commit is contained in:
Bartosz Taudul
2022-10-30 00:31:15 +02:00
parent 343e7b6866
commit fbfd7e5186
2 changed files with 10 additions and 4 deletions
+7 -2
View File
@@ -35,7 +35,7 @@ extern "C" int nativeOpenFile()
} }
#endif #endif
void OpenFile( const char* ext, const char* desc, std::function<void(const char*)> callback ) bool OpenFile( const char* ext, const char* desc, std::function<void(const char*)> callback )
{ {
#ifndef TRACY_NO_FILESELECTOR #ifndef TRACY_NO_FILESELECTOR
# ifdef __EMSCRIPTEN__ # ifdef __EMSCRIPTEN__
@@ -58,6 +58,7 @@ void OpenFile( const char* ext, const char* desc, std::function<void(const char*
}; };
input.click(); input.click();
}, ext ); }, ext );
return true;
# else # else
nfdu8filteritem_t filter = { desc, ext }; nfdu8filteritem_t filter = { desc, ext };
nfdu8char_t* fn; nfdu8char_t* fn;
@@ -65,12 +66,14 @@ void OpenFile( const char* ext, const char* desc, std::function<void(const char*
{ {
callback( (const char*)fn ); callback( (const char*)fn );
NFD_FreePathU8( fn ); NFD_FreePathU8( fn );
return true;
} }
# endif # endif
#endif #endif
return false;
} }
void SaveFile( const char* ext, const char* desc, std::function<void(const char*)> callback ) bool SaveFile( const char* ext, const char* desc, std::function<void(const char*)> callback )
{ {
#if !defined TRACY_NO_FILESELECTOR && !defined __EMSCRIPTEN__ #if !defined TRACY_NO_FILESELECTOR && !defined __EMSCRIPTEN__
nfdu8filteritem_t filter = { desc, ext }; nfdu8filteritem_t filter = { desc, ext };
@@ -79,8 +82,10 @@ void SaveFile( const char* ext, const char* desc, std::function<void(const char*
{ {
callback( (const char*)fn ); callback( (const char*)fn );
NFD_FreePathU8( fn ); NFD_FreePathU8( fn );
return true;
} }
#endif #endif
return false;
} }
} }
+3 -2
View File
@@ -9,8 +9,9 @@ namespace tracy::Fileselector
void Init(); void Init();
void Shutdown(); void Shutdown();
void OpenFile( const char* ext, const char* desc, std::function<void(const char*)> callback ); // Will return false if file selector cannot be presented to the user.
void SaveFile( const char* ext, const char* desc, std::function<void(const char*)> callback ); bool OpenFile( const char* ext, const char* desc, std::function<void(const char*)> callback );
bool SaveFile( const char* ext, const char* desc, std::function<void(const char*)> callback );
} }