Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ You can find its changes [documented below](#060---2020-06-01).
- 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])
- Added `BoxConstraints::UNBOUNDED` constant. ([#1126] by [@danieldulaney])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The links must be added manually, see CONTRIBUTING.md.
Also, the "Added" prefix in the previous entry should not be there, nor should this entry have one.


### Changed

Expand Down
21 changes: 21 additions & 0 deletions druid/src/box_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
}