Skip to content

Mairooriam/FileTree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FileTree

Learning repository. Imgui filetree with callbacks onClick, onDoubleClick and onContextMenu with extension specific variants. If u wanna use this i recommend stripping away the callback system and actually making something good or using ImGui stuff raw.

Rendering

There are some behavior that isnt controller trough the callbacks. For example double clicking a file in filetree will open readonly preview of the file.

static std::shared_ptr<FileTree> fTree = std::make_shared<FileTree>();
static FileTreeRenderer r(fTree);
r.Render();

File Tree Screenshot

FileTree

Too bad no information about filetree. Defaults to current project directory when constructred.

Callback examples

Bad implementation of a callback system. Split into two: General and Extension specific

Extension Callback Example

Incase you add RegisterExtensionCallback the filetree will automatically add ImGui::MenuItem to ImGui::ContextMenu in File Tree Context Menu Implementation. You can also see this in the See the Check out the example for a visual example. red and purple boxes compares effect of this functionality.

r.RegisterExtensionCallback(".any", FileTreeRenderer::CallbackType::ContextMenu, [](const std::filesystem::path& path) {
    std::cout << "[ANY_CONTEXT] " << path.string() << " - Triggers on context menu for any file without specific handler" << std::endl;
});

General file callbacks

// File callbacks
r.RegisterFileCallback(FileTreeRenderer::CallbackType::Click, [](const std::filesystem::path& path) {});
r.RegisterFileCallback(FileTreeRenderer::CallbackType::DoubleClick, [](const std::filesystem::path& path) {});
r.RegisterFileCallback(FileTreeRenderer::CallbackType::ContextMenu, [](const std::filesystem::path& path) {});

General directory callbacks

// Director callbacks
r.RegisterDirectoryCallback(FileTreeRenderer::CallbackType::Click, [](const std::filesystem::path& path) {});
r.RegisterDirectoryCallback(FileTreeRenderer::CallbackType::DoubleClick, [](const std::filesystem::path& path) {});
r.RegisterDirectoryCallback(FileTreeRenderer::CallbackType::ContextMenu, [](const std::filesystem::path& path) {});

Extension specific callbacks

// Generic "any" extension callbacks
r.RegisterExtensionCallback(".any", FileTreeRenderer::CallbackType::Click, [](const std::filesystem::path& path) {});
r.RegisterExtensionCallback(".any", FileTreeRenderer::CallbackType::DoubleClick, [](const std::filesystem::path& path) {});
r.RegisterExtensionCallback(".any", FileTreeRenderer::CallbackType::ContextMenu, [](const std::filesystem::path& path) {});

Licenses

This project is licensed under the MIT License - see the LICENSE.txt file for details.

Third-Party Libraries

This project uses the following third-party libraries:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages