Skip to content

Commit 1e9db61

Browse files
committed
[API] Implement ImGuiTextFilter
1 parent 897ca49 commit 1e9db61

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package imgui;
2+
3+
import imgui.binding.ImGuiStructDestroyable;
4+
5+
/**
6+
* Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
7+
*/
8+
public final class ImGuiTextFilter extends ImGuiStructDestroyable {
9+
public ImGuiTextFilter() {
10+
this("");
11+
}
12+
13+
public ImGuiTextFilter(final String defaultFilter) {
14+
ptr = nCreate(defaultFilter);
15+
}
16+
17+
ImGuiTextFilter(final long ptr) {
18+
super(ptr);
19+
}
20+
21+
/*JNI
22+
#include <imgui.h>
23+
#include <stdint.h>
24+
#include "jni_binding_struct.h"
25+
26+
#define IMGUI_TEXT_FILTER ((ImGuiTextFilter*)STRUCT_PTR)
27+
*/
28+
29+
@Override
30+
protected long create() {
31+
return nCreate("");
32+
}
33+
34+
private native long nCreate(String defaultFilter); /*
35+
return (intptr_t)(new ImGuiTextFilter(defaultFilter));
36+
*/
37+
38+
public boolean draw() {
39+
return draw("Filter (inc,-exc)");
40+
}
41+
42+
public boolean draw(final String label) {
43+
return draw(label, 0f);
44+
}
45+
46+
public native boolean draw(String label, float width); /*
47+
return IMGUI_TEXT_FILTER->Draw(label, width);
48+
*/
49+
50+
public native boolean passFilter(String text); /*
51+
return IMGUI_TEXT_FILTER->PassFilter(text);
52+
*/
53+
54+
public native void build(); /*
55+
IMGUI_TEXT_FILTER->Build();
56+
*/
57+
58+
public native void clear(); /*
59+
IMGUI_TEXT_FILTER->Clear();
60+
*/
61+
62+
public native boolean isActive(); /*
63+
return IMGUI_TEXT_FILTER->IsActive();
64+
*/
65+
}

0 commit comments

Comments
 (0)