ryanmcgrath / cacao

Rust bindings for AppKit (macOS) and UIKit (iOS/tvOS). Experimental, but working!
MIT License
1.79k stars 65 forks source link

Method to access the layout anchors of a view #107

Closed Isaac-Leonard closed 9 months ago

Isaac-Leonard commented 9 months ago

I'd like to attempt to write some helper methods that can take a list of views that have top, leading, etc properties on them and create the layout constraints for them automatically, at least for simple cases. Write now this doesn't seem to be doable as those properties are not exposed in a way that can be accessed with generics. Would it be possible to add some sort of HasLayout trait that would possess methods like

fn get_top(&self)->LayoutAnchorY;

please. I'm happy to make a PR with this if needed.

Isaac-Leonard commented 9 months ago

Okay, I've got this trait working in my own code now with some basic functions that make use of it. Let me know if you'd like a pull request

ryanmcgrath commented 9 months ago

I'd be open to seeing the PR to better understand what you're after here, sure.

ryanmcgrath commented 9 months ago

(Closed this one but feel free to just have further discussion in the PR for less clutter~)