Updated ImGui.

This commit is contained in:
Branimir Karadžić 2015-12-09 20:44:30 -08:00
parent a02086c119
commit cf5ef86ecc
2 changed files with 28 additions and 23 deletions

View File

@ -148,6 +148,7 @@
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code. Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
Also read releases logs https://github.com/ocornut/imgui/releases for more details. Also read releases logs https://github.com/ocornut/imgui/releases for more details.
- 2015/12/04 (1.47) - renamed Color() helpers to ValueColor() - dangerously named, rarely used and probably to be made obsolete.
- 2015/08/29 (1.45) - with the addition of horizontal scrollbar we made various fixes to inconsistencies with dealing with cursor position. - 2015/08/29 (1.45) - with the addition of horizontal scrollbar we made various fixes to inconsistencies with dealing with cursor position.
GetCursorPos()/SetCursorPos() functions now include the scrolled amount. It shouldn't affect the majority of users, but take note that SetCursorPosX(100.0f) puts you at +100 from the starting x position which may include scrolling, not at +100 from the window left side. GetCursorPos()/SetCursorPos() functions now include the scrolled amount. It shouldn't affect the majority of users, but take note that SetCursorPosX(100.0f) puts you at +100 from the starting x position which may include scrolling, not at +100 from the window left side.
GetContentRegionMax()/GetWindowContentRegionMin()/GetWindowContentRegionMax() functions allow include the scrolled amount. Typically those were used in cases where no scrolling would happen so it may not be a problem, but watch out! GetContentRegionMax()/GetWindowContentRegionMin()/GetWindowContentRegionMax() functions allow include the scrolled amount. Typically those were used in cases where no scrolling would happen so it may not be a problem, but watch out!
@ -463,6 +464,7 @@
- tabs - tabs
- separator: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y) - separator: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y)
- gauge: various forms of gauge/loading bars widgets - gauge: various forms of gauge/loading bars widgets
- color: the color helpers/typing is a mess and needs sorting out.
- color: add a better color picker - color: add a better color picker
- plot: PlotLines() should use the polygon-stroke facilities (currently issues with averaging normals) - plot: PlotLines() should use the polygon-stroke facilities (currently issues with averaging normals)
- plot: make it easier for user to draw extra stuff into the graph (e.g: draw basis, highlight certain points, 2d plots, multiple plots) - plot: make it easier for user to draw extra stuff into the graph (e.g: draw basis, highlight certain points, 2d plots, multiple plots)
@ -3924,16 +3926,18 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
// Window background // Window background
if (bg_alpha > 0.0f) if (bg_alpha > 0.0f)
{ {
ImGuiCol col_idx;
if ((flags & ImGuiWindowFlags_ComboBox) != 0) if ((flags & ImGuiWindowFlags_ComboBox) != 0)
window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_ComboBg, bg_alpha), window_rounding); col_idx = ImGuiCol_ComboBg;
else if ((flags & ImGuiWindowFlags_Tooltip) != 0) else if ((flags & ImGuiWindowFlags_Tooltip) != 0)
window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_TooltipBg, bg_alpha), window_rounding); col_idx = ImGuiCol_TooltipBg;
else if ((flags & ImGuiWindowFlags_Popup) != 0) else if ((flags & ImGuiWindowFlags_Popup) != 0)
window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_WindowBg, bg_alpha), window_rounding); col_idx = ImGuiCol_WindowBg;
else if ((flags & ImGuiWindowFlags_ChildWindow) != 0) else if ((flags & ImGuiWindowFlags_ChildWindow) != 0)
window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_ChildWindowBg, bg_alpha), window_rounding); col_idx = ImGuiCol_ChildWindowBg;
else else
window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(ImGuiCol_WindowBg, bg_alpha), window_rounding); col_idx = ImGuiCol_WindowBg;
window->DrawList->AddRectFilled(window->Pos, window->Pos+window->Size, window->Color(col_idx, bg_alpha), window_rounding);
} }
// Title bar // Title bar
@ -9016,14 +9020,14 @@ void ImGui::Value(const char* prefix, float v, const char* float_format)
} }
// FIXME: May want to remove those helpers? // FIXME: May want to remove those helpers?
void ImGui::Color(const char* prefix, const ImVec4& v) void ImGui::ValueColor(const char* prefix, const ImVec4& v)
{ {
ImGui::Text("%s: (%.2f,%.2f,%.2f,%.2f)", prefix, v.x, v.y, v.z, v.w); ImGui::Text("%s: (%.2f,%.2f,%.2f,%.2f)", prefix, v.x, v.y, v.z, v.w);
ImGui::SameLine(); ImGui::SameLine();
ImGui::ColorButton(v, true); ImGui::ColorButton(v, true);
} }
void ImGui::Color(const char* prefix, unsigned int v) void ImGui::ValueColor(const char* prefix, unsigned int v)
{ {
ImGui::Text("%s: %08X", prefix, v); ImGui::Text("%s: %08X", prefix, v);
ImGui::SameLine(); ImGui::SameLine();
@ -9180,21 +9184,22 @@ void ImGui::ShowMetricsWindow(bool* opened)
for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.begin(); pcmd < draw_list->CmdBuffer.end(); elem_offset += pcmd->ElemCount, pcmd++) for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.begin(); pcmd < draw_list->CmdBuffer.end(); elem_offset += pcmd->ElemCount, pcmd++)
{ {
if (pcmd->UserCallback) if (pcmd->UserCallback)
ImGui::BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData);
else
{ {
ImGui::BulletText("Draw %d indexed vtx, tex = %p, clip_rect = (%.0f,%.0f)..(%.0f,%.0f)", pcmd->ElemCount, pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); ImGui::BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData);
if (show_clip_rects && ImGui::IsItemHovered()) continue;
{ }
ImRect clip_rect = pcmd->ClipRect; ImGui::BulletText("Draw %d %s vtx, tex = %p, clip_rect = (%.0f,%.0f)..(%.0f,%.0f)", pcmd->ElemCount, draw_list->IdxBuffer.Size > 0 ? "indexed" : "non-indexed", pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
ImRect vtxs_rect; if (show_clip_rects && ImGui::IsItemHovered())
for (int i = elem_offset; i < elem_offset + (int)pcmd->ElemCount; i++) {
vtxs_rect.Add(draw_list->VtxBuffer[draw_list->IdxBuffer[i]].pos); ImRect clip_rect = pcmd->ClipRect;
GImGui->OverlayDrawList.PushClipRectFullScreen(); ImRect vtxs_rect;
clip_rect.Round(); GImGui->OverlayDrawList.AddRect(clip_rect.Min, clip_rect.Max, ImColor(255,255,0)); ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL;
vtxs_rect.Round(); GImGui->OverlayDrawList.AddRect(vtxs_rect.Min, vtxs_rect.Max, ImColor(255,0,255)); for (int i = elem_offset; i < elem_offset + (int)pcmd->ElemCount; i++)
GImGui->OverlayDrawList.PopClipRect(); vtxs_rect.Add(draw_list->VtxBuffer[idx_buffer ? idx_buffer[i] : i].pos);
} GImGui->OverlayDrawList.PushClipRectFullScreen();
clip_rect.Round(); GImGui->OverlayDrawList.AddRect(clip_rect.Min, clip_rect.Max, ImColor(255,255,0));
vtxs_rect.Round(); GImGui->OverlayDrawList.AddRect(vtxs_rect.Min, vtxs_rect.Max, ImColor(255,0,255));
GImGui->OverlayDrawList.PopClipRect();
} }
} }
ImGui::TreePop(); ImGui::TreePop();

View File

@ -325,8 +325,8 @@ namespace ImGui
IMGUI_API void Value(const char* prefix, int v); IMGUI_API void Value(const char* prefix, int v);
IMGUI_API void Value(const char* prefix, unsigned int v); IMGUI_API void Value(const char* prefix, unsigned int v);
IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL); IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL);
IMGUI_API void Color(const char* prefix, const ImVec4& v); IMGUI_API void ValueColor(const char* prefix, const ImVec4& v);
IMGUI_API void Color(const char* prefix, unsigned int v); IMGUI_API void ValueColor(const char* prefix, unsigned int v);
// Tooltip // Tooltip
IMGUI_API void SetTooltip(const char* fmt, ...) IM_PRINTFARGS(1); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins IMGUI_API void SetTooltip(const char* fmt, ...) IM_PRINTFARGS(1); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins