diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f1372b3e2..c401bd63dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,8 @@ You can find its changes [documented below](#060---2020-06-01). - Export `Image` and `ImageData` by default. ([#1011] by [@covercash2]) - Re-export `druid_shell::Scalable` under `druid` namespace. ([#1075] by [@ForLoveOfCats]) - `TextBox` now supports ctrl and shift hotkeys. ([#1076] by [@vkahl]) -- Added selection text color to textbox. ([#1093] by [@sysint64]) +- Selection text color to textbox. ([#1093] by [@sysint64]) +- `BoxConstraints::UNBOUNDED` constant. ([#1126] by [@danieldulaney]) - Close requests from the shell can now be intercepted ([#1118] by [@jneem]) ### Changed @@ -386,6 +387,7 @@ Last release without a changelog :( [#1118]: https://github.com/linebender/druid/pull/1118 [#1119]: https://github.com/linebender/druid/pull/1119 [#1120]: https://github.com/linebender/druid/pull/1120 +[#1126]: https://github.com/linebender/druid/pull/1120 [Unreleased]: https://github.com/linebender/druid/compare/v0.6.0...master [0.6.0]: https://github.com/linebender/druid/compare/v0.5.0...v0.6.0 diff --git a/druid/src/box_constraints.rs b/druid/src/box_constraints.rs index dedb912e45..c0af3f1bb5 100644 --- a/druid/src/box_constraints.rs +++ b/druid/src/box_constraints.rs @@ -41,6 +41,14 @@ pub struct BoxConstraints { } impl BoxConstraints { + /// An unbounded box constraints object. + /// + /// Can be satisfied by any nonnegative size. + pub const UNBOUNDED: BoxConstraints = BoxConstraints { + min: Size::ZERO, + max: Size::new(f64::INFINITY, f64::INFINITY), + }; + /// Create a new box constraints object. /// /// Create constraints based on minimum and maximum size. @@ -156,3 +164,16 @@ impl BoxConstraints { BoxConstraints::new(min, max) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn unbounded() { + assert!(!BoxConstraints::UNBOUNDED.is_width_bounded()); + assert!(!BoxConstraints::UNBOUNDED.is_height_bounded()); + + assert_eq!(BoxConstraints::UNBOUNDED.min(), Size::ZERO); + } +}