Add LinearLayout::get_child and get_child_mut

This commit is contained in:
Alexandre Bury 2018-01-17 11:07:04 -08:00
parent cf0392db64
commit c3f2e9ad9c

View File

@ -160,6 +160,16 @@ impl LinearLayout {
LinearLayout::new(direction::Orientation::Horizontal) LinearLayout::new(direction::Orientation::Horizontal)
} }
/// Returns a reference to a child.
pub fn get_child(&self, i: usize) -> Option<&View> {
self.children.get(i).map(|child| &*child.view)
}
/// Returns a mutable reference to a child.
pub fn get_child_mut(&mut self, i: usize) -> Option<&mut View> {
self.children.get_mut(i).map(|child| &mut *child.view)
}
// If the cache can be used, return the cached size. // If the cache can be used, return the cached size.
// Otherwise, return None. // Otherwise, return None.
fn get_cache(&self, req: Vec2) -> Option<Vec2> { fn get_cache(&self, req: Vec2) -> Option<Vec2> {