mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 21:48:36 +00:00
Replace old nonUDT2 function variants
This commit is contained in:
parent
a69d856163
commit
290429bd12
@ -21,7 +21,9 @@ impl<'ui> Ui<'ui> {
|
||||
///
|
||||
/// Useful for drawing custom shapes with the draw list API.
|
||||
pub fn font_tex_uv_white_pixel(&self) -> [f32; 2] {
|
||||
unsafe { sys::igGetFontTexUvWhitePixel_nonUDT2().into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetFontTexUvWhitePixel(&mut out) };
|
||||
out.into()
|
||||
}
|
||||
/// Sets the font scale of the current window
|
||||
pub fn set_window_font_scale(&self, scale: f32) {
|
||||
|
||||
@ -126,14 +126,18 @@ impl<'ui> Ui<'ui> {
|
||||
}
|
||||
/// Returns the mouse position backed up at the time of opening a popup
|
||||
pub fn mouse_pos_on_opening_current_popup(&self) -> [f32; 2] {
|
||||
unsafe { sys::igGetMousePosOnOpeningCurrentPopup_nonUDT2().into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetMousePosOnOpeningCurrentPopup(&mut out) };
|
||||
out.into()
|
||||
}
|
||||
/// Returns the delta from the initial clicking position.
|
||||
///
|
||||
/// This is locked and returns [0.0, 0.0] until the mouse has moved past the global distance
|
||||
/// threshold (`io.mouse_drag_threshold`).
|
||||
pub fn mouse_drag_delta(&self, button: MouseButton) -> [f32; 2] {
|
||||
unsafe { sys::igGetMouseDragDelta_nonUDT2(button as i32, -1.0).into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetMouseDragDelta(&mut out, button as i32, -1.0) };
|
||||
out.into()
|
||||
}
|
||||
/// Returns the delta from the initial clicking position.
|
||||
///
|
||||
@ -141,7 +145,9 @@ impl<'ui> Ui<'ui> {
|
||||
/// If the given threshold is invalid or negative, the global distance threshold is used
|
||||
/// (`io.mouse_drag_threshold`).
|
||||
pub fn mouse_drag_delta_with_threshold(&self, button: MouseButton, threshold: f32) -> [f32; 2] {
|
||||
unsafe { sys::igGetMouseDragDelta_nonUDT2(button as i32, threshold).into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetMouseDragDelta(&mut out, button as i32, threshold) };
|
||||
out.into()
|
||||
}
|
||||
/// Resets the current delta from initial clicking position.
|
||||
pub fn reset_mouse_drag_delta(&self, button: MouseButton) {
|
||||
|
||||
@ -97,7 +97,9 @@ impl<'ui> Ui<'ui> {
|
||||
}
|
||||
/// Returns the cursor position (in window coordinates)
|
||||
pub fn cursor_pos(&self) -> [f32; 2] {
|
||||
unsafe { sys::igGetCursorPos_nonUDT2().into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetCursorPos(&mut out) };
|
||||
out.into()
|
||||
}
|
||||
/// Sets the cursor position (in window coordinates).
|
||||
///
|
||||
@ -107,13 +109,17 @@ impl<'ui> Ui<'ui> {
|
||||
}
|
||||
/// Returns the initial cursor position (in window coordinates)
|
||||
pub fn cursor_start_pos(&self) -> [f32; 2] {
|
||||
unsafe { sys::igGetCursorStartPos_nonUDT2().into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetCursorStartPos(&mut out) };
|
||||
out.into()
|
||||
}
|
||||
/// Returns the cursor position (in absolute screen coordinates).
|
||||
///
|
||||
/// This is especially useful for drawing, as the drawing API uses screen coordinates.
|
||||
pub fn cursor_screen_pos(&self) -> [f32; 2] {
|
||||
unsafe { sys::igGetCursorScreenPos_nonUDT2().into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetCursorScreenPos(&mut out) };
|
||||
out.into()
|
||||
}
|
||||
/// Sets the cursor position (in absolute screen coordinates)
|
||||
pub fn set_cursor_screen_pos(&self, pos: [f32; 2]) {
|
||||
|
||||
@ -466,15 +466,17 @@ impl<'ui> Ui<'ui> {
|
||||
hide_text_after_double_hash: bool,
|
||||
wrap_width: f32,
|
||||
) -> [f32; 2] {
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe {
|
||||
sys::igCalcTextSize_nonUDT2(
|
||||
sys::igCalcTextSize(
|
||||
&mut out,
|
||||
text.as_ptr(),
|
||||
std::ptr::null(),
|
||||
hide_text_after_double_hash,
|
||||
wrap_width,
|
||||
)
|
||||
.into()
|
||||
}
|
||||
};
|
||||
out.into()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
12
src/utils.rs
12
src/utils.rs
@ -82,15 +82,21 @@ impl<'ui> Ui<'ui> {
|
||||
}
|
||||
/// Returns the upper-left bounding rectangle of the last item (in screen coordinates)
|
||||
pub fn item_rect_min(&self) -> [f32; 2] {
|
||||
unsafe { sys::igGetItemRectMin_nonUDT2().into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetItemRectMin(&mut out) }
|
||||
out.into()
|
||||
}
|
||||
/// Returns the lower-right bounding rectangle of the last item (in screen coordinates)
|
||||
pub fn item_rect_max(&self) -> [f32; 2] {
|
||||
unsafe { sys::igGetItemRectMax_nonUDT2().into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetItemRectMax(&mut out) }
|
||||
out.into()
|
||||
}
|
||||
/// Returns the size of the last item
|
||||
pub fn item_rect_size(&self) -> [f32; 2] {
|
||||
unsafe { sys::igGetItemRectSize_nonUDT2().into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetItemRectSize(&mut out) }
|
||||
out.into()
|
||||
}
|
||||
/// Allows the last item to be overlapped by a subsequent item.
|
||||
///
|
||||
|
||||
@ -5,23 +5,31 @@ use crate::Ui;
|
||||
impl<'ui> Ui<'ui> {
|
||||
/// Returns the current content boundaries (in *window coordinates*)
|
||||
pub fn content_region_max(&self) -> [f32; 2] {
|
||||
unsafe { sys::igGetContentRegionMax_nonUDT2().into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetContentRegionMax(&mut out) };
|
||||
out.into()
|
||||
}
|
||||
/// Equal to `ui.content_region_max()` - `ui.cursor_pos()`
|
||||
pub fn content_region_avail(&self) -> [f32; 2] {
|
||||
unsafe { sys::igGetContentRegionAvail_nonUDT2().into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetContentRegionAvail(&mut out) };
|
||||
out.into()
|
||||
}
|
||||
/// Content boundaries min (in *window coordinates*).
|
||||
///
|
||||
/// Roughly equal to [0.0, 0.0] - scroll.
|
||||
pub fn window_content_region_min(&self) -> [f32; 2] {
|
||||
unsafe { sys::igGetWindowContentRegionMin_nonUDT2().into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetWindowContentRegionMin(&mut out) };
|
||||
out.into()
|
||||
}
|
||||
/// Content boundaries max (in *window coordinates*).
|
||||
///
|
||||
/// Roughly equal to [0.0, 0.0] + size - scroll.
|
||||
pub fn window_content_region_max(&self) -> [f32; 2] {
|
||||
unsafe { sys::igGetWindowContentRegionMax_nonUDT2().into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetWindowContentRegionMax(&mut out) };
|
||||
out.into()
|
||||
}
|
||||
pub fn window_content_region_width(&self) -> f32 {
|
||||
unsafe { sys::igGetWindowContentRegionWidth() }
|
||||
|
||||
@ -140,11 +140,15 @@ impl<'ui> Ui<'ui> {
|
||||
}
|
||||
/// Returns the position of the current window (in screen space)
|
||||
pub fn window_pos(&self) -> [f32; 2] {
|
||||
unsafe { sys::igGetWindowPos_nonUDT2().into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetWindowPos(&mut out) };
|
||||
out.into()
|
||||
}
|
||||
/// Returns the size of the current window
|
||||
pub fn window_size(&self) -> [f32; 2] {
|
||||
unsafe { sys::igGetWindowSize_nonUDT2().into() }
|
||||
let mut out = sys::ImVec2::zero();
|
||||
unsafe { sys::igGetWindowSize(&mut out) };
|
||||
out.into()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user