From c1f20f03c59ff485bfe548537f99c12e4e27b77f Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 15 Feb 2015 13:50:04 +0000 Subject: [PATCH] ImGuiTextFilter() can take a default filter string --- imgui.cpp | 14 +++++++++++--- imgui.h | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 4281c24c..67fc5da3 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1260,10 +1260,18 @@ void ImGuiStorage::SetAllInt(int v) //----------------------------------------------------------------------------- // Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]" -ImGuiTextFilter::ImGuiTextFilter() +ImGuiTextFilter::ImGuiTextFilter(const char* default_filter) { - InputBuf[0] = 0; - CountGrep = 0; + if (default_filter) + { + ImFormatString(InputBuf, IM_ARRAYSIZE(InputBuf), "%s", default_filter); + Build(); + } + else + { + InputBuf[0] = 0; + CountGrep = 0; + } } void ImGuiTextFilter::Draw(const char* label, float width) diff --git a/imgui.h b/imgui.h index b2572c46..71c87ca0 100644 --- a/imgui.h +++ b/imgui.h @@ -651,7 +651,7 @@ struct ImGuiTextFilter ImVector Filters; int CountGrep; - ImGuiTextFilter(); + ImGuiTextFilter(const char* default_filter = ""); void Clear() { InputBuf[0] = 0; Build(); } void Draw(const char* label = "Filter (inc,-exc)", float width = -1.0f); // Helper calling InputText+Build bool PassFilter(const char* val) const;