New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add TextFilter #658
add TextFilter #658
Conversation
I'm not sure about the path of the source file. I don't think it's a widget but idk where to put it. |
Thanks for this! 🥳
I think probably just |
imgui/src/widget/text_filter.rs
Outdated
} | ||
} | ||
|
||
pub fn pass_filter_with_end(&self, mut start: String, mut end: String) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this method used for? It's not immediatly clear (..even looking at imgui.cpp!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't exactly know too.. I have to try it but I don't have time lately.
imgui/src/widget/text_filter.rs
Outdated
|
||
/// Returns true if the buffer matches the filter. | ||
/// | ||
/// [`draw()`](Self::draw) or [`build()`](Self::build) mut be called **before** this function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if pass_filter
is called without build? I guess imgui aborts?
If so, I wonder if it'd be worth adding some extra object so you do
fn draw(&'a mut self) -> &'a TextFilterHandle {
...
}
fn build(&'a mut self) -> &'a TextFilterHandle {
And since the pass_filter
methods etc would be on that TextFilterHandle
struct, it would be impossible to misuse (since you can't get at the pass_filter
method without calling one of those methods)
Not a vital thing - there are plenty of ways to make imgui abort via the bindings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried to run pass_filter
without build
or draw
in test_window_impl
. It doesn't crash, just does nothing, like InputText
without build
. I just specify in the documentation that we have to call them before using the filter.
The CI failure in the Rust 1.54 checks is unrelated to PR I think the |
Thanks! This seems good to me, merging There's some room for optimizing away the internally allocated |
I opened the issue #649 to add TextFilter. I did it but I think it could be better. I'ven't found an example in the library so I tried something. I also added it in the
test_window_impl
to test.