Merge branch 'master' into navigation

This commit is contained in:
omar
2017-12-23 16:27:48 +01:00
10 changed files with 93 additions and 67 deletions

View File

@ -622,7 +622,6 @@
#include "imgui.h"
#define IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_PLACEMENT_NEW
#include "imgui_internal.h"
#include <ctype.h> // toupper, isprint
@ -1908,8 +1907,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
ItemWidthDefault = 0.0f;
FontWindowScale = 1.0f;
DrawList = (ImDrawList*)ImGui::MemAlloc(sizeof(ImDrawList));
IM_PLACEMENT_NEW(DrawList) ImDrawList(&context->DrawListSharedData);
DrawList = IM_NEW(ImDrawList)(&context->DrawListSharedData);
DrawList->_OwnerName = Name;
ParentWindow = NULL;
RootWindow = NULL;
@ -1923,11 +1921,8 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
ImGuiWindow::~ImGuiWindow()
{
DrawList->~ImDrawList();
ImGui::MemFree(DrawList);
DrawList = NULL;
ImGui::MemFree(Name);
Name = NULL;
IM_DELETE(DrawList);
IM_DELETE(Name);
}
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()
{
ImGuiContext& g = *GImGui;
g.LogClipboard = (ImGuiTextBuffer*)ImGui::MemAlloc(sizeof(ImGuiTextBuffer));
IM_PLACEMENT_NEW(g.LogClipboard) ImGuiTextBuffer();
g.LogClipboard = IM_NEW(ImGuiTextBuffer)();
// Add .ini handle for ImGuiWindow type
ImGuiSettingsHandler ini_handler;
@ -3418,10 +3412,7 @@ void ImGui::Shutdown()
SaveIniSettingsToDisk(g.IO.IniFilename);
for (int i = 0; i < g.Windows.Size; i++)
{
g.Windows[i]->~ImGuiWindow();
ImGui::MemFree(g.Windows[i]);
}
IM_DELETE(g.Windows[i]);
g.Windows.clear();
g.WindowsSortBuffer.clear();
g.CurrentWindow = NULL;
@ -3433,7 +3424,7 @@ void ImGui::Shutdown()
g.ActiveIdWindow = NULL;
g.MovingWindow = NULL;
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.StyleModifiers.clear();
g.FontStack.clear();
@ -3458,10 +3449,7 @@ void ImGui::Shutdown()
g.LogFile = NULL;
}
if (g.LogClipboard)
{
g.LogClipboard->~ImGuiTextBuffer();
ImGui::MemFree(g.LogClipboard);
}
IM_DELETE(g.LogClipboard);
g.Initialized = false;
}
@ -3651,15 +3639,17 @@ 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((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)
// If this assert triggers because you are drawing lots of stuff manually, you can:
// 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.
// 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);'
// 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:
// 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.
// 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.
// 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.
// 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.
IM_ASSERT(((ImU64)draw_list->_VtxCurrentIdx >> (sizeof(ImDrawIdx)*8)) == 0); // Too many vertices in same ImDrawList. See comment above.
// 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.
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);
GImGui->IO.MetricsRenderVertices += draw_list->VtxBuffer.Size;
GImGui->IO.MetricsRenderIndices += draw_list->IdxBuffer.Size;
@ -4086,22 +4076,23 @@ void ImGui::RenderTriangle(ImVec2 p_min, ImGuiDir dir, float scale)
switch (dir)
{
case ImGuiDir_Up:
r = -r; // ...fall through, no break!
case ImGuiDir_Down:
if (dir == ImGuiDir_Up) r = -r;
center.y -= r * 0.25f;
a = ImVec2(0,1) * r;
b = ImVec2(-0.866f,-0.5f) * r;
c = ImVec2(+0.866f,-0.5f) * r;
break;
case ImGuiDir_Left:
r = -r; // ...fall through, no break!
case ImGuiDir_Right:
if (dir == ImGuiDir_Left) r = -r;
center.x -= r * 0.25f;
a = ImVec2(1,0) * r;
b = ImVec2(-0.500f,+0.866f) * r;
c = ImVec2(-0.500f,-0.866f) * r;
break;
default:
case ImGuiDir_None:
case ImGuiDir_Count_:
IM_ASSERT(0);
break;
}
@ -5053,8 +5044,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
ImGuiContext& g = *GImGui;
// Create window the first time
ImGuiWindow* window = (ImGuiWindow*)ImGui::MemAlloc(sizeof(ImGuiWindow));
IM_PLACEMENT_NEW(window) ImGuiWindow(&g, name);
ImGuiWindow* window = IM_NEW(ImGuiWindow)(&g, name);
window->Flags = flags;
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_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;
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))
#undef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <Windows.h>
#endif
// Win32 API clipboard implementation