From d820d9b7ca2efdb66f526c71525b16c8b00454ae Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Tue, 15 Jul 2014 13:56:47 -0700 Subject: [PATCH] Convert static Layer methods into instance methods It is possible to call methods directly on types contained in Rc<...> containers, so these methods do not have to be static. --- layers.rs | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/layers.rs b/layers.rs index 12e8c13..7b9b98d 100644 --- a/layers.rs +++ b/layers.rs @@ -27,7 +27,7 @@ pub struct Layer { pub tiles: RefCell>>, pub transform: RefCell>, pub bounds: RefCell>, - tile_size: uint, + pub tile_size: uint, pub extra_data: RefCell, tile_grid: RefCell, } @@ -49,37 +49,33 @@ impl Layer { self.children.borrow_mut() } - pub fn add_child(this: Rc>, new_child: Rc>) { - this.children().push(new_child); + pub fn add_child(&self, new_child: Rc>) { + self.children().push(new_child); } - pub fn tile_size(this: Rc>) -> uint { - this.tile_size - } - - pub fn get_tile_rects_page(this: Rc>, window: Rect, scale: f32) -> (Vec, Vec>) { - let mut tile_grid = this.tile_grid.borrow_mut(); + pub fn get_tile_rects_page(&self, window: Rect, scale: f32) -> (Vec, Vec>) { + let mut tile_grid = self.tile_grid.borrow_mut(); (tile_grid.get_buffer_requests_in_rect(window, scale), tile_grid.take_unused_tiles()) } - pub fn resize(this: Rc>, new_size: Size2D) { - this.bounds.borrow_mut().size = new_size; + pub fn resize(&self, new_size: Size2D) { + self.bounds.borrow_mut().size = new_size; } - pub fn do_for_all_tiles(this: Rc>, f: |&Box|) { - this.tile_grid.borrow().do_for_all_tiles(f); + pub fn do_for_all_tiles(&self, f: |&Box|) { + self.tile_grid.borrow().do_for_all_tiles(f); } - pub fn add_tile_pixel(this: Rc>, tile: Box) { - this.tile_grid.borrow_mut().add_tile(tile); + pub fn add_tile_pixel(&self, tile: Box) { + self.tile_grid.borrow_mut().add_tile(tile); } - pub fn collect_unused_tiles(this: Rc>) -> Vec> { - this.tile_grid.borrow_mut().take_unused_tiles() + pub fn collect_unused_tiles(&self) -> Vec> { + self.tile_grid.borrow_mut().take_unused_tiles() } - pub fn collect_tiles(this: Rc>) -> Vec> { - this.tile_grid.borrow_mut().collect_tiles() + pub fn collect_tiles(&self) -> Vec> { + self.tile_grid.borrow_mut().collect_tiles() } pub fn flush_pending_buffer_requests(&self) -> (Vec, f32) {