Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,7 @@ ImGuiTextFilter::ImGuiTextFilter(const char* default_filter)
: MatchMode(ImGuiTextFilterMode_Or)
, WordSplitter(',')
, MinWordSize(0)
, ShowSettings(false)
{
if (default_filter)
{
Expand All @@ -2061,11 +2062,36 @@ ImGuiTextFilter::ImGuiTextFilter(const char* default_filter)

bool ImGuiTextFilter::Draw(const char* label, float width)
{
ImGui::PushID(this);
const ImGuiDir ArrowDirection = ShowSettings ? ImGuiDir_Down : ImGuiDir_Right;
if (ImGui::ArrowButton("Settings", ArrowDirection))
ShowSettings = !ShowSettings;
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Filter settings");
ImGui::PopID();

ImGui::SameLine();

if (width != 0.0f)
ImGui::SetNextItemWidth(width);
bool value_changed = ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf));
if (value_changed)
Build();

if (ShowSettings)
{
ImGui::TreePush(this);
const char *modes[] = {"Or", "And"};
ImGui::Combo("Match mode", &MatchMode, modes, 2);

char buff[2] = {WordSplitter, 0};
ImGui::InputText("Word splitter", buff, sizeof(buff));
WordSplitter = buff[0];

ImGui::InputScalar("Min word size", ImGuiDataType_S8, &MinWordSize);
ImGui::TreePop();
}

return value_changed;
}

Expand Down
1 change: 1 addition & 0 deletions imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,7 @@ struct ImGuiTextFilter
char InputBuf[256];
ImVector<ImGuiTextRange> Filters;
int NegativeFilterCount;
bool ShowSettings;

// [Configuration]
ImGuiTextFilterMode MatchMode; // if true then all words must match, otherwise any matching word will be a pass
Expand Down