mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Updated ImGui.
This commit is contained in:
126
3rdparty/ocornut-imgui/imgui.cpp
vendored
126
3rdparty/ocornut-imgui/imgui.cpp
vendored
@@ -4018,6 +4018,8 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
|
||||
{
|
||||
ImRect menu_bar_rect = window->MenuBarRect();
|
||||
window->DrawList->AddRectFilled(menu_bar_rect.GetTL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_MenuBarBg), (flags & ImGuiWindowFlags_NoTitleBar) ? window_rounding : 0.0f, 1|2);
|
||||
if (flags & ImGuiWindowFlags_ShowBorders)
|
||||
window->DrawList->AddLine(menu_bar_rect.GetBL()-ImVec2(0,0), menu_bar_rect.GetBR()-ImVec2(0,0), GetColorU32(ImGuiCol_Border));
|
||||
}
|
||||
|
||||
// Scrollbars
|
||||
@@ -4205,14 +4207,14 @@ static void Scrollbar(ImGuiWindow* window, bool horizontal)
|
||||
? ImRect(window->Pos.x + border_size, window_rect.Max.y - style.ScrollbarSize, window_rect.Max.x - other_scrollbar_size_w - border_size, window_rect.Max.y - border_size)
|
||||
: ImRect(window_rect.Max.x - style.ScrollbarSize, window->Pos.y + border_size, window_rect.Max.x - border_size, window_rect.Max.y - other_scrollbar_size_w - border_size);
|
||||
if (!horizontal)
|
||||
bb.Min.y += window->TitleBarHeight() + ((window->Flags & ImGuiWindowFlags_MenuBar) ? window->MenuBarHeight() - border_size : 0.0f);
|
||||
bb.Min.y += window->TitleBarHeight() + ((window->Flags & ImGuiWindowFlags_MenuBar) ? window->MenuBarHeight() : 0.0f);
|
||||
|
||||
float window_rounding = (window->Flags & ImGuiWindowFlags_ChildWindow) ? style.ChildWindowRounding : style.WindowRounding;
|
||||
int window_rounding_corners;
|
||||
if (horizontal)
|
||||
window_rounding_corners = 8 | (other_scrollbar ? 0 : 4);
|
||||
else
|
||||
window_rounding_corners = ((window->Flags & ImGuiWindowFlags_NoTitleBar) ? 2 : 0) | (other_scrollbar ? 0 : 4);
|
||||
window_rounding_corners = (((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) ? 2 : 0) | (other_scrollbar ? 0 : 4);
|
||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_ScrollbarBg), window_rounding, window_rounding_corners);
|
||||
bb.Reduce(ImVec2(ImClamp((float)(int)((bb.Max.x - bb.Min.x - 2.0f) * 0.5f), 0.0f, 3.0f), ImClamp((float)(int)((bb.Max.y - bb.Min.y - 2.0f) * 0.5f), 0.0f, 3.0f)));
|
||||
|
||||
@@ -5729,65 +5731,6 @@ bool ImGui::CollapsingHeader(const char* label, const char* str_id, bool display
|
||||
return opened;
|
||||
}
|
||||
|
||||
void ImGui::Bullet()
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
|
||||
ImGuiState& g = *GImGui;
|
||||
const ImGuiStyle& style = g.Style;
|
||||
const float line_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + g.Style.FramePadding.y*2), g.FontSize);
|
||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize, line_height));
|
||||
ItemSize(bb);
|
||||
if (!ItemAdd(bb, NULL))
|
||||
{
|
||||
ImGui::SameLine(0, style.FramePadding.x*2);
|
||||
return;
|
||||
}
|
||||
|
||||
// Render
|
||||
const float bullet_size = g.FontSize*0.15f;
|
||||
window->DrawList->AddCircleFilled(bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, line_height*0.5f), bullet_size, GetColorU32(ImGuiCol_Text));
|
||||
|
||||
// Stay on same line
|
||||
ImGui::SameLine(0, style.FramePadding.x*2);
|
||||
}
|
||||
|
||||
// Text with a little bullet aligned to the typical tree node.
|
||||
void ImGui::BulletTextV(const char* fmt, va_list args)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
|
||||
ImGuiState& g = *GImGui;
|
||||
const ImGuiStyle& style = g.Style;
|
||||
|
||||
const char* text_begin = g.TempBuffer;
|
||||
const char* text_end = text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
|
||||
const ImVec2 label_size = CalcTextSize(text_begin, text_end, true);
|
||||
const float text_base_offset_y = ImMax(0.0f, window->DC.CurrentLineTextBaseOffset); // Latch before ItemSize changes it
|
||||
const float line_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + g.Style.FramePadding.y*2), g.FontSize);
|
||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize + (label_size.x > 0.0f ? (label_size.x + style.FramePadding.x*2) : 0.0f), ImMax(line_height, label_size.y))); // Empty text doesn't add padding
|
||||
ItemSize(bb);
|
||||
if (!ItemAdd(bb, NULL))
|
||||
return;
|
||||
|
||||
// Render
|
||||
const float bullet_size = g.FontSize*0.15f;
|
||||
window->DrawList->AddCircleFilled(bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, line_height*0.5f), bullet_size, GetColorU32(ImGuiCol_Text));
|
||||
RenderText(bb.Min+ImVec2(g.FontSize + style.FramePadding.x*2, text_base_offset_y), text_begin, text_end);
|
||||
}
|
||||
|
||||
void ImGui::BulletText(const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
BulletTextV(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
// If returning 'true' the node is open and the user is responsible for calling TreePop
|
||||
bool ImGui::TreeNodeV(const char* str_id, const char* fmt, va_list args)
|
||||
{
|
||||
@@ -5909,6 +5852,65 @@ ImGuiID ImGui::GetID(const void* ptr_id)
|
||||
return GImGui->CurrentWindow->GetID(ptr_id);
|
||||
}
|
||||
|
||||
void ImGui::Bullet()
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
|
||||
ImGuiState& g = *GImGui;
|
||||
const ImGuiStyle& style = g.Style;
|
||||
const float line_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + g.Style.FramePadding.y*2), g.FontSize);
|
||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize, line_height));
|
||||
ItemSize(bb);
|
||||
if (!ItemAdd(bb, NULL))
|
||||
{
|
||||
ImGui::SameLine(0, style.FramePadding.x*2);
|
||||
return;
|
||||
}
|
||||
|
||||
// Render
|
||||
const float bullet_size = g.FontSize*0.15f;
|
||||
window->DrawList->AddCircleFilled(bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, line_height*0.5f), bullet_size, GetColorU32(ImGuiCol_Text));
|
||||
|
||||
// Stay on same line
|
||||
ImGui::SameLine(0, style.FramePadding.x*2);
|
||||
}
|
||||
|
||||
// Text with a little bullet aligned to the typical tree node.
|
||||
void ImGui::BulletTextV(const char* fmt, va_list args)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
|
||||
ImGuiState& g = *GImGui;
|
||||
const ImGuiStyle& style = g.Style;
|
||||
|
||||
const char* text_begin = g.TempBuffer;
|
||||
const char* text_end = text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
|
||||
const ImVec2 label_size = CalcTextSize(text_begin, text_end, true);
|
||||
const float text_base_offset_y = ImMax(0.0f, window->DC.CurrentLineTextBaseOffset); // Latch before ItemSize changes it
|
||||
const float line_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + g.Style.FramePadding.y*2), g.FontSize);
|
||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize + (label_size.x > 0.0f ? (label_size.x + style.FramePadding.x*2) : 0.0f), ImMax(line_height, label_size.y))); // Empty text doesn't add padding
|
||||
ItemSize(bb);
|
||||
if (!ItemAdd(bb, NULL))
|
||||
return;
|
||||
|
||||
// Render
|
||||
const float bullet_size = g.FontSize*0.15f;
|
||||
window->DrawList->AddCircleFilled(bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, line_height*0.5f), bullet_size, GetColorU32(ImGuiCol_Text));
|
||||
RenderText(bb.Min+ImVec2(g.FontSize + style.FramePadding.x*2, text_base_offset_y), text_begin, text_end);
|
||||
}
|
||||
|
||||
void ImGui::BulletText(const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
BulletTextV(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, const char* display_format, char* buf, int buf_size)
|
||||
{
|
||||
if (data_type == ImGuiDataType_Int)
|
||||
@@ -8814,6 +8816,7 @@ bool ImGui::IsRectVisible(const ImVec2& size)
|
||||
return window->ClipRect.Overlaps(ImRect(window->DC.CursorPos, window->DC.CursorPos + size));
|
||||
}
|
||||
|
||||
// Lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
|
||||
void ImGui::BeginGroup()
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
@@ -9057,7 +9060,6 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
|
||||
{
|
||||
if (g.ActiveIdIsJustActivated)
|
||||
g.ActiveClickDeltaToCenter.x = x - g.IO.MousePos.x;
|
||||
|
||||
x = GetDraggedColumnOffset(i);
|
||||
SetColumnOffset(i, x);
|
||||
}
|
||||
|
||||
4
3rdparty/ocornut-imgui/imgui.h
vendored
4
3rdparty/ocornut-imgui/imgui.h
vendored
@@ -187,14 +187,14 @@ namespace ImGui
|
||||
IMGUI_API void PopButtonRepeat();
|
||||
|
||||
// Cursor / Layout
|
||||
IMGUI_API void BeginGroup(); // lock horizontal starting position. once closing a group it is seen as a single item (so you can use IsItemHovered() on a group, SameLine() between groups, etc.
|
||||
IMGUI_API void EndGroup();
|
||||
IMGUI_API void Separator(); // horizontal line
|
||||
IMGUI_API void SameLine(float pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally
|
||||
IMGUI_API void Spacing(); // add spacing
|
||||
IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size
|
||||
IMGUI_API void Indent(); // move content position toward the right by style.IndentSpacing pixels
|
||||
IMGUI_API void Unindent(); // move content position back to the left (cancel Indent)
|
||||
IMGUI_API void BeginGroup(); // lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
|
||||
IMGUI_API void EndGroup();
|
||||
IMGUI_API ImVec2 GetCursorPos(); // cursor position is relative to window position
|
||||
IMGUI_API float GetCursorPosX(); // "
|
||||
IMGUI_API float GetCursorPosY(); // "
|
||||
|
||||
4
3rdparty/ocornut-imgui/imgui_demo.cpp
vendored
4
3rdparty/ocornut-imgui/imgui_demo.cpp
vendored
@@ -268,7 +268,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
|
||||
if (ImGui::CollapsingHeader("Widgets"))
|
||||
{
|
||||
if (ImGui::TreeNode("Tree"))
|
||||
if (ImGui::TreeNode("Trees"))
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
@@ -412,7 +412,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
ImGui::PushID(i);
|
||||
if (ImGui::Selectable("Me", &selected[i], 0, ImVec2(50,50)))
|
||||
if (ImGui::Selectable("Sailor", &selected[i], 0, ImVec2(50,50)))
|
||||
{
|
||||
int x = i % 4, y = i / 4;
|
||||
if (x > 0) selected[i - 1] ^= 1;
|
||||
|
||||
Reference in New Issue
Block a user