mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 13:38:35 +00:00
add new function in ui for textfilter and doc
This commit is contained in:
parent
5450ee6136
commit
2d8ae7c9d0
@ -1,8 +1,8 @@
|
||||
//! Helper to parse and apply text filters
|
||||
use crate::sys;
|
||||
use crate::Ui;
|
||||
use std::ptr;
|
||||
|
||||
/// Helper to parse and apply text filters
|
||||
pub struct TextFilter {
|
||||
id: String,
|
||||
raw: *mut sys::ImGuiTextFilter,
|
||||
@ -27,9 +27,9 @@ impl TextFilter {
|
||||
}
|
||||
|
||||
/// Builds the TextFilter with its filter attribute. You can use
|
||||
/// `[pass_filter()](Self::pass_filter)` after it.
|
||||
/// [`pass_filter()`](Self::pass_filter) after it.
|
||||
///
|
||||
/// If you want control the filter with an InputText, check `[draw()](Self::draw)`.
|
||||
/// If you want control the filter with an InputText, check [`draw()`](Self::draw).
|
||||
pub fn build(&self) {
|
||||
unsafe {
|
||||
sys::ImGuiTextFilter_Build(self.raw);
|
||||
@ -61,6 +61,8 @@ impl TextFilter {
|
||||
}
|
||||
|
||||
/// Returns true if the buffer matches the filter.
|
||||
///
|
||||
/// [`draw()`](Self::draw) or [`build()`](Self::build) mut be called **before** this function.
|
||||
pub fn pass_filter(&self, mut buf: String) -> bool {
|
||||
buf.push('\0');
|
||||
let ptr = buf.as_mut_ptr();
|
||||
@ -95,4 +97,8 @@ impl Ui {
|
||||
pub fn text_filter(label: String) -> TextFilter {
|
||||
TextFilter::new(label)
|
||||
}
|
||||
|
||||
pub fn text_filter_with_filter(label: String, filter: String) -> TextFilter {
|
||||
TextFilter::new_with_filter(label, filter)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user