Giter Site home page Giter Site logo

ocornut / imgui Goto Github PK

View Code? Open in Web Editor NEW
55.7K 1.0K 9.6K 90.83 MB

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies

License: MIT License

C 9.53% C++ 88.62% Objective-C 0.15% Objective-C++ 1.66% Shell 0.01% GLSL 0.02% GDB 0.01%
gui gamedev tools ui toolkit native imgui api cplusplus framework library game-development game-engine multi-platform immediate-gui

imgui's Introduction

Dear ImGui

"Give someone state and they'll have a bug one day, but teach them how to represent state in two separate locations that have to be kept in sync and they'll have bugs for a lifetime." -ryg

Build Status Static Analysis Status Tests Status

(This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using Dear ImGui, please consider reaching out.)

Businesses: support continued development and maintenance via invoiced sponsoring/support contracts:
  E-mail: contact @ dearimgui dot com
Individuals: support continued development and maintenance here. Also see Funding page.

The Pitch - Usage - How it works - Releases & Changelogs - Demo - Integration
Gallery - Support, FAQ - How to help - Funding & Sponsors - Credits - License
Wiki - Extensions - Languages bindings & frameworks backends - Software using Dear ImGui - User quotes

The Pitch

Dear ImGui is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline-enabled application. It is fast, portable, renderer agnostic, and self-contained (no external dependencies).

Dear ImGui is designed to enable fast iterations and to empower programmers to create content creation tools and visualization / debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal and lacks certain features commonly found in more high-level libraries.

Dear ImGui is particularly suited to integration in game engines (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on console platforms where operating system features are non-standard.

  • Minimize state synchronization.
  • Minimize UI-related state storage on user side.
  • Minimize setup and maintenance.
  • Easy to use to create dynamic UI which are the reflection of a dynamic data set.
  • Easy to use to create code-driven and data-driven tools.
  • Easy to use to create ad hoc short-lived tools and long-lived, more elaborate tools.
  • Easy to hack and improve.
  • Portable, minimize dependencies, run on target (consoles, phones, etc.).
  • Efficient runtime and memory consumption.
  • Battle-tested, used by many major actors in the game industry.

Usage

The core of Dear ImGui is self-contained within a few platform-agnostic files which you can easily compile in your application/engine. They are all the files in the root folder of the repository (imgui*.cpp, imgui*.h). No specific build process is required. You can add the .cpp files into your existing project.

Backends for a variety of graphics API and rendering platforms are provided in the backends/ folder, along with example applications in the examples/ folder. You may also create your own backend. Anywhere where you can render textured triangles, you can render Dear ImGui.

See the Getting Started guide and Integration section of this document for more details.

After Dear ImGui is set up in your application, you can use it from _anywhere_ in your program loop:

ImGui::Text("Hello, world %d", 123);
if (ImGui::Button("Save"))
    MySaveFunction();
ImGui::InputText("string", buf, IM_ARRAYSIZE(buf));
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);

sample code output (dark, segoeui font, freetype) sample code output (light, segoeui font, freetype)

// Create a window called "My First Tool", with a menu bar.
ImGui::Begin("My First Tool", &my_tool_active, ImGuiWindowFlags_MenuBar);
if (ImGui::BeginMenuBar())
{
    if (ImGui::BeginMenu("File"))
    {
        if (ImGui::MenuItem("Open..", "Ctrl+O")) { /* Do stuff */ }
        if (ImGui::MenuItem("Save", "Ctrl+S"))   { /* Do stuff */ }
        if (ImGui::MenuItem("Close", "Ctrl+W"))  { my_tool_active = false; }
        ImGui::EndMenu();
    }
    ImGui::EndMenuBar();
}

// Edit a color stored as 4 floats
ImGui::ColorEdit4("Color", my_color);

// Generate samples and plot them
float samples[100];
for (int n = 0; n < 100; n++)
    samples[n] = sinf(n * 0.2f + ImGui::GetTime() * 1.5f);
