mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-23 02:04:22 +00:00
Merge branch 'master' into docking (require next commit)
# Conflicts: # backends/imgui_impl_glfw.cpp # backends/imgui_impl_glfw.h # backends/imgui_impl_osx.mm # backends/imgui_impl_sdl3.cpp # backends/imgui_impl_vulkan.cpp # backends/imgui_impl_vulkan.h # backends/imgui_impl_win32.cpp # imgui.cpp
This commit is contained in:
commit
66e08b6575
14 changed files with 152 additions and 91 deletions
|
|
@ -836,11 +836,10 @@ bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg, ImGuiBut
|
|||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
// Cannot use zero-size for InvisibleButton(). Unlike Button() there is not way to fallback using the label size.
|
||||
IM_ASSERT(size_arg.x != 0.0f && size_arg.y != 0.0f);
|
||||
// Ensure zero-size fits to contents
|
||||
ImVec2 size = CalcItemSize(ImVec2(size_arg.x != 0.0f ? size_arg.x : -FLT_MIN, size_arg.y != 0.0f ? size_arg.y : -FLT_MIN), 0.0f, 0.0f);
|
||||
|
||||
const ImGuiID id = window->GetID(str_id);
|
||||
ImVec2 size = CalcItemSize(size_arg, 0.0f, 0.0f);
|
||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
||||
ItemSize(size);
|
||||
if (!ItemAdd(bb, id, NULL, (flags & ImGuiButtonFlags_EnableNav) ? ImGuiItemFlags_None : ImGuiItemFlags_NoNav))
|
||||
|
|
@ -1137,11 +1136,15 @@ void ImGui::ImageWithBg(ImTextureRef tex_ref, const ImVec2& image_size, const Im
|
|||
return;
|
||||
|
||||
// Render
|
||||
if (g.Style.ImageBorderSize > 0.0f)
|
||||
window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_Border), 0.0f, ImDrawFlags_None, g.Style.ImageBorderSize);
|
||||
float rounding = g.Style.ImageRounding;
|
||||
if (bg_col.w > 0.0f)
|
||||
window->DrawList->AddRectFilled(bb.Min + padding, bb.Max - padding, GetColorU32(bg_col));
|
||||
window->DrawList->AddImage(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col));
|
||||
window->DrawList->AddRectFilled(bb.Min + padding, bb.Max - padding, GetColorU32(bg_col), rounding);
|
||||
if (rounding > 0.0f)
|
||||
window->DrawList->AddImageRounded(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col), rounding);
|
||||
else
|
||||
window->DrawList->AddImage(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col));
|
||||
if (g.Style.ImageBorderSize > 0.0f)
|
||||
window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_Border), rounding, ImDrawFlags_None, g.Style.ImageBorderSize);
|
||||
}
|
||||
|
||||
void ImGui::Image(ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1)
|
||||
|
|
@ -1181,10 +1184,14 @@ bool ImGui::ImageButtonEx(ImGuiID id, ImTextureRef tex_ref, const ImVec2& image_
|
|||
// Render
|
||||
const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
||||
RenderNavCursor(bb, id);
|
||||
RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, g.Style.FrameRounding));
|
||||
RenderFrame(bb.Min, bb.Max, col, true, g.Style.FrameRounding);
|
||||
if (bg_col.w > 0.0f)
|
||||
window->DrawList->AddRectFilled(bb.Min + padding, bb.Max - padding, GetColorU32(bg_col));
|
||||
window->DrawList->AddImage(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col));
|
||||
float image_rounding = ImMax(g.Style.FrameRounding - ImMax(padding.x, padding.y), g.Style.ImageRounding);
|
||||
if (image_rounding > 0.0f)
|
||||
window->DrawList->AddImageRounded(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col), image_rounding);
|
||||
else
|
||||
window->DrawList->AddImage(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col));
|
||||
|
||||
return pressed;
|
||||
}
|
||||
|
|
@ -2060,8 +2067,15 @@ bool ImGui::BeginComboPopup(ImGuiID popup_id, const ImRect& bb, ImGuiComboFlags
|
|||
void ImGui::EndCombo()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
EndPopup();
|
||||
g.BeginComboDepth--;
|
||||
char name[16];
|
||||
ImFormatString(name, IM_COUNTOF(name), "##Combo_%02d", g.BeginComboDepth); // FIXME: Move those to helpers?
|
||||
if (strcmp(g.CurrentWindow->Name, name) != 0)
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(0, "Calling EndCombo() in wrong window!");
|
||||
return;
|
||||
}
|
||||
EndPopup();
|
||||
}
|
||||
|
||||
// Call directly after the BeginCombo/EndCombo block. The preview is designed to only host non-interactive elements
|
||||
|
|
@ -4854,6 +4868,8 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||
SetActiveID(id, window);
|
||||
SetFocusID(id, window);
|
||||
FocusWindow(window);
|
||||
if (input_requested_by_nav)
|
||||
SetNavCursorVisibleAfterMove();
|
||||
}
|
||||
if (g.ActiveId == id)
|
||||
{
|
||||
|
|
@ -9409,7 +9425,12 @@ void ImGui::EndMenu()
|
|||
// Nav: When a left move request our menu failed, close ourselves.
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
IM_ASSERT(window->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginMenu()/EndMenu() calls
|
||||
|
||||
if ((window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) != (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu))
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(0, "Calling EndMenu() in wrong window!");
|
||||
return;
|
||||
}
|
||||
ImGuiWindow* parent_window = window->ParentWindow; // Should always be != NULL is we passed assert.
|
||||
if (window->BeginCount == window->BeginCountPreviousFrame)
|
||||
if (g.NavMoveDir == ImGuiDir_Left && NavMoveRequestButNoResultYet())
|
||||
|
|
@ -10397,7 +10418,7 @@ bool ImGui::BeginTabItem(const char* label, bool* p_open, ImGuiTabItemFlags f
|
|||
ImGuiTabBar* tab_bar = g.CurrentTabBar;
|
||||
if (tab_bar == NULL)
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(tab_bar, "Needs to be called between BeginTabBar() and EndTabBar()!");
|
||||
IM_ASSERT_USER_ERROR(tab_bar != NULL, "Needs to be called between BeginTabBar() and EndTabBar()!");
|
||||
return false;
|
||||
}
|
||||
IM_ASSERT((flags & ImGuiTabItemFlags_Button) == 0); // BeginTabItem() Can't be used with button flags, use TabItemButton() instead!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue