Merge pull request #181 from malikolivier/wrap-PushTextWrapPos

[Ui] Add with_text_wrap_pos
This commit is contained in:
Malik Olivier Boussejra 2018-11-27 07:12:15 +09:00 committed by GitHub
commit f994d71461
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -2,6 +2,10 @@
## [Unreleased]
### Added
- `Ui::with_test_wrap_pos`
### Changed
- Upgrade to cimgui 1.65.2 / imgui 1.65. **This is a very big update, so there

View File

@ -827,6 +827,19 @@ impl<'ui> Ui<'ui> {
sys::igTextWrapped(fmt_ptr(), text.as_ptr());
}
}
/// Set word-wrapping for `text_*()` commands.
/// - `< 0.0`: no wrapping;
/// - `= 0.0`: wrap to end of window (or column);
/// - `> 0.0`: wrap at `wrap_pos_x` position in window local space
pub fn with_text_wrap_pos<F: FnOnce()>(&self, wrap_pos_x: f32, f: F) {
unsafe {
sys::igPushTextWrapPos(wrap_pos_x);
}
f();
unsafe {
sys::igPopTextWrapPos();
}
}
pub fn label_text<'p>(&self, label: &'p ImStr, text: &'p ImStr) {
unsafe {
sys::igLabelText(label.as_ptr(), fmt_ptr(), text.as_ptr());