proposed extra methods

This commit is contained in:
Jonathan Spira 2023-09-17 17:20:00 -04:00
parent c61fd30eaf
commit 47bb38be50

View File

@ -249,7 +249,10 @@ impl Ui {
}
/// Open and begin popup when clicked with the right mouse button on last item.
/// If you want to use that on a non-interactive item such as text() use [`Self::begin_popup_context_item_id`].
///
/// This does not take a label, which means that multiple calls **in a row** will use the same label, which
/// is based on the last node which had a label. Text and other non-interactive elements generally don't have
/// ids, so you'll need to use [begin_popup_context_with_label] for them.
#[doc(alias = "BeginPopupContextItem")]
pub fn begin_popup_context_item(&self) -> Option<PopupToken<'_>> {
let render = unsafe {
@ -266,10 +269,12 @@ impl Ui {
}
}
/// Open and begin popup when clicked with the right mouse button on the given item.
/// If you want to use the last item and it has an id you, you can use [`Self::begin_popup_context_item`].
/// Open and begin popup when clicked with the right mouse button on the given item with a dedicated label.
///
/// If you want to use the label of the previous popup (outside of `Text` and other non-interactive cases, that
/// is the more normal case), use [begin_popup_context_item].
#[doc(alias = "BeginPopupContextItem")]
pub fn begin_popup_context_item_id<Label: AsRef<str>>(
pub fn begin_popup_context_with_label<Label: AsRef<str>>(
&self,
str_id: Label,
) -> Option<PopupToken<'_>> {
@ -288,8 +293,32 @@ impl Ui {
}
/// Open and begin popup when clicked on current window.
///
/// This does not take a label, which means that multiple calls will use the same provided label.
/// If you want an explicit label, such as having two different kinds of windows popups in your program,
/// use [begin_popup_context_window_with_label].
#[doc(alias = "BeginPopupContextWindow")]
pub fn begin_popup_context_window<Label: AsRef<str>>(
pub fn begin_popup_context_window(&self) -> Option<PopupToken<'_>> {
let render = unsafe {
sys::igBeginPopupContextWindow(
std::ptr::null(),
imgui_sys::ImGuiPopupFlags_MouseButtonRight as i32,
)
};
if render {
Some(PopupToken::new(self))
} else {
None
}
}
/// Open and begin popup when clicked on current window.
///
/// This takes a label explicitly. This is useful when multiple code
/// locations may want to manipulate/open the same popup, given an explicit id.
#[doc(alias = "BeginPopupContextWindow")]
pub fn begin_popup_context_window_with_label<Label: AsRef<str>>(
&self,
str_id: Label,
) -> Option<PopupToken<'_>> {
@ -308,8 +337,32 @@ impl Ui {
}
/// Open and begin popup when right clicked in void (where there are no windows).
///
/// This does not take a label, which means that multiple calls will use the same provided label.
/// If you want an explicit label, such as having two different kinds of void popups in your program,
/// use [begin_popup_context_void_with_label].
#[doc(alias = "BeginPopupContextWindow")]
pub fn begin_popup_context_void(&self) -> Option<PopupToken<'_>> {
let render = unsafe {
sys::igBeginPopupContextVoid(
std::ptr::null(),
imgui_sys::ImGuiPopupFlags_MouseButtonRight as i32,
)
};
if render {
Some(PopupToken::new(self))
} else {
None
}
}
/// Open and begin popup when right clicked in void (where there are no windows).
///
/// This takes a label explicitly. This is useful when multiple code
/// locations may want to manipulate/open the same popup, given an explicit id.
#[doc(alias = "BeginPopupContextVoid")]
pub fn begin_popup_context_void<Label: AsRef<str>>(
pub fn begin_popup_context_void_with_label<Label: AsRef<str>>(
&self,
str_id: Label,
) -> Option<PopupToken<'_>> {