ImGui::PlotLines("Samples", samples, 100);

// Display contents in a scrolling region
ImGui::TextColored(ImVec4(1,1,0,1), "Important Stuff");
ImGui::BeginChild("Scrolling");
for (int n = 0; n < 50; n++)
    ImGui::Text("%04d: Some text", n);
ImGui::EndChild();
ImGui::End();

my_first_tool_v188

Dear ImGui allows you to create elaborate tools as well as very short-lived ones. On the extreme side of short-livedness: using the Edit&Continue (hot code reload) feature of modern compilers you can add a few widgets to tweak variables while your application is running, and remove the code a minute later! Dear ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, an entire game-making editor/framework, etc.

How it works

The IMGUI paradigm through its API tries to minimize superfluous state duplication, state synchronization, and state retention from the user's point of view. It is less error-prone (less code and fewer bugs) than traditional retained-mode interfaces, and lends itself to creating dynamic user interfaces. Check out the Wiki's About the IMGUI paradigm section for more details.

Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes required to render them is fairly small. Because Dear ImGui doesn't know or touch graphics state directly, you can call its functions anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate Dear ImGui with your existing codebase.

A common misunderstanding is to mistake immediate mode GUI for immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes as the GUI functions are called. This is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are decently optimal and you can render them later, in your app or even remotely.

Releases & Changelogs

See Releases page for decorated Changelogs. Reading the changelogs is a good way to keep up to date with the things Dear ImGui has to offer, and maybe will give you ideas of some features that you've been ignoring until now!

Demo

Calling the ImGui::ShowDemoWindow() function will create a demo window showcasing a variety of features and examples. The code is always available for reference in imgui_demo.cpp. Here's how the demo looks.

You should be able to build the examples from sources. If you don't, let us know! If you want to have a quick look at some Dear ImGui features, you can download Windows binaries of the demo app here:

The demo applications are not DPI aware so expect some blurriness on a 4K screen. For DPI awareness in your application, you can load/reload your font at a different scale and scale your style with style.ScaleAllSizes() (see FAQ).

Integration

See the Getting Started guide for details.

On most platforms and when using C++, you should be able to use a combination of the imgui_impl_xxxx backends without modification (e.g. imgui_impl_win32.cpp + imgui_impl_dx11.cpp). If your engine supports multiple platforms, consider using more imgui_impl_xxxx files instead of rewriting them: this will be less work for you, and you can get Dear ImGui running immediately. You can later decide to rewrite a custom backend using your custom engine functions if you wish so.

Integrating Dear ImGui within your custom engine is a matter of 1) wiring mouse/keyboard/gamepad inputs 2) uploading a texture to your GPU/render engine 3) providing a render function that can bind textures and render textured triangles, which is essentially what Backends are doing. The examples/ folder is populated with applications doing just that: setting up a window and using backends. If you follow the Getting Started guide it should in theory takes you less than an hour to integrate Dear ImGui. Make sure to spend time reading the FAQ, comments, and the examples applications!

Officially maintained backends/bindings (in repository):

  • Renderers: DirectX9, DirectX10, DirectX11, DirectX12, Metal, OpenGL/ES/ES2, SDL_Renderer, Vulkan, WebGPU.
  • Platforms: GLFW, SDL2/SDL3, Win32, Glut, OSX, Android.
  • Frameworks: Allegro5, Emscripten.

