From 71ae5673b8dba24333c8c6a5ebe197d04b24f5a3 Mon Sep 17 00:00:00 2001 From: Joonas Javanainen Date: Sat, 13 Jul 2019 10:38:14 +0300 Subject: [PATCH] Add set_next_item_width and calc_item_width --- src/stacks.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/stacks.rs b/src/stacks.rs index d0c59d1..6c3a96f 100644 --- a/src/stacks.rs +++ b/src/stacks.rs @@ -228,6 +228,19 @@ impl<'ui> Ui<'ui> { unsafe { sys::igPushItemWidth(item_width) }; ItemWidthStackToken { _ui: PhantomData } } + /// Sets the width of the next item. + /// + /// - `> 0.0`: width is `item_width` pixels + /// - `= 0.0`: default to ~2/3 of window width + /// - `< 0.0`: `item_width` pixels relative to the right of window (-1.0 always aligns width to + /// the right side) + pub fn set_next_item_width(&self, item_width: f32) { + unsafe { sys::igSetNextItemWidth(item_width) }; + } + /// Returns the width of the item given the pushed settings and the current cursor position + pub fn calc_item_width(&self) -> f32 { + unsafe { sys::igCalcItemWidth() } + } /// Changes the text wrapping position by pushing a change to the text wrapping position stack. /// /// - `> 0.0`: wrap at `wrap_pos_x` position in window local space