mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-11-04 09:44:29 +00:00 
			
		
		
		
	Merge branch 'master' into navigation
This commit is contained in:
		@@ -228,7 +228,7 @@ void ImGui_ImplDX10_RenderDrawLists(ImDrawData* draw_data)
 | 
				
			|||||||
static bool IsAnyMouseButtonDown()
 | 
					static bool IsAnyMouseButtonDown()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ImGuiIO& io = ImGui::GetIO();
 | 
					    ImGuiIO& io = ImGui::GetIO();
 | 
				
			||||||
    for (int n = 0; n < ARRAYSIZE(io.MouseDown); n++)
 | 
					    for (int n = 0; n < IM_ARRAYSIZE(io.MouseDown); n++)
 | 
				
			||||||
        if (io.MouseDown[n])
 | 
					        if (io.MouseDown[n])
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -235,7 +235,7 @@ void ImGui_ImplDX11_RenderDrawLists(ImDrawData* draw_data)
 | 
				
			|||||||
static bool IsAnyMouseButtonDown()
 | 
					static bool IsAnyMouseButtonDown()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ImGuiIO& io = ImGui::GetIO();
 | 
					    ImGuiIO& io = ImGui::GetIO();
 | 
				
			||||||
    for (int n = 0; n < ARRAYSIZE(io.MouseDown); n++)
 | 
					    for (int n = 0; n < IM_ARRAYSIZE(io.MouseDown); n++)
 | 
				
			||||||
        if (io.MouseDown[n])
 | 
					        if (io.MouseDown[n])
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -174,7 +174,7 @@ void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
 | 
				
			|||||||
static bool IsAnyMouseButtonDown()
 | 
					static bool IsAnyMouseButtonDown()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ImGuiIO& io = ImGui::GetIO();
 | 
					    ImGuiIO& io = ImGui::GetIO();
 | 
				
			||||||
    for (int n = 0; n < ARRAYSIZE(io.MouseDown); n++)
 | 
					    for (int n = 0; n < IM_ARRAYSIZE(io.MouseDown); n++)
 | 
				
			||||||
        if (io.MouseDown[n])
 | 
					        if (io.MouseDown[n])
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								examples/null_example/build_win32.bat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								examples/null_example/build_win32.bat
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
 | 
				
			||||||
 | 
					mkdir Debug
 | 
				
			||||||
 | 
					cl /nologo /Zi /MD /I ..\.. *.cpp ..\..\*.cpp /FeDebug/null_example.exe /FoDebug/ /link gdi32.lib shell32.lib
 | 
				
			||||||
							
								
								
									
										33
									
								
								examples/null_example/main.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								examples/null_example/main.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					// ImGui - null/dummy example application (compile and link imgui with no inputs, no outputs)
 | 
				
			||||||
 | 
					#include <imgui.h>
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main(int, char**)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    ImGuiIO& io = ImGui::GetIO();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Build atlas
 | 
				
			||||||
 | 
					    unsigned char* tex_pixels = NULL;
 | 
				
			||||||
 | 
					    int tex_w, tex_h;
 | 
				
			||||||
 | 
					    io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_w, &tex_h);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (int n = 0; n < 50; n++)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        printf("NewFrame() %d\n", n);
 | 
				
			||||||
 | 
					        io.DisplaySize = ImVec2(1920, 1080);
 | 
				
			||||||
 | 
					        io.DeltaTime = 1.0f / 60.0f;
 | 
				
			||||||
 | 
					        ImGui::NewFrame();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        static float f = 0.0f;
 | 
				
			||||||
 | 
					        ImGui::Text("Hello, world!");
 | 
				
			||||||
 | 
					        ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
 | 
				
			||||||
 | 
					        ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
 | 
				
			||||||
 | 
					        ImGui::ShowTestWindow(NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ImGui::Render();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    printf("Shutdown()\n");
 | 
				
			||||||
 | 
					    ImGui::Shutdown();
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										56
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										56
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -622,7 +622,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "imgui.h"
 | 
					#include "imgui.h"
 | 
				
			||||||
#define IMGUI_DEFINE_MATH_OPERATORS
 | 
					#define IMGUI_DEFINE_MATH_OPERATORS
 | 
				
			||||||
#define IMGUI_DEFINE_PLACEMENT_NEW
 | 
					 | 
				
			||||||
#include "imgui_internal.h"
 | 
					#include "imgui_internal.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <ctype.h>      // toupper, isprint
 | 
					#include <ctype.h>      // toupper, isprint
 | 
				
			||||||
@@ -1908,8 +1907,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
 | 
				
			|||||||
    ItemWidthDefault = 0.0f;
 | 
					    ItemWidthDefault = 0.0f;
 | 
				
			||||||
    FontWindowScale = 1.0f;
 | 
					    FontWindowScale = 1.0f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DrawList = (ImDrawList*)ImGui::MemAlloc(sizeof(ImDrawList));
 | 
					    DrawList = IM_NEW(ImDrawList)(&context->DrawListSharedData);
 | 
				
			||||||
    IM_PLACEMENT_NEW(DrawList) ImDrawList(&context->DrawListSharedData);
 | 
					 | 
				
			||||||
    DrawList->_OwnerName = Name;
 | 
					    DrawList->_OwnerName = Name;
 | 
				
			||||||
    ParentWindow = NULL;
 | 
					    ParentWindow = NULL;
 | 
				
			||||||
    RootWindow = NULL;
 | 
					    RootWindow = NULL;
 | 
				
			||||||
@@ -1923,11 +1921,8 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
ImGuiWindow::~ImGuiWindow()
 | 
					ImGuiWindow::~ImGuiWindow()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    DrawList->~ImDrawList();
 | 
					    IM_DELETE(DrawList);
 | 
				
			||||||
    ImGui::MemFree(DrawList);
 | 
					    IM_DELETE(Name);
 | 
				
			||||||
    DrawList = NULL;
 | 
					 | 
				
			||||||
    ImGui::MemFree(Name);
 | 
					 | 
				
			||||||
    Name = NULL;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end)
 | 
					ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end)
 | 
				
			||||||
