mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 06:06:35 +00:00
Merge branch 'master' into 2016-02-colorpicker
This commit is contained in:
commit
326c4e40f8
@ -47,7 +47,11 @@ Gallery
|
|||||||
|
|
||||||
See the [Screenshots Thread](https://github.com/ocornut/imgui/issues/123) for some user creations.
|
See the [Screenshots Thread](https://github.com/ocornut/imgui/issues/123) for some user creations.
|
||||||
|
|
||||||
![screenshot 1](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v143/examples_04.png)
|
![screenshot 1](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v148/examples_01.png)
|
||||||
|
![screenshot 2](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v148/examples_02.png)
|
||||||
|
|
||||||
|
[![profiler](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v148/profiler-880.jpg)](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v148/profiler.png)
|
||||||
|
|
||||||
![screenshot 2](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v143/test_window_01.png)
|
![screenshot 2](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v143/test_window_01.png)
|
||||||
![screenshot 3](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v143/test_window_02.png)
|
![screenshot 3](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v143/test_window_02.png)
|
||||||
![screenshot 4](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v143/test_window_03.png)
|
![screenshot 4](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v143/test_window_03.png)
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui Allegro 5 bindings
|
// ImGui Allegro 5 bindings
|
||||||
|
// In this binding, ImTextureID is used to store a 'ALLEGRO_BITMAP*' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui Allegro 5 bindings
|
// ImGui Allegro 5 bindings
|
||||||
|
// In this binding, ImTextureID is used to store a 'ALLEGRO_BITMAP*' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui Win32 + DirectX10 binding
|
// ImGui Win32 + DirectX10 binding
|
||||||
|
// In this binding, ImTextureID is used to store a 'ID3D10ShaderResourceView*' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui Win32 + DirectX10 binding
|
// ImGui Win32 + DirectX10 binding
|
||||||
|
// In this binding, ImTextureID is used to store a 'ID3D10ShaderResourceView*' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui Win32 + DirectX11 binding
|
// ImGui Win32 + DirectX11 binding
|
||||||
|
// In this binding, ImTextureID is used to store a 'ID3D11ShaderResourceView*' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui Win32 + DirectX11 binding
|
// ImGui Win32 + DirectX11 binding
|
||||||
|
// In this binding, ImTextureID is used to store a 'ID3D11ShaderResourceView*' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui Win32 + DirectX9 binding
|
// ImGui Win32 + DirectX9 binding
|
||||||
|
// In this binding, ImTextureID is used to store a 'LPDIRECT3DTEXTURE9' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui Win32 + DirectX9 binding
|
// ImGui Win32 + DirectX9 binding
|
||||||
|
// In this binding, ImTextureID is used to store a 'LPDIRECT3DTEXTURE9' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
//
|
// ImGui iOS+OpenGL+Synergy binding
|
||||||
// imgui_impl_ios.h
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
// imguiex
|
// Providing a standalone iOS application with Synergy integration makes this sample more verbose than others. It also hasn't been tested as much.
|
||||||
//
|
// Refer to other examples to get an easier understanding of how to integrate ImGui into your existing application.
|
||||||
// Joel Davis (joeld42@gmail.com)
|
|
||||||
//
|
// by Joel Davis (joeld42@gmail.com)
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
//
|
// ImGui iOS+OpenGL+Synergy binding
|
||||||
// imgui_impl_ios.cpp
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
// imguiex
|
// Providing a standalone iOS application with Synergy integration makes this sample more verbose than others. It also hasn't been tested as much.
|
||||||
|
// Refer to other examples to get an easier understanding of how to integrate ImGui into your existing application.
|
||||||
|
|
||||||
#import <OpenGLES/ES3/gl.h>
|
#import <OpenGLES/ES3/gl.h>
|
||||||
#import <OpenGLES/ES3/glext.h>
|
#import <OpenGLES/ES3/glext.h>
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui Marmalade binding with IwGx
|
// ImGui Marmalade binding with IwGx
|
||||||
|
// In this binding, ImTextureID is used to store a 'CIwTexture*' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui Marmalade binding with IwGx
|
// ImGui Marmalade binding with IwGx
|
||||||
|
// In this binding, ImTextureID is used to store a 'CIwTexture*' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui GLFW binding with OpenGL3 + shaders
|
// ImGui GLFW binding with OpenGL3 + shaders
|
||||||
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui GLFW binding with OpenGL3 + shaders
|
// ImGui GLFW binding with OpenGL3 + shaders
|
||||||
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui GLFW binding with OpenGL
|
// ImGui GLFW binding with OpenGL
|
||||||
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui GLFW binding with OpenGL
|
// ImGui GLFW binding with OpenGL
|
||||||
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui SDL2 binding with OpenGL3
|
// ImGui SDL2 binding with OpenGL3
|
||||||
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
@ -13,7 +15,6 @@
|
|||||||
#include <GL/gl3w.h>
|
#include <GL/gl3w.h>
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
static SDL_Window* g_Window = NULL;
|
|
||||||
static double g_Time = 0.0f;
|
static double g_Time = 0.0f;
|
||||||
static bool g_MousePressed[3] = { false, false, false };
|
static bool g_MousePressed[3] = { false, false, false };
|
||||||
static float g_MouseWheel = 0.0f;
|
static float g_MouseWheel = 0.0f;
|
||||||
@ -296,8 +297,6 @@ void ImGui_ImplSdlGL3_InvalidateDeviceObjects()
|
|||||||
|
|
||||||
bool ImGui_ImplSdlGL3_Init(SDL_Window* window)
|
bool ImGui_ImplSdlGL3_Init(SDL_Window* window)
|
||||||
{
|
{
|
||||||
g_Window = window;
|
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.KeyMap[ImGuiKey_Tab] = SDLK_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
|
io.KeyMap[ImGuiKey_Tab] = SDLK_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
|
||||||
io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
|
io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
|
||||||
@ -339,7 +338,7 @@ void ImGui_ImplSdlGL3_Shutdown()
|
|||||||
ImGui::Shutdown();
|
ImGui::Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSdlGL3_NewFrame()
|
void ImGui_ImplSdlGL3_NewFrame(SDL_Window* window)
|
||||||
{
|
{
|
||||||
if (!g_FontTexture)
|
if (!g_FontTexture)
|
||||||
ImGui_ImplSdlGL3_CreateDeviceObjects();
|
ImGui_ImplSdlGL3_CreateDeviceObjects();
|
||||||
@ -348,9 +347,11 @@ void ImGui_ImplSdlGL3_NewFrame()
|
|||||||
|
|
||||||
// Setup display size (every frame to accommodate for window resizing)
|
// Setup display size (every frame to accommodate for window resizing)
|
||||||
int w, h;
|
int w, h;
|
||||||
SDL_GetWindowSize(g_Window, &w, &h);
|
int display_w, display_h;
|
||||||
|
SDL_GetWindowSize(window, &w, &h);
|
||||||
|
SDL_GL_GetDrawableSize(window, &display_w, &display_h);
|
||||||
io.DisplaySize = ImVec2((float)w, (float)h);
|
io.DisplaySize = ImVec2((float)w, (float)h);
|
||||||
io.DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
|
io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
Uint32 time = SDL_GetTicks();
|
Uint32 time = SDL_GetTicks();
|
||||||
@ -362,7 +363,7 @@ void ImGui_ImplSdlGL3_NewFrame()
|
|||||||
// (we already got mouse wheel, keyboard keys & characters from SDL_PollEvent())
|
// (we already got mouse wheel, keyboard keys & characters from SDL_PollEvent())
|
||||||
int mx, my;
|
int mx, my;
|
||||||
Uint32 mouseMask = SDL_GetMouseState(&mx, &my);
|
Uint32 mouseMask = SDL_GetMouseState(&mx, &my);
|
||||||
if (SDL_GetWindowFlags(g_Window) & SDL_WINDOW_MOUSE_FOCUS)
|
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_FOCUS)
|
||||||
io.MousePos = ImVec2((float)mx, (float)my); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
io.MousePos = ImVec2((float)mx, (float)my); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
||||||
else
|
else
|
||||||
io.MousePos = ImVec2(-1, -1);
|
io.MousePos = ImVec2(-1, -1);
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui SDL2 binding with OpenGL3
|
// ImGui SDL2 binding with OpenGL3
|
||||||
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
@ -9,7 +11,7 @@ typedef union SDL_Event SDL_Event;
|
|||||||
|
|
||||||
IMGUI_API bool ImGui_ImplSdlGL3_Init(SDL_Window* window);
|
IMGUI_API bool ImGui_ImplSdlGL3_Init(SDL_Window* window);
|
||||||
IMGUI_API void ImGui_ImplSdlGL3_Shutdown();
|
IMGUI_API void ImGui_ImplSdlGL3_Shutdown();
|
||||||
IMGUI_API void ImGui_ImplSdlGL3_NewFrame();
|
IMGUI_API void ImGui_ImplSdlGL3_NewFrame(SDL_Window* window);
|
||||||
IMGUI_API bool ImGui_ImplSdlGL3_ProcessEvent(SDL_Event* event);
|
IMGUI_API bool ImGui_ImplSdlGL3_ProcessEvent(SDL_Event* event);
|
||||||
|
|
||||||
// Use if you want to reset your rendering device without losing ImGui state.
|
// Use if you want to reset your rendering device without losing ImGui state.
|
||||||
|
@ -58,7 +58,7 @@ int main(int, char**)
|
|||||||
if (event.type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
ImGui_ImplSdlGL3_NewFrame();
|
ImGui_ImplSdlGL3_NewFrame(window);
|
||||||
|
|
||||||
// 1. Show a simple window
|
// 1. Show a simple window
|
||||||
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui SDL2 binding with OpenGL
|
// ImGui SDL2 binding with OpenGL
|
||||||
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
@ -235,8 +237,11 @@ void ImGui_ImplSdl_NewFrame(SDL_Window *window)
|
|||||||
|
|
||||||
// Setup display size (every frame to accommodate for window resizing)
|
// Setup display size (every frame to accommodate for window resizing)
|
||||||
int w, h;
|
int w, h;
|
||||||
|
int display_w, display_h;
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
SDL_GetWindowSize(window, &w, &h);
|
||||||
|
SDL_GL_GetDrawableSize(window, &display_w, &display_h);
|
||||||
io.DisplaySize = ImVec2((float)w, (float)h);
|
io.DisplaySize = ImVec2((float)w, (float)h);
|
||||||
|
io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
Uint32 time = SDL_GetTicks();
|
Uint32 time = SDL_GetTicks();
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// ImGui SDL2 binding with OpenGL
|
// ImGui SDL2 binding with OpenGL
|
||||||
|
// In this binding, ImTextureID is used to store an OpenGL 'GLuint' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
114
imgui.cpp
114
imgui.cpp
@ -19,9 +19,10 @@
|
|||||||
- FREQUENTLY ASKED QUESTIONS (FAQ), TIPS
|
- FREQUENTLY ASKED QUESTIONS (FAQ), TIPS
|
||||||
- How can I help?
|
- How can I help?
|
||||||
- How do I update to a newer version of ImGui?
|
- How do I update to a newer version of ImGui?
|
||||||
|
- What is ImTextureID and how do I display an image?
|
||||||
- Can I have multiple widgets with the same label? Can I have widget without a label? (Yes) / A primer on the use of labels/IDs in ImGui.
|
- Can I have multiple widgets with the same label? Can I have widget without a label? (Yes) / A primer on the use of labels/IDs in ImGui.
|
||||||
- I integrated ImGui in my engine and the text or lines are blurry..
|
- I integrated ImGui in my engine and the text or lines are blurry..
|
||||||
- I integrated ImGui in my engine and some elements are disappearing when I move windows around..
|
- I integrated ImGui in my engine and some elements are clipping or disappearing when I move windows around..
|
||||||
- How can I load a different font than the default?
|
- How can I load a different font than the default?
|
||||||
- How can I load multiple fonts?
|
- How can I load multiple fonts?
|
||||||
- How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?
|
- How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?
|
||||||
@ -78,6 +79,7 @@
|
|||||||
- your code creates the UI, if your code doesn't run the UI is gone! == very dynamic UI, no construction/destructions steps, less data retention on your side, no state duplication, less sync, less bugs.
|
- your code creates the UI, if your code doesn't run the UI is gone! == very dynamic UI, no construction/destructions steps, less data retention on your side, no state duplication, less sync, less bugs.
|
||||||
- call and read ImGui::ShowTestWindow() for demo code demonstrating most features.
|
- call and read ImGui::ShowTestWindow() for demo code demonstrating most features.
|
||||||
- see examples/ folder for standalone sample applications. Prefer reading examples/opengl_example/ first at it is the simplest.
|
- see examples/ folder for standalone sample applications. Prefer reading examples/opengl_example/ first at it is the simplest.
|
||||||
|
you may be able to grab and copy a ready made imgui_impl_*** file from the examples/.
|
||||||
- customization: PushStyleColor()/PushStyleVar() or the style editor to tweak the look of the interface (e.g. if you want a more compact UI or a different color scheme).
|
- customization: PushStyleColor()/PushStyleVar() or the style editor to tweak the look of the interface (e.g. if you want a more compact UI or a different color scheme).
|
||||||
|
|
||||||
- getting started:
|
- getting started:
|
||||||
@ -85,12 +87,13 @@
|
|||||||
- init: call io.Fonts->GetTexDataAsRGBA32(...) and load the font texture pixels into graphics memory.
|
- init: call io.Fonts->GetTexDataAsRGBA32(...) and load the font texture pixels into graphics memory.
|
||||||
- every frame:
|
- every frame:
|
||||||
1/ in your mainloop or right after you got your keyboard/mouse info, call ImGui::GetIO() and fill the fields marked 'Input'
|
1/ in your mainloop or right after you got your keyboard/mouse info, call ImGui::GetIO() and fill the fields marked 'Input'
|
||||||
2/ call ImGui::NewFrame().
|
2/ call ImGui::NewFrame() as early as you can!
|
||||||
3/ use any ImGui function you want between NewFrame() and Render()
|
3/ use any ImGui function you want between NewFrame() and Render()
|
||||||
4/ call ImGui::Render() to render all the accumulated command-lists. it will call your RenderDrawListFn handler that you set in the IO structure.
|
4/ call ImGui::Render() as late as you can to end the frame and finalize render data. it will call your RenderDrawListFn handler that you set in the IO structure.
|
||||||
|
(if you don't need to render, you still need to call Render() and ignore the callback, or call EndFrame() instead. if you call neither some aspects of windows focusing/moving will appear broken.)
|
||||||
- all rendering information are stored into command-lists until ImGui::Render() is called.
|
- all rendering information are stored into command-lists until ImGui::Render() is called.
|
||||||
- ImGui never touches or know about your GPU state. the only function that knows about GPU is the RenderDrawListFn handler that you must provide.
|
- ImGui never touches or know about your GPU state. the only function that knows about GPU is the RenderDrawListFn handler that you provide.
|
||||||
- effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render" phases.
|
- effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render" phases of your own application.
|
||||||
- refer to the examples applications in the examples/ folder for instruction on how to setup your code.
|
- refer to the examples applications in the examples/ folder for instruction on how to setup your code.
|
||||||
- a typical application skeleton may be:
|
- a typical application skeleton may be:
|
||||||
|
|
||||||
@ -134,7 +137,7 @@
|
|||||||
|
|
||||||
// 4) render & swap video buffers
|
// 4) render & swap video buffers
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
// swap video buffer, etc.
|
SwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
- after calling ImGui::NewFrame() you can read back flags from the IO structure to tell how ImGui intends to use your inputs.
|
- after calling ImGui::NewFrame() you can read back flags from the IO structure to tell how ImGui intends to use your inputs.
|
||||||
@ -260,6 +263,18 @@
|
|||||||
Check the "API BREAKING CHANGES" sections for a list of occasional API breaking changes. If you have a problem with a function, search for its name
|
Check the "API BREAKING CHANGES" sections for a list of occasional API breaking changes. If you have a problem with a function, search for its name
|
||||||
in the code, there will likely be a comment about it. Please report any issue to the GitHub page!
|
in the code, there will likely be a comment about it. Please report any issue to the GitHub page!
|
||||||
|
|
||||||
|
|
||||||
|
Q: What is ImTextureID and how do I display an image?
|
||||||
|
A: ImTextureID is a void* used to pass renderer-agnostic texture references around until it hits your render function.
|
||||||
|
ImGui knows nothing about what those bits represent, it just passes them around. It is up to you to decide what you want the void* to carry!
|
||||||
|
It could be an identifier to your OpenGL texture (cast GLuint to void*), a pointer to your custom engine material (cast MyMaterial* to void*), etc.
|
||||||
|
At the end of the chain, your renderer takes this void* to cast it back into whatever it needs to select a current texture to render.
|
||||||
|
Refer to examples applications, where each renderer (in a imgui_impl_xxxx.cpp file) is treating ImTextureID as a different thing.
|
||||||
|
(c++ tip: OpenGL uses integers to identify textures. You can safely store an integer into a void*, just cast it to void*, don't take it's address!)
|
||||||
|
To display a custom image/texture within an ImGui window, you may use ImGui::Image(), ImGui::ImageButton(), ImDrawList::AddImage() functions.
|
||||||
|
ImGui will generate the geometry and draw calls using the ImTextureID that you passed and which your renderer can use.
|
||||||
|
It is your responsibility to get textures uploaded to your GPU.
|
||||||
|
|
||||||
Q: Can I have multiple widgets with the same label? Can I have widget without a label? (Yes)
|
Q: Can I have multiple widgets with the same label? Can I have widget without a label? (Yes)
|
||||||
A: Yes. A primer on the use of labels/IDs in ImGui..
|
A: Yes. A primer on the use of labels/IDs in ImGui..
|
||||||
|
|
||||||
@ -357,8 +372,8 @@
|
|||||||
A: In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
|
A: In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
|
||||||
Also make sure your orthographic projection matrix and io.DisplaySize matches your actual framebuffer dimension.
|
Also make sure your orthographic projection matrix and io.DisplaySize matches your actual framebuffer dimension.
|
||||||
|
|
||||||
Q. I integrated ImGui in my engine and some elements are disappearing when I move windows around..
|
Q: I integrated ImGui in my engine and some elements are clipping or disappearing when I move windows around..
|
||||||
Most likely you are mishandling the clipping rectangles in your render function. Rectangles provided by ImGui are defined as (x1,y1,x2,y2) and NOT as (x1,y1,width,height).
|
A: Most likely you are mishandling the clipping rectangles in your render function. Rectangles provided by ImGui are defined as (x1,y1,x2,y2) and NOT as (x1,y1,width,height).
|
||||||
|
|
||||||
Q: How can I load a different font than the default? (default is an embedded version of ProggyClean.ttf, rendered at size 13)
|
Q: How can I load a different font than the default? (default is an embedded version of ProggyClean.ttf, rendered at size 13)
|
||||||
A: Use the font atlas to load the TTF file you want:
|
A: Use the font atlas to load the TTF file you want:
|
||||||
@ -641,7 +656,7 @@ static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const
|
|||||||
static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, const char* display_format, char* buf, int buf_size);
|
static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, const char* display_format, char* buf, int buf_size);
|
||||||
static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, int decimal_precision, char* buf, int buf_size);
|
static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, int decimal_precision, char* buf, int buf_size);
|
||||||
static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* value1, const void* value2);
|
static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* value1, const void* value2);
|
||||||
static void DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format);
|
static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Platform dependent default implementations
|
// Platform dependent default implementations
|
||||||
@ -5919,7 +5934,7 @@ static void DataTypeApplyOp(ImGuiDataType data_type, int op, void* value1, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// User can input math operators (e.g. +100) to edit a numerical values.
|
// User can input math operators (e.g. +100) to edit a numerical values.
|
||||||
static void DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format)
|
static bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* scalar_format)
|
||||||
{
|
{
|
||||||
while (ImCharIsSpace(*buf))
|
while (ImCharIsSpace(*buf))
|
||||||
buf++;
|
buf++;
|
||||||
@ -5938,41 +5953,47 @@ static void DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
|||||||
op = 0;
|
op = 0;
|
||||||
}
|
}
|
||||||
if (!buf[0])
|
if (!buf[0])
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if (data_type == ImGuiDataType_Int)
|
if (data_type == ImGuiDataType_Int)
|
||||||
{
|
{
|
||||||
if (!scalar_format)
|
if (!scalar_format)
|
||||||
scalar_format = "%d";
|
scalar_format = "%d";
|
||||||
int* v = (int*)data_ptr;
|
int* v = (int*)data_ptr;
|
||||||
int ref_v = *v;
|
const int old_v = *v;
|
||||||
if (op && sscanf(initial_value_buf, scalar_format, &ref_v) < 1)
|
int arg0 = *v;
|
||||||
return;
|
if (op && sscanf(initial_value_buf, scalar_format, &arg0) < 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Store operand in a float so we can use fractional value for multipliers (*1.1), but constant always parsed as integer so we can fit big integers (e.g. 2000000003) past float precision
|
// Store operand in a float so we can use fractional value for multipliers (*1.1), but constant always parsed as integer so we can fit big integers (e.g. 2000000003) past float precision
|
||||||
float op_v = 0.0f;
|
float arg1 = 0.0f;
|
||||||
if (op == '+') { if (sscanf(buf, "%f", &op_v) == 1) *v = (int)(ref_v + op_v); } // Add (use "+-" to subtract)
|
if (op == '+') { if (sscanf(buf, "%f", &arg1) == 1) *v = (int)(arg0 + arg1); } // Add (use "+-" to subtract)
|
||||||
else if (op == '*') { if (sscanf(buf, "%f", &op_v) == 1) *v = (int)(ref_v * op_v); } // Multiply
|
else if (op == '*') { if (sscanf(buf, "%f", &arg1) == 1) *v = (int)(arg0 * arg1); } // Multiply
|
||||||
else if (op == '/') { if (sscanf(buf, "%f", &op_v) == 1 && op_v != 0.0f) *v = (int)(ref_v / op_v); }// Divide
|
else if (op == '/') { if (sscanf(buf, "%f", &arg1) == 1 && arg1 != 0.0f) *v = (int)(arg0 / arg1); }// Divide
|
||||||
else { if (sscanf(buf, scalar_format, &ref_v) == 1) *v = ref_v; } // Assign constant
|
else { if (sscanf(buf, scalar_format, &arg0) == 1) *v = arg0; } // Assign constant
|
||||||
|
return (old_v != *v);
|
||||||
}
|
}
|
||||||
else if (data_type == ImGuiDataType_Float)
|
else if (data_type == ImGuiDataType_Float)
|
||||||
{
|
{
|
||||||
// For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in
|
// For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in
|
||||||
scalar_format = "%f";
|
scalar_format = "%f";
|
||||||
float* v = (float*)data_ptr;
|
float* v = (float*)data_ptr;
|
||||||
float ref_v = *v;
|
const float old_v = *v;
|
||||||
if (op && sscanf(initial_value_buf, scalar_format, &ref_v) < 1)
|
float arg0 = *v;
|
||||||
return;
|
if (op && sscanf(initial_value_buf, scalar_format, &arg0) < 1)
|
||||||
float op_v = 0.0f;
|
return false;
|
||||||
if (sscanf(buf, scalar_format, &op_v) < 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (op == '+') { *v = ref_v + op_v; } // Add (use "+-" to subtract)
|
float arg1 = 0.0f;
|
||||||
else if (op == '*') { *v = ref_v * op_v; } // Multiply
|
if (sscanf(buf, scalar_format, &arg1) < 1)
|
||||||
else if (op == '/') { if (op_v != 0.0f) *v = ref_v / op_v; } // Divide
|
return false;
|
||||||
else { *v = op_v; } // Assign constant
|
if (op == '+') { *v = arg0 + arg1; } // Add (use "+-" to subtract)
|
||||||
|
else if (op == '*') { *v = arg0 * arg1; } // Multiply
|
||||||
|
else if (op == '/') { if (arg1 != 0.0f) *v = arg0 / arg1; } // Divide
|
||||||
|
else { *v = arg1; } // Assign constant
|
||||||
|
return (old_v != *v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create text input in place of a slider (when CTRL+Clicking on slider)
|
// Create text input in place of a slider (when CTRL+Clicking on slider)
|
||||||
@ -5988,7 +6009,7 @@ bool ImGui::InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label
|
|||||||
|
|
||||||
char buf[32];
|
char buf[32];
|
||||||
DataTypeFormatString(data_type, data_ptr, decimal_precision, buf, IM_ARRAYSIZE(buf));
|
DataTypeFormatString(data_type, data_ptr, decimal_precision, buf, IM_ARRAYSIZE(buf));
|
||||||
bool value_changed = InputTextEx(label, buf, IM_ARRAYSIZE(buf), aabb.GetSize(), ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_AutoSelectAll);
|
bool text_value_changed = InputTextEx(label, buf, IM_ARRAYSIZE(buf), aabb.GetSize(), ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_AutoSelectAll);
|
||||||
if (g.ScalarAsInputTextId == 0)
|
if (g.ScalarAsInputTextId == 0)
|
||||||
{
|
{
|
||||||
// First frame
|
// First frame
|
||||||
@ -6001,9 +6022,9 @@ bool ImGui::InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label
|
|||||||
// Release
|
// Release
|
||||||
g.ScalarAsInputTextId = 0;
|
g.ScalarAsInputTextId = 0;
|
||||||
}
|
}
|
||||||
if (value_changed)
|
if (text_value_changed)
|
||||||
DataTypeApplyOpFromText(buf, GImGui->InputTextState.InitialText.begin(), data_type, data_ptr, NULL);
|
return DataTypeApplyOpFromText(buf, GImGui->InputTextState.InitialText.begin(), data_type, data_ptr, NULL);
|
||||||
return value_changed;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse display precision back from the display format string
|
// Parse display precision back from the display format string
|
||||||
@ -7825,10 +7846,7 @@ bool ImGui::InputScalarEx(const char* label, ImGuiDataType data_type, void* data
|
|||||||
extra_flags |= ImGuiInputTextFlags_CharsDecimal;
|
extra_flags |= ImGuiInputTextFlags_CharsDecimal;
|
||||||
extra_flags |= ImGuiInputTextFlags_AutoSelectAll;
|
extra_flags |= ImGuiInputTextFlags_AutoSelectAll;
|
||||||
if (ImGui::InputText("", buf, IM_ARRAYSIZE(buf), extra_flags))
|
if (ImGui::InputText("", buf, IM_ARRAYSIZE(buf), extra_flags))
|
||||||
{
|
value_changed = DataTypeApplyOpFromText(buf, GImGui->InputTextState.InitialText.begin(), data_type, data_ptr, scalar_format);
|
||||||
DataTypeApplyOpFromText(buf, GImGui->InputTextState.InitialText.begin(), data_type, data_ptr, scalar_format);
|
|
||||||
value_changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step buttons
|
// Step buttons
|
||||||
if (step_ptr)
|
if (step_ptr)
|
||||||
@ -8033,10 +8051,12 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
|||||||
|
|
||||||
const float arrow_size = (g.FontSize + style.FramePadding.x * 2.0f);
|
const float arrow_size = (g.FontSize + style.FramePadding.x * 2.0f);
|
||||||
const bool hovered = IsHovered(frame_bb, id);
|
const bool hovered = IsHovered(frame_bb, id);
|
||||||
|
bool popup_opened = IsPopupOpen(id);
|
||||||
|
bool popup_opened_now = false;
|
||||||
|
|
||||||
const ImRect value_bb(frame_bb.Min, frame_bb.Max - ImVec2(arrow_size, 0.0f));
|
const ImRect value_bb(frame_bb.Min, frame_bb.Max - ImVec2(arrow_size, 0.0f));
|
||||||
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||||
RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32(hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING
|
RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32(popup_opened || hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING
|
||||||
RenderCollapseTriangle(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y) + style.FramePadding, true);
|
RenderCollapseTriangle(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y) + style.FramePadding, true);
|
||||||
|
|
||||||
if (*current_item >= 0 && *current_item < items_count)
|
if (*current_item >= 0 && *current_item < items_count)
|
||||||
@ -8049,7 +8069,6 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
|||||||
if (label_size.x > 0)
|
if (label_size.x > 0)
|
||||||
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
||||||
|
|
||||||
bool menu_toggled = false;
|
|
||||||
if (hovered)
|
if (hovered)
|
||||||
{
|
{
|
||||||
SetHoveredID(id);
|
SetHoveredID(id);
|
||||||
@ -8063,8 +8082,8 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
FocusWindow(window);
|
FocusWindow(window);
|
||||||
ImGui::OpenPopup(label);
|
OpenPopup(label);
|
||||||
menu_toggled = true;
|
popup_opened = popup_opened_now = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8077,8 +8096,15 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
|||||||
height_in_items = 7;
|
height_in_items = 7;
|
||||||
|
|
||||||
float popup_height = (label_size.y + style.ItemSpacing.y) * ImMin(items_count, height_in_items) + (style.FramePadding.y * 3);
|
float popup_height = (label_size.y + style.ItemSpacing.y) * ImMin(items_count, height_in_items) + (style.FramePadding.y * 3);
|
||||||
ImRect popup_rect(ImVec2(frame_bb.Min.x, frame_bb.Max.y), ImVec2(frame_bb.Max.x, frame_bb.Max.y + popup_height));
|
float popup_y1 = frame_bb.Max.y;
|
||||||
popup_rect.Max.y = ImMin(popup_rect.Max.y, g.IO.DisplaySize.y - style.DisplaySafeAreaPadding.y); // Adhoc height limit for Combo. Ideally should be handled in Begin() along with other popups size, we want to have the possibility of moving the popup above as well.
|
float popup_y2 = ImClamp(popup_y1 + popup_height, popup_y1, g.IO.DisplaySize.y - style.DisplaySafeAreaPadding.y);
|
||||||
|
if ((popup_y2 - popup_y1) < ImMin(popup_height, frame_bb.Min.y - style.DisplaySafeAreaPadding.y))
|
||||||
|
{
|
||||||
|
// Position our combo ABOVE because there's more space to fit! (FIXME: Handle in Begin() or use a shared helper. We have similar code in Begin() for popup placement)
|
||||||
|
popup_y1 = ImClamp(frame_bb.Min.y - popup_height, style.DisplaySafeAreaPadding.y, frame_bb.Min.y);
|
||||||
|
popup_y2 = frame_bb.Min.y;
|
||||||
|
}
|
||||||
|
ImRect popup_rect(ImVec2(frame_bb.Min.x, popup_y1), ImVec2(frame_bb.Max.x, popup_y2));
|
||||||
ImGui::SetNextWindowPos(popup_rect.Min);
|
ImGui::SetNextWindowPos(popup_rect.Min);
|
||||||
ImGui::SetNextWindowSize(popup_rect.GetSize());
|
ImGui::SetNextWindowSize(popup_rect.GetSize());
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding);
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding);
|
||||||
@ -8101,7 +8127,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
|||||||
value_changed = true;
|
value_changed = true;
|
||||||
*current_item = i;
|
*current_item = i;
|
||||||
}
|
}
|
||||||
if (item_selected && menu_toggled)
|
if (item_selected && popup_opened_now)
|
||||||
ImGui::SetScrollHere();
|
ImGui::SetScrollHere();
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
13
imgui.h
13
imgui.h
@ -58,7 +58,7 @@ struct ImGuiListClipper; // Helper to manually clip large list of ite
|
|||||||
// Enumerations (declared as int for compatibility and to not pollute the top of this file)
|
// Enumerations (declared as int for compatibility and to not pollute the top of this file)
|
||||||
typedef unsigned int ImU32;
|
typedef unsigned int ImU32;
|
||||||
typedef unsigned short ImWchar; // character for keyboard input/display
|
typedef unsigned short ImWchar; // character for keyboard input/display
|
||||||
typedef void* ImTextureID; // user data to refer to a texture (e.g. store your texture handle/id)
|
typedef void* ImTextureID; // user data to identify a texture (this is whatever to you want it to be! read the FAQ about ImTextureID in imgui.cpp)
|
||||||
typedef ImU32 ImGuiID; // unique ID used by widgets (typically hashed from a stack of string)
|
typedef ImU32 ImGuiID; // unique ID used by widgets (typically hashed from a stack of string)
|
||||||
typedef int ImGuiCol; // a color identifier for styling // enum ImGuiCol_
|
typedef int ImGuiCol; // a color identifier for styling // enum ImGuiCol_
|
||||||
typedef int ImGuiStyleVar; // a variable identifier for styling // enum ImGuiStyleVar_
|
typedef int ImGuiStyleVar; // a variable identifier for styling // enum ImGuiStyleVar_
|
||||||
@ -103,14 +103,15 @@ namespace ImGui
|
|||||||
// Main
|
// Main
|
||||||
IMGUI_API ImGuiIO& GetIO();
|
IMGUI_API ImGuiIO& GetIO();
|
||||||
IMGUI_API ImGuiStyle& GetStyle();
|
IMGUI_API ImGuiStyle& GetStyle();
|
||||||
IMGUI_API ImDrawData* GetDrawData(); // same value as passed to your io.RenderDrawListsFn() function. valid after Render() and until the next call to NewFrame().
|
IMGUI_API ImDrawData* GetDrawData(); // same value as passed to your io.RenderDrawListsFn() function. valid after Render() and until the next call to NewFrame()
|
||||||
IMGUI_API void NewFrame();
|
IMGUI_API void NewFrame(); // start a new ImGui frame, you can submit any command from this point until NewFrame()/Render().
|
||||||
IMGUI_API void Render(); // finalize rendering data, then call your io.RenderDrawListsFn() function if set.
|
IMGUI_API void EndFrame(); // ends the ImGui frame. automatically called by Render()!
|
||||||
|
IMGUI_API void Render(); // ends the ImGui frame, finalize rendering data, then call your io.RenderDrawListsFn() function if set.
|
||||||
IMGUI_API void Shutdown();
|
IMGUI_API void Shutdown();
|
||||||
IMGUI_API void ShowUserGuide(); // help block
|
IMGUI_API void ShowUserGuide(); // help block
|
||||||
IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // style editor block
|
IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // style editor block
|
||||||
IMGUI_API void ShowTestWindow(bool* opened = NULL); // test window, demonstrate ImGui features
|
IMGUI_API void ShowTestWindow(bool* opened = NULL); // test window demonstrating ImGui features
|
||||||
IMGUI_API void ShowMetricsWindow(bool* opened = NULL); // metrics window for debugging imgui
|
IMGUI_API void ShowMetricsWindow(bool* opened = NULL); // metrics window for debugging ImGui
|
||||||
|
|
||||||
// Window
|
// Window
|
||||||
IMGUI_API bool Begin(const char* name, bool* p_opened = NULL, ImGuiWindowFlags flags = 0); // see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_opened' creates a widget on the upper-right to close the window (which sets your bool to false).
|
IMGUI_API bool Begin(const char* name, bool* p_opened = NULL, ImGuiWindowFlags flags = 0); // see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_opened' creates a widget on the upper-right to close the window (which sets your bool to false).
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "imgui_internal.h"
|
#include "imgui_internal.h"
|
||||||
|
|
||||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||||
#if !defined(alloca) && !defined(__FreeBSD__)
|
#if !defined(alloca) && !defined(__FreeBSD__) && !defined(__DragonFly__)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <malloc.h> // alloca
|
#include <malloc.h> // alloca
|
||||||
#else
|
#else
|
||||||
|
@ -682,8 +682,6 @@ namespace ImGui
|
|||||||
IMGUI_API void SetHoveredID(ImGuiID id);
|
IMGUI_API void SetHoveredID(ImGuiID id);
|
||||||
IMGUI_API void KeepAliveID(ImGuiID id);
|
IMGUI_API void KeepAliveID(ImGuiID id);
|
||||||
|
|
||||||
IMGUI_API void EndFrame(); // Automatically called by Render()
|
|
||||||
|
|
||||||
IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
|
IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
|
||||||
IMGUI_API void ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
|
IMGUI_API void ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
|
||||||
IMGUI_API bool ItemAdd(const ImRect& bb, const ImGuiID* id);
|
IMGUI_API bool ItemAdd(const ImRect& bb, const ImGuiID* id);
|
||||||
|
Loading…
Reference in New Issue
Block a user