mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-26 12:59:00 +00:00
updated doc comments to fix intra-doc breakages
This commit is contained in:
parent
213433ffd3
commit
805f5e93e7
@ -110,7 +110,7 @@ impl<'ui> Ui<'ui> {
|
|||||||
self.is_key_index_down(key_index)
|
self.is_key_index_down(key_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Same as [`is_key_down`] but takes a key index. The meaning of
|
/// Same as [`is_key_down`](Self::is_key_down) but takes a key index. The meaning of
|
||||||
/// index is defined by your backend implementation.
|
/// index is defined by your backend implementation.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[doc(alias = "IsKeyDown")]
|
#[doc(alias = "IsKeyDown")]
|
||||||
@ -128,7 +128,7 @@ impl<'ui> Ui<'ui> {
|
|||||||
self.is_key_index_pressed(key_index)
|
self.is_key_index_pressed(key_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Same as [`is_key_pressed`] but takes a key index.
|
/// Same as [`is_key_pressed`](Self::is_key_pressed) but takes a key index.
|
||||||
///
|
///
|
||||||
/// The meaning of index is defined by your backend
|
/// The meaning of index is defined by your backend
|
||||||
/// implementation.
|
/// implementation.
|
||||||
@ -148,7 +148,8 @@ impl<'ui> Ui<'ui> {
|
|||||||
self.is_key_index_pressed_no_repeat(key_index)
|
self.is_key_index_pressed_no_repeat(key_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Same as [`is_key_pressed_no_repeat`] but takes a key index.
|
/// Same as [`is_key_pressed_no_repeat`](Self::is_key_pressed_no_repeat)
|
||||||
|
/// but takes a key index.
|
||||||
///
|
///
|
||||||
/// The meaning of index is defined by your backend
|
/// The meaning of index is defined by your backend
|
||||||
/// implementation.
|
/// implementation.
|
||||||
@ -166,7 +167,7 @@ impl<'ui> Ui<'ui> {
|
|||||||
self.is_key_index_released(key_index)
|
self.is_key_index_released(key_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Same as [`is_key_released`] but takes a key index.
|
/// Same as [`is_key_released`](Self::is_key_released) but takes a key index.
|
||||||
///
|
///
|
||||||
/// The meaning of index is defined by your backend
|
/// The meaning of index is defined by your backend
|
||||||
/// implementation.
|
/// implementation.
|
||||||
|
|||||||
@ -552,7 +552,7 @@ pub trait TextCallbackHandler {
|
|||||||
/// during this callback (for some reason).
|
/// during this callback (for some reason).
|
||||||
///
|
///
|
||||||
/// To make ImGui run this callback, use [InputTextCallback::CHAR_FILTER] or
|
/// To make ImGui run this callback, use [InputTextCallback::CHAR_FILTER] or
|
||||||
/// [InputTextMultilineCallback::CALLBACK].
|
/// [InputTextMultilineCallback::CHAR_FILTER].
|
||||||
fn char_filter(&mut self, c: char) -> Option<char> {
|
fn char_filter(&mut self, c: char) -> Option<char> {
|
||||||
Some(c)
|
Some(c)
|
||||||
}
|
}
|
||||||
@ -590,8 +590,8 @@ pub enum HistoryDirection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// This struct provides methods to edit the underlying text buffer that
|
/// This struct provides methods to edit the underlying text buffer that
|
||||||
/// Dear ImGui manipulates. Primarily, it gives [remove_chars], [insert_chars],
|
/// Dear ImGui manipulates. Primarily, it gives [remove_chars](Self::remove_chars),
|
||||||
/// and mutable access to what text is selected.
|
/// [insert_chars](Self::insert_chars), and mutable access to what text is selected.
|
||||||
pub struct TextCallbackData<'a>(&'a mut sys::ImGuiInputTextCallbackData);
|
pub struct TextCallbackData<'a>(&'a mut sys::ImGuiInputTextCallbackData);
|
||||||
|
|
||||||
impl<'a> TextCallbackData<'a> {
|
impl<'a> TextCallbackData<'a> {
|
||||||
@ -625,6 +625,11 @@ impl<'a> TextCallbackData<'a> {
|
|||||||
///
|
///
|
||||||
/// This function should have highly limited usage, but could be for
|
/// This function should have highly limited usage, but could be for
|
||||||
/// editing certain characters in the buffer based on some external condition.
|
/// editing certain characters in the buffer based on some external condition.
|
||||||
|
///
|
||||||
|
/// [remove_chars]: Self::remove_chars
|
||||||
|
/// [set_dirty]: Self::set_dirty
|
||||||
|
/// [insert_chars]: Self::insert_chars
|
||||||
|
/// [push_str]: Self::push_str
|
||||||
pub unsafe fn str_as_bytes_mut(&mut self) -> &mut [u8] {
|
pub unsafe fn str_as_bytes_mut(&mut self) -> &mut [u8] {
|
||||||
let str = std::str::from_utf8_mut(std::slice::from_raw_parts_mut(
|
let str = std::str::from_utf8_mut(std::slice::from_raw_parts_mut(
|
||||||
self.0.Buf as *const _ as *mut _,
|
self.0.Buf as *const _ as *mut _,
|
||||||
@ -638,19 +643,23 @@ impl<'a> TextCallbackData<'a> {
|
|||||||
/// Sets the dirty flag on the text to imgui, indicating that
|
/// Sets the dirty flag on the text to imgui, indicating that
|
||||||
/// it should reapply this string to its internal state.
|
/// it should reapply this string to its internal state.
|
||||||
///
|
///
|
||||||
/// **NB:** You only need to use this method if you're using `[buf_mut]`.
|
/// **NB:** You only need to use this method if you're using `[str_as_bytes_mut]`.
|
||||||
/// If you use the helper methods [remove_chars] and [insert_chars],
|
/// If you use the helper methods [remove_chars] and [insert_chars],
|
||||||
/// this will be set for you. However, this is no downside to setting
|
/// this will be set for you. However, this is no downside to setting
|
||||||
/// the dirty flag spuriously except the minor CPU time imgui will spend.
|
/// the dirty flag spuriously except the minor CPU time imgui will spend.
|
||||||
|
///
|
||||||
|
/// [str_as_bytes_mut]: Self::str_as_bytes_mut
|
||||||
|
/// [remove_chars]: Self::remove_chars
|
||||||
|
/// [insert_chars]: Self::insert_chars
|
||||||
pub fn set_dirty(&mut self) {
|
pub fn set_dirty(&mut self) {
|
||||||
self.0.BufDirty = true;
|
self.0.BufDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets a range of the selected text. See [selection_start_mut] and
|
/// Gets a range of the selected text. See [selection_start_mut](Self::selection_start_mut)
|
||||||
/// [selection_end_mut] to mutably edit these values.
|
/// and [selection_end_mut](Self::selection_end_mut) to mutably edit these values.
|
||||||
///
|
///
|
||||||
/// This Range is given in `usize` so that it might be used in indexing
|
/// This Range is given in `usize` so that it might be used in indexing
|
||||||
/// operations more easily. To quickly grab the selected text, use [selected].
|
/// operations more easily. To quickly grab the selected text, use [selected](Self::selected).
|
||||||
pub fn selection(&self) -> Range<usize> {
|
pub fn selection(&self) -> Range<usize> {
|
||||||
self.0.SelectionStart as usize..self.0.SelectionEnd as usize
|
self.0.SelectionStart as usize..self.0.SelectionEnd as usize
|
||||||
}
|
}
|
||||||
@ -661,16 +670,14 @@ impl<'a> TextCallbackData<'a> {
|
|||||||
&self.str()[self.selection()]
|
&self.str()[self.selection()]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the cursor to select all. This is always a valid operation,
|
/// Sets the cursor to select all.
|
||||||
/// and so it takes an `&self`.
|
|
||||||
pub fn select_all(&mut self) {
|
pub fn select_all(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
sys::ImGuiInputTextCallbackData_SelectAll(self.0);
|
sys::ImGuiInputTextCallbackData_SelectAll(self.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clears the selection. This is always a valid operation,
|
/// Clears the selection.
|
||||||
/// and so it takes an `&self`.
|
|
||||||
pub fn clear_selection(&mut self) {
|
pub fn clear_selection(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
sys::ImGuiInputTextCallbackData_ClearSelection(self.0);
|
sys::ImGuiInputTextCallbackData_ClearSelection(self.0);
|
||||||
@ -683,8 +690,8 @@ impl<'a> TextCallbackData<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Pushes the given str to the end of this buffer. If this
|
/// Pushes the given str to the end of this buffer. If this
|
||||||
/// would require the String to resize, it will be resized by calling the
|
/// would require the String to resize, it will be resized.
|
||||||
/// `CALLBACK_RESIZE` callback. This is automatically handled.
|
/// This is automatically handled.
|
||||||
pub fn push_str(&mut self, s: &str) {
|
pub fn push_str(&mut self, s: &str) {
|
||||||
// this is safe because the ench of a self.str is a char_boundary.
|
// this is safe because the ench of a self.str is a char_boundary.
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -693,8 +700,8 @@ impl<'a> TextCallbackData<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Inserts the given string at the given position. If this
|
/// Inserts the given string at the given position. If this
|
||||||
/// would require the String to resize, it will be resized by calling the
|
/// would require the String to resize, it will be resized
|
||||||
/// `CALLBACK_RESIZE` callback. This is automatically handled.
|
/// automatically.
|
||||||
///
|
///
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
/// Panics if the `pos` is not a char_boundary.
|
/// Panics if the `pos` is not a char_boundary.
|
||||||
@ -706,13 +713,13 @@ impl<'a> TextCallbackData<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Inserts the given string at the given position, unsafely. If this
|
/// Inserts the given string at the given position, unsafely. If this
|
||||||
/// would require the String to resize, it will be resized by calling the
|
/// would require the String to resize, it will be resized automatically.
|
||||||
/// Callback_Resize callback. This is automatically handled.
|
|
||||||
///
|
///
|
||||||
/// ## Safety
|
/// ## Safety
|
||||||
///
|
///
|
||||||
/// It is up to the caller to confirm that the `pos` is a valid byte
|
/// It is up to the caller to confirm that the `pos` is a valid byte
|
||||||
/// position, or use [insert_chars] which will panic if it isn't.
|
/// position, or use [insert_chars](Self::insert_chars) which will panic
|
||||||
|
/// if it isn't.
|
||||||
pub unsafe fn insert_chars_unsafe(&mut self, pos: usize, s: &str) {
|
pub unsafe fn insert_chars_unsafe(&mut self, pos: usize, s: &str) {
|
||||||
let start = s.as_ptr();
|
let start = s.as_ptr();
|
||||||
let end = start.add(s.len());
|
let end = start.add(s.len());
|
||||||
@ -752,8 +759,8 @@ impl<'a> TextCallbackData<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Removes the given number of bytes from the string starting
|
/// Removes the given number of bytes from the string starting
|
||||||
/// at some byte pos, without checking for utf8 validity. Use [remove_chars]
|
/// at some byte pos, without checking for utf8 validity. Use
|
||||||
/// for a safe variant.
|
/// [remove_chars](Self::remove_chars) for a safe variant.
|
||||||
///
|
///
|
||||||
/// ## Safety
|
/// ## Safety
|
||||||
///
|
///
|
||||||
|
|||||||
@ -134,8 +134,8 @@ impl<'p> PopupModal<'p> {
|
|||||||
/// Consume and draw the PopupModal.
|
/// Consume and draw the PopupModal.
|
||||||
/// Construct a popup that can have any kind of content.
|
/// Construct a popup that can have any kind of content.
|
||||||
///
|
///
|
||||||
/// This should be called *per frame*, whereas [`open_popup`](Self::open_popup) should be called *once*
|
/// This should be called *per frame*, whereas [`Ui::open_popup`]
|
||||||
/// when you want to actual create the popup.
|
/// should be called *once* when you want to actual create the popup.
|
||||||
#[doc(alias = "BeginPopupModal")]
|
#[doc(alias = "BeginPopupModal")]
|
||||||
pub fn begin_popup<'ui>(self, ui: &Ui<'ui>) -> Option<PopupToken<'ui>> {
|
pub fn begin_popup<'ui>(self, ui: &Ui<'ui>) -> Option<PopupToken<'ui>> {
|
||||||
let render = unsafe {
|
let render = unsafe {
|
||||||
@ -159,7 +159,7 @@ impl<'p> PopupModal<'p> {
|
|||||||
// Widgets: Popups
|
// Widgets: Popups
|
||||||
impl<'ui> Ui<'ui> {
|
impl<'ui> Ui<'ui> {
|
||||||
/// Instructs ImGui to open a popup, which must be began with either [`begin_popup`](Self::begin_popup)
|
/// Instructs ImGui to open a popup, which must be began with either [`begin_popup`](Self::begin_popup)
|
||||||
/// or [`popup`](Self::popup). You also use this function to begin [ModalPopups].
|
/// or [`popup`](Self::popup). You also use this function to begin [PopupModal].
|
||||||
///
|
///
|
||||||
/// The confusing aspect to popups is that ImGui holds "control" over the popup fundamentally, so that ImGui
|
/// The confusing aspect to popups is that ImGui holds "control" over the popup fundamentally, so that ImGui
|
||||||
/// can also force close a popup when a user clicks outside a popup. If you do not want users to be
|
/// can also force close a popup when a user clicks outside a popup. If you do not want users to be
|
||||||
|
|||||||
@ -391,7 +391,7 @@ impl<'a> CollapsingHeader<'a> {
|
|||||||
///
|
///
|
||||||
/// Returns true if the collapsing header is open and content should be rendered.
|
/// Returns true if the collapsing header is open and content should be rendered.
|
||||||
///
|
///
|
||||||
/// This is the same as [build] but is provided for consistent naming.
|
/// This is the same as [build](Self::build) but is provided for consistent naming.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn begin(self, ui: &Ui) -> bool {
|
pub fn begin(self, ui: &Ui) -> bool {
|
||||||
self.build(ui)
|
self.build(ui)
|
||||||
@ -401,7 +401,8 @@ impl<'a> CollapsingHeader<'a> {
|
|||||||
///
|
///
|
||||||
/// Returns true if the collapsing header is open and content should be rendered.
|
/// Returns true if the collapsing header is open and content should be rendered.
|
||||||
///
|
///
|
||||||
/// This is the same as [build_with_close_button] but is provided for consistent naming.
|
/// This is the same as [build_with_close_button](Self::build_with_close_button)
|
||||||
|
/// but is provided for consistent naming.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn begin_with_close_button(self, ui: &Ui, opened: &mut bool) -> bool {
|
pub fn begin_with_close_button(self, ui: &Ui, opened: &mut bool) -> bool {
|
||||||
self.build_with_close_button(ui, opened)
|
self.build_with_close_button(ui, opened)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user