Third-party backends/bindings wiki page:

  • Languages: C, C# and: Beef, ChaiScript, CovScript, Crystal, D, Go, Haskell, Haxe/hxcpp, Java, JavaScript, Julia, Kotlin, Lobster, Lua, Nim, Odin, Pascal, PureBasic, Python, ReaScript, Ruby, Rust, Swift, Zig...
  • Frameworks: AGS/Adventure Game Studio, Amethyst, Blender, bsf, Cinder, Cocos2d-x, Defold, Diligent Engine, Ebiten, Flexium, GML/Game Maker Studio, GLEQ, Godot, GTK3, Irrlicht Engine, JUCE, LÖVE+LUA, Mach Engine, Magnum, Marmalade, Monogame, NanoRT, nCine, Nim Game Lib, Nintendo 3DS/Switch/WiiU (homebrew), Ogre, openFrameworks, OSG/OpenSceneGraph, Orx, Photoshop, px_render, Qt/QtDirect3D, raylib, SFML, Sokol, Unity, Unreal Engine 4/5, UWP, vtk, VulkanHpp, VulkanSceneGraph, Win32 GDI, WxWidgets.
  • Many bindings are auto-generated (by good old cimgui or newer/experimental dear_bindings), you can use their metadata output to generate bindings for other languages.

Useful Extensions/Widgets wiki page:

  • Automation/testing, Text editors, node editors, timeline editors, plotting, software renderers, remote network access, memory editors, gizmos, etc. Notable and well supported extensions include ImPlot and Dear ImGui Test Engine.

Also see Wiki for more links and ideas.

Gallery

Examples projects using Dear ImGui: Tracy (profiler), ImHex (hex editor/data analysis), RemedyBG (debugger) and hundreds of others.

For more user-submitted screenshots of projects using Dear ImGui, check out the Gallery Threads!

For a list of third-party widgets and extensions, check out the Useful Extensions/Widgets wiki page.

Custom engine erhe (docking branch)
erhe
Custom engine for Wonder Boy: The Dragon's Trap (2017)
the dragon's trap
Custom engine (untitled)
editor white
Tracy Profiler (github)
tracy profiler

Support, Frequently Asked Questions (FAQ)

See: Frequently Asked Questions (FAQ) where common questions are answered.

See: Getting Started and Wiki for many links, references, articles.

See: Articles about the IMGUI paradigm to read/learn about the Immediate Mode GUI paradigm.

See: Upcoming Changes.

See: Dear ImGui Test Engine + Test Suite for Automation & Testing.

For the purposes of getting search engines to crawl the wiki, here's a link to the Crawable Wiki (not for humans, here's why).

Getting started? For first-time users having issues compiling/linking/running or issues loading fonts, please use GitHub Discussions. For ANY other questions, bug reports, requests, feedback, please post on GitHub Issues. Please read and fill the New Issue template carefully.

Private support is available for paying business customers (E-mail: contact @ dearimgui dot com).

Which version should I get?

We occasionally tag Releases (with nice releases notes) but it is generally safe and recommended to sync to latest master or docking branch. The library is fairly stable and regressions tend to be fixed fast when reported. Advanced users may want to use the docking branch with Multi-Viewport and Docking features. This branch is kept in sync with master regularly.

Who uses Dear ImGui?

See the Quotes, Funding & Sponsors, and Software using Dear ImGui Wiki pages for an idea of who is using Dear ImGui. Please add your game/software if you can! Also, see the Gallery Threads!

How to help

How can I help?

  • See GitHub Forum/Issues.
  • You may help with development and submit pull requests! Please understand that by submitting a PR you are also submitting a request for the maintainer to review your code and then take over its maintenance forever. PR should be crafted both in the interest of the end-users and also to ease the maintainer into understanding and accepting it.
  • See Help wanted on the Wiki for some more ideas.
  • Be a Funding Supporter! Have your company financially support this project via invoiced sponsors/maintenance or by buying a license for Dear ImGui Test Engine (please reach out: omar AT dearimgui DOT com).

Sponsors

Ongoing Dear ImGui development is and has been financially supported by users and private sponsors.
Please see the detailed list of current and past Dear ImGui funding supporters and sponsors for details.
From November 2014 to December 2019, ongoing development has also been financially supported by its users on Patreon and through individual donations.

THANK YOU to all past and present supporters for helping to keep this project alive and thriving!

Dear ImGui is using software and services provided free of charge for open source projects:

Credits

Developed by Omar Cornut and every direct or indirect contributors to the GitHub. The early version of this library was developed with the support of Media Molecule and first used internally on the game Tearaway (PS Vita).

