Giter VIP home page Giter VIP logo

imguifiledialog's Introduction

ImGuiFileDialog

Build Matrix

Win Linux MacOs
Msvc Win Msvc
Gcc Linux Gcc Osx Gcc
Clang Linux Clang Osx Clang
Leak Sanitizer Leak Sanitizer

Purpose

ImGuiFileDialog is a file selection dialog built for (and using only) Dear ImGui.

My primary goal was to have a custom pane with widgets according to file extension. This was not possible using other solutions.

Possible Dialog Customization

alt text

ImGui Supported Version

Note

ImGuiFileDialog follow the master and docking branch of ImGui. Currently : Wrapped Dear ImGui Version

Documentation :

Note

for a complete explanation and howto about ImGuiFileDialog Api, you can check the Documentation

Structure

This library is designed to be dropped into your source code rather than compiled separately.

From your project directory:

mkdir lib    <or 3rdparty, or externals, etc.>
cd lib
git clone https://github.com/aiekick/ImGuiFileDialog.git
git checkout master

These commands create a lib directory where you can store any third-party dependencies used in your project, downloads the ImGuiFileDialog git repository and checks out the Lib_Only branch where the actual library code is located.

Add lib/ImGuiFileDialog/ImGuiFileDialog.cpp to your build system and include lib/ImGuiFileDialog/ImGuiFileDialog.h in your source code. ImGuiFileLib will compile with and be included directly in your executable file.

If, for example, your project uses cmake, look for a line like add_executable(my_project_name main.cpp) and change it to add_executable(my_project_name lib/ImGuiFileDialog/ImGuiFileDialog.cpp main.cpp). This tells the compiler where to find the source code declared in ImGuiFileDialog.h which you included in your own source code.

Requirements:

You must also, of course, have added Dear ImGui to your project for this to work at all.

dirent v1.23 is required to use ImGuiFileDialog under Windows. It is included in the Lib_Only branch for your convenience.

Android Requirements : Api 21 mini

Features

  • C Api (succesfully tested with CimGui)
  • Separate system for call and display
    • Can have many function calls with different parameters for one display function, for example
  • Can create a custom pane with any widgets via function binding
    • This pane can block the validation of the dialog
    • Can also display different things according to current filter and UserDatas
  • Advanced file style for file/dir/link coloring / icons / font
    • predefined form or user custom form by lambda function (the lambda mode is not available for the C API)
  • Multi-selection (ctrl/shift + click) :
    • 0 => Infinite
    • 1 => One file (default)
    • n => n files
  • Compatible with MacOs, Linux, Windows, Emscripten, Android
  • Supports modal or standard dialog types
  • Select files or directories
  • Filter groups and custom filter names
  • can ignore filter Case for file searching
  • Keyboard navigation (arrows, backspace, enter)
  • Exploring by entering characters (case insensitive)
  • Custom places (bookmarks, system devices, whatever you want)
  • Directory manual entry (right click on any path element)
  • Optional 'Confirm to Overwrite" dialog if file exists
  • Thumbnails Display (agnostic way for compatibility with any backend, sucessfully tested with OpenGl and Vulkan)
  • The dialog can be embedded in another user frame than the standard or modal dialog
  • Can tune validation buttons (placements, widths, inversion)
  • Can quick select a parrallel directory of a path, in the path composer (when you clikc on a / you have a popup)
  • regex support for filters, collection of filters and filestyle (the regex is recognized when between (( and )) in a filter)
  • multi layer extentions like : .a.b.c .json.cpp .vcxproj.filters etc..
  • advanced behavior regarding asterisk based filter. like : .* .. .vcx.* ..filters .vcs.filt.* etc.. (internally regex is used)
  • result modes GetFilePathName, GetFileName and GetSelection (overwrite file ext, keep file, add ext if no user ext exist)
  • you can use your own FileSystem Api
    • by default Api Dirent and std::filesystem are defined
    • you can override GetDrieveList for specify by ex on android other fs, like local and SDCards

WARNINGS :

  • the nav system keyboard behavior is not working as expected, so maybe full of bug for ImGuiFileDialog

Simple Usage :

void drawGui() { 
  // open Dialog Simple
  if (ImGui::Button("Open File Dialog")) {
    IGFD::FileDialogConfig config;
	config.path = ".";
    ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Choose File", ".cpp,.h,.hpp", config);
  }
  // display
  if (ImGuiFileDialog::Instance()->Display("ChooseFileDlgKey")) {
    if (ImGuiFileDialog::Instance()->IsOk()) { // action if OK
      std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName();
      std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath();
      // action
    }
    
    // close
    ImGuiFileDialog::Instance()->Close();
  }
}

alt text

How to build the sample app

The sample app is [here in master branch]((https://github.com/aiekick/ImGuiFileDialog/tree/master)

You need to use cMake. For the 3 Os (Win, Linux, MacOs), the cMake usage is exactly the same,

Choose a build directory. (called here my_build_directory for instance) and
Choose a Build Mode : "Release" / "MinSizeRel" / "RelWithDebInfo" / "Debug" (called here BuildMode for instance)
Run cMake in console : (the first for generate cmake build files, the second for build the binary)

cmake -B my_build_directory -DCMAKE_BUILD_TYPE=BuildMode cmake --build my_build_directory --config BuildMode

Some cMake version need Build mode define via the directive CMAKE_BUILD_TYPE or via --Config when we launch the build. This is why i put the boths possibilities

By the way you need before, to make sure, you have needed dependencies.

On Windows :

You need to have the opengl library installed

On Linux :

You need many lib : (X11, xrandr, xinerama, xcursor, mesa)

If you are on debian you can run :

sudo apt-get update sudo apt-get install libgl1-mesa-dev libx11-dev libxi-dev libxrandr-dev libxinerama-dev libxcursor-dev

On MacOs :

you need many lib : opengl and cocoa framework

Thats all folks :-)

You can check by example in this repo with the file CustomImGuiFileDialogConfig.h :

  • this trick was used for have custom icon font instead of labels for buttons or messages titles
  • you can also use your custom imgui button, the button call stamp must be same by the way :)

