mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-22 01:54:21 +00:00
Merge branch 'master' into docking
# Conflicts: # docs/TODO.txt
This commit is contained in:
commit
8dd5425182
21 changed files with 145 additions and 164 deletions
|
|
@ -167,7 +167,21 @@ void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags)
|
|||
const ImVec2 text_pos(window->DC.CursorPos.x, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
||||
const float wrap_pos_x = window->DC.TextWrapPos;
|
||||
const bool wrap_enabled = (wrap_pos_x >= 0.0f);
|
||||
if (text_end - text > 2000 && !wrap_enabled)
|
||||
if (text_end - text <= 2000 || wrap_enabled)
|
||||
{
|
||||
// Common case
|
||||
const float wrap_width = wrap_enabled ? CalcWrapWidthForPos(window->DC.CursorPos, wrap_pos_x) : 0.0f;
|
||||
const ImVec2 text_size = CalcTextSize(text_begin, text_end, false, wrap_width);
|
||||
|
||||
ImRect bb(text_pos, text_pos + text_size);
|
||||
ItemSize(text_size, 0.0f);
|
||||
if (!ItemAdd(bb, 0))
|
||||
return;
|
||||
|
||||
// Render (we don't hide text after ## in this end-user function)
|
||||
RenderTextWrapped(bb.Min, text_begin, text_end, wrap_width);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Long text!
|
||||
// Perform manual coarse clipping to optimize for long multi-line text
|
||||
|
|
@ -240,19 +254,6 @@ void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags)
|
|||
ItemSize(text_size, 0.0f);
|
||||
ItemAdd(bb, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
const float wrap_width = wrap_enabled ? CalcWrapWidthForPos(window->DC.CursorPos, wrap_pos_x) : 0.0f;
|
||||
const ImVec2 text_size = CalcTextSize(text_begin, text_end, false, wrap_width);
|
||||
|
||||
ImRect bb(text_pos, text_pos + text_size);
|
||||
ItemSize(text_size, 0.0f);
|
||||
if (!ItemAdd(bb, 0))
|
||||
return;
|
||||
|
||||
// Render (we don't hide text after ## in this end-user function)
|
||||
RenderTextWrapped(bb.Min, text_begin, text_end, wrap_width);
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::TextUnformatted(const char* text, const char* text_end)
|
||||
|
|
@ -862,7 +863,7 @@ bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos, ImGuiDockNode* dock_no
|
|||
|
||||
ImGuiID ImGui::GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis)
|
||||
{
|
||||
return window->GetIDNoKeepAlive(axis == ImGuiAxis_X ? "#SCROLLX" : "#SCROLLY");
|
||||
return window->GetID(axis == ImGuiAxis_X ? "#SCROLLX" : "#SCROLLY");
|
||||
}
|
||||
|
||||
// Return scrollbar rectangle, must only be called for corresponding axis if window->ScrollbarX/Y is set.
|
||||
|
|
@ -1291,7 +1292,7 @@ void ImGui::Bullet()
|
|||
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiStyle& style = g.Style;
|
||||
const float line_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + g.Style.FramePadding.y * 2), g.FontSize);
|
||||
const float line_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + 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, 0))
|
||||
|
|
@ -1347,6 +1348,7 @@ void ImGui::NewLine()
|
|||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiLayoutType backup_layout_type = window->DC.LayoutType;
|
||||
window->DC.LayoutType = ImGuiLayoutType_Vertical;
|
||||
window->DC.IsSameLine = false;
|
||||
if (window->DC.CurrLineSize.y > 0.0f) // In the event that we are on a line with items that is smaller that FontSize high, we will preserve its height.
|
||||
ItemSize(ImVec2(0, 0));
|
||||
else
|
||||
|
|
@ -1741,6 +1743,7 @@ bool ImGui::BeginComboPreview()
|
|||
window->DC.CursorPos = preview_data->PreviewRect.Min + g.Style.FramePadding;
|
||||
window->DC.CursorMaxPos = window->DC.CursorPos;
|
||||
window->DC.LayoutType = ImGuiLayoutType_Horizontal;
|
||||
window->DC.IsSameLine = false;
|
||||
PushClipRect(preview_data->PreviewRect.Min, preview_data->PreviewRect.Max, true);
|
||||
|
||||
return true;
|
||||
|
|
@ -1766,6 +1769,7 @@ void ImGui::EndComboPreview()
|
|||
window->DC.CursorPosPrevLine = preview_data->BackupCursorPosPrevLine;
|
||||
window->DC.PrevLineTextBaseOffset = preview_data->BackupPrevLineTextBaseOffset;
|
||||
window->DC.LayoutType = preview_data->BackupLayout;
|
||||
window->DC.IsSameLine = false;
|
||||
preview_data->PreviewRect = ImRect();
|
||||
}
|
||||
|
||||
|
|
@ -6738,6 +6742,7 @@ bool ImGui::BeginMenuBar()
|
|||
// We overwrite CursorMaxPos because BeginGroup sets it to CursorPos (essentially the .EmitItem hack in EndMenuBar() would need something analogous here, maybe a BeginGroupEx() with flags).
|
||||
window->DC.CursorPos = window->DC.CursorMaxPos = ImVec2(bar_rect.Min.x + window->DC.MenuBarOffset.x, bar_rect.Min.y + window->DC.MenuBarOffset.y);
|
||||
window->DC.LayoutType = ImGuiLayoutType_Horizontal;
|
||||
window->DC.IsSameLine = false;
|
||||
window->DC.NavLayerCurrent = ImGuiNavLayer_Menu;
|
||||
window->DC.MenuBarAppending = true;
|
||||
AlignTextToFramePadding();
|
||||
|
|
@ -6781,6 +6786,7 @@ void ImGui::EndMenuBar()
|
|||
g.GroupStack.back().EmitItem = false;
|
||||
EndGroup(); // Restore position on layer 0
|
||||
window->DC.LayoutType = ImGuiLayoutType_Vertical;
|
||||
window->DC.IsSameLine = false;
|
||||
window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
|
||||
window->DC.MenuBarAppending = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue