Game-Pencil-Engine-Editor icon indicating copy to clipboard operation
Game-Pencil-Engine-Editor copied to clipboard

libfiledialogs Git Submodule (Optional Dear ImGui File Dialogs Dependency)

Open time-killer-games opened this issue 1 year ago • 1 comments

what my thought on this was, it won't actually go inside your repository as a git submodule it will be optional they will have to specify git clone --recurse-submodules without --recurse-submodules it can use dlgmodule or tiny file dialogs or whatever you prefer as the fallback the executable will look in its working directory for the dll and if it exists override the dialogs with the imgui ones if the dll isn't found on the filesystem, don't attempt to call functions from nonexistent dll and then use the fallback you already have in your repos it won't require much code added to your codebase what do you think? having it as a submodule will allow you to maintain your ide how you like and i can maintain my dialogs with my own write access without directly affecting you upon breakages for example people can use yours if mine breaks or vise versa the most compelling reason for this to be added is less maintenance needed for building on mac mac is currently broken with dlgmod and will likely break after i fix it, just a matter of yearly os updates as for the imgui dialogs it relies on code that apple rarely changes in my experience even then i can reimport a newer version of imgui if stuff breaks and let the imgui devs fix things for me ok so ill make a pull request but before that ill write a pseudo code real quick to give you a better idea

string get_open_filename(filter, fname) {
  if (file_exists(libfiledialogs_dll_file)) {
    return call_dll(libfiledialogs_dll_file, "get_open_filename", filter, fname);
  }
  // existing code from dlgmodule here
}

basically that for each dialog function 2-3 lines each of course, not counting the helper function for call_dll that's just a helper function wrapping dlopen(), dlsym(), and dlclose() on unix-likes and LoadLibraryW() for win32

dlopen(), dlsym() dlclose() docs - https://man7.org/linux/man-pages/man3/dlopen.3.html LoadLibraryW() docs - https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryw the dialogs are fully customizeable you can set the localization, button text, title bar text, set them to borderless, parent window, always on top (when there is no parent), fullscreen, fixed, sizeable, change theme just to name a few of the features already in the library doesn't just do file dialogs and also message boxes and i will also add input box, login box, color picker and other stuff in the future

libfiledialogs library repos: https://github.com/time-killer-games/libfiledialogs

Preview:

207476087-f0f98e0e-2d60-465d-aa78-47cbe9d1f343

Motivation:

primarily to have consistent looking dialogs for every platform while also ensuring macos support goes stale less often as imgui devs will handle most of the required maintenance for us, because in my experience of working with macOS's native dialogs they need to have code maintained nearly every year because os upgrades keep on breaking dlgmodule's code. This also opens the door to unofficially supporting DragonFly BSD, NetBSD, OpenBSD, and SunOS variants which are currently not supported by the version of dlgmodule used in the GPE IDE repos.

Additional Notes:

  • You don't need all of those fonts files in my repos. It depends how many languages you want to support, ultimately.
  • Ubuntu/Debian needs dependencies installed with: sudo apt-get install -y libsdl2-dev libgtk-3-dev libglib2.0-dev if the dll is to be used at all, we can use the fallback if calling the dll fails for whatever reason, as if the file doesn't exist
  • libgtk-3-dev and libglib2.0-dev are needed for loading system-defined icons from the default icon theme. libsdl2-dev is needed for the dialog window itself.
  • FreeBSD/DragonFlyBSD needs dependencies installed with: su -l root -c "pkg install sdl2 gtk3 glib" if the dll is to be used at all, we can use the fallback if calling the dll fails for whatever reason, as if the file doesn't exist
  • The dialogs support localization if you want to make translations of this app. All elements can be translated with the environment variables found in this header, using environment_set_variable(name, value) within C++:
  • https://github.com/time-killer-games/libfiledialogs/blob/main/filedialogs/ImFileDialogMacros.h

time-killer-games avatar Mar 23 '23 23:03 time-killer-games