Minor API tweaks
This commit is contained in:
parent
6b5da83642
commit
97bbc6f066
2 changed files with 7 additions and 1 deletions
|
@ -618,7 +618,7 @@ impl Region {
|
||||||
text_style: TextStyle,
|
text_style: TextStyle,
|
||||||
align: (Align, Align),
|
align: (Align, Align),
|
||||||
text_color: Option<Color>,
|
text_color: Option<Color>,
|
||||||
) {
|
) -> Vec2 {
|
||||||
let font = &self.fonts()[text_style];
|
let font = &self.fonts()[text_style];
|
||||||
let (text, text_size) = font.layout_multiline(text, std::f32::INFINITY);
|
let (text, text_size) = font.layout_multiline(text, std::f32::INFINITY);
|
||||||
|
|
||||||
|
@ -633,6 +633,7 @@ impl Region {
|
||||||
Align::Max => pos.y - text_size.y,
|
Align::Max => pos.y - text_size.y,
|
||||||
};
|
};
|
||||||
self.add_text(vec2(x, y), text_style, text, text_color);
|
self.add_text(vec2(x, y), text_style, text, text_color);
|
||||||
|
text_size
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_text(
|
pub fn add_text(
|
||||||
|
|
|
@ -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 {
|
pub fn contains(&self, p: Vec2) -> bool {
|
||||||
self.pos.x <= p.x
|
self.pos.x <= p.x
|
||||||
&& p.x <= self.pos.x + self.size.x
|
&& p.x <= self.pos.x + self.size.x
|
||||||
|
|
Loading…
Reference in a new issue