diff --git a/emigui/src/layout.rs b/emigui/src/layout.rs index 72001006..8be6ec3f 100644 --- a/emigui/src/layout.rs +++ b/emigui/src/layout.rs @@ -618,7 +618,7 @@ impl Region { text_style: TextStyle, align: (Align, Align), text_color: Option, - ) { + ) -> Vec2 { let font = &self.fonts()[text_style]; let (text, text_size) = font.layout_multiline(text, std::f32::INFINITY); @@ -633,6 +633,7 @@ impl Region { Align::Max => pos.y - text_size.y, }; self.add_text(vec2(x, y), text_style, text, text_color); + text_size } pub fn add_text( diff --git a/emigui/src/math.rs b/emigui/src/math.rs index fd8ddc52..446dc9cc 100644 --- a/emigui/src/math.rs +++ b/emigui/src/math.rs @@ -117,6 +117,11 @@ impl Rect { } } + /// Expand by this much in each direction + pub fn expand(self, amnt: f32) -> Self { + Rect::from_center_size(self.center(), self.size() + 2.0 * vec2(amnt, amnt)) + } + pub fn contains(&self, p: Vec2) -> bool { self.pos.x <= p.x && p.x <= self.pos.x + self.size.x