1 use crate::widgets::{HorizontalPlacement, VerticalPlacement, Widget}; 2 3 pub trait Transform: Sized + Widget { 4 fn reposition(&self, x: i32, y: i32) -> &Self { 5 let mut position = self.local_position().get(); 6 let mut rect = self.rect().get(); 7 position.x = x; 8 position.y = y; 9 rect.x = x; 10 rect.y = y; 11 self.local_position().set(position); 12 self.rect().set(rect); 13 self.arrange(); 14 self 15 } 16 17 fn resize(&self, width: u32, height: u32) -> &Self { 18 let mut rect = self.rect().get(); 19 rect.width = width; 20 rect.height = height; 21 self.rect().set(rect); 22 self.arrange(); 23 self 24 } 25 26 fn placement( 27 &self, 28 vertical_placement: VerticalPlacement, 29 horizontal_placement: HorizontalPlacement, 30 ) -> &Self { 31 self.vertical_placement().set(vertical_placement); 32 self.horizontal_placement().set(horizontal_placement); 33 self.arrange(); 34 self 35 } 36 } 37