@@ -3384,8 +3379,7 @@ static void SettingsHandlerWindow_WriteAll(ImGuiContext& g, ImGuiTextBuffer* buf
 | 
				
			|||||||
void ImGui::Initialize()
 | 
					void ImGui::Initialize()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ImGuiContext& g = *GImGui;
 | 
					    ImGuiContext& g = *GImGui;
 | 
				
			||||||
    g.LogClipboard = (ImGuiTextBuffer*)ImGui::MemAlloc(sizeof(ImGuiTextBuffer));
 | 
					    g.LogClipboard = IM_NEW(ImGuiTextBuffer)();
 | 
				
			||||||
    IM_PLACEMENT_NEW(g.LogClipboard) ImGuiTextBuffer();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Add .ini handle for ImGuiWindow type
 | 
					    // Add .ini handle for ImGuiWindow type
 | 
				
			||||||
    ImGuiSettingsHandler ini_handler;
 | 
					    ImGuiSettingsHandler ini_handler;
 | 
				
			||||||
@@ -3418,10 +3412,7 @@ void ImGui::Shutdown()
 | 
				
			|||||||
    SaveIniSettingsToDisk(g.IO.IniFilename);
 | 
					    SaveIniSettingsToDisk(g.IO.IniFilename);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (int i = 0; i < g.Windows.Size; i++)
 | 
					    for (int i = 0; i < g.Windows.Size; i++)
 | 
				
			||||||
    {
 | 
					        IM_DELETE(g.Windows[i]);
 | 
				
			||||||
        g.Windows[i]->~ImGuiWindow();
 | 
					 | 
				
			||||||
        ImGui::MemFree(g.Windows[i]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    g.Windows.clear();
 | 
					    g.Windows.clear();
 | 
				
			||||||
    g.WindowsSortBuffer.clear();
 | 
					    g.WindowsSortBuffer.clear();
 | 
				
			||||||
    g.CurrentWindow = NULL;
 | 
					    g.CurrentWindow = NULL;
 | 
				
			||||||
@@ -3433,7 +3424,7 @@ void ImGui::Shutdown()
 | 
				
			|||||||
    g.ActiveIdWindow = NULL;
 | 
					    g.ActiveIdWindow = NULL;
 | 
				
			||||||
    g.MovingWindow = NULL;
 | 
					    g.MovingWindow = NULL;
 | 
				
			||||||
    for (int i = 0; i < g.SettingsWindows.Size; i++)
 | 
					    for (int i = 0; i < g.SettingsWindows.Size; i++)
 | 
				
			||||||
        ImGui::MemFree(g.SettingsWindows[i].Name);
 | 
					        IM_DELETE(g.SettingsWindows[i].Name);
 | 
				
			||||||
    g.ColorModifiers.clear();
 | 
					    g.ColorModifiers.clear();
 | 
				
			||||||
    g.StyleModifiers.clear();
 | 
					    g.StyleModifiers.clear();
 | 
				
			||||||
    g.FontStack.clear();
 | 
					    g.FontStack.clear();
 | 
				
			||||||
@@ -3458,10 +3449,7 @@ void ImGui::Shutdown()
 | 
				
			|||||||
        g.LogFile = NULL;
 | 
					        g.LogFile = NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (g.LogClipboard)
 | 
					    if (g.LogClipboard)
 | 
				
			||||||
    {
 | 
					        IM_DELETE(g.LogClipboard);
 | 
				
			||||||
        g.LogClipboard->~ImGuiTextBuffer();
 | 
					 | 
				
			||||||
        ImGui::MemFree(g.LogClipboard);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g.Initialized = false;
 | 
					    g.Initialized = false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -3651,14 +3639,16 @@ static void AddDrawListToRenderList(ImVector<ImDrawList*>& out_render_list, ImDr
 | 
				
			|||||||
    IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size);
 | 
					    IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size);
 | 
				
			||||||
    IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size);
 | 
					    IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Check that draw_list doesn't use more vertices than indexable in a single draw call (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per window)
 | 
					    // Check that draw_list doesn't use more vertices than indexable in a single draw call (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per ImDrawList = per window)
 | 
				
			||||||
    // If this assert triggers because you are drawing lots of stuff manually, you can:
 | 
					    // If this assert triggers because you are drawing lots of stuff manually:
 | 
				
			||||||
    // A) Add '#define ImDrawIdx unsigned int' in imconfig.h to set the index size to 4 bytes. You'll need to handle the 4-bytes indices to your renderer.
 | 
					    // A) Make sure you are coarse clipping, because ImDrawList let all your vertices pass. You can use thre Metrics window to inspect draw list contents.
 | 
				
			||||||
    //    For example, the OpenGL example code detect index size at compile-time by doing:
 | 
					    // B) If you need/want meshes with more than 64K vertices, uncomment the '#define ImDrawIdx unsigned int' line in imconfig.h to set the index size to 4 bytes. 
 | 
				
			||||||
    //    'glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);'
 | 
					    //    You'll need to handle the 4-bytes indices to your renderer. For example, the OpenGL example code detect index size at compile-time by doing:
 | 
				
			||||||
 | 
					    //      glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
 | 
				
			||||||
    //    Your own engine or render API may use different parameters or function calls to specify index sizes. 2 and 4 bytes indices are generally supported by most API.
 | 
					    //    Your own engine or render API may use different parameters or function calls to specify index sizes. 2 and 4 bytes indices are generally supported by most API.
 | 
				
			||||||
    // B) If for some reason you cannot use 4 bytes indices or don't want to, a workaround is to call BeginChild()/EndChild() before reaching the 64K limit to split your draw commands in multiple draw lists.
 | 
					    // C) If for some reason you cannot use 4 bytes indices or don't want to, a workaround is to call BeginChild()/EndChild() before reaching the 64K limit to split your draw commands in multiple draw lists.
 | 
				
			||||||
    IM_ASSERT(((ImU64)draw_list->_VtxCurrentIdx >> (sizeof(ImDrawIdx)*8)) == 0);  // Too many vertices in same ImDrawList. See comment above.
 | 
					    if (sizeof(ImDrawIdx) == 2)
 | 
				
			||||||
 | 
					        IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    out_render_list.push_back(draw_list);
 | 
					    out_render_list.push_back(draw_list);
 | 
				
			||||||
    GImGui->IO.MetricsRenderVertices += draw_list->VtxBuffer.Size;
 | 
					    GImGui->IO.MetricsRenderVertices += draw_list->VtxBuffer.Size;
 | 
				
			||||||
@@ -4086,22 +4076,23 @@ void ImGui::RenderTriangle(ImVec2 p_min, ImGuiDir dir, float scale)
 | 
				
			|||||||
    switch (dir)
 | 
					    switch (dir)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    case ImGuiDir_Up:
 | 
					    case ImGuiDir_Up:
 | 
				
			||||||
        r = -r; // ...fall through, no break!
 | 
					 | 
				
			||||||
    case ImGuiDir_Down:
 | 
					    case ImGuiDir_Down:
 | 
				
			||||||
 | 
					        if (dir == ImGuiDir_Up) r = -r;
 | 
				
			||||||
        center.y -= r * 0.25f;
 | 
					        center.y -= r * 0.25f;
 | 
				
			||||||
        a = ImVec2(0,1) * r;
 | 
					        a = ImVec2(0,1) * r;
 | 
				
			||||||
        b = ImVec2(-0.866f,-0.5f) * r;
 | 
					        b = ImVec2(-0.866f,-0.5f) * r;
 | 
				
			||||||
        c = ImVec2(+0.866f,-0.5f) * r;
 | 
					        c = ImVec2(+0.866f,-0.5f) * r;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    case ImGuiDir_Left:
 | 
					    case ImGuiDir_Left:
 | 
				
			||||||
        r = -r; // ...fall through, no break!
 | 
					 | 
				
			||||||
    case ImGuiDir_Right:
 | 
					    case ImGuiDir_Right:
 | 
				
			||||||
 | 
					        if (dir == ImGuiDir_Left) r = -r;
 | 
				
			||||||
        center.x -= r * 0.25f;
 | 
					        center.x -= r * 0.25f;
 | 
				
			||||||
        a = ImVec2(1,0) * r;
 | 
					        a = ImVec2(1,0) * r;
 | 
				
			||||||
        b = ImVec2(-0.500f,+0.866f) * r;
 | 
					        b = ImVec2(-0.500f,+0.866f) * r;
 | 
				
			||||||
        c = ImVec2(-0.500f,-0.866f) * r;
 | 
					        c = ImVec2(-0.500f,-0.866f) * r;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    default:
 | 
					    case ImGuiDir_None: 
 | 
				
			||||||
 | 
					    case ImGuiDir_Count_: 
 | 
				
			||||||
        IM_ASSERT(0);
 | 
					        IM_ASSERT(0);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -5053,8 +5044,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
 | 
				
			|||||||
    ImGuiContext& g = *GImGui;
 | 
					    ImGuiContext& g = *GImGui;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Create window the first time
 | 
					    // Create window the first time
 | 
				
			||||||
    ImGuiWindow* window = (ImGuiWindow*)ImGui::MemAlloc(sizeof(ImGuiWindow));
 | 
					    ImGuiWindow* window = IM_NEW(ImGuiWindow)(&g, name);
 | 
				
			||||||
    IM_PLACEMENT_NEW(window) ImGuiWindow(&g, name);
 | 
					 | 
				
			||||||
    window->Flags = flags;
 | 
					    window->Flags = flags;
 | 
				
			||||||
    g.WindowsById.SetVoidPtr(window->ID, window);
 | 
					    g.WindowsById.SetVoidPtr(window->ID, window);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -11422,7 +11412,7 @@ static void RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGui
 | 
				
			|||||||
    case ImGuiDir_Right: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), pos, col); return;
 | 
					    case ImGuiDir_Right: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), pos, col); return;
 | 
				
			||||||
    case ImGuiDir_Up:    draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), pos, col); return;
 | 
					    case ImGuiDir_Up:    draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), pos, col); return;
 | 
				
			||||||
    case ImGuiDir_Down:  draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), pos, col); return;
 | 
					    case ImGuiDir_Down:  draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), pos, col); return;
 | 
				
			||||||
    default: return; // Fix warning for ImGuiDir_None
 | 
					    case ImGuiDir_None: case ImGuiDir_Count_: break; // Fix warnings
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -12663,7 +12653,7 @@ void ImGui::EndDragDropTarget()
 | 
				
			|||||||
