Patch a few small autolayout bugs - not a huge fan of the clone() in constraints but fine for now

This commit is contained in:
Ryan McGrath 2020-03-12 19:18:16 -07:00
parent 86980d7329
commit 3a89d8e5f5
No known key found for this signature in database
GPG key ID: 811674B62B666830
3 changed files with 19 additions and 2 deletions

View file

@ -27,7 +27,7 @@ impl LayoutAnchorX {
pub fn constraint_equal_to(&self, anchor_to: &LayoutAnchorX) -> LayoutConstraint { pub fn constraint_equal_to(&self, anchor_to: &LayoutAnchorX) -> LayoutConstraint {
match (&self.0, &anchor_to.0) { match (&self.0, &anchor_to.0) {
(Some(from), Some(to)) => LayoutConstraint::new(unsafe { (Some(from), Some(to)) => LayoutConstraint::new(unsafe {
msg_send![*from, constraintEqualToAnchor:&*to] msg_send![*from, constraintEqualToAnchor:&*to.clone()]
}), }),
_ => { panic!("Attempted to create horizontal constraints with an uninitialized anchor!"); } _ => { panic!("Attempted to create horizontal constraints with an uninitialized anchor!"); }

View file

@ -27,7 +27,8 @@ impl LayoutAnchorY {
pub fn constraint_equal_to(&self, anchor_to: &LayoutAnchorY) -> LayoutConstraint { pub fn constraint_equal_to(&self, anchor_to: &LayoutAnchorY) -> LayoutConstraint {
match (&self.0, &anchor_to.0) { match (&self.0, &anchor_to.0) {
(Some(from), Some(to)) => LayoutConstraint::new(unsafe { (Some(from), Some(to)) => LayoutConstraint::new(unsafe {
msg_send![*from, constraintEqualToAnchor:&*to] let b: id = msg_send![*from, constraintEqualToAnchor:&*to.clone()];
b
}), }),
_ => { panic!("Attempted to create vertical constraints with an uninitialized anchor!"); } _ => { panic!("Attempted to create vertical constraints with an uninitialized anchor!"); }

View file

@ -162,6 +162,22 @@ impl<T> View<T> where T: ViewController + 'static {
self.objc_controller.register_for_dragged_types(types); self.objc_controller.register_for_dragged_types(types);
} }
pub fn top(&self) -> &LayoutAnchorY {
&self.objc_controller.top
}
pub fn leading(&self) -> &LayoutAnchorX {
&self.objc_controller.leading
}
pub fn trailing(&self) -> &LayoutAnchorX {
&self.objc_controller.trailing
}
pub fn bottom(&self) -> &LayoutAnchorY {
&self.objc_controller.bottom
}
pub fn width(&self) -> &LayoutAnchorDimension { pub fn width(&self) -> &LayoutAnchorDimension {
&self.objc_controller.width &self.objc_controller.width
} }