ImGui-Addons
ImGui-Addons copied to clipboard
Testing on Linux
I tested compiling on Linux and this is what I found.
My system (Arch Linux) does not supply d_namlen
or define _DIRENT_HAVE_D_NAMLEN
.
There are a few windows-specific calls used:
-
GetLogicalDriveStringsA
-
GetLogicalDriveStringsA
-
GetDriveTypeA
Here are the errors. (warnings ommited)
$ clang++ -c FileBrowser/ImGuiFileBrowser.cpp -I imgui -o ImGuiFileBrowser.cpp
FileBrowser/ImGuiFileBrowser.cpp:306:51: error: no member named 'd_namlen' in 'dirent'; did you mean 'd_reclen'?
if((ent->d_name[0] == '.' && ent->d_namlen == 1))
^~~~~~~~
d_reclen
/usr/include/bits/dirent.h:31:24: note: 'd_reclen' declared here
unsigned short int d_reclen;
^
FileBrowser/ImGuiFileBrowser.cpp:308:28: error: no member named 'd_namlen' in 'dirent'; did you mean 'd_reclen'?
if( !(ent->d_namlen == 2 && ent->d_name[0] == '.' && ent->d_name[1] == '.') )
^~~~~~~~
d_reclen
/usr/include/bits/dirent.h:31:24: note: 'd_reclen' declared here
unsigned short int d_reclen;
^
FileBrowser/ImGuiFileBrowser.cpp:319:55: error: no member named 'd_namlen' in 'dirent'; did you mean 'd_reclen'?
if((ent->d_name[0] == '.' && ent->d_namlen > 1))
^~~~~~~~
d_reclen
/usr/include/bits/dirent.h:31:24: note: 'd_reclen' declared here
unsigned short int d_reclen;
^
FileBrowser/ImGuiFileBrowser.cpp:361:9: error: unknown type name 'DWORD'
DWORD len = GetLogicalDriveStringsA(0,NULL);
^
FileBrowser/ImGuiFileBrowser.cpp:361:21: error: use of undeclared identifier 'GetLogicalDriveStringsA'
DWORD len = GetLogicalDriveStringsA(0,NULL);
^
FileBrowser/ImGuiFileBrowser.cpp:370:16: error: use of undeclared identifier 'DRIVE_REMOVABLE'
if(DRIVE_REMOVABLE == GetDriveTypeA(drv))
^
FileBrowser/ImGuiFileBrowser.cpp:370:35: error: use of undeclared identifier 'GetDriveTypeA'
if(DRIVE_REMOVABLE == GetDriveTypeA(drv))
^
FileBrowser/ImGuiFileBrowser.cpp:372:21: error: use of undeclared identifier 'DRIVE_FIXED'
else if(DRIVE_FIXED == GetDriveTypeA(drv))
^
FileBrowser/ImGuiFileBrowser.cpp:372:36: error: use of undeclared identifier 'GetDriveTypeA'
else if(DRIVE_FIXED == GetDriveTypeA(drv))
^
2 warnings and 9 errors generated.
Hey much appreciated, thanks for the effort. I removed all the calls to d_namelen
and just used a simple string. ~~As for the windows calls I did place all the windows specific calls in an #ifdef
check and I don't understand why it's still executing windows specific code on linux.~~
Holy shit, I actually defined a class function related to windows related call, silly me. Reason why the #ifdefs
won't work, will work around it shortly xD
@bwrsandman - Try checking it now, errors should be fixed with commit 7f4dd8505f537554fef8c8b9132b1cb9127642b2
And again thanks for the help
There is still one instance of d_namelen
in FileBrowser/ImGuiFileBrowser.cpp
at line 320.
Without that it compiles with this command:
clang++ imgui/examples/example_sdl_opengl3/main.cpp imgui/examples/imgui_impl_sdl.cpp imgui/examples/imgui_impl_opengl3.cpp imgui/imgui.cpp imgui/imgui_draw.cpp imgui/imgui_widgets.cpp FileBrowser/imgui_demo.cpp FileBrowser/ImGuiFileBrowser.cpp -I imgui -I imgui/examples/ -I /usr/include/SDL2 -lSDL2 -lGL -lGLEW -o imgui_demo
I would recommend you use a travis-ci to validate that new changes work.
I would note a few things though, it's a bit jarring that the directories aren't sorted. Second there shouldn't be a ..
option at root.
Additionally, clicking on root on the top bar causes an error which shouldn't happen.
The size of the file view is a bit off as you can see, there are both scroll bars horizontally and vertically. I would expect only the horizontal one.
The hidden files checkbox and the filter work as expected.
Finally, I don't know if this is just me, but double clicking on a directory to open it doesn't always works which is not ideal. The top bar works fine with clicking though.
Thanks for the amazing info, I'll look into travis-ci, first time writing code for multiple platforms. I'll fix the ..
problem appearing at the root. If you find any other bugs related to paths, do tell me as I'm unfamiliar with Unix file path system.
About the file view, yes. I had it initially hardcoded to 12 items in a columns. I'll try to fix it to automatically compute the number of items in a column based on the size so there isn't any need for the vertical one.
About the double click issue, that is strange. Does it stop working in specific cases or it's random? I'm using ImGui::IsMouseDoubleClicked(0)
to check for double clicks inside selectables and have used the double click flag for selectables as well. I see many other issues related to double clicking on ImGui's site. For example one issue on ImGui's site states the problem where double clicking actually requires 3 clicks, One for focusing, the other two are the actual double click. Is that the case here?
Also Can you tell me what backend are you using. Double clicking works fine for me on Windows and glfw3+opengl3
.
I used example_sdl_opengl3
. The double clicking is random AFAIK, I have to double-tap (laptop) for a while and then it registers.
Sorry for the delay, had been coding for 4 5 days straight so needed a rest :p Anyways I fixed the extra namelen error. Also tweaked a few things as you said. I've also added a new feature, where if you provide a list of extensions, selecting any file that doesn't have any of those extension shows an error and keeps the file dialog open.
Thanks for helping testing this on linux, really appreciate the help.
FileBrowser/ImGuiFileBrowser.cpp:358:34: error: assigning to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' (aka 'char') from incompatible type 'const char [2]'
if(name[0] = ".")
Should be if(name[0] = '.')
because it's a char.
Opening the dialog shows an empty file system.
I don't know if this happened before but I can't move the dialog either.
Actually there were two bugs in one
if(name[0] = ".")
should be if(name[0] == '.')
with the single quotes and ==
The root from the top bar works, the files are sorted and no .. from the root folder. Still can't drag the window though.