#if defined(_WIN32) && !defined(_WINDOWS_) && (!defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) || !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS))
 | 
					#if defined(_WIN32) && !defined(_WINDOWS_) && (!defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) || !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS))
 | 
				
			||||||
#undef WIN32_LEAN_AND_MEAN
 | 
					#undef WIN32_LEAN_AND_MEAN
 | 
				
			||||||
#define WIN32_LEAN_AND_MEAN
 | 
					#define WIN32_LEAN_AND_MEAN
 | 
				
			||||||
#include <windows.h>
 | 
					#include <Windows.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Win32 API clipboard implementation
 | 
					// Win32 API clipboard implementation
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										23
									
								
								imgui.h
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								imgui.h
									
									
									
									
									
								
							@@ -94,7 +94,7 @@ typedef int ImGuiTreeNodeFlags;     // flags: for TreeNode*(),CollapsingHeader()
 | 
				
			|||||||
typedef int ImGuiWindowFlags;       // flags: for Begin*()                      // enum ImGuiWindowFlags_
 | 
					typedef int ImGuiWindowFlags;       // flags: for Begin*()                      // enum ImGuiWindowFlags_
 | 
				
			||||||
typedef int (*ImGuiTextEditCallback)(ImGuiTextEditCallbackData *data);
 | 
					typedef int (*ImGuiTextEditCallback)(ImGuiTextEditCallbackData *data);
 | 
				
			||||||
