Coder Social home page Coder Social logo

imgui-addons's People

Contributors

bwrsandman avatar gallickgunner avatar gargaj avatar havardgraff avatar jared-swislow-haptx avatar lluns avatar rickyviking avatar ricop avatar rishabhsinghvi avatar schmidt9898 avatar sphaero 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

imgui-addons's Issues

Invalid new path if clicking on folder that has same name as a parent or contains part of a parent's name

Here's a simple fix I made. I haven't tested it thoroughly but it seems to have fix the bug.

- new_path = current_path.substr(0, current_path.find("/" + current_dirlist[idx]) + current_dirlist[idx].length() + 2 );
+ {
+     new_path = "";
+     for (auto iter = current_dirlist.begin() + 1; iter != current_dirlist.begin() + idx + 1; ++iter)
+         new_path += *iter + "/";
+ }

Since there was two folders with the same name in the path, if you navigate to the deepest one by clicking on it the current_path.find is going to find the first folder instead.

Example: C:/a/path/to/a/folder

Clicking on the second folder "a" is going to cause the bug. In this case the path is still valid.

Example: C:/app/path/to/a/folder

In that case the new path would be "C:/ap" which does not exist.

Cannot pop up file dialog with ImGui 1.84.2

Hi,

I'm trying to get the file dialog working using 1.84.2 but the dialog is not showing up
the function BeginPopupModal line 130 returns false:
if (ImGui::BeginPopupModal(label.c_str(), nullptr, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse))

my code:

    bool open = false;

    if (ImGui::MenuItem("Open", "Ctrl+O"))
    {
        open = true;
    }
    if (open)
    {
        ImGui::OpenPopup("Open File");
    }
    if (file_dialog.showFileDialog("Open File", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN, ImVec2(700, 310), ".bin"))
    {
       //std::cout << file_dialog.selected_fn << std::endl;      // The name of the selected file or directory in case of Select Directory dialog mode
       // std::cout << file_dialog.selected_path << std::endl;    // The absolute path to the selected file
    }

How to use cancel?

I don't see how to differentiate between the user clicking cancel and the user not giving any input. Looking at the code, it appears like clicking cancel causes showFileDialog to return false, just like if the user didn't click anything. Is there something I am missing here? Would it be possible to give a quick example of how the cancel button works?

Remember the last opened path

Hello,

Currently, the initial path looks based on the current path.
Is there any way to set the last opened path as the initial path?
Thank you

Incorrect child window height in "Invalid File!" popup

Issue

  • Invalid visual height with empty content
  • User interaction is blocked, no OK button showing and thus no way back

See the screenshot below
Screenshot 2023-06-03 at 06 16 48

Ways to reproduce

  1. Open the dialog with only one extension provided (e.g. .zip)
  2. Pick a nonexistent file path

Cause

float cw_content_height = (valid_exts.size() - 1) * frame_height;
float cw_height = std::min<float>(4.0f * frame_height, cw_content_height);

The fact that valid_exts.size() - 1 is regarded as "display extension count" is based on the assumption that there is a "All valid files" in the valid_exts, which is only true if users provided more than 1 extension.
In the case of 1 extension, cw_height would be 0 which is invalid for BeginChild().

Possible fix

  • auto ext_count = valid_exts.back() == "All valid files" ? valid_exts.size() - 1 : valid_exts.size(), and replace the 2 occurrences of valid_exts.size() - 1

P.S. I tried that and it works, except that the visual is not very pleasing with child window showing scrollbar, so I think it's best for the repo owner to fix this problem.

validateFile extension bug

Hi, i've found a small bug inside the bool validateFile() function, file ImGuiFileBrowser.cpp, line 1055:

std::string file_ext = idx == std::string::npos ? "" : selected_fn.substr(idx, selected_fn.length() - idx);

is returning ".ext"

while in needed the extension without the dot to correctly check, "ext"

so idx+1, in the substring extraction, fix the issue:

std::string file_ext = idx == std::string::npos ? "" : selected_fn.substr(idx+1, selected_fn.length() - idx);

enum value changed

Thanks for sharing your code.
I think
ImGuiSelectableFlags_PressedOnClick
is obsolete (and does not compile with the latest version of ImGUI) and I replaced it with
ImGuiSelectableFlags_SelectOnClick
but I am not 100% sure.

Bests
Roberto

Filter Alignment issue (20/02/12 version)

Hi ,

I'm using the extension on Windows , and I get this opening the file dialog :
filebrowserproblem
As you can see there's a small alignment problem of the filter that is behind the file list.
Anyway thanks for your work ! Until now it's the best file browser for imgui windows users :)

SELECT folder option

It would be great for the SELECT folder option to specify also a file filter, so as to get also the list of those filenames contained in the selected folder. Something like this:

file_dialog.showFileDialog("Select Directory##popup", imgui_addons::ImGuiFileBrowser::DialogMode::SELECT, ImVec2(500,300), ".zip,.tgz", &filelist)

Thanks
-R

Min Max macros in Windows (again)

Not sure what change made this happen but I can't build on Windows anymore with imgui 1.85.

C:\projects\gazebosc-sphaero\ext\ImGui-Addons\FileBrowser\ImGuiFileBrowser.cpp(121,46): error C2589: '(': illegal token on right side of '::' [C:\projects\gazebosc-sphaero\build\gazebosc.vcxproj]
C:\projects\gazebosc-sphaero\ext\ImGui-Addons\FileBrowser\ImGuiFileBrowser.cpp(121): error C2144: syntax error: 'unknown-type' should be preceded by ')' [C:\projects\gazebosc-sphaero\build\gazebosc.vcxproj]

