mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 20:07:01 +00:00
Merge branch 'master' into navigation
# Conflicts: # imgui.cpp # imgui_internal.h
This commit is contained in:
commit
f10a1d7b9e
@ -8,15 +8,16 @@ Third party languages and frameworks bindings: https://github.com/ocornut/imgui/
|
||||
|
||||
TL;DR;
|
||||
- Newcomers, read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup ImGui in your codebase.
|
||||
- To LEARN how the library is setup, you may refer to 'opengl2_example' because is the simplest one.
|
||||
The other examples requires more boilerplate and are harder to read.
|
||||
However, USE 'opengl3_example' in your application if you are using any modern OpenGL3+ calls.
|
||||
Mixing old fixed pipeline OpenGL2 and programmable pipeline OpenGL3+ isn't well supported by some drivers.
|
||||
If you are not sure, in doubt, use 'opengl3_example'.
|
||||
- If you are using of the backend provided here, so you can copy the imgui_impl_xxx.cpp/h files
|
||||
to your project and use them unmodified.
|
||||
- If you have your own engine, you probably want to start from one of the OpenGL example and adapt it to
|
||||
your engine, but you can read the other examples as well.
|
||||
- To LEARN how the library is setup, you may refer to 'opengl2_example' because is the simplest one to read.
|
||||
However, do NOT USE the 'opengl2_example' if your code is using any modern GL3+ calls.
|
||||
Mixing old fixed-pipeline OpenGL2 and modern OpenGL3+ is going to make everything more complicated.
|
||||
Read comments below for details. If you are not sure, in doubt, use 'opengl3_example'.
|
||||
- If you have your own engine, you probably want to read a few of the examples first then adapt it to
|
||||
your engine. Please note that if your engine is based on OpenGL/DirectX you can perfectly use the
|
||||
existing rendering backends, don't feel forced to rewrite them with your own engine API, or you can
|
||||
do that later when you already got things to work.
|
||||
|
||||
ImGui is highly portable and only requires a few things to run:
|
||||
- Providing mouse/keyboard inputs
|
||||
@ -45,12 +46,12 @@ Also note that some setup or GPU drivers may be causing extra lag (possibly by e
|
||||
leaving you with no option but sadness/anger (Intel GPU drivers were reported as such).
|
||||
|
||||
opengl2_example/
|
||||
*DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL*
|
||||
GLFW + OpenGL example (old, fixed graphic pipeline).
|
||||
This is only provided as a reference to learn how ImGui integration works, because it is easier to read.
|
||||
However, if your code is using GL3+ context, using this may confuse your driver. Please use the GL3 example below.
|
||||
(You might be able to use this code in a GL3/GL4 context but make sure you disable the programmable
|
||||
pipeline by calling "glUseProgram(0)" before ImGui::Render. It appears that many librairies and drivers
|
||||
are having issues mixing GL2 calls and newer GL3/GL4 calls. So it isn't recommended that you use that.)
|
||||
This is mostly provided as a reference to learn how ImGui integration works, because it is easier to read.
|
||||
If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything
|
||||
more complicated, will require your code to reset every single OpenGL attributes to their initial state,
|
||||
and might confuse your GPU driver. Prefer using opengl3_example.
|
||||
|
||||
opengl3_example/
|
||||
GLFW + OpenGL example (programmable pipeline, binding modern functions with GL3W).
|
||||
@ -74,7 +75,12 @@ apple_example/
|
||||
Synergy keyboard integration is rather hacky.
|
||||
|
||||
sdl_opengl2_example/
|
||||
*DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL*
|
||||
SDL2 + OpenGL example (old fixed pipeline).
|
||||
This is mostly provided as a reference to learn how ImGui integration works, because it is easier to read.
|
||||
If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything
|
||||
more complicated, will require your code to reset every single OpenGL attributes to their initial state,
|
||||
and might confuse your GPU driver. Prefer using sdl_opengl3_example.
|
||||
|
||||
sdl_opengl3_example/
|
||||
SDL2 + OpenGL3 example.
|
||||
|
@ -1,10 +1,12 @@
|
||||
// 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.
|
||||
|
||||
// If your context or own usage of OpenGL involve anything GL3/GL4, prefer using the code in opengl3_example.
|
||||
// If you are not sure what that means, prefer using the code in opengl3_example.
|
||||
// You *might* use this code with a GL3/GL4 context but make sure you disable the programmable pipeline by calling "glUseProgram(0)" before ImGui::Render().
|
||||
// We cannot do that from GL2 code because the function doesn't exist. Mixing GL2 calls and GL3/GL4 calls is giving trouble to many librairies/drivers.
|
||||
// *DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL*
|
||||
// This is mostly provided as a reference to learn how ImGui integration works, because it is easier to read.
|
||||
// If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything
|
||||
// more complicated, will require your code to reset every single OpenGL attributes to their initial state,
|
||||
// and might confuse your GPU driver. Prefer using opengl3_example.
|
||||
// The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API.
|
||||
|
||||
// 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().
|
||||
|
@ -1,8 +1,12 @@
|
||||
// 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.
|
||||
|
||||
// If your context or own usage of OpenGL involve anything GL3/GL4, prefer using the code in sdl_opengl3_example.
|
||||
// If you are not sure what that means, prefer using the code in sdl_opengl3_example.
|
||||
// *DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL*
|
||||
// This is mostly provided as a reference to learn how ImGui integration works, because it is easier to read.
|
||||
// If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything
|
||||
// more complicated, will require your code to reset every single OpenGL attributes to their initial state,
|
||||
// and might confuse your GPU driver. Prefer using sdl_opengl3_example.
|
||||
// The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API.
|
||||
|
||||
// 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().
|
||||
|
34
imgui.cpp
34
imgui.cpp
@ -3129,29 +3129,29 @@ void ImGui::NewFrame()
|
||||
g.IO.Framerate = 1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame));
|
||||
|
||||
// Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering). Only valid for root windows.
|
||||
if (g.MovedWindowMoveId && g.MovedWindowMoveId == g.ActiveId && g.ActiveIdSource == ImGuiInputSource_Mouse)
|
||||
if (g.MovingWindowMoveId && g.MovingWindowMoveId == g.ActiveId && g.ActiveIdSource == ImGuiInputSource_Mouse)
|
||||
{
|
||||
KeepAliveID(g.MovedWindowMoveId);
|
||||
IM_ASSERT(g.MovedWindow && g.MovedWindow->RootWindow);
|
||||
IM_ASSERT(g.MovedWindow->MoveId == g.MovedWindowMoveId);
|
||||
KeepAliveID(g.MovingWindowMoveId);
|
||||
IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow);
|
||||
IM_ASSERT(g.MovingWindow->MoveId == g.MovingWindowMoveId);
|
||||
if (g.IO.MouseDown[0])
|
||||
{
|
||||
g.MovedWindow->RootWindow->PosFloat += g.IO.MouseDelta;
|
||||
g.MovingWindow->RootWindow->PosFloat += g.IO.MouseDelta;
|
||||
if (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f)
|
||||
MarkIniSettingsDirty(g.MovedWindow->RootWindow);
|
||||
FocusWindow(g.MovedWindow);
|
||||
MarkIniSettingsDirty(g.MovingWindow->RootWindow);
|
||||
FocusWindow(g.MovingWindow);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearActiveID();
|
||||
g.MovedWindow = NULL;
|
||||
g.MovedWindowMoveId = 0;
|
||||
g.MovingWindow = NULL;
|
||||
g.MovingWindowMoveId = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g.MovedWindow = NULL;
|
||||
g.MovedWindowMoveId = 0;
|
||||
g.MovingWindow = NULL;
|
||||
g.MovingWindowMoveId = 0;
|
||||
}
|
||||
|
||||
// Delay saving settings so we don't spam disk too much
|
||||
@ -3163,11 +3163,11 @@ void ImGui::NewFrame()
|
||||
}
|
||||
|
||||
// Find the window we are hovering. Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow
|
||||
g.HoveredWindow = g.MovedWindow ? g.MovedWindow : FindHoveredWindow(g.IO.MousePos, false);
|
||||
g.HoveredWindow = g.MovingWindow ? g.MovingWindow : FindHoveredWindow(g.IO.MousePos, false);
|
||||
if (g.HoveredWindow && (g.HoveredWindow->Flags & ImGuiWindowFlags_ChildWindow))
|
||||
g.HoveredRootWindow = g.HoveredWindow->RootWindow;
|
||||
else
|
||||
g.HoveredRootWindow = g.MovedWindow ? g.MovedWindow->RootWindow : FindHoveredWindow(g.IO.MousePos, true);
|
||||
g.HoveredRootWindow = g.MovingWindow ? g.MovingWindow->RootWindow : FindHoveredWindow(g.IO.MousePos, true);
|
||||
|
||||
if (ImGuiWindow* modal_window = GetFrontMostModalRootWindow())
|
||||
{
|
||||
@ -3311,7 +3311,7 @@ void ImGui::Shutdown()
|
||||
g.HoveredWindow = NULL;
|
||||
g.HoveredRootWindow = NULL;
|
||||
g.ActiveIdWindow = NULL;
|
||||
g.MovedWindow = NULL;
|
||||
g.MovingWindow = NULL;
|
||||
for (int i = 0; i < g.Settings.Size; i++)
|
||||
ImGui::MemFree(g.Settings[i].Name);
|
||||
g.Settings.clear();
|
||||
@ -3614,9 +3614,9 @@ void ImGui::EndFrame()
|
||||
*/
|
||||
if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove) && !(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoMove))
|
||||
{
|
||||
g.MovedWindow = g.HoveredWindow;
|
||||
g.MovedWindowMoveId = g.HoveredWindow->MoveId;
|
||||
SetActiveID(g.MovedWindowMoveId, g.HoveredRootWindow);
|
||||
g.MovingWindow = g.HoveredWindow;
|
||||
g.MovingWindowMoveId = g.MovingWindow->MoveId;
|
||||
SetActiveID(g.MovingWindowMoveId, g.HoveredRootWindow);
|
||||
}
|
||||
}
|
||||
else if (g.NavWindow != NULL && GetFrontMostModalRootWindow() == NULL)
|
||||
|
6
imgui.h
6
imgui.h
@ -30,14 +30,16 @@
|
||||
#define IM_ASSERT(_EXPR) assert(_EXPR)
|
||||
#endif
|
||||
|
||||
// Helpers
|
||||
// Some compilers support applying printf-style warnings to user functions.
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1)))
|
||||
#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0)))
|
||||
#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1)))
|
||||
#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0)))
|
||||
#else
|
||||
#define IM_FMTARGS(FMT)
|
||||
#define IM_FMTLIST(FMT)
|
||||
#endif
|
||||
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR)))
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
|
@ -81,9 +81,8 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit ImGui context pointe
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR)))
|
||||
#define IM_PI 3.14159265358979323846f
|
||||
#define IM_OFFSETOF(_TYPE,_ELM) ((size_t)&(((_TYPE*)0)->_ELM))
|
||||
#define IM_PI 3.14159265358979323846f
|
||||
#define IM_OFFSETOF(_TYPE,_ELM) ((size_t)&(((_TYPE*)0)->_ELM))
|
||||
|
||||
// Helpers: UTF-8 <> wchar
|
||||
IMGUI_API int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
|
||||
@ -457,8 +456,8 @@ struct ImGuiContext
|
||||
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
||||
ImGuiWindow* ActiveIdWindow;
|
||||
ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
|
||||
ImGuiWindow* MovedWindow; // Track the child window we clicked on to move a window (only apply to moving with mouse)
|
||||
ImGuiID MovedWindowMoveId; // == MovedWindow->RootWindow->MoveId
|
||||
ImGuiWindow* MovingWindow; // Track the child window we clicked on to move a window.
|
||||
ImGuiID MovingWindowMoveId; // == MovingWindow->MoveId
|
||||
ImVector<ImGuiIniData> Settings; // .ini Settings
|
||||
float SettingsDirtyTimer; // Save .ini Settings on disk when time reaches zero
|
||||
ImVector<ImGuiColMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
|
||||
@ -586,8 +585,8 @@ struct ImGuiContext
|
||||
ActiveIdClickOffset = ImVec2(-1,-1);
|
||||
ActiveIdWindow = NULL;
|
||||
ActiveIdSource = ImGuiInputSource_None;
|
||||
MovedWindow = NULL;
|
||||
MovedWindowMoveId = 0;
|
||||
MovingWindow = NULL;
|
||||
MovingWindowMoveId = 0;
|
||||
SettingsDirtyTimer = 0.0f;
|
||||
|
||||
NavWindow = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user