typedef void (*ImGuiSizeConstraintCallback)(ImGuiSizeConstraintCallbackData* data);
 | 
					typedef void (*ImGuiSizeConstraintCallback)(ImGuiSizeConstraintCallbackData* data);
 | 
				
			||||||
#ifdef _MSC_VER
 | 
					#if defined(_MSC_VER) && !defined(__clang__)
 | 
				
			||||||
typedef unsigned __int64 ImU64;     // 64-bit unsigned integer
 | 
					typedef unsigned __int64 ImU64;     // 64-bit unsigned integer
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
typedef unsigned long long ImU64;   // 64-bit unsigned integer
 | 
					typedef unsigned long long ImU64;   // 64-bit unsigned integer
 | 
				
			||||||
@@ -630,7 +630,7 @@ enum ImGuiFocusedFlags_
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    ImGuiFocusedFlags_ChildWindows                  = 1 << 0,   // IsWindowFocused(): Return true if any children of the window is focused
 | 
					    ImGuiFocusedFlags_ChildWindows                  = 1 << 0,   // IsWindowFocused(): Return true if any children of the window is focused
 | 
				
			||||||
    ImGuiFocusedFlags_RootWindow                    = 1 << 1,   // IsWindowFocused(): Test from root window (top most parent of the current hierarchy)
 | 
					    ImGuiFocusedFlags_RootWindow                    = 1 << 1,   // IsWindowFocused(): Test from root window (top most parent of the current hierarchy)
 | 
				
			||||||
    ImGuiFocusedFlags_RootAndChildWindows           = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows,
 | 
					    ImGuiFocusedFlags_RootAndChildWindows           = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered()
 | 
					// Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered()
 | 
				
			||||||