Very much related to #7

I think it can also be fixed by using std::max<float> instead of std::max etc

However it's just a workaround.

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.

Unable to specify folder…

Hi GallickRunner,

The dialog window works great! Is there a way to provide the dialog window with a path that would override the default path? There are cases where an application may want to specify a location, based on the context of the operation. I did attempt to make a tweak, but haven’t been successful.

Peter

Problem compiling in Windows

Hello, I have a program that currently runs on Linux, and I'm porting it to windows too.

I'm trying to use clang++ on windows to build it, but it gives me an error:

The command used to build is the following:

clang++ -c --std=c++17 ../ImGui-Addons/FileBrowser/ImGuiFileBrowser.cpp -I../ImGui-Addons/imgui -o filebrowser.o

(My makefile was not working, so i'm doing this at the moment)

It gives me the errors:

../ImGui-Addons/FileBrowser/ImGuiFileBrowser.cpp:589:47: error: no member named 'GetFocusScopeID' in namespace 'ImGui'; did you mean
      'GetFocusScope'?
        if(show_inputbar_combobox && ( ImGui::GetFocusScopeID() == focus_scope_id || ImGui::GetCurrentContext()->ActiveIdIsAliv...      
                                       ~~~~~~~^~~~~~~~~~~~~~~
                                              GetFocusScope
../ImGui-Addons/imgui\imgui_internal.h:2276:29: note: 'GetFocusScope' declared here
    inline ImGuiID          GetFocusScope()                 { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.NavFocusScop...     
                            ^
../ImGui-Addons/FileBrowser/ImGuiFileBrowser.cpp:614:113: error: use of undeclared identifier 'ImGuiSelectableFlags_PressedOnClick'; did
      you mean 'ImGuiSelectableFlags_SelectOnClick'?
  ...false, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_PressedOnClick))
                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                     ImGuiSelectableFlags_SelectOnClick
../ImGui-Addons/imgui\imgui_internal.h:728:5: note: 'ImGuiSelectableFlags_SelectOnClick' declared here
    ImGuiSelectableFlags_SelectOnClick          = 1 << 21,  // Override button behavior to react on Click (default is Click+Release)  

Can someone give me some help?

errors when compiling

Hello, I just started using imgui about 2 days ago, only thing i changed was in ImGuiFileBrowser.h from #include <imgui.h> to #include "imgui.h. and I get all these errors and I dont get whats wrong.
error
If someone could give a noob any help it would be appreciated.

ImGuiSelectableFlags_PressedOnClick becomes ImGuiSelectableFlags_SelectOnClick ?

Hi there,
first, a big thx for this addon to Imgui.
Then it seems that there has been a litle change in Imgui, so that your file does not compile anymore with Imgui 1.77.
In imgui_internal.h it seems that ImGuiSelectableFlags_PressedOnClick becomes ImGuiSelectableFlags_SelectOnClick .
So you have to change accordingly you ImguiFileBrowser.ccp , line 615 .
I suppose that this line was in relation with the file filter combobox that seems to work ok.

Is there a way to only display a browser for a single directory?

I'm working on a game engine, and I'm already using this file browser to open and save projects and scenes. However, I'd also like to use it for selecting sprites, scripts, etc, but they are only in the Assets folder, so how could I modify it to only search in the Assets folder?

Change Style

Hello, first of all, thanks for your contribution, works so well.

I'm trying to change de style, but don't find how to change the yellow color of the text inside the popup.

image

The style at the moment I'm changing it like this

image

Thanks for your attention.

Allowing any files on subsequent file dialogs after using "All valid files"

After the file dialog is used once and a file is selected with the option "All valid files," the next file dialog opened will have the first extension selected, but will allow all files to be selected. The problem persists on future file dialogs until another extension is selected on the drop down

Steps to reproduce

  1. Open a file dialog
  2. Select "All valid files"
  3. Select any file
  4. Open another file dialog. Now the first extension will be selected, but all files will be listed and able to be selected

Like I said, it goes back to normal after the user selects an extension from the dropdown

Usage example in README missing a call to ImGui::EndMenu()

The example code in the README is missing a ImGui::EndMenu() after a call to ImGui::BeingMenu("Menu"). This was causing the following error when trying to click on the top bar:

void ImGui::EndMenuBar(): Assertion `window->Flags & ImGuiWindowFlags_MenuBar' failed.

Adding the missing line should make it work again:

if(ImGui::BeginMainMenuBar())
{
        if (ImGui::BeginMenu("Menu"))
        {
            if (ImGui::MenuItem("Open", nullptr))
                open = true;
            if (ImGui::MenuItem("Save", nullptr))
                save = true;

            ImGui::EndMenu();
        }
        ImGui::EndMainMenuBar();
}

Improvements

I started to play with the extension but I can see several improvement that could be made. It(s just my point , so it could differs from one to another :)

Here's a Windows 10 file dialog :
filebrowser2

The allowed extensions are displayed in a list at the right of the filter in a list after the name filter.
So the names that don't corresponding to the extension pattern are not displayed , so not selectable.

Moreover, adding the classical jokers like '*' to the filter could be an improvement, at least for windows users :)

Finally it should be possible to pass a filename as a string to open the save dialog , to allow acting as a 'save as' with a already existing file

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.