Minor API tweaks

This commit is contained in:
Emil Ernerfeldt 2019-03-16 15:14:22 +01:00
parent 6b5da83642
commit 97bbc6f066
2 changed files with 7 additions and 1 deletions

View file

@ -618,7 +618,7 @@ impl Region {
text_style: TextStyle,
align: (Align, Align),
text_color: Option<Color>,
) {
) -> 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(

View file

@ -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