1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-24 15:50:25 +01:00

TreeNode(), CollapsingHeader() fixed not being to use "##" sequence in formatted label.

Removed DisableHideTextAfterDoubleHash hack used by Metrics window.
This commit is contained in:
ocornut 2016-01-16 12:25:40 +00:00
parent 739e73b07b
commit 3922988dea
2 changed files with 5 additions and 17 deletions

View File

@ -2488,17 +2488,8 @@ static const char* FindTextDisplayEnd(const char* text, const char* text_end)
if (!text_end)
text_end = (const char*)-1;
ImGuiState& g = *GImGui;
if (g.DisableHideTextAfterDoubleHash > 0)
{
while (text_display_end < text_end && *text_display_end != '\0')
text_display_end++;
}
else
{
while (text_display_end < text_end && *text_display_end != '\0' && (text_display_end[0] != '#' || text_display_end[1] != '#'))
text_display_end++;
}
while (text_display_end < text_end && *text_display_end != '\0' && (text_display_end[0] != '#' || text_display_end[1] != '#'))
text_display_end++;
return text_display_end;
}
@ -5601,8 +5592,9 @@ bool ImGui::CollapsingHeader(const char* label, const char* str_id, bool display
str_id = label;
if (label == NULL)
label = str_id;
const bool label_hide_text_after_double_hash = (label == str_id); // Only search and hide text after ## if we have passed label and ID separately, otherwise allow "##" within format string.
const ImGuiID id = window->GetID(str_id);
const ImVec2 label_size = CalcTextSize(label, NULL, true);
const ImVec2 label_size = CalcTextSize(label, NULL, label_hide_text_after_double_hash);
// We vertically grow up to current line height up the typical widget height.
const float text_base_offset_y = ImMax(0.0f, window->DC.CurrentLineTextBaseOffset - padding.y); // Latch before ItemSize changes it
@ -5665,7 +5657,7 @@ bool ImGui::CollapsingHeader(const char* label, const char* str_id, bool display
RenderCollapseTriangle(bb.Min + ImVec2(padding.x, g.FontSize*0.15f + text_base_offset_y), opened, 0.70f, false);
if (g.LogEnabled)
LogRenderedText(text_pos, ">");
RenderText(text_pos, label);
RenderText(text_pos, label, NULL, label_hide_text_after_double_hash);
}
return opened;
@ -9288,7 +9280,6 @@ void ImGui::ShowMetricsWindow(bool* opened)
};
ImGuiState& g = *GImGui; // Access private state
g.DisableHideTextAfterDoubleHash++; // Not exposed (yet). Disable processing that hides text after '##' markers.
Funcs::NodeWindows(g.Windows, "Windows");
if (ImGui::TreeNode("DrawList", "Active DrawLists (%d)", g.RenderDrawLists[0].Size))
{
@ -9314,7 +9305,6 @@ void ImGui::ShowMetricsWindow(bool* opened)
ImGui::Text("ActiveID: 0x%08X/0x%08X", g.ActiveId, g.ActiveIdPreviousFrame);
ImGui::TreePop();
}
g.DisableHideTextAfterDoubleHash--;
}
ImGui::End();
}

View File

@ -371,7 +371,6 @@ struct ImGuiState
ImGuiWindow* MovedWindow; // Track the child window we clicked on to move a window. Pointer is only valid if ActiveID is the "#MOVE" identifier of a window.
ImVector<ImGuiIniData> Settings; // .ini Settings
float SettingsDirtyTimer; // Save .ini settinngs on disk when time reaches zero
int DisableHideTextAfterDoubleHash;
ImVector<ImGuiColMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont()
@ -455,7 +454,6 @@ struct ImGuiState
ActiveIdWindow = NULL;
MovedWindow = NULL;
SettingsDirtyTimer = 0.0f;
DisableHideTextAfterDoubleHash = 0;
SetNextWindowPosVal = ImVec2(0.0f, 0.0f);
SetNextWindowSizeVal = ImVec2(0.0f, 0.0f);