mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-28 17:40:56 +01:00
Merge remote-tracking branch 'origin' into 2015-03-antialiased-primitives
Conflicts: imgui.cpp
This commit is contained in:
commit
0ff2a6ff64
41
imgui.cpp
41
imgui.cpp
@ -1329,10 +1329,8 @@ struct ImGuiState
|
||||
// Render
|
||||
ImVector<ImDrawList*> RenderDrawLists[3];
|
||||
float ModalWindowDarkeningRatio;
|
||||
|
||||
// Mouse cursor
|
||||
ImDrawList OverlayDrawList; // Optional software render of mouse cursors, if io.MouseDrawCursor is set + a few debug overlays
|
||||
ImGuiMouseCursor MouseCursor;
|
||||
ImDrawList MouseCursorDrawList; // Optional software render of mouse cursors, if io.MouseDrawCursor is set
|
||||
ImGuiMouseCursorData MouseCursorData[ImGuiMouseCursor_Count_];
|
||||
|
||||
// Widget state
|
||||
@ -1412,6 +1410,7 @@ struct ImGuiState
|
||||
PrivateClipboard = NULL;
|
||||
|
||||
ModalWindowDarkeningRatio = 0.0f;
|
||||
OverlayDrawList.owner_name = "##Overlay"; // Give it a name for debugging
|
||||
MouseCursor = ImGuiMouseCursor_Arrow;
|
||||
|
||||
LogEnabled = false;
|
||||
@ -1832,6 +1831,7 @@ ImGuiWindow::ImGuiWindow(const char* name)
|
||||
|
||||
DrawList = (ImDrawList*)ImGui::MemAlloc(sizeof(ImDrawList));
|
||||
new(DrawList) ImDrawList();
|
||||
DrawList->owner_name = Name;
|
||||
RootWindow = NULL;
|
||||
RootNonPopupWindow = NULL;
|
||||
|
||||
@ -2123,6 +2123,7 @@ void ImGui::NewFrame()
|
||||
g.Time += g.IO.DeltaTime;
|
||||
g.FrameCount += 1;
|
||||
g.Tooltip[0] = '\0';
|
||||
g.OverlayDrawList.Clear();
|
||||
|
||||
// Update inputs state
|
||||
if (g.IO.MousePos.x < 0 && g.IO.MousePos.y < 0)
|
||||
@ -2263,9 +2264,7 @@ void ImGui::NewFrame()
|
||||
// Pressing TAB activate widget focus
|
||||
// NB: Don't discard FocusedWindow if it isn't active, so that a window that go on/off programatically won't lose its keyboard focus.
|
||||
if (g.ActiveId == 0 && g.FocusedWindow != NULL && g.FocusedWindow->Active && IsKeyPressedMap(ImGuiKey_Tab, false))
|
||||
{
|
||||
g.FocusedWindow->FocusIdxTabRequestNext = 0;
|
||||
}
|
||||
|
||||
// Mark all windows as not visible
|
||||
for (size_t i = 0; i != g.Windows.size(); i++)
|
||||
@ -2317,7 +2316,7 @@ void ImGui::Shutdown()
|
||||
g.CurrentPopupStack.clear();
|
||||
for (size_t i = 0; i < IM_ARRAYSIZE(g.RenderDrawLists); i++)
|
||||
g.RenderDrawLists[i].clear();
|
||||
g.MouseCursorDrawList.ClearFreeMemory();
|
||||
g.OverlayDrawList.ClearFreeMemory();
|
||||
g.ColorEditModeStorage.Clear();
|
||||
if (g.PrivateClipboard)
|
||||
{
|
||||
@ -2511,15 +2510,15 @@ void ImGui::Render()
|
||||
const ImVec2 pos = g.IO.MousePos - cursor_data.Offset;
|
||||
const ImVec2 size = cursor_data.Size;
|
||||
const ImTextureID tex_id = g.IO.Fonts->TexID;
|
||||
g.MouseCursorDrawList.Clear();
|
||||
g.MouseCursorDrawList.PushTextureID(tex_id);
|
||||
g.MouseCursorDrawList.AddImage(tex_id, pos+ImVec2(1,0), pos+ImVec2(1,0) + size, cursor_data.TexUvMin[1], cursor_data.TexUvMax[1], 0x30000000); // Shadow
|
||||
g.MouseCursorDrawList.AddImage(tex_id, pos+ImVec2(2,0), pos+ImVec2(2,0) + size, cursor_data.TexUvMin[1], cursor_data.TexUvMax[1], 0x30000000); // Shadow
|
||||
g.MouseCursorDrawList.AddImage(tex_id, pos, pos + size, cursor_data.TexUvMin[1], cursor_data.TexUvMax[1], 0xFF000000); // Black border
|
||||
g.MouseCursorDrawList.AddImage(tex_id, pos, pos + size, cursor_data.TexUvMin[0], cursor_data.TexUvMax[0], 0xFFFFFFFF); // White fill
|
||||
g.MouseCursorDrawList.PopTextureID();
|
||||
AddDrawListToRenderList(g.RenderDrawLists[0], &g.MouseCursorDrawList);
|
||||
g.OverlayDrawList.PushTextureID(tex_id);
|
||||
g.OverlayDrawList.AddImage(tex_id, pos+ImVec2(1,0), pos+ImVec2(1,0) + size, cursor_data.TexUvMin[1], cursor_data.TexUvMax[1], 0x30000000); // Shadow
|
||||
g.OverlayDrawList.AddImage(tex_id, pos+ImVec2(2,0), pos+ImVec2(2,0) + size, cursor_data.TexUvMin[1], cursor_data.TexUvMax[1], 0x30000000); // Shadow
|
||||
g.OverlayDrawList.AddImage(tex_id, pos, pos + size, cursor_data.TexUvMin[1], cursor_data.TexUvMax[1], 0xFF000000); // Black border
|
||||
g.OverlayDrawList.AddImage(tex_id, pos, pos + size, cursor_data.TexUvMin[0], cursor_data.TexUvMax[0], 0xFFFFFFFF); // White fill
|
||||
g.OverlayDrawList.PopTextureID();
|
||||
}
|
||||
if (!g.OverlayDrawList.vtx_buffer.empty())
|
||||
AddDrawListToRenderList(g.RenderDrawLists[0], &g.OverlayDrawList);
|
||||
|
||||
// Render
|
||||
if (!g.RenderDrawLists[0].empty())
|
||||
@ -12224,13 +12223,15 @@ void ImGui::ShowMetricsWindow(bool* opened)
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||
ImGui::Text("%d vertices, %d triangles", ImGui::GetIO().MetricsRenderVertices, ImGui::GetIO().MetricsRenderIndices / 3);
|
||||
ImGui::Text("%d allocations", ImGui::GetIO().MetricsAllocs);
|
||||
static bool show_clip_rects = false;
|
||||
ImGui::Checkbox("Show clipping rectangles when hovering ImDrawList", &show_clip_rects);
|
||||
ImGui::Separator();
|
||||
|
||||
struct Funcs
|
||||
{
|
||||
static void NodeDrawList(ImDrawList* draw_list, const char* label)
|
||||
{
|
||||
bool node_opened = ImGui::TreeNode(draw_list, "%s: %d vtx, %d indices, %d cmds", label, draw_list->vtx_buffer.size(), draw_list->idx_buffer.size(), draw_list->commands.size());
|
||||
bool node_opened = ImGui::TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->owner_name ? draw_list->owner_name : "", draw_list->vtx_buffer.size(), draw_list->idx_buffer.size(), draw_list->commands.size());
|
||||
if (draw_list == ImGui::GetWindowDrawList())
|
||||
{
|
||||
ImGui::SameLine();
|
||||
@ -12242,7 +12243,15 @@ void ImGui::ShowMetricsWindow(bool* opened)
|
||||
if (pcmd->user_callback)
|
||||
ImGui::BulletText("Callback %p, user_data %p", pcmd->user_callback, pcmd->user_callback_data);
|
||||
else
|
||||
ImGui::BulletText("Draw %d indexed vtx, tex = %p", pcmd->elem_count, pcmd->texture_id);
|
||||
{
|
||||
ImGui::BulletText("Draw %d indexed vtx, tex = %p, clip_rect = (%d,%d)..(%d,%d)", pcmd->elem_count, pcmd->texture_id, (int)pcmd->clip_rect.x, (int)pcmd->clip_rect.y, (int)pcmd->clip_rect.z, (int)pcmd->clip_rect.w);
|
||||
if (show_clip_rects && ImGui::IsItemHovered())
|
||||
{
|
||||
GImGui->OverlayDrawList.PushClipRectFullScreen();
|
||||
GImGui->OverlayDrawList.AddRect(ImVec2(pcmd->clip_rect.x, pcmd->clip_rect.y), ImVec2(pcmd->clip_rect.z, pcmd->clip_rect.w), ImColor(255,255,0));
|
||||
GImGui->OverlayDrawList.PopClipRect();
|
||||
}
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
|
3
imgui.h
3
imgui.h
@ -1038,6 +1038,7 @@ struct ImDrawList
|
||||
ImVector<ImDrawIdx> idx_buffer; // Index buffer. Each command consume ImDrawCmd::idx_count of those
|
||||
|
||||
// [Internal to ImGui]
|
||||
const char* owner_name; // Pointer to owner window's name, if any
|
||||
ImVector<ImVec4> clip_rect_stack; // [Internal]
|
||||
ImVector<ImTextureID> texture_id_stack; // [Internal]
|
||||
ImVector<ImVec2> path; // [Internal] current path building
|
||||
@ -1045,7 +1046,7 @@ struct ImDrawList
|
||||
unsigned int vtx_current_idx; // [Internal] == vtx_buffer.size()
|
||||
ImDrawIdx* idx_write; // [Internal] point within idx_buffer after each add command (to avoid using the ImVector<> operators too much)
|
||||
|
||||
ImDrawList() { Clear(); }
|
||||
ImDrawList() { owner_name = NULL; Clear(); }
|
||||
IMGUI_API void Clear();
|
||||
IMGUI_API void ClearFreeMemory();
|
||||
IMGUI_API void PushClipRect(const ImVec4& clip_rect); // Scissoring. The values are x1, y1, x2, y2.
|
||||
|
Loading…
Reference in New Issue
Block a user