Coder Social home page Coder Social logo

ocornut / imgui Goto Github PK

View Code? Open in Web Editor NEW
59.0K 59.0K 10.1K 91.57 MB

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

License: MIT License

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

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

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

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! :)

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.

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!

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

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 ๐Ÿ‘

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...

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.

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.

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.

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.

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?

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.

Missing includes

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

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.

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.

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.

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).

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...

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

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?

Range Slider

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

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.

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).

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.

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?"

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.

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!

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 ?

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

Keyboard focus

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

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.

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.

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

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.