Skip to content

generic editor widget for classes/structs (C++17)

License

MIT, OFL-1.1 licenses found

Licenses found

MIT
LICENSE
OFL-1.1
SourceCodePro-license.txt
Notifications You must be signed in to change notification settings

junkdog/pupene_imgui

Repository files navigation

pupene_imgui

A small demo exploring automatically building editor widgets for structs. Objects are introspected using pupene, while imgui provides the underlying UI.

A struct:

struct complex_thing {
    vec22fi v22fi;
    vec2f xy;
    float decimal;
    int32_t integer;
    uint8_t byte;
    Color color;
    std::string hallo = "hi there";
};

Called every frame:

ui::widget::object_editor(object, config);

pupene_imgui demo

A quick intro

pupene requires that a pup() function is provided for each serializable type. These functions work with all puppers. As such, for any type for which a UI can be constructed, binary and json serialization is available too.

Simplified usage:

    // object to edit
    auto ct = complex_thing{};

    // the config object holds state for the current editor
    auto config = EditorConfig{"object"};
    config.filter.pattern.reserve(50); // rough edges

    while (!poll_events(key_callback)) {
        render_frame(window, [&ct, &config]() {
            
            // called each frame
            ui::widget::object_editor(ct, config);
        });
    }

pup-fns.h contains all necessary pup() functions and types.

Project setup

This has only been tested on Kubuntu 17.10, using clang-5.0 and gcc 7.2. It should/might work elsewhere too.

Requirements:

  • Recent compiler with C++17 support
  • CMake 3.8+
  • Python and conan (pip install conan)

Add this conan remote for imgui and pupene dependencies:

conan remote add junkdog https://api.bintray.com/conan/junkdog/conan

Configure

This step also builds the dependencies and installs them into the local conan cache.

cmake -H. -B_builds \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=_install

Build

 cmake --build _builds --target install -- -j 8

Run

Unless running the executable from a folder containingSourceCodePro-Semibold.ttf, the default imgui font will be used.

cd _install/bin
./example

About

generic editor widget for classes/structs (C++17)

Topics

Resources

License

MIT, OFL-1.1 licenses found

Licenses found

MIT
LICENSE
OFL-1.1
SourceCodePro-license.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published