Recurring contributors include Rokas Kupstys @rokups (2020-2022): a good portion of work on automation system and regression tests now available in Dear ImGui Test Engine.

Maintenance/support contracts, sponsoring invoices and other B2B transactions are hosted and handled by Disco Hello.

Omar: "I first discovered the IMGUI paradigm at Q-Games where Atman Binstock had dropped his own simple implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating and improving it."

Embeds ProggyClean.ttf font by Tristan Grimmer (MIT license).
Embeds stb_textedit.h, stb_truetype.h, stb_rect_pack.h by Sean Barrett (public domain).

Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. Also thank you to everyone posting feedback, questions and patches on GitHub.

License

Dear ImGui is licensed under the MIT License, see LICENSE.txt for more information.

imgui's People

Contributors

andres-asm avatar andrewwillmott avatar bear24rw avatar bfierz avatar bkaradzic avatar cfillion avatar clownacy avatar domgries avatar elect86 avatar eliasdaler avatar gamingminds-danielc avatar jdm3 avatar jtilander avatar loftilus avatar martty avatar memononen avatar nicolasnoble avatar ocornut avatar particlepeter avatar pathogendavid avatar podsvirov avatar rokups avatar samhocevar avatar septag avatar shironekoben avatar stuartcarnie avatar thedmd avatar warrenm avatar waywardmonkeys avatar xipiryon 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  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

imgui's Issues

Font quality in Linux

Running Ubuntu with the latest GLWF 3.0.4, fonts are very poorly rendered. The rightmost column of each glyph is clipped off, and the y baseline of each glyph is not consistent.

image

Feature request - Intercept certain keypresses in text input fields?

I was looking to make a sort of script console with ImGui but as it is the text input is pretty un-customizable. I'd like to be able to hit the up arrow to go through history (which I could manage myself, no need to put input history in ImGui) and use tab for autocompletion (again, I can handle that).

InputText looks for a bunch of specific keys with IsKeyPressedMap() and then delegates them to edit_state or the stb_textedit control. Obviously that's where the customized keys need to be intercepted. Maybe it could take a structure that holds two arrays, one that flags which keys have custom behavior, and one to put the state of the key in:

struct InputTextKeyOverrides
{
    bool IsOverridden[ImGuiKey_Count];
    bool IsPressed[ImGuiKey_Count];
};

...

bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags, InputTextKeyOverrides* overrides)
{
...

if (IsKeyPressedMap(ImGuiKey_UpArrow)) {
    if(overrides->IsOverridden[ImGuiKey_UpArrow])
        overrides->IsKeyPressed[ImGuiKey_UpArrow] = true;
    else
        edit_state.OnKeyboardPressed(STB_TEXTEDIT_K_UP | k_mask);
}

And then user code would check for a keypress after calling InputText and handle it appropriately. (Would be nice to have an ImGuiKey_Tab for this as well.)

I dunno, just a thought.

Patreon page - feedback & support imgui development

I have just set up a Patreon page - http://www.patreon.com/imgui

I'm interested in feedback about this. Obviously this won't change the license and it's not aimed at changing the dynamics of the project. It is just a way for me to see if it could allow me to sit down and spend focused days working on ImGui.

The idea is that I'm currently out of job, about to start a freelancing lifestyle. As much as I would love spending lots of time on ImGui I can't really justify it from an economical point of view so my time on it is rather limited at the moment. Because I have been hearing of various companies using ImGui for their work I would like the test the waters and see if Patreon might provide enough financial support to allow me to spend more time on ImGui (xxx days a week).

I don't expect small developers to financially support the project but for a middle-sized company it may be make sense to provide Patreon support rather than invest their own developers on improving/maintaining the library.

Again just testing the waters, please feedback!

patreon

Range Slider

I would find a range slider very handy. Any plans to implement one?

ImGui needs a better name!

ImGui is a generic term which makes googling for this library uneasy.
While we can keep the git and source code "imgui" (if desired), it would be beneficial to include a keyword or two that would uniquely identify the library. Any suggestions?

Clamped frame rate usage and ImGui::MouseDoubleClicked

Hi everybody. Many compliments for the project! That's what I was looking for...
I'm new to ImGui (and to Github thanx to ImGui), so please be patient with me...
Now the issue:

I've found out that when I clamp the frame rate of my application to save CPU/GPU usage, double clicks stop working.
That's probably caused to the fact that ImGui::NewFrame() is called less frequently and the ImGui::MouseDoubleClickTime is too small to catch double clicks in these cases.

I've been able to work around the issue by using my own variables, catching double click events myself and refeeding the ImGui::MouseDoubleClicked array with them soon after ImGui::NewFrame().

This works, but maybe we could add a variable to tell ImGui we're going to set the ImGui::MouseDoubleClicked array directly ourself and ImGui should skip updating it inside ImGui::NewFrame(), can't we?

Another think I would like to know is whether or not ImGui can be used at zero frame per seconds.
I mean in 3D editor-like applications, where a postUpdate() should be called only as a response to some action by the user (e.g. dragging a window and stuff like that). That's the main reason why I've tried clamping the frame rate in the first place (currently I've tested it at 10 fps: ImGui works well with the double click fix, it's only not very smooth when dragging a window).

P.S. I'm using openGL on Ubuntu Linux 64 bit, but that shouldn't make any difference.

P.S.2. Actually another minor issue happened when working at low frame rates with my fix: in the demo project I wasn't able to minimize the "Debug" window (double clicking its title bar). All the other windows work as expected. And if I add the ImGui::Begin()/End() when creating it PLUS a name different from "Debug" it starts working again.

Wrong parameter declaration for SliderFloat4

Function is declared as (imgui.h, 211):

bool SliderFloat4(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);

but defined as (imgui.cpp, 3469):

bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* display_format, float power) {

Parameter in declaration v[3] should be v[4], obviously (functionality is fine since the array size is basically just a comment, but users might declare v without enough storage space and end up stomping memory).

Missing includes

When compiling with gcc 4.6 in Linux, two needed includes are missing from imgui.cpp:
limits.h
stdint.h

custom vertex setup

For my engine it would be better if ImDrawVert had this layout instead. (Note: col and uv are flipped.) I can then memcpy the draw calls into my existing 2D pipeline.

struct ImDrawVert
{
ImVec2 pos;
ImU32 col;
ImVec2 uv;
};

At this moment I just hacked this into the code. It would be nice it there was a way to define this externally if possible.

Clip rectangles in the command list can be inverted

In certain cases the clip rectangle in the command lists can have the max bounds (z,w) less than the min bounds (x,y). In the OpenGL example, expand the "Child regions" section and scroll the "With borders" all the way down. Then expand the "Widgets" section. The column separator for the "With border" widget is not clipped properly:

cliprectbug

In this case, a negative height is passed to glScissor, which causes an invalid value error (GL_INVALID_VALUE).

Detect mouse over any ImGUI window

This is more of a question. How do I detect if the mouse is currently over any ImGui window? Is this supported? Also, how do I detect if any input box currently has focus?

InputText should handle enter key

I'm trying to execute a command entered into an InputText when the user presses the enter key, but it doesn't seem to be possible.

InputText could return true not only if the text changed, but also if enter was pressed. Or a bool* or callback parameter could be added.

OpenGL setup using GLUT

First of all, thanks for this marvelous gui library!
I've just started using it, and it looks quite promising.

I found it is easy to integrate in existing, however the example provided isn't completely explanatory.

In my case i'm using GLUT, and the issue is that rendering the ImGui overwrites anything that has already been drawn.
The ImGui::Render call is made just before glutSwapBuffers(); and after the application's drawing calls.
However, the background of the gui has the same color of the glClearColor, and is not transparent.
If I move a gui window around, or fiddle with its size, the background sometimes becomes transparent (See the enclosed example images, nr1 is the expected result)
I've copied the ImImpl_RenderDrawLists() function and most of the InitImGui() function of the opengl example.

My question is, how do I set up the ImGui rendering using GLUT such that it doesn't interfere with the items that have already been drawn?
Thanks in advance!

Callback versions of PlotLines/Histogram?

I'm writing a binding to ImGui for my scripting language and the existing API for PlotLines/Histogram isn't a very good fit. Something like the Combo() API that takes a callback function would be much nicer.

Actually, I may just make my own implementation and then submit a pull request! :)

