Code Monkey home page Code Monkey logo

imgui-app's Introduction

imgui-app

Imgui-app is an amalgamation of two amazing projects Dear Imgui and Sokol libraries into two files to make it very easy to start working with imgui. It might be useful when you need to do some UI quickly for a project but do not want to care that much how to get imgui up and running (imgui compilation, backend rendering, window handling, ...).

test.png

Howto

To start using imgui-app you need to add these two files to your project:

Once you are ready to display the UI, just call imgui_app, see the example.

#include "imgui.h"

void frame() {
    ImGui::Text("Hello, world %d", 123);
    ImGui::ShowDemoWindow();
}

int main(int, char **) {
    // when ready, call the UI:
    imgui_app(frame, "IMGUI_APP", 800, 600);
    // execution continues when window is closed
    return 0;
}

Finally, make sure to select the proper sokol render backend, by compiling your project with -DSOKOL_GLCORE33 or any of the available backends.

Optional files:

This files are not required to use imgui-app, but if you need access to more advanced components from imgui or sokol here they are:

  • imgui_internal.h. Might be needed if you need access to advanced rendering, or you us a 3rd party widget that requires it.
  • sokol.h, amalgamation of sokol_app and sokol_time. You might require this if you want to initialize the window manually and provide callbacks for sokol events (input, drag and drop, etc...).

Notes:

  • Try not to modify the files imgui.h, imgui_app.cpp, or imgui_internal.h they are generated from the original sources by the Makefile of this project
  • We chose to use imgui.h for the headers to make the project compatible with other exisiting imgui code.
  • imgui_app.cpp is BIG, it is the result of including in one file imgui, sokol, and all the dependencies. Try not to compile every time on your project :)
  • The amalgamation idea comes from Sqlite amalgamation

imgui-app's People

Contributors

philck avatar pplux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imgui-app's Issues

How to hide and unhide OS-level window (X11)?

Hello,

I want to hide and unhide the complete program window. The program is controlled through an external MIDI controller which sends the signals to hide and show. I am personally on X11 where this is called Unmap() and Map(), but other OSes need something else of course.

sokol.h has private functions to do this: _SOKOL_PRIVATE void _sapp_x11_show_window(void) and _SOKOL_PRIVATE void _sapp_x11_hide_window(void).

I want to avoid editing sokol.h and imgui.h. Any recommendation for a best practise how to extend imgui-app here?

Updating Sokol and Imgui

What would be the best path (if possible) to update Imgui and Sokol and compile the resulting new imgui_app.cpp into new archive for linking? Or is the amalgamation pretty well fixed to those branches of Sokol and Imgui?

How to access the style colors outside of the main loop Frame

I want to write my own color-scheme. I imagine it is better and more efficient to change the colors directly with GetStyle().Colors[...] = ImVec4(…)
I would have to access this before frame is called the first itme. But since imgui-app encapsulates the whole startup process into the single imgui_app()function I can't call GetStyle(). The error message says it needs to be called in a context, but calling CreateContext() is not the right one, correct?

So… how do I change the colors permanently without pushing onto the temporary color stack each frame. OR maybe pushing to the stack is no problem?

When trying to drag window with touch interface (WASM on mobile) get stuck in moving window state

I compiled using emscripten (latest pre-compiled release as of today) with the example app in the main readme for imgui-app. I then hosted the resulting html/wasm/js and tested on my mobile phone.

When I give the top of an imgui window a series of taps, it then glues to my finger and I can move it, however, all subsequent taps move the window to the new tap's location and there is no way to stop tat from happening save from restarting the application (refreshing the page).

This does not happen on the live imgui emscripten example: https://www.dearimgui.org/webdemo/master/example_emscripten.html

Any tips on how to fix this? I don't mind working on a fix and submitting a pull request if I can figure this out.

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.