The Custom Icon Font (in CustomFont.cpp and CustomFont.h) was made with ImGuiFontStudio (https://github.com/aiekick/ImGuiFontStudio) i wrote for that :) ImGuiFontStudio is using also ImGuiFileDialog.$

Alt

imguifiledialog's People

Contributors

adrianodidio avatar aiekick avatar brawner avatar chrismile avatar conhlee avatar dfranx avatar dmlo avatar esnosy avatar hoffstadt avatar khiner avatar lilggamegenius avatar m9710797 avatar mataron avatar maxlisui avatar maxsupermanhd avatar palikar avatar puzzlepaint avatar simonmaracine avatar uusdnfdsfhnttyh avatar vawx avatar zachmetcalf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imguifiledialog's Issues

Double-click-to-open does not work under Directory Chooser mode.

Describe the bug
The folder selection mode does not work.
According to the guide here, the Directory Chooser should allow single-click for choosing folder and double-click for opening one.
But now the double-click-to-open is not working at all, the only thing I can do is choose one.

To Reproduce

  • Use the exact example code.
  • Use the latest ImGui with no Viewport or Docking.
  • Using OpenGL 3 with GLFW.
  • With freetype and stb.
  • With ImGui config

#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
#define IMGUI_USE_STB_SPRINTF
#define IMGUI_ENABLE_FREETYPE

  • With ImGuiFileDialogConfig.h

#define USE_STD_FILESYSTEM
#define USE_EXPLORATION_BY_KEYS
// this mapping by default is for GLFW but you can use another
#include <GLFW/glfw3.h>
// Up key for explore to the top
#define IGFD_KEY_UP GLFW_KEY_UP
// Down key for explore to the bottom
#define IGFD_KEY_DOWN GLFW_KEY_DOWN
// Enter key for open directory
#define IGFD_KEY_ENTER GLFW_KEY_ENTER
// BackSpace for comming back to the last directory
#define IGFD_KEY_BACKSPACE GLFW_KEY_BACKSPACE

  • With Visual Studio 2022 and compiling option "/std:c++latest" (Hence C++20 or 23?)

Expected behavior
A clear double-clear can open a folder instead of selecting it.

Screenshots
Not applicable.

Desktop (please complete the following information):

  • Windows 10 21H1

Smartphone (please complete the following information):

  • None

Additional context
Add any other context about the problem here.

Wrong directory bug when using dialog a second time

When I used the simple dialog example and selected a file, everything worked perfectly. When I opened the dialog again to select another file, I was sort of "stuck" in a directory, which is the "." vPath specified before on creation of the ImGuiFileDialog class, but none of the folders were clickable. Its like I was in the directory and could see everything but could not interact. When I clicked ".." however, I went up a directory from the previously chosen file, and not where I seemed to be, which is ".".
For example, lets say I was in directory assets/.
We have:
assets/
|---> textures
| ----> image.png
|---> test.txt

Let's say I opened the dialog and chose image.png. The next time I open the dialog, I see the following:

  • . .
  • textures
  • test.txt

But they are both not clickable.
Only thing clickable is ". .", and when I do click it, I find myself in directory assets, which means I was actually in textures the second time but it looked like I was already in assets.

A quick workaround I wrote that works perfectly is the following:

void ImGuiFileDialog::CloseDialog(const std::string & vKey)
{
	if (dlg_key == vKey)
	{
        ------> SetPath(m_CurrentPath);
		dlg_key.clear();
		m_ShowDialog = false;
	}
}

Use <filesystem> with std::filesystem::path

First of all, thanks for maintaining this great widget!

What do you think about using C++17 and the header to simplify all the path and filename logic.
Using the std makes it easier to be multi-platform at the cost of needing a relatively modern compiler.

A random example:

	inline PathStruct ParsePathFileName(const std::string& vPathFileName)
	{
		PathStruct res;

		if (!vPathFileName.empty())
		{
			std::string pfn = vPathFileName;
			std::string separator(1u, PATH_SEP);
			replaceString(pfn, "\\", separator);
			replaceString(pfn, "/", separator);

			size_t lastSlash = pfn.find_last_of(separator);
			if (lastSlash != std::string::npos)
			{
				res.name = pfn.substr(lastSlash + 1);
				res.path = pfn.substr(0, lastSlash);
				res.isOk = true;
			}

			size_t lastPoint = pfn.find_last_of('.');
			if (lastPoint != std::string::npos)
			{
				if (!res.isOk)
				{
					res.name = pfn;
					res.isOk = true;
				}
				res.ext = pfn.substr(lastPoint + 1);
				replaceString(res.name, "." + res.ext, "");
			}
		}
		return res;
	}
#include <filesystem>

inline PathStruct ParsePathFileName(const std::string& vPathFileName)
{
  namespace fs = std::filesystem;
  PathStruct res;
  if (vPathFileName.empty())
    return res;

  auto fsPath = fs::path(vPathFileName);

  if(fs::is_regular_file(fsPath)) {
    res.name = fsPath.string();
    res.path = fsPath.parent_path().string();
    res.ok = true;
  } // else if fs::is_directory?

  return res;
}

Describe the solution you'd like
Use c++17 and replace all the in-house string substitution code.

returned file name extension changed to ".*" when filter is ".*"

I set .* as filter string to select file name as data.log, but returned file name is data.*
demo code:

 ImGui::Begin("open", NULL, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);   // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
        if(ImGui::Button("open")) {
            igfd::ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Choose File", ".*", ".");
        }
        // display
        if (igfd::ImGuiFileDialog::Instance()->FileDialog("ChooseFileDlgKey"))
        {
            // action if OK
            if (igfd::ImGuiFileDialog::Instance()->IsOk == true)
            {
                std::string filePathName = igfd::ImGuiFileDialog::Instance()->GetFilePathName();
                std::string filePath = igfd::ImGuiFileDialog::Instance()->GetCurrentPath();

                printf("select log file: [%s], [%s]\n", filePathName.c_str(), filePath.c_str());
            // action
            }
            // close
            igfd::ImGuiFileDialog::Instance()->CloseDialog("ChooseFileDlgKey");
        }

double click file to open no longer works

In the past it was possible to open a file by double clicking it. This no longer works (already for a while). Opening folders with double click still works fine and off course you can still open files by selecting them and then hitting the ok button. Thanks for looking at this.

Compile issue with USE_BOOKMARK not defined

Got the following error when compiling without USE_BOOKMARK defined:

1>ImGuiFileDialog.cpp
1><...>\Externals\ImGuiFileDialog\ImGuiFileDialog\ImGuiFileDialog.cpp(1008,23): error C2065: 'bookmarksButtonString': undeclared identifier
1><...>\Externals\ImGuiFileDialog\ImGuiFileDialog\ImGuiFileDialog.cpp(1008,47): error C2065: 'm_BookmarkPaneShown': undeclared identifier
1><...>\Externals\ImGuiFileDialog\ImGuiFileDialog\ImGuiFileDialog.cpp(1008,3): error C3861: 'IMGUI_TOGGLE_BUTTON': identifier not found
1><...>\Externals\ImGuiFileDialog\ImGuiFileDialog\ImGuiFileDialog.cpp(1011,22): error C2065: 'bookmarksButtonHelpString': undeclared identifier

To fix it, I've locally put ImGuiFileDialog::DrawBookMark() inside #ifdef USE_BOOKMARK on both the header and source file

Release has an empty ImGuiFileDialog directory

Describe the bug
If you download:
https://github.com/aiekick/ImGuiFileDialog/archive/v0.5.5.zip

The submodule is making the ImGuiFileDialog directory empty the only way to get everything is by git cloning the repo and running

git submodule init
git submodule update

The result is that taking a dependency on the release isn't possible.

I recommend switching to a mono repo, but any solution that fixes the ImGuiFileDialog-0.5.5.zip and subsequent releases would be awesome.

igfd::ImGuiFileDialog::Instance(), Segmentation fault (core dumped)

Describe the bug
Segmentation fault (core dumped), When doing igfd::ImGuiFileDialog::Instance().

Expected behavior
I just followed Simple Dialog code for test.
The error was printed when I click the button which described of "Open File Dialog"

Desktop (please complete the following information):

  • OS: Ubuntu 18.04
  • Version ImGuiFileDialog 0.4v

Screenshots
Screenshot 2020-10-05 22:32:50

Linux compilation failing

Describe the bug
I had to add -fpermissive to the build flags in order to get past the first error.
Then I received a second error:
ImGuiFileDialog.cpp:885:31: error: โ€˜infosโ€™ was not declared in this scope

I changed infos to vInfos
I was then able to build successfully.

Desktop (please complete the following information):

  • OS:Ubuntu 18.04.4

Allow double click and intro to select a file.

I can double-click to navigate into a folder, or use intro enter key when #def USE_EXPLORATION_BY_KEYS, however, I cannot double-click or press enter to select the file.

Would it be possible to allow double-click/enter key to "press OK button" if the selected item is a file?

ImGuiFileDialog "?" ?

dlg_simple
The above is from github page

But when I tried I get:
Screenshot (13)

Why it's showing "?" ?

Please note that the "?" buttons works perfectly when I click on it, hovering is working fine too

Example when I hover on one of them it shows a tooltip "Drivers"
Screenshot (15)

Issue: Question - Supported Platforms?

explanation

So im making a rythm game ind im planning on having inbuilt modding tools that are made using linux I need it to work on all platforms including: emscripten - โœ… which I have as the default way to build the game, windows - โŒ wich i havent gotten working since I dont have a windows 10 pc, macOS - โŒ i dont expect this one to happen anytime soon if it isnt already done cuz apple makes developing harder than it needs to be, and linux - โœ… Linux is the only other build option i could use so yeah.

Wich ones are supported

Info would be appreciated

Im an open source newbie

sorry for any bad markdown formatting I havent quite got the hang of being an open source gamedev, lol

Items Dissapear after Mouse Release

Many thanks for making and sharing this library it has been very useful for my project.

After the introduction of double clicking a couple of months ago noticed a graphical glitch. When single clicking an item in the list, after the mouse is released, the remaining items on the list are not rendered for one frame. It is not random and always happens. I managed to capture some screenshots by making a movie.

What it looks like before mouse release:
image

One frame after releasing the mouse:
image

Then everything goes back to normal.

Thanks for looking at this

GetFilepathName not defined

In your first example in the readme.md you write

std::string filePathName = igfd::ImGuiFileDialog::Instance()->GetFilepathName();

But GetFilepathName is not defined, do you mean GetFilePathName ?

Problem with OVERWRITE DIALOG

In the function
bool IGFD::FileDialog::Confirm_Or_OpenOverWriteFileDialog_IfNeeded(bool vLastAction, ImGuiWindowFlags vFlags)
GetFilePathName is used to get the file name.
As you know GetFilePathName always return current file with selected extension,
making the test to see if the file already exists, return an incorrect result.
Thanks.

A modal popup cause the Dialog to disapear if the dialog is modal too

ImGui not support many modal popup at same time.
maybe i can have a way to :

  • detect when a new model is opened, and put the dialog in standard mode, until the modal disapear (if we permit to have a new modal. maybe by a flag ?)
  • block the other modal ?

for the moment this can be an issue because can block the user to have acces to the ui.
not specifically related to ImGuiFileDialog btw

GetFilepathName() bug

GetFilepathName() returns, for example, E:file.ext when opening/saving a file to root directory which is invalid path.

Info:

  • OS: Windows 10
  • on latest commit

Emscripten, Create Dir on Windows

I've just found that ImGuiFileDialog is compatible with Emscripten.
The only problem is CreateDirectoryIfNotExist function. Here my version of this function (additionally supports unicode paths on Windows).
It is also necessary to add the following modification at the beginning of the file ImGuiFileDialog.cpp

#if defined (__EMSCRIPTEN__)
#include <emscripten.h>
#endif

The Line

#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)

should be extended to

#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__) || defined (__EMSCRIPTEN__)
inline bool CreateDirectoryIfNotExist(const std::string& name)
	{
		bool res = false;

		if (!name.empty())
		{
			if (!IsDirectoryExist(name))
			{
				res = true;
#ifdef WIN32
				std::vector<wchar_t> wn(name.size() + 1);
				size_t n;
				int error = dirent_mbstowcs_s(
					&n, wn.data(), wn.size(), name.c_str(), wn.size());
				if (error || !CreateDirectoryW(wn.data(), nullptr)) {
					res = false;
				}
#elif defined(__EMSCRIPTEN__)
				std::string str = std::string("FS.mkdir('") + name.c_str() + "');";
				emscripten_run_script(str.c_str());
#elif defined(UNIX)
				char buffer[PATH_MAX] = {};
				snprintf(buffer, PATH_MAX, "mkdir -p %s", name.c_str());
				const int dir_err = std::system(buffer);
				if (dir_err == -1)
				{
					std::cout << "Error creating directory " << name << std::endl;
					res = false;
				}
#endif // defined(UNIX)
			}
		}

		return res;
	}

File Dialog stops working after moving to docking branch.

After moving to imgui/docking branch, the file dialog stops working.
I have a simple example implemented. The code works with the master branch.
Behavior: The button does nothing.

    ImGui::Begin("File Browser");
    int my_image_width, my_image_height;
    if (ImGui::Button("Browse Files"))
        ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Choose File", ".png, .jpg, .jpeg", ".");
    if (ImGuiFileDialog::Instance()->Display("ChooseFileDlgKey"))
    {
        if (ImGuiFileDialog::Instance()->IsOk())
        {
            filename = ImGuiFileDialog::Instance()->GetFilePathName();
            LayerLoadTextureFromFile(filename.c_str(), &my_image_texture, &my_image_width, &my_image_height);
            std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath();
        }
        ImGuiFileDialog::Instance()->Close();
    }
    ImGui::End();

`
OS: Ubuntu 20.04

Provide option to disable Create Directory

I know that read/write operations share the same dialog, I wonder if it would be possible to disable the "Create Directory" DrawDirectoryCreation() in DrawHeader()at runtime.

Maybe passing vFlags to DrawHeader?

It doesn't fit to have the option to create a folder when opening a file IMO.

Not an Issue. Just a thank you!

This may be closed when you see it. I just wanted to say thanks for making this, you're a life saver. I orignally wrote a library which uses native dialogs and is cross-platform but maintenance on macOS became a bit annoying, so this makes for a nice fallback solution that won't face constant breakage every new major OS version, like I would I've had to deal with using NSOpenPanel and NSSavePanel.

I would like to contribute an example for using this with the SDL2Renderer, as an extra means of saying thank you.

The example will look similar to this:

IPRQpmz

I'll submit a pr shortly. Thanks again!
Samuel

Support installation from vcpkg

I used the sample code in vs2019, but got multiple errors, , I donโ€™t know which steps I did wrong...

if (ImGui::Button("Open File Dialog"))
	ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Choose File", ".cpp,.h,.hpp", ".");
if (ImGuiFileDialog::Instance()->Display("ChooseFileDlgKey"))
{
	if (ImGuiFileDialog::Instance()->IsOk())
	{
		std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName();
		std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath();
	}
	ImGuiFileDialog::Instance()->Close();
}

1>main.obj : error LNK2019: ๅœจๅ‡ฝๅผ "public: __thiscall IGFD::FileDialog::FileDialog(void)" (??0FileDialog@IGFD@@QAE@XZ)"public: static class IGFD::FileDialog * __cdecl IGFD::FileDialog::Instance(void)" (?Instance@FileDialog@IGFD@@SAPAV12@XZ) ไธญๅƒ่€ƒไบ†็„กๆณ•่งฃๆž็š„ๅค–้ƒจ็ฌฆ่™Ÿ
1>main.obj : error LNK2019: ๅœจๅ‡ฝๅผ "public: void __thiscall IGFD::FileDialog::OpenDialog(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > const &,char const *,class std::basic_string<char,struct std::char_traits,class std::allocator > const &,int const &,void *,int)" (?OpenDialog@FileDialog@IGFD@@QAEXABV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@0PBD0ABHPAXH@Z)_main ไธญๅƒ่€ƒไบ†็„กๆณ•่งฃๆž็š„ๅค–้ƒจ็ฌฆ่™Ÿ
1>main.obj : error LNK2019: ๅœจๅ‡ฝๅผ "public: bool __thiscall IGFD::FileDialog::Display(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,int,struct ImVec2,struct ImVec2)" (?Display@FileDialog@IGFD@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@HUImVec2@@1@Z)_main ไธญๅƒ่€ƒไบ†็„กๆณ•่งฃๆž็š„ๅค–้ƒจ็ฌฆ่™Ÿ
1>main.obj : error LNK2019: ๅœจๅ‡ฝๅผ "public: void __thiscall IGFD::FileDialog::Close(void)" (?Close@FileDialog@IGFD@@QAEXXZ)_main ไธญๅƒ่€ƒไบ†็„กๆณ•่งฃๆž็š„ๅค–้ƒจ็ฌฆ่™Ÿ
1>main.obj : error LNK2019: ๅœจๅ‡ฝๅผ "public: bool __thiscall IGFD::FileDialog::IsOk(void)" (?IsOk@FileDialog@IGFD@@QAE_NXZ)_main ไธญๅƒ่€ƒไบ†็„กๆณ•่งฃๆž็š„ๅค–้ƒจ็ฌฆ่™Ÿ
1>main.obj : error LNK2019: ๅœจๅ‡ฝๅผ "public: class std::basic_string<char,struct std::char_traits,class std::allocator > __thiscall IGFD::FileDialog::GetFilePathName(void)" (?GetFilePathName@FileDialog@IGFD@@QAE?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@xz)_main ไธญๅƒ่€ƒไบ†็„กๆณ•่งฃๆž็š„ๅค–้ƒจ็ฌฆ่™Ÿ
1>main.obj : error LNK2019: ๅœจๅ‡ฝๅผ "public: class std::basic_string<char,struct std::char_traits,class std::allocator > __thiscall IGFD::FileDialog::GetCurrentPath(void)" (?GetCurrentPath@FileDialog@IGFD@@QAE?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@xz)_main ไธญๅƒ่€ƒไบ†็„กๆณ•่งฃๆž็š„ๅค–้ƒจ็ฌฆ่™Ÿ
1>C:\Users\weijen\source\repos\PainterWithGUI\Debug\PainterWithGUI.exe : fatal error LNK1120: 7 ๅ€‹็„กๆณ•่งฃๆž็š„ๅค–้ƒจ็ฌฆ่™Ÿ

Compilation warnings.

In file included from lib/imgui/ImGuiFileDialog.cpp:28:
lib/imgui/ImGuiFileDialog.h: In constructor โ€˜igfd::FileExtentionInfosStruct::FileExtentionInfosStruct(const ImVec4&, const string&)โ€™:
lib/imgui/ImGuiFileDialog.h:125:10: warning: โ€˜igfd::FileExtentionInfosStruct::colorโ€™ will be initialized after [-Wreorder]
  125 |   ImVec4 color = ImVec4(0, 0, 0, 0);
      |          ^~~~~
lib/imgui/ImGuiFileDialog.h:123:15: warning:   โ€˜std::string igfd::FileExtentionInfosStruct::iconโ€™ [-Wreorder]
  123 |   std::string icon;
      |               ^~~~
lib/imgui/ImGuiFileDialog.h:126:3: warning:   when initialized here [-Wreorder]
  126 |   FileExtentionInfosStruct(const ImVec4& vColor, const std::string& vIcon = std::string()) : color(vColor), icon(vIcon){}
      |   ^~~~~~~~~~~~~~~~~~~~~~~~

I don't know hot this can affect anything but to solve it you need to just swap order of string and ImVec4.

Current path buttons

The buttons used to show the current path should have some unique identifier (example: *itPathDecomp + "##curpath" + std::to_string(index)).
The lack of such identifier currently causes some buttons not to work, for example when the path is E:/SHADERed/src/SHADERed pressing on the latter SHADERed button does nothing.

Info:

  • OS: Windows 10
  • on latest commit

Support for wide-chars as casual calls to i.e. GetDirectory functions are LPWSTR

Describe the bug
Currently the code tends to support only ANSI strings- however calls to functions like GetFullPathName or GetLogicalDriveStrings are extended to GetLogicalDriveStringsW, not GetLogicalDriveStringsA- therefore ImGuiFileDialog will crash as it won't expect one-byte char but two-bytes char if strings will be cased to LPCWSTR or LPWSTR

To Reproduce
-/-

Expected behavior
Change all std::string to std::wstring and char to WCHAR

Desktop (please complete the following information):

  • OS: Windows 10
  • Visual Studio 2019 with C++17

LNK2019 error

Hi,

I just added your module (with your example code) into my imgui glfw example then compiled but it failed with LNK2019 error. Is there any libs that I didn't use ?

here is my code block like in example:

if (ImGui::Button("Button"))
{
	igfd::ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Choose Image", ".png\0.jpg\0.bmp\0\0", ".");
	if (igfd::ImGuiFileDialog::Instance()->FileDialog("ChooseFileDlgKey"))
	{
		// action if OK
		if (igfd::ImGuiFileDialog::Instance()->IsOk == true)
		{
			filePathName = igfd::ImGuiFileDialog::Instance()->GetFilepathName();
			filePath = igfd::ImGuiFileDialog::Instance()->GetCurrentPath();
			// action
		}
		// close
		igfd::ImGuiFileDialog::Instance()->CloseDialog("ChooseFileDlgKey");
	}
	bool ret = LoadTextureFromFile(filePath.c_str(), &my_image_texture, &my_image_width, &my_image_height);
	IM_ASSERT(ret);
}        

Thanks in advance.

You seem to be missing a scandir implementation on Windows - one below - all yours :)

#if defined WIN32 || defined WIN64

#include <windows.h>
#include <wchar.h>
#include <shlwapi.h>

int _alphasort(const void *d1, const void d2)
{
return stricmp((
(struct dirent * const )d1)->d_name, ((struct dirent * const *)d2)->d_name);
}

// Scan a directory for all its entries
#include <tchar.h>
#include <stdio.h>
#include <strsafe.h>

int scandir(const char *dirname, struct dirent ***dest, int (*sdfilter)(struct dirent *), int (*dcomp)(const void *, const void *))
{
WIN32_FIND_DATAA ffd;
char szDir[MAX_PATH];
size_t length_of_path;
HANDLE hFind = INVALID_HANDLE_VALUE;
DWORD dwError=0;

// Check that the input path plus 3 is not longer than MAX_PATH.
// Three characters are for the "*" plus NULL appended below.

StringCchLengthA(dirname, MAX_PATH, &length_of_path);

if (length_of_path > (MAX_PATH - 3))
{
printf("\nDirectory path is too long.\n");
return (-1);
}

// Prepare string for use with FindFile functions. First, copy the
// string to a buffer, then append '*' to the directory name.

StringCchCopyA(szDir, MAX_PATH, dirname);
StringCchCatA(szDir, MAX_PATH, "\*");

// 1st pass count how many entries we'll need.

size_t entry_count = 0;

{
hFind = FindFirstFileA(szDir, &ffd);

  if (INVALID_HANDLE_VALUE == hFind) 
     return -1;

  // Count all the files in the directory 

  do
  {
     entry_count++;
  }
  while (::FindNextFileA(hFind, &ffd) != 0);

  ::FindClose(hFind);

}

// Second pass allocate & store.

struct dirent **entries = (struct dirent **) malloc(sizeof(struct dirent *) * entry_count);

{
size_t index = 0;

  hFind = FindFirstFileA(szDir, &ffd);

  if (INVALID_HANDLE_VALUE == hFind) 
     return -1;

  // List all the files in the directory with some info about them.

  do
  {
     struct dirent *entry = (struct dirent*) calloc(sizeof(struct dirent), 1);
     entries[index] = entry;
     index++;
     
     char *fn = strrchr(ffd.cFileName, PATH_SEP);
     if (fn)
        fn++; // skip over seperator.
     else
        fn = ffd.cFileName;
              
     strncpy(entry->d_name, fn, PATH_MAX); 

     entry->d_type =(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? DT_DIR : DT_REG;
  }
  while (::FindNextFileA(hFind, &ffd) != 0);

  ::FindClose(hFind);

}

// Optional sort ...

if (dcomp)
qsort (entries, entry_count, sizeof(struct dirent *), dcomp);

*dest = entries;

return entry_count;
}

#endif // WIN32/64

Detached head or something in git

Is your feature request related to a problem? Please describe.
image
Source code of file dialog lays somewhere not in master, thats not good at all

Describe the solution you'd like
Store source code in simple folder (so you won't need to use submodules to download source code of this widget)

Using the latest version cannot see directories without setting filters

Describe the bug
Using the latest version containing ImGuiFileDialogFlags_DontShowHiddenFiles, when I set ImGuiFileDialog as this(want to see directories in current path):

    ImGuiFileDialog::Instance()->OpenDialog(
        "ChooseScenDownloadPath", "Choose Scenario Download Path", nullptr, ".",
        "", 1, nullptr, ImGuiFileDialogFlags_DontShowHiddenFiles);

But I get this
image

I cannot see directories when changing path. In last version which have not added the
ImGuiFileDialogFlags_DontShowHiddenFiles, it works.

I can see directories only if set the filters.(eg. set the filters .json,.txt)
image

Desktop (please complete the following information):

  • OS: Linux zcy-omen 5.4.0-58-generic #64~18.04.1-Ubuntu

File Name Input box always defaults to the first vDefaultFileName

Describe the bug
This bug happens when opening a dialog window with a different default file name. The file name is always the previous one, hence the parameter vDefaultFileName of method OpenDialog only works once. I could not find documentation if this was intended by the author, so sorry if this is not classified as a BUG, but I'd like to know what would be the correct way to change the default file name every time the parameter vDefaultFileName is different.

To Reproduce
Steps to reproduce the behavior:

  1. Simply perform a test, calling OpenDialog method with vDefaultFileName different in a posterior call:
    string file_name = "file1";
    igfd::ImGuiFileDialog::Instance()->OpenDialog("dialog1", "BUG REPORT", ".json", "relative/path/", file_name);
    // Later on the code, same line, but different default file name:
    string file_name = "file2"; // < ---- the issue, file2 is never shown as default file name in the dialog file name input box
    igfd::ImGuiFileDialog::Instance()->OpenDialog("dialog1", "BUG REPORT", ".json", "relative/path/", file_name);

Expected behavior
File name: input box always defaults to the first vDefaultFileName "file_name1".

Screenshots
Not applicable since it's not a visual bug, but a functional one.

Desktop (please complete the following information):

  • OS: Ubuntu 18.04

Additional context
Let me know if the explanation is enough. If you'd like I can provide a standalone example if you didn't get the steps, but simply changing the vDefaultFileName with the example calls mentioned here is enough to see that the default file name input box does not change to match the second OpenDialog call.

Possible fix
An ugly workaround is shown below

void ImGuiFileDialog::SetPath(const std::string &vPath)
{
	m_CurrentPath.clear(); // < ---------- forcibly clearing this works???
	m_ShowDrives = false;
	m_CurrentPath = vPath;
	m_FileList.clear();
	m_CurrentPath_Decomposition.clear();
	ScanDir(m_CurrentPath);
}

Which version of imgui do you base on ?

Describe the bug
My imgui version is 1.73. My project is organised by google's bazel.When compiling the project, the error occurs

third_party/ImGuiFileDialog/ImGuiFileDialog.cpp: In member function 'bool IGFD::FileDialog::Display(const string&, ImGuiWindowFlags, ImVec2, ImVec2)':
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1009:56: error: 'struct ImGuiWindow' has no member named 'ContentRegionRect'; did you mean 'ContentsRegionRect'?
     m_DialogCenterPos = ImGui::GetCurrentWindowRead()->ContentRegionRect.GetCenter();
                                                        ^~~~~~~~~~~~~~~~~
                                                        ContentsRegionRect
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp: In member function 'virtual void IGFD::FileDialog::DrawPathComposer()':
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1273:31: error: 'ImGuiMouseButton_Right' was not declared in this scope
      if (ImGui::IsItemClicked(ImGuiMouseButton_Right))
                               ^~~~~~~~~~~~~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1273:31: note: suggested alternative: 'ImGuiMouseCursor_Count_'
      if (ImGui::IsItemClicked(ImGuiMouseButton_Right))
                               ^~~~~~~~~~~~~~~~~~~~~~
                               ImGuiMouseCursor_Count_
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp: In member function 'virtual void IGFD::FileDialog::DrawFileListView(ImVec2)':
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1312:10: error: 'ImGuiTableFlags' does not name a type; did you mean 'ImGuiTabItemFlags'?
   static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg |
          ^~~~~~~~~~~~~~~
          ImGuiTabItemFlags
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1319:14: error: 'BeginTable' is not a member of 'ImGui'
   if (ImGui::BeginTable("##fileTable", 4, flags, vSize))
              ^~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1319:14: note: suggested alternative: 'BeginTabItem'
   if (ImGui::BeginTable("##fileTable", 4, flags, vSize))
              ^~~~~~~~~~
              BeginTabItem
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1319:43: error: 'flags' was not declared in this scope
   if (ImGui::BeginTable("##fileTable", 4, flags, vSize))
                                           ^~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1319:43: note: suggested alternative: 'llabs'
   if (ImGui::BeginTable("##fileTable", 4, flags, vSize))
                                           ^~~~~
                                           llabs
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1321:11: error: 'TableSetupScrollFreeze' is not a member of 'ImGui'
    ImGui::TableSetupScrollFreeze(0, 1); // Make header always visible
           ^~~~~~~~~~~~~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1321:11: note: suggested alternative: 'SetScrollHere'
    ImGui::TableSetupScrollFreeze(0, 1); // Make header always visible
           ^~~~~~~~~~~~~~~~~~~~~~
           SetScrollHere
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1322:11: error: 'TableSetupColumn' is not a member of 'ImGui'
    ImGui::TableSetupColumn(m_HeaderFileName.c_str(), ImGuiTableColumnFlags_WidthStretch, -1, 0);
           ^~~~~~~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1322:11: note: suggested alternative: 'NextColumn'
    ImGui::TableSetupColumn(m_HeaderFileName.c_str(), ImGuiTableColumnFlags_WidthStretch, -1, 0);
           ^~~~~~~~~~~~~~~~
           NextColumn
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1322:54: error: 'ImGuiTableColumnFlags_WidthStretch' was not declared in this scope
    ImGui::TableSetupColumn(m_HeaderFileName.c_str(), ImGuiTableColumnFlags_WidthStretch, -1, 0);
                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1322:54: note: suggested alternative: 'ImGuiTabItemFlags_SetSelected'
    ImGui::TableSetupColumn(m_HeaderFileName.c_str(), ImGuiTableColumnFlags_WidthStretch, -1, 0);
                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                      ImGuiTabItemFlags_SetSelected
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1323:11: error: 'TableSetupColumn' is not a member of 'ImGui'
    ImGui::TableSetupColumn(m_HeaderFileType.c_str(), ImGuiTableColumnFlags_WidthFixed, -1, 1);
           ^~~~~~~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1323:11: note: suggested alternative: 'NextColumn'
    ImGui::TableSetupColumn(m_HeaderFileType.c_str(), ImGuiTableColumnFlags_WidthFixed, -1, 1);
           ^~~~~~~~~~~~~~~~
           NextColumn
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1323:54: error: 'ImGuiTableColumnFlags_WidthFixed' was not declared in this scope
    ImGui::TableSetupColumn(m_HeaderFileType.c_str(), ImGuiTableColumnFlags_WidthFixed, -1, 1);
                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1323:54: note: suggested alternative: 'ImGuiColumnsFlags_NoResize'
    ImGui::TableSetupColumn(m_HeaderFileType.c_str(), ImGuiTableColumnFlags_WidthFixed, -1, 1);
                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                      ImGuiColumnsFlags_NoResize
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1324:11: error: 'TableSetupColumn' is not a member of 'ImGui'
    ImGui::TableSetupColumn(m_HeaderFileSize.c_str(), ImGuiTableColumnFlags_WidthFixed, -1, 2);
           ^~~~~~~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1324:11: note: suggested alternative: 'NextColumn'
    ImGui::TableSetupColumn(m_HeaderFileSize.c_str(), ImGuiTableColumnFlags_WidthFixed, -1, 2);
           ^~~~~~~~~~~~~~~~
           NextColumn
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1325:11: error: 'TableSetupColumn' is not a member of 'ImGui'
    ImGui::TableSetupColumn(m_HeaderFileDate.c_str(), ImGuiTableColumnFlags_WidthFixed, -1, 3);
           ^~~~~~~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1325:11: note: suggested alternative: 'NextColumn'
    ImGui::TableSetupColumn(m_HeaderFileDate.c_str(), ImGuiTableColumnFlags_WidthFixed, -1, 3);
           ^~~~~~~~~~~~~~~~
           NextColumn
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1329:8: error: 'ImGuiTableSortSpecs' was not declared in this scope
    if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs())
        ^~~~~~~~~~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1329:8: note: suggested alternative: 'ImGuiTabItem'
    if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs())
        ^~~~~~~~~~~~~~~~~~~
        ImGuiTabItem
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1329:29: error: 'sorts_specs' was not declared in this scope
    if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs())
                             ^~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1329:50: error: 'TableGetSortSpecs' is not a member of 'ImGui'
    if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs())
                                                  ^~~~~~~~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1346:11: error: 'TableHeadersRow' is not a member of 'ImGui'
    ImGui::TableHeadersRow();
           ^~~~~~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1398:14: error: 'TableNextRow' is not a member of 'ImGui'
       ImGui::TableNextRow();
              ^~~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1402:18: error: 'TableNextColumn' is not a member of 'ImGui'
       if (ImGui::TableNextColumn()) // file name
                  ^~~~~~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1402:18: note: suggested alternative: 'NextColumn'
       if (ImGui::TableNextColumn()) // file name
                  ^~~~~~~~~~~~~~~
                  NextColumn
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1406:18: error: 'TableNextColumn' is not a member of 'ImGui'
       if (ImGui::TableNextColumn()) // file type
                  ^~~~~~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1406:18: note: suggested alternative: 'NextColumn'
       if (ImGui::TableNextColumn()) // file type
                  ^~~~~~~~~~~~~~~
                  NextColumn
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1410:18: error: 'TableNextColumn' is not a member of 'ImGui'
       if (ImGui::TableNextColumn()) // file size
                  ^~~~~~~~~~~~~~~
third_party/ImGuiFileDialog/ImGuiFileDialog.cpp:1410:18: note: suggested alternative: 'NextColumn'
       if (ImGui::TableNextColumn()) // file size
                  ^~~~~~~~~~~~~~~
                  NextColumn

I think it's caused by the difference with imgui version .
Thank you !

ps.here's my cc_library of ImGuiFileDialog

load("@rules_cc//cc:defs.bzl", "cc_library")

package(default_visibility = ["//visibility:public"])

cc_library(
    name = "ImGuiFileDialog",
    srcs = [
        "GL/gl3w.c",
        "ImGuiFileDialog.cpp",
    ],
    hdrs = [
        "GL/gl3w.h",
        "GL/glcorearb.h",
        "ImGuiFileDialog.h",
        "ImGuiFileDialogConfig.h",
    ],
    includes = [
        ".",
        "GL/",
    ],
    linkopts = [
        "-ldl",
        "-lm",
        "-lGL",
        "-lGLU",
        "-lX11",
        "-lXi",
        "-lXrandr",
        "-lXxf86vm",
        "-lXinerama",
        "-lXcursor",
    ],
    deps = [
        "//third_party/imgui",
    ],
)

Desktop (please complete the following information):
x86_64
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS"
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"

Documentation needed for use as addon, instead of modifying existing project

I am attempting to include this library and use it in my application which is running on DirectX11, which is different than the OpenGL that the example application here uses, so I am trying to incorporate the FileDialog code into my app (using Visual Studio 2019, Windows).

I have been having issues. It would be the best if there was documentation on how to add this in to preexisting projects.

Larger Fonts Hide Buttons

Describe the bug
The Cancel and Ok buttons do not fit on the window with larger fonts. I believe that it is due to the fixed number on line 719 which sets the space available after the file list to 120 pixels. This should be scaled depending on the size of the font.

To Reproduce
Steps to reproduce the behavior:

  1. Load a font with a font size greater than 15.
  2. Open the File Dialog

Expected behavior
I would expect that the buttons are always visible no matter the font size and that the length of the file list is scaled to use less space. Although it is possible to reveal the buttons with the scroll bar, I believe that this behavior is undesirable.

Not enough GUI backends

For now, there's only GLFW+GLAD+OPENGL support, AFAIK, so it's hard to integrate ImGuiFileDialog into a project that uses something else (SDL2+GLEW+OPENGL in my case)

It would be great if user could decide which backend to use either by providing them as variable in his project which later would be used by cmake in FileDialog build script or by selecting from predefined options.

Only for Windows.

This code is 100% only for Windows. Apart from the many many Windows specific bits, like using the \ character as a path separator, Microsoft have once again horribly bastardised a standard Posix function. The whole "dirent" family of functions are clearly very very different on Windows to any Posix system.

Apart from that, thankyou for taking the time to write this. It will be much quicker for me to fix this than write my own from scratch.

Multiple file dialogs with different filters conflict

I created two file dialogs, one for .ext1 and another for .ext2. When I choose my first file using dialog 1 with filter .ext1, everything works perfectly. But when I try using the second dialog, it still filters according to .ext1 instead of using .ext2.

A way around this is triggering the combo box for choosing filters, which shows the right filters, and just pressing on .ext2 for example. This refreshes the filters somehow. I still don't know how to fix this in code, as I don't understand the filtering much.

This should be easy to fix since using the combo box and selecting the right extensions results in the expected behavior, but I'm not as familiar with the library. Tu peux m'aider? @aiekick

[EDIT]
This code workaround works, I added to ALL OpenDialog constructors :

void ImGuiFileDialog::OpenDialog(const std::string & vKey, const char* vName, const char* vFilters,
	const std::string & vPath, const std::string & vDefaultFileName,
	const std::function<void(std::string, bool*)> & vOptionsPane, size_t vOptionsPaneWidth, const std::string & vUserString)
{
	if (m_ShowDialog) // si deja ouvert on ne fou pas la merde en voulant en ecrire une autre
		return;

	dlg_key = vKey;
	dlg_name = std::string(vName);
	dlg_filters = vFilters;
	dlg_path = vPath;
	dlg_defaultFileName = vDefaultFileName;
	dlg_optionsPane = std::move(vOptionsPane);
	dlg_userString = vUserString;
	dlg_optionsPaneWidth = vOptionsPaneWidth;

	dlg_defaultExt = "";

	+int itemIdx = 0;
	+const char* p = dlg_filters;
	+while (*p)
	+{
	+	if (FilterIndex == itemIdx)
	+	{
	+		m_SelectedExt = std::string(p);
	+		break;
	+	}
	+	p += strlen(p) + 1;
	+	itemIdx++;
	+}

	m_ShowDialog = true;
}

I copied this code from comboClick in the filter combo box display in FileDialog.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.