add `DrawWithHint` to `ImGuiTextFilter`

This commit is contained in:
Chaojimengnan 2023-05-23 13:04:32 +08:00
parent 45c8c3b611
commit 20fb286e4f
2 changed files with 11 additions and 0 deletions

View File

@ -2472,6 +2472,16 @@ bool ImGuiTextFilter::Draw(const char* label, float width)
return value_changed;
}
bool ImGuiTextFilter::DrawWithHint(const char* label, const char* hint, float width)
{
if (width != 0.0f)
ImGui::SetNextItemWidth(width);
bool value_changed = ImGui::InputTextWithHint(label, hint, InputBuf, IM_ARRAYSIZE(InputBuf));
if (value_changed)
Build();
return value_changed;
}
void ImGuiTextFilter::ImGuiTextRange::split(char separator, ImVector<ImGuiTextRange>* out) const
{
out->resize(0);

View File

@ -2213,6 +2213,7 @@ struct ImGuiTextFilter
{
IMGUI_API ImGuiTextFilter(const char* default_filter = "");
IMGUI_API bool Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build
IMGUI_API bool DrawWithHint(const char* label, const char* hint = "Filter (inc,-exc)", float width = 0.0f);
IMGUI_API bool PassFilter(const char* text, const char* text_end = NULL) const;
IMGUI_API void Build();
void Clear() { InputBuf[0] = 0; Build(); }