Support file drag & drop on Web
Using by default memory filesystem (MEMFS), provided by Emscripten
This commit is contained in:
parent
2deb35be27
commit
c6b526de66
21
src/core.c
21
src/core.c
@ -397,10 +397,9 @@ static double targetTime = 0.0; // Desired time for one frame, if 0
|
|||||||
static unsigned char configFlags = 0; // Configuration flags (bit based)
|
static unsigned char configFlags = 0; // Configuration flags (bit based)
|
||||||
static bool showLogo = false; // Track if showing logo at init is enabled
|
static bool showLogo = false; // Track if showing logo at init is enabled
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
|
||||||
static char **dropFilesPath; // Store dropped files paths as strings
|
static char **dropFilesPath; // Store dropped files paths as strings
|
||||||
static int dropFilesCount = 0; // Count dropped files strings
|
static int dropFilesCount = 0; // Count dropped files strings
|
||||||
#endif
|
|
||||||
static char **dirFilesPath; // Store directory files paths as strings
|
static char **dirFilesPath; // Store directory files paths as strings
|
||||||
static int dirFilesCount = 0; // Count directory files strings
|
static int dirFilesCount = 0; // Count directory files strings
|
||||||
|
|
||||||
@ -449,8 +448,6 @@ static void ScrollCallback(GLFWwindow *window, double xoffset, double yoffset);
|
|||||||
static void CursorEnterCallback(GLFWwindow *window, int enter); // GLFW3 Cursor Enter Callback, cursor enters client area
|
static void CursorEnterCallback(GLFWwindow *window, int enter); // GLFW3 Cursor Enter Callback, cursor enters client area
|
||||||
static void WindowSizeCallback(GLFWwindow *window, int width, int height); // GLFW3 WindowSize Callback, runs when window is resized
|
static void WindowSizeCallback(GLFWwindow *window, int width, int height); // GLFW3 WindowSize Callback, runs when window is resized
|
||||||
static void WindowIconifyCallback(GLFWwindow *window, int iconified); // GLFW3 WindowIconify Callback, runs when window is minimized/restored
|
static void WindowIconifyCallback(GLFWwindow *window, int iconified); // GLFW3 WindowIconify Callback, runs when window is minimized/restored
|
||||||
#endif
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
|
||||||
static void WindowDropCallback(GLFWwindow *window, int count, const char **paths); // GLFW3 Window Drop Callback, runs when drop files into window
|
static void WindowDropCallback(GLFWwindow *window, int count, const char **paths); // GLFW3 Window Drop Callback, runs when drop files into window
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1692,29 +1689,20 @@ bool ChangeDirectory(const char *dir)
|
|||||||
// Check if a file has been dropped into window
|
// Check if a file has been dropped into window
|
||||||
bool IsFileDropped(void)
|
bool IsFileDropped(void)
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_DESKTOP)
|
|
||||||
if (dropFilesCount > 0) return true;
|
if (dropFilesCount > 0) return true;
|
||||||
else return false;
|
else return false;
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get dropped files names
|
// Get dropped files names
|
||||||
char **GetDroppedFiles(int *count)
|
char **GetDroppedFiles(int *count)
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_DESKTOP)
|
|
||||||
*count = dropFilesCount;
|
*count = dropFilesCount;
|
||||||
return dropFilesPath;
|
return dropFilesPath;
|
||||||
#else
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear dropped files paths buffer
|
// Clear dropped files paths buffer
|
||||||
void ClearDroppedFiles(void)
|
void ClearDroppedFiles(void)
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_DESKTOP)
|
|
||||||
if (dropFilesCount > 0)
|
if (dropFilesCount > 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < dropFilesCount; i++) free(dropFilesPath[i]);
|
for (int i = 0; i < dropFilesCount; i++) free(dropFilesPath[i]);
|
||||||
@ -1723,11 +1711,10 @@ void ClearDroppedFiles(void)
|
|||||||
|
|
||||||
dropFilesCount = 0;
|
dropFilesCount = 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get file modification time (last write time)
|
// Get file modification time (last write time)
|
||||||
RLAPI long GetFileModTime(const char *fileName)
|
long GetFileModTime(const char *fileName)
|
||||||
{
|
{
|
||||||
struct stat result = { 0 };
|
struct stat result = { 0 };
|
||||||
|
|
||||||
@ -2381,9 +2368,7 @@ static bool InitGraphicsDevice(int width, int height)
|
|||||||
glfwSetCharCallback(window, CharCallback);
|
glfwSetCharCallback(window, CharCallback);
|
||||||
glfwSetScrollCallback(window, ScrollCallback);
|
glfwSetScrollCallback(window, ScrollCallback);
|
||||||
glfwSetWindowIconifyCallback(window, WindowIconifyCallback);
|
glfwSetWindowIconifyCallback(window, WindowIconifyCallback);
|
||||||
#if defined(PLATFORM_DESKTOP)
|
|
||||||
glfwSetDropCallback(window, WindowDropCallback);
|
glfwSetDropCallback(window, WindowDropCallback);
|
||||||
#endif
|
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
|
|
||||||
@ -3319,9 +3304,7 @@ static void WindowIconifyCallback(GLFWwindow *window, int iconified)
|
|||||||
if (iconified) windowMinimized = true; // The window was iconified
|
if (iconified) windowMinimized = true; // The window was iconified
|
||||||
else windowMinimized = false; // The window was restored
|
else windowMinimized = false; // The window was restored
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP)
|
|
||||||
// GLFW3 Window Drop Callback, runs when drop files into window
|
// GLFW3 Window Drop Callback, runs when drop files into window
|
||||||
// NOTE: Paths are stored in dinamic memory for further retrieval
|
// NOTE: Paths are stored in dinamic memory for further retrieval
|
||||||
// Everytime new files are dropped, old ones are discarded
|
// Everytime new files are dropped, old ones are discarded
|
||||||
|
Loading…
Reference in New Issue
Block a user