PlotLines with more than one graph

It would be great if PlotLines could handle multiple graphs and get a format string for tooltip, for example "x %f\ny %f\nz %f" for a vector

Keyboard storage can't fit keycodes that are large

mattiasljungstrom says:
"I'm using SDL2, and when I input the key mappings from SDL2 for special keys they all have very large values. This also seems to brake the internal code of ImGui. I think it assumes all key code values are between 0-255?"

openGL and glEnable(GL_CULL_FACE)

In the openGL demo glDisable(GL_CULL_FACE) is used.

I'm not an expert of openGL, so I'm not sure if screen rendering is faster with cull face or not.
However I've found out that in ImImpl_RenderDrawLists(...) by using:

glEnable(GL_CULL_FACE);glCullFace(GL_FRONT);
// rendering code
glCullFace(GL_BACK); // at the end

everything seems to work, except the rendering of the caret when inserting text, that is missing.

I didn't test it very much, but if it's possible and if it's faster, maybe we can add some variable
that we can use to render the caret correctly with these settings.

This issue probably needs more testing to see if it's really worthy and if all the widgets get rendered in the correct way...

Pixel perfect text with multisampling

On my machine I get blurry text when multisampling is enabled.
I fixed it with the following change in void ImBitmapFont::RenderText (line)

// Align to be pixel perfect
pos.x = (float)(int)(pos.x + 0.5f);
pos.y = (float)(int)(pos.y + 0.5f);

Note the brackets. I also set the io.PixelCenterOffset to 0.375 instead of 0.5.

Tested on an AMD HD6850 and Intel HD 3000.

Macbook touchpad tap-click unreliable

Running the OpenGL sample on a macbook, doing a physical click on the trackpad works fine with ImGui, but using tap-to-click produces about 50/50 UI response to no response.

Remote network access/viewer

(Edit 2020: See https://github.com/ocornut/imgui/wiki/Useful-Extensions#remoting)

An idea I had in mind for a bit - recently people at my previous workplace started implementing something along the same line so I'd thought I'd describe the idea here.

Implement a way for ImGui to export its output to a client on the network (likely local network). The client would display the UI and feed back mouse/keyboard inputs. This would be useful to save screen real-estate on the host.

Jordi at Media Molecule has been working on a web client to do that:
twitter_imgui

The "simple" implementation of that would be to be sending vertex buffers along the network.
Pros:

  • simple to implement, doesn't require to aggressively modify and change a lot of the code
  • little to no maintenance required when new features are added to the library (the remote client doesn't need to be updated, Etc.)
    Cons
  • network usage may be high (need to transmit vertex buffer)

Aside from that the application or protocol needs a way to

  • transmit inputs
  • perhaps define "virtual desktops" (define size and position? dragging window from host to remote viewer would be nice.)
  • implement as much glue as possible so the thing ideally just magically works. the glue may or not end up within imgui.cpp depending of how much code is required and how portable it is.

And we need to implement a client. Jordi's approach to create a web based client using webgl sounds like a good approach to me.

Based on this idea it looks like the amount of vertex data may be the bottleneck.

a) Obviously we need to compress data. we need a compressor that is efficient and "imgui" friendly in the sense that ideally it would be added to ImGui.cpp without doubling its size. we also need a suitable decompressor on the client side (javascript if we are aiming for a web client).

b) Split the stream for each ImDrawList (corresponding to each window) and only send a diff of the data. Need to look for a diff engine. The imgui code would be able to place extra marker based on the layout to minimize the diff size if it can help.

