Coder Social home page Coder Social logo

pupene_imgui's Introduction

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

pupene_imgui's People

Contributors

junkdog avatar

Watchers

 avatar

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.