@@ -1048,7 +1048,7 @@ namespace ImGui
 | 
				
			|||||||
//-----------------------------------------------------------------------------
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Lightweight std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug).
 | 
					// Lightweight std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug).
 | 
				
			||||||
// Our implementation does NOT call c++ constructors because we don't use them in ImGui. Don't use this class as a straight std::vector replacement in your code!
 | 
					// Our implementation does NOT call C++ constructors/destructors. This is intentional and we do not require it. Do not use this class as a straight std::vector replacement in your code!
 | 
				
			||||||
template<typename T>
 | 
					template<typename T>
 | 
				
			||||||
class ImVector
 | 
					class ImVector
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -1061,8 +1061,10 @@ public:
 | 
				
			|||||||
    typedef value_type*         iterator;
 | 
					    typedef value_type*         iterator;
 | 
				
			||||||
    typedef const value_type*   const_iterator;
 | 
					    typedef const value_type*   const_iterator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ImVector()                  { Size = Capacity = 0; Data = NULL; }
 | 
					    inline ImVector()                                           { Size = Capacity = 0; Data = NULL; }
 | 
				
			||||||
    ~ImVector()                 { if (Data) ImGui::MemFree(Data); }
 | 
					    inline ~ImVector()                                          { if (Data) ImGui::MemFree(Data); }
 | 
				
			||||||
 | 
					    inline ImVector(const ImVector<T>& rhs)                     { Size = Capacity = 0; Data = NULL; if (rhs.Size) { resize(rhs.Size); memcpy(Data, rhs.Data, (size_t)rhs.Size * sizeof(T)); } }
 | 
				
			||||||
 | 
					    inline ImVector<T>& operator=(const ImVector<T>& rhs)       { resize(rhs.Size); if (rhs.Size) memcpy(Data, rhs.Data, (size_t)rhs.Size * sizeof(T)); return *this; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    inline bool                 empty() const                   { return Size == 0; }
 | 
					    inline bool                 empty() const                   { return Size == 0; }
 | 
				
			||||||
    inline int                  size() const                    { return Size; }
 | 
					    inline int                  size() const                    { return Size; }
 | 
				
			||||||
@@ -1078,8 +1080,8 @@ public:
 | 
				
			|||||||
    inline const_iterator       end() const                     { return Data + Size; }
 | 
					    inline const_iterator       end() const                     { return Data + Size; }
 | 
				
			||||||
    inline value_type&          front()                         { IM_ASSERT(Size > 0); return Data[0]; }
 | 
					    inline value_type&          front()                         { IM_ASSERT(Size > 0); return Data[0]; }
 | 
				
			||||||
    inline const value_type&    front() const                   { IM_ASSERT(Size > 0); return Data[0]; }
 | 
					    inline const value_type&    front() const                   { IM_ASSERT(Size > 0); return Data[0]; }
 | 
				
			||||||
    inline value_type&          back()                          { IM_ASSERT(Size > 0); return Data[Size-1]; }
 | 
					    inline value_type&          back()                          { IM_ASSERT(Size > 0); return Data[Size - 1]; }
 | 
				
			||||||
    inline const value_type&    back() const                    { IM_ASSERT(Size > 0); return Data[Size-1]; }
 | 
					    inline const value_type&    back() const                    { IM_ASSERT(Size > 0); return Data[Size - 1]; }
 | 
				
			||||||
    inline void                 swap(ImVector<T>& rhs)          { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
 | 
					    inline void                 swap(ImVector<T>& rhs)          { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    inline int                  _grow_capacity(int size) const  { int new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > size ? new_capacity : size; }
 | 
					    inline int                  _grow_capacity(int size) const  { int new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > size ? new_capacity : size; }
 | 
				
			||||||
@@ -1088,7 +1090,8 @@ public:
 | 
				
			|||||||
    inline void                 resize(int new_size, const T& v){ if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) Data[n] = v; Size = new_size; }
 | 
					    inline void                 resize(int new_size, const T& v){ if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) Data[n] = v; Size = new_size; }
 | 
				
			||||||
    inline void                 reserve(int new_capacity)
 | 
					    inline void                 reserve(int new_capacity)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (new_capacity <= Capacity) return;
 | 
					        if (new_capacity <= Capacity) 
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
        T* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(T));
 | 
					        T* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(T));
 | 
				
			||||||
        if (Data)
 | 
					        if (Data)
 | 
				
			||||||
            memcpy(new_data, Data, (size_t)Size * sizeof(T));
 | 
					            memcpy(new_data, Data, (size_t)Size * sizeof(T));
 | 
				
			||||||
@@ -1097,12 +1100,12 @@ public:
 | 
				
			|||||||
        Capacity = new_capacity;
 | 
					        Capacity = new_capacity;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    inline void                 push_back(const value_type& v)  { if (Size == Capacity) reserve(_grow_capacity(Size+1)); Data[Size++] = v; }
 | 
					    inline void                 push_back(const value_type& v)  { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); Data[Size++] = v; }
 | 
				
			||||||
    inline void                 pop_back()                      { IM_ASSERT(Size > 0); Size--; }
 | 
					    inline void                 pop_back()                      { IM_ASSERT(Size > 0); Size--; }
 | 
				
			||||||
    inline void                 push_front(const value_type& v) { if (Size == 0) push_back(v); else insert(Data, v); }
 | 
					    inline void                 push_front(const value_type& v) { if (Size == 0) push_back(v); else insert(Data, v); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    inline iterator             erase(const_iterator it)        { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(value_type)); Size--; return Data + off; }
 | 
					    inline iterator             erase(const_iterator it)        { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(value_type)); Size--; return Data + off; }
 | 
				
			||||||
    inline iterator             insert(const_iterator it, const value_type& v)  { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(value_type)); Data[off] = v; Size++; return Data + off; }
 | 
					    inline iterator             insert(const_iterator it, const value_type& v)  { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(value_type)); Data[off] = v; Size++; return Data + off; }
 | 
				
			||||||
    inline bool                 contains(const value_type& v) const             { const T* data = Data;  const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; }
 | 
					    inline bool                 contains(const value_type& v) const             { const T* data = Data;  const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1307,7 +1307,8 @@ void ImGui::ShowTestWindow(bool* p_open)
 | 
				
			|||||||
                    if (n > 0) ImGui::SameLine();
 | 
					                    if (n > 0) ImGui::SameLine();
 | 
				
			||||||
                    ImGui::PushID(n + line * 1000);
 | 
					                    ImGui::PushID(n + line * 1000);
 | 
				
			||||||
                    char num_buf[16];
 | 
					                    char num_buf[16];
 | 
				
			||||||
                    const char* label = (!(n%15)) ? "FizzBuzz" : (!(n%3)) ? "Fizz" : (!(n%5)) ? "Buzz" : (sprintf(num_buf, "%d", n), num_buf);
 | 
					                    sprintf(num_buf, "%d", n);
 | 
				
			||||||
 | 
					                    const char* label = (!(n%15)) ? "FizzBuzz" : (!(n%3)) ? "Fizz" : (!(n%5)) ? "Buzz" : num_buf;
 | 
				
			||||||
                    float hue = n*0.05f;
 | 
					                    float hue = n*0.05f;
 | 
				
			||||||
                    ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(hue, 0.6f, 0.6f));
 | 
					                    ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(hue, 0.6f, 0.6f));
 | 
				
			||||||
                    ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(hue, 0.7f, 0.7f));
 | 
					                    ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(hue, 0.7f, 0.7f));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "imgui.h"
 | 
					#include "imgui.h"
 | 
				
			||||||
#define IMGUI_DEFINE_MATH_OPERATORS
 | 
					#define IMGUI_DEFINE_MATH_OPERATORS
 | 
				
			||||||
#define IMGUI_DEFINE_PLACEMENT_NEW
 | 
					 | 
				
			||||||
#include "imgui_internal.h"
 | 
					#include "imgui_internal.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>      // vsnprintf, sscanf, printf
 | 
					#include <stdio.h>      // vsnprintf, sscanf, printf
 | 
				
			||||||
@@ -43,6 +42,7 @@
 | 
				
			|||||||
#pragma clang diagnostic ignored "-Wfloat-equal"            // warning : comparing floating point with == or != is unsafe   // storing and comparing against same constants ok.
 | 
					#pragma clang diagnostic ignored "-Wfloat-equal"            // warning : comparing floating point with == or != is unsafe   // storing and comparing against same constants ok.
 | 
				
			||||||
#pragma clang diagnostic ignored "-Wglobal-constructors"    // warning : declaration requires a global destructor           // similar to above, not sure what the exact difference it.
 | 
					#pragma clang diagnostic ignored "-Wglobal-constructors"    // warning : declaration requires a global destructor           // similar to above, not sure what the exact difference it.
 | 
				
			||||||
#pragma clang diagnostic ignored "-Wsign-conversion"        // warning : implicit conversion changes signedness             //
 | 
					#pragma clang diagnostic ignored "-Wsign-conversion"        // warning : implicit conversion changes signedness             //
 | 
				
			||||||
 | 
					#pragma clang diagnostic ignored "-Wcomma"                  // warning : possible misuse of comma operator here             //
 | 
				
			||||||
#if __has_warning("-Wreserved-id-macro")
 | 
					#if __has_warning("-Wreserved-id-macro")
 | 
				
			||||||
#pragma clang diagnostic ignored "-Wreserved-id-macro"      // warning : macro name is a reserved identifier                //
 | 
					#pragma clang diagnostic ignored "-Wreserved-id-macro"      // warning : macro name is a reserved identifier                //
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -78,6 +78,7 @@ namespace IMGUI_STB_NAMESPACE
 | 
				
			|||||||
#pragma clang diagnostic push
 | 
					#pragma clang diagnostic push
 | 
				
			||||||
#pragma clang diagnostic ignored "-Wunused-function"
 | 
					#pragma clang diagnostic ignored "-Wunused-function"
 | 
				
			||||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
 | 
					#pragma clang diagnostic ignored "-Wmissing-prototypes"
 | 
				
			||||||
 | 
					#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __GNUC__
 | 
					#ifdef __GNUC__
 | 
				
			||||||
