Merge branch 'kylawl-master'

This commit is contained in:
ocornut 2016-03-21 13:02:33 -07:00
commit 1bd3942b8e
2 changed files with 16 additions and 17 deletions

View File

@ -591,7 +591,6 @@
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
static void LogRenderedText(const ImVec2& ref_pos, const char* text, const char* text_end = NULL); static void LogRenderedText(const ImVec2& ref_pos, const char* text, const char* text_end = NULL);
static const char* FindTextDisplayEnd(const char* text, const char* text_end = NULL);
static void PushMultiItemsWidths(int components, float w_full = 0.0f); static void PushMultiItemsWidths(int components, float w_full = 0.0f);
static float GetDraggedColumnOffset(int column_index); static float GetDraggedColumnOffset(int column_index);
@ -2509,8 +2508,7 @@ void ImGui::Render()
} }
} }
// Find the optional ## from which we stop displaying text. const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end)
static const char* FindTextDisplayEnd(const char* text, const char* text_end)
{ {
const char* text_display_end = text; const char* text_display_end = text;
if (!text_end) if (!text_end)
@ -2549,7 +2547,7 @@ static void LogRenderedText(const ImVec2& ref_pos, const char* text, const char*
ImGuiWindow* window = ImGui::GetCurrentWindowRead(); ImGuiWindow* window = ImGui::GetCurrentWindowRead();
if (!text_end) if (!text_end)
text_end = FindTextDisplayEnd(text, text_end); text_end = ImGui::FindRenderedTextEnd(text, text_end);
const bool log_new_line = ref_pos.y > window->DC.LogLinePosY+1; const bool log_new_line = ref_pos.y > window->DC.LogLinePosY+1;
window->DC.LogLinePosY = ref_pos.y; window->DC.LogLinePosY = ref_pos.y;
@ -2603,7 +2601,7 @@ void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool
const char* text_display_end; const char* text_display_end;
if (hide_text_after_hash) if (hide_text_after_hash)
{ {
text_display_end = FindTextDisplayEnd(text, text_end); text_display_end = FindRenderedTextEnd(text, text_end);
} }
else else
{ {
@ -2642,7 +2640,7 @@ void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end
void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, ImGuiAlign align, const ImVec2* clip_min, const ImVec2* clip_max) void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, ImGuiAlign align, const ImVec2* clip_min, const ImVec2* clip_max)
{ {
// Hide anything after a '##' string // Hide anything after a '##' string
const char* text_display_end = FindTextDisplayEnd(text, text_end); const char* text_display_end = FindRenderedTextEnd(text, text_end);
const int text_len = (int)(text_display_end - text); const int text_len = (int)(text_display_end - text);
if (text_len == 0) if (text_len == 0)
return; return;
@ -2749,7 +2747,7 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex
const char* text_display_end; const char* text_display_end;
if (hide_text_after_double_hash) if (hide_text_after_double_hash)
text_display_end = FindTextDisplayEnd(text, text_end); // Hide anything after a '##' string text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string
else else
text_display_end = text_end; text_display_end = text_end;
@ -6334,7 +6332,7 @@ bool ImGui::SliderFloatN(const char* label, float* v, int components, float v_mi
} }
ImGui::PopID(); ImGui::PopID();
ImGui::TextUnformatted(label, FindTextDisplayEnd(label)); ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
ImGui::EndGroup(); ImGui::EndGroup();
return value_changed; return value_changed;
@ -6376,7 +6374,7 @@ bool ImGui::SliderIntN(const char* label, int* v, int components, int v_min, int
} }
ImGui::PopID(); ImGui::PopID();
ImGui::TextUnformatted(label, FindTextDisplayEnd(label)); ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
ImGui::EndGroup(); ImGui::EndGroup();
return value_changed; return value_changed;
@ -6556,7 +6554,7 @@ bool ImGui::DragFloatN(const char* label, float* v, int components, float v_spee
} }
ImGui::PopID(); ImGui::PopID();
ImGui::TextUnformatted(label, FindTextDisplayEnd(label)); ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
ImGui::EndGroup(); ImGui::EndGroup();
return value_changed; return value_changed;
@ -6595,7 +6593,7 @@ bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_cu
ImGui::PopItemWidth(); ImGui::PopItemWidth();
ImGui::SameLine(0, g.Style.ItemInnerSpacing.x); ImGui::SameLine(0, g.Style.ItemInnerSpacing.x);
ImGui::TextUnformatted(label, FindTextDisplayEnd(label)); ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
ImGui::EndGroup(); ImGui::EndGroup();
ImGui::PopID(); ImGui::PopID();
@ -6634,7 +6632,7 @@ bool ImGui::DragIntN(const char* label, int* v, int components, float v_speed, i
} }
ImGui::PopID(); ImGui::PopID();
ImGui::TextUnformatted(label, FindTextDisplayEnd(label)); ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
ImGui::EndGroup(); ImGui::EndGroup();
return value_changed; return value_changed;
@ -6673,7 +6671,7 @@ bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_
ImGui::PopItemWidth(); ImGui::PopItemWidth();
ImGui::SameLine(0, g.Style.ItemInnerSpacing.x); ImGui::SameLine(0, g.Style.ItemInnerSpacing.x);
ImGui::TextUnformatted(label, FindTextDisplayEnd(label)); ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
ImGui::EndGroup(); ImGui::EndGroup();
ImGui::PopID(); ImGui::PopID();
@ -7893,7 +7891,7 @@ bool ImGui::InputFloatN(const char* label, float* v, int components, int decimal
ImGui::PopID(); ImGui::PopID();
window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.CurrentLineTextBaseOffset, g.Style.FramePadding.y); window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.CurrentLineTextBaseOffset, g.Style.FramePadding.y);
ImGui::TextUnformatted(label, FindTextDisplayEnd(label)); ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
ImGui::EndGroup(); ImGui::EndGroup();
return value_changed; return value_changed;
@ -7936,7 +7934,7 @@ bool ImGui::InputIntN(const char* label, int* v, int components, ImGuiInputTextF
ImGui::PopID(); ImGui::PopID();
window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.CurrentLineTextBaseOffset, g.Style.FramePadding.y); window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.CurrentLineTextBaseOffset, g.Style.FramePadding.y);
ImGui::TextUnformatted(label, FindTextDisplayEnd(label)); ImGui::TextUnformatted(label, FindRenderedTextEnd(label));
ImGui::EndGroup(); ImGui::EndGroup();
return value_changed; return value_changed;
@ -8647,7 +8645,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], bool alpha)
g.ColorEditModeStorage.SetInt(id, (edit_mode + 1) % 3); // Don't set local copy of 'edit_mode' right away! g.ColorEditModeStorage.SetInt(id, (edit_mode + 1) % 3); // Don't set local copy of 'edit_mode' right away!
} }
const char* label_display_end = FindTextDisplayEnd(label); const char* label_display_end = FindRenderedTextEnd(label);
if (label != label_display_end) if (label != label_display_end)
{ {
ImGui::SameLine(0, (window->DC.ColorEditMode == ImGuiColorEditMode_UserSelectShowButton) ? -1.0f : style.ItemInnerSpacing.x); ImGui::SameLine(0, (window->DC.ColorEditMode == ImGuiColorEditMode_UserSelectShowButton) ? -1.0f : style.ItemInnerSpacing.x);

View File

@ -707,7 +707,8 @@ namespace ImGui
IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, ImGuiAlign align = ImGuiAlign_Default, const ImVec2* clip_min = NULL, const ImVec2* clip_max = NULL); IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, ImGuiAlign align = ImGuiAlign_Default, const ImVec2* clip_min = NULL, const ImVec2* clip_max = NULL);
IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f); IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
IMGUI_API void RenderCollapseTriangle(ImVec2 p_min, bool opened, float scale = 1.0f, bool shadow = false); IMGUI_API void RenderCollapseTriangle(ImVec2 p_min, bool opened, float scale = 1.0f, bool shadow = false);
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col); IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col);
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_existing_clip_rect = true); IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_existing_clip_rect = true);
IMGUI_API void PopClipRect(); IMGUI_API void PopClipRect();