c) Deinterleave the stream (e.g store all x position, then all y position, then all colors, etc.) + store everything as delta from the previous vertex. This will make operations such as moving a window very cheap (only the first vertex will change). Will result in lots of zeros (highly compressible) or patterns using value within close range.

d) Use indexed triangles or quads. Currently Imgui uses non-indexed triangles to simplify the implementation of the ImDrawList renderer but it isn't optimal when it comes to data size.

A combination of those things hopefully can get the data small enough to work over local network.

Buttons with identical labels do not work

Before rattling any discussion: This could be considered improper usage of ImGui, however in my ignorance I did use ImGui like this. I noticed the issue, and I think you should now about it.

Onto the issue:
Having Buttons with the same label, can cause unpredictable results.
In my case, with 2 buttons controlling two separate settings:

ImGui::Text("Settting 1:");
ImGui::SameLine();
if (ImGui::Button((setting1enabled) ? "Yes" : "No")){
    setting1enabled = !setting1enabled;
}

ImGui::Text("Settting 2:");
ImGui::SameLine();
if (ImGui::Button((setting2enabled) ? "Yes" : "No")){
    setting2enabled = !setting2enabled;
}

In both settings are true, the label is identical ("Yes") for both buttons.
When the 2nd button is then clicked, ImGui::Button will return false because
window->GetID(label); (imgui.cpp: line 3076) will return the ID of the 1st item with that label.
Since it will check the mouse coordinates against the coordinates of the wrong button, it will report as not being pressed.

When setting1enabled = false (or setting1enabled != setting2enabled), the label on each button will be different, and everything works as expected.

In case more than two buttons have an identical label, button Bn will only respond if the labels of B0,B1,...,Bn-1 != Bn (I have not tried this, but this is what will happen most likely).

Idea for a solution:

  • Allow supplying an extra ID to the ImGui::Button function call (ID=-1 by default).
  • If the optional ID is given, use that instead of the text label to index the Button in ImGui's storage (hash table?).

This problem may also apply to other widgets.
Note: You may close this issue I you regard this issue as being unintended library usage. That being said, I think it would be nice if users could choose to use it like this anyway

Mouse cursor

Hi Omar,

I bound uSynergy on imgui but I need to manually draw a mouse cursor on top of imgui on platform that lacks "hardware" one, typically, smartphone and consoles.

I tried to implement it in imgui but it' s a bit tricky. I need to create a fake window with tooltip flag set to be put at the end of the draw list and as method in ImGuiWindow are not virtual i must set a custom GUIStyle...

So, It can be convenient to add a method to display a cursor (ImGui::DisplayMouseCursor()) on demand, don't you think ?

Word-wrapping in ImGui::Text

This might be a nice-to-have feature.

Currently, all content that doesn't fit into a window is cut off at the window edge (apart from margin & padding) besides for several autofit widgets.

Would it be nice for ImGui::Text to support autofitting as well?
This especially applies when the ImGuiWindowFlags_NoResize flag is set, since there is no way to reveal any text not fitting into the window.

Images

Have you thought much about adding image widgets? Along with that: buttons as widgets, checkboxes, radio buttons, etc.

I'm adding it to my fork at the moment but it would help you had any thoughts on how you'd approach it.

One option of course is to just add fonts to the glyph.

Keyboard focus

I'm missing some way to give keyboard focus to a specific text input field.

Possible problems with endianess

I'm using a little endian machine.

I was wondering if the library would still work on big endian systems (I guess I'll never use one, but my mind seems to like to create problems...).

Possible issues I can see:

  1. Binary .fnt loading. Is that format endian free ?
  2. The bin2c file conversion used by ImGui seems to group bytes into blocks of 4 (4 bytes -> 1 Uin32).

These problems could be solved in two ways:
a) creating all the binaries on the same machine they're supposed to be used.
b) using a more robust approach:

    1. Adding code to support loading .fnt in text format (currently it's not trivial to extend the ImBitmapFont class, because it seems to store the binary .fnt blob in a single block and use pointers to access its parts.).
    1. Using a different bin2c file conversion that just stores bytes one after another (producing longer source code, but the binary code size should be equal).

I don't think this is a high-priority problem [solution (a) above needs no code change], but maybe some note should be written about it...

Textures and skinning.

Hi Omar,

This is not really an issue, but more a suggestion about the library. I wanted to open the discussion with you before trying to implement something and send a PR. Let me know what you think!

I noticed the handy system to change colors per call using the PushStyleColor/PopStyleColor. That made me think about adding a PushTexCoords/PopTexCoords. If I'm correct every draw call that is not a text have texcoords that point to the upper-left corner of the font texture atlas, where a white pixel allow everything to get coloured correctly. Adding the pushpop methods I'm suggesting would allow to bypass this system and specify the texture coordinate of a custom skin. Allowing the library to render widgets with a much more customisable and complete style. At the same time it will continue to leverage the texture atlas and have only one texture binding for the whole batch of draw calls. The PushTexCoord would allow to specify the position of the skin in the atlas, and the PopTexCoord will at some point come back to the default notexture (0,0).

To be able to properly texture the different rectangles, I guess that it means that we will have to double the number of vertices per rectangles (to properly scale the texture at the corners). This can probably be done in the fragment shader without changing the number of vertices.

Except for this last bit, I think it would be a relatively easy and awesome feature to add to the library. Skinning is never totally required for a gui library but when well designed, it definitely push it to the next level.

So that was my random thoughts about your already really nice library!

Cheers,
Simon.

Font Change

This is more of a request than an issue.

Is there an easy way to change the font? I'm trying to embed this in my application, and the font is somewhat anti-aliased and pixelated.

NewFrame() vs Render()

First of all, thanks for this great little tool!

In my game engine I can sometimes call update() several times before I call render(). If I do this it seems like it triggers asserts in the ImGui code. Would it be possible to support this? I can code around it, but I figured it was worth mentioning.

Also, I'm using SDL2, and when I input the key mappings from SDL2 for special keys they all have very large values. This also seems to brake the internal code of ImGui. I think it assumes all key code values are between 0-255?

Thanks!

OpenGL/DirectX setup

Hello!

ImGui looks very cool to me. A question though: in the README.md there are about ~5-7 lines of code to create the UI shown, but the examples include a rather long OpenGL/DirectX setup.
I understand the setup is required, because the library itself is agnostic of it.

Could you please write about how-to best setup OpenGL for the use with the library? Is it possible that at some moment the setup code would be included as a part of the library facilities?

Thanks 👍

C code examples

Are there any examples of using this library with C? The readme mentions that it works with C and C++, but I don't see any C function definitions.

interpolation widget

i'm missing simple interpolation widget editor like http://cubic-bezier.com , simply t=<0, 1>, two movable inner points. through sliders it's unintuitive for editing. Do you planning something like that? if not, i'll try to implement myself as imgui_user.inl

Change all tabs to spaces

Considering changing all tabs to spaces because it create noise in patches and makes the readability of code on GitHub a bit awkward. This will probably break the existing Pull Requests and perhaps forks. Better done earlier than later.

Extending ImGUI with custom widgets?

Hey Omar,

In using ImGUI for a project, I'd like to make a custom plot widget (e.g. multiple timeseries on the same axis). I'm wondering how I should go about implementing something like this. I can't just copy the code for ImGui::Plot outside of imgui.cpp, because some of the methods it calls are declared static. I could just add a new method to your ImGui namespace, but then I'm editing the imgui.cpp file directly, which means I'd have to merge in any updates that you push. Have you given any thought to how a developer could add their own widgets?

Obviously messing around with the low level ImGui code might break things if I don't implement it correctly, but this seems fine given the purpose.

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.