You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extend ImGuiTextFilter to be customizable and usable for multiple fields. Preserved current behavior and performance.
* Fixed negative matches not working when located after a positive matches. Optimized by keeping all negative matches at the front of the filter list.
* Add the following customization options:
** Custom split character, default is still ','
** Minimum word match length can be used to keep the search more stable for the first couple characters of input
** Match mode can be switch from Or (any pass causes a success) to And (all positive filters must match).
* Add a utility to allow applying a single filter to multiple fields.
typedefint ImGuiStyleVar; // -> enum ImGuiStyleVar_ // Enum: A variable identifier for styling
137
+
typedefint ImGuiTextFilterMode; // -> enum ImGuiTextFilterMode_ // Enum: To control how text filter handles multiple words
138
+
typedefint ImGuiTextFilterMatchResult; // -> enum ImGuiTextFilterMatchResult_ // Enum: A match identifier to better control applying a text filter over multiple fields
136
139
typedefint ImDrawCornerFlags; // -> enum ImDrawCornerFlags_ // Flags: for ImDrawList::AddRect(), AddRectFilled() etc.
137
140
typedefint ImDrawListFlags; // -> enum ImDrawListFlags_ // Flags: for ImDrawList
138
141
typedefint ImFontAtlasFlags; // -> enum ImFontAtlasFlags_ // Flags: for ImFontAtlas
@@ -1582,6 +1585,12 @@ struct ImGuiOnceUponAFrame
1582
1585
operatorbool() const { int current_frame = ImGui::GetFrameCount(); if (RefFrame == current_frame) returnfalse; RefFrame = current_frame; returntrue; }
1583
1586
};
1584
1587
1588
+
enum ImGuiTextFilterMode_
1589
+
{
1590
+
ImGuiTextFilterMode_Or, // A single word match will pass the filter
1591
+
ImGuiTextFilterMode_And // All words must match to pass the filter
1592
+
};
1593
+
1585
1594
// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
1586
1595
structImGuiTextFilter
1587
1596
{
@@ -1595,17 +1604,54 @@ struct ImGuiTextFilter
1595
1604
// [Internal]
1596
1605
structImGuiTextRange
1597
1606
{
1598
-
constchar* b;
1599
-
constchar* e;
1600
-
1601
-
ImGuiTextRange() { b = e = NULL; }
1602
-
ImGuiTextRange(constchar* _b, constchar* _e) { b = _b; e = _e; }
ImGuiTextFilterMode MatchMode; // if true then all words must match, otherwise any matching word will be a pass
1623
+
char WordSplitter; // Character used to split user string, ',' by default
1624
+
char MinWordSize; // Minimum number of characters before a word is used for matching, can help improve UX by avoiding mass matching against 1 or 2 characters
1625
+
};
1626
+
1627
+
enum ImGuiTextFilterMatchResult_
1628
+
{
1629
+
ImGuiTextFilterMatchResultNone, // There have been no matches or failures
1630
+
ImGuiTextFilterMatchResultFail, // The match explicitly failed because of a subtractive clause or because no positive matches passed
1631
+
ImGuiTextFilterMatchResultPass, // The match explicitly passed because of positive match
1632
+
};
1633
+
1634
+
// Helper: Extend a single ImGuiTextFilter to multiple fields. It tracks explicit pass/failure conditions and will
1635
+
// stop processing text after an explicit failure.
0 commit comments