Skip to content

Commit

Permalink
add new function in ui for textfilter and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
tetenpapier committed Aug 11, 2022
1 parent 5450ee6 commit 2d8ae7c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions imgui/src/widget/text_filter.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 2d8ae7c

Please sign in to comment.