Remove Rect::default() since there is no sensible default rectangle

This commit is contained in:
Emil Ernerfeldt 2020-10-10 08:03:38 +02:00
parent adec27a7dd
commit 2615d1bce1
3 changed files with 12 additions and 4 deletions

View file

@ -650,7 +650,7 @@ fn show_title_bar(
title_label,
title_galley,
title_rect,
rect: Default::default(), // Will be filled in later
rect: Rect::invalid(), // Will be filled in later
}
});

View file

@ -5,7 +5,7 @@ use crate::math::*;
/// A rectangular region of space.
///
/// Normally given in points, e.g. logical pixels.
#[derive(Clone, Copy, Default, Eq, PartialEq)]
#[derive(Clone, Copy, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Rect {
pub min: Pos2,
@ -30,6 +30,14 @@ impl Rect {
}
}
/// invalid, NAN filled Rect.
pub fn invalid() -> Self {
Self {
min: pos2(f32::NAN, f32::NAN),
max: pos2(f32::NAN, f32::NAN),
}
}
pub fn from_min_max(min: Pos2, max: Pos2) -> Self {
Rect { min, max }
}

View file

@ -1,6 +1,6 @@
use crate::*;
#[derive(Clone, Copy, Debug, Default)]
#[derive(Clone, Copy, Debug)]
pub struct Image {
texture_id: TextureId,
uv: Rect,
@ -15,8 +15,8 @@ impl Image {
texture_id,
uv: Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)),
desired_size,
bg_fill: Default::default(),
tint: color::WHITE,
..Default::default()
}
}