Open KeyWorksRW opened 3 months ago
This is a custom dialog, so unless the same size/button configuration makes sense for all the locations it's used for, then it should get duplicated with a unique class name for System Header Files. That will ensure that the resizing is persistent.
Adding some smarts to a <Add Custom...>
could also be helpful. E.g., walk up the directory tree to look for a CMakeLists.txt file, and if found look at the target_include_directories
for lists of project-wide directories. Looking for c_cpp_properties.json
for VSCode and the equivalent for VS might be useful as well, though less so given that the build system might not be aware of those directories. Just brainstorming, I'm envisioning a list of directories parsed out of a build system or properties that lists all the include directories for the project. Selecting one, would update a second list of all the header files (including subdirectories) in that location. So the user would first click the directory, then click the filename to add.
There are so many ways to specify an include directory with macros, lists, substitutions, etc. that there isn't any reasonable way to get the actual directory from CMakeLists.txt
. Scratch that idea...
Getting it from an IDE also isn't practical because that assumes everyone working on the project file is using the same IDE with the same configuration.
With wxWidgets, files are added in source files as #include "wx/foo.h"
which requires the build system to pass the location of the Include
directory to the compiler. Even if wxWidgets was a submodule, I can't think of any way to persistently set that location in the project file that would still work if the folder containing the project file was move into any other folder that wasn't at exactly the same level.
Using wxWidgets as the model, I could have a dialog where the dev specifies the prefix such as "wx/generic" which would be stored in the project file and then specify the location of the root folder (Include
in the wxWidgets case) which I could store on an individual basis. That would enable a file selector that would easily get to the correct directory, and could generate #include "prefix/foo.h"
which would certainly save having to type out all the filenames, and would be immune to the location of the source or header file where the #include
is generated.
There are other issues revolving around header files, so adding the 1.2.2 milestone with the intention of putting all the header issues in the same milestone.
Okay now that I have some time to actually work on this, I have questions. Taking the example of tkxLutEditorPanel.h
, if you were editing the source file manually, how would you include this in a way that would work even if you moved that source file to a different directory? Is tkx.www.libraries/imgproc
a subfolder that is under a folder you compile with something like -Iroot_include
to get "root_include/tkx.www.libraries/imgproc/tkxLutEditorPanel.h"
?
See the Edit section in the larger comment above about the way wxWidgets header files are included -- would something like that approach work better for you?
@KeyWorksRW In my case the folder tkx.www.libraries/imgproc/tkxImageViewerPanel.h
would be inserted by using system_hdr_includes attribute, which results in a line of code like #include <kx.www.libraries/imgproc/tkxImageViewerPanel.h>
<> symbols are used to include header files that are part of the standard library or other libraries installed in the system's include path. With angle brackets, the compiler searches for the file in predefined directories, such as system directories or directories specified with compiler options.
Actually I can't achive it as the editor you provide inserts always a relative path to the wxUI project. Instead, it is necessary to enable users to insert a header file using the editor while avoiding making it relative for both Local and system headers files.
As I see it, you should modify your dialog in this way, no more than this. That's why, in my picture above, I drew a new button with the sole purpose of inserting 'free text'
It is already possible, but it is necessary to modify directly local_hdr_includes and system_hdr_includes attributes, which is unconfortable if you have may files to insert.
Discussed in https://github.com/KeyWorksRW/wxUiEditor/discussions/1434