@@ -1260,8 +1261,8 @@ void ImGui::ShadeVertsLinearUV(ImDrawVert* vert_start, ImDrawVert* vert_end, con
 | 
				
			|||||||
    const ImVec2 size = b - a;
 | 
					    const ImVec2 size = b - a;
 | 
				
			||||||
    const ImVec2 uv_size = uv_b - uv_a;
 | 
					    const ImVec2 uv_size = uv_b - uv_a;
 | 
				
			||||||
    const ImVec2 scale = ImVec2(
 | 
					    const ImVec2 scale = ImVec2(
 | 
				
			||||||
        size.x ? (uv_size.x / size.x) : 0.0f,
 | 
					        size.x != 0.0f ? (uv_size.x / size.x) : 0.0f,
 | 
				
			||||||
        size.y ? (uv_size.y / size.y) : 0.0f);
 | 
					        size.y != 0.0f ? (uv_size.y / size.y) : 0.0f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (clamp)
 | 
					    if (clamp)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -1408,10 +1409,7 @@ void    ImFontAtlas::ClearTexData()
 | 
				
			|||||||
void    ImFontAtlas::ClearFonts()
 | 
					void    ImFontAtlas::ClearFonts()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    for (int i = 0; i < Fonts.Size; i++)
 | 
					    for (int i = 0; i < Fonts.Size; i++)
 | 
				
			||||||
    {
 | 
					        IM_DELETE(Fonts[i]);
 | 
				
			||||||
        Fonts[i]->~ImFont();
 | 
					 | 
				
			||||||
        ImGui::MemFree(Fonts[i]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    Fonts.clear();
 | 
					    Fonts.clear();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1466,15 +1464,9 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Create new font
 | 
					    // Create new font
 | 
				
			||||||
    if (!font_cfg->MergeMode)
 | 
					    if (!font_cfg->MergeMode)
 | 
				
			||||||
    {
 | 
					        Fonts.push_back(IM_NEW(ImFont));
 | 
				
			||||||
        ImFont* font = (ImFont*)ImGui::MemAlloc(sizeof(ImFont));
 | 
					 | 
				
			||||||
        IM_PLACEMENT_NEW(font) ImFont();
 | 
					 | 
				
			||||||
        Fonts.push_back(font);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        IM_ASSERT(!Fonts.empty()); // When using MergeMode make sure that a font has already been added before. You can use ImGui::GetIO().Fonts->AddFontDefault() to add the default imgui font.
 | 
					        IM_ASSERT(!Fonts.empty()); // When using MergeMode make sure that a font has already been added before. You can use ImGui::GetIO().Fonts->AddFontDefault() to add the default imgui font.
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ConfigData.push_back(*font_cfg);
 | 
					    ConfigData.push_back(*font_cfg);
 | 
				
			||||||
    ImFontConfig& new_font_cfg = ConfigData.back();
 | 
					    ImFontConfig& new_font_cfg = ConfigData.back();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -162,10 +162,14 @@ static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
 | 
					// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
 | 
				
			||||||
// Defining a custom placement new() with a dummy parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
 | 
					// Defining a custom placement new() with a dummy parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
 | 
				
			||||||
struct ImPlacementNewDummy {};
 | 
					struct ImNewAllocDummy {};
 | 
				
			||||||
inline void* operator new(size_t, ImPlacementNewDummy, void* ptr) { return ptr; }
 | 
					struct ImNewPlacementDummy {};
 | 
				
			||||||
inline void operator delete(void*, ImPlacementNewDummy, void*) {}
 | 
					inline void* operator   new(size_t, ImNewPlacementDummy, void* ptr) { return ptr; }
 | 
				
			||||||
#define IM_PLACEMENT_NEW(_PTR)  new(ImPlacementNewDummy(), _PTR)
 | 
					inline void  operator   delete(void*, ImNewPlacementDummy, void*)   {} // This is only required so we can use the symetrical new()
 | 
				
			||||||
 | 
					inline void  operator   delete(void* p, ImNewAllocDummy)            { ImGui::MemFree(p); }
 | 
				
			||||||
 | 
					#define IM_PLACEMENT_NEW(_PTR)  new(ImNewPlacementDummy(), _PTR)
 | 
				
			||||||
 | 
					#define IM_NEW(_TYPE)           new(ImNewPlacementDummy(), ImGui::MemAlloc(sizeof(_TYPE))) _TYPE
 | 
				
			||||||
 | 
					#define IM_DELETE(_PTR)         delete(ImNewAllocDummy(), _PTR), _PTR = NULL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//-----------------------------------------------------------------------------
 | 
					//-----------------------------------------------------------------------------
 | 
				
			||||||
// Types
 | 
					// Types
 | 
				
			||||||
@@ -233,7 +237,7 @@ enum ImGuiAxis
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    ImGuiAxis_None = -1,
 | 
					    ImGuiAxis_None = -1,
 | 
				
			||||||
    ImGuiAxis_X = 0,
 | 
					    ImGuiAxis_X = 0,
 | 
				
			||||||
    ImGuiAxis_Y = 1,
 | 
					    ImGuiAxis_Y = 1
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum ImGuiPlotType
 | 
					enum ImGuiPlotType
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user