[DRAFT] Project Browser - Marmalade-Engine/marmalade GitHub Wiki

[DRAFT] Project Browser API

File Type Registrations

Allows custom file types to be registered.

This will allow developers to display thumbnails, and custom context menu items to file types.

For example, the ItemRenameFunc could be used to internally change the name of an item when it is renamed in the project browser.

FileTypeCategory is a simple system for categorising file types. It is used to check if a file type is valid, e.g. in dragging and dropping of textures to make sure it is an image.

#define MATCH_BY_EXTENSION(ext)                                                  \
    .MatchFunc = &engineApi.ProjectBrowserApi->GetRegistry()->MatchByExtension, \
    .MatchFuncArgs = &(struct MatchByExtArgs) { ext }

struct FileTypeCategory {
    char* Name;
    char* Description;
};

PLUGIN_PROVIDED struct FileRegistration {
    char* Name;
    char* Description;

    MarmResult (*MatchFunc)();
    void* MatchFuncArgs;

    char* (*DisplayNameFunc)();

    MarmResult (*LoadThumbnailFunc)();

    MarmResult (*ContextMenuItemsFunc)();
    MarmResult (*ItemRenameFunc)();
    MarmResult (*ItemDeleteFunc)();
    MarmResult (*ItemClickFunc)();

    void (*FreeItemFunc)();

    struct FileTypeCategory** categories;
};

There are macros provided for convenience, for example, a file registration could be built with the following functions:

FileRegistration reg = {
    .name = "PNG",
    MATCH_BY_EXTENSION("png"),
    .display_name_func = &png_display_name,
    .load_img_func = &load_png_preview,
    DEFAULT_FILE_ACTIONS,
    .free_item = &free_png,
};

Project Browser GUI

Adding items to Project Browser GUI.