pub fn mouse_down(&mut self, pos: (usize, usize), asset: &mut Asset, context: &mut ScreenContext) -> bool {
        for atom_widget in &mut self.widgets {
            if atom_widget.mouse_down(pos, asset, context) {
                self.dirty = true;
                self.clicked = true;
                self.clicked_id = atom_widget.behavior_id.clone();
                return true;
            }
        }

        // Test widget resizing
        if context.contains_pos_for(pos, (0, self.size.1 - 20, 30, 20)) {
            self.drag_size = Some(self.size.clone());
            context.target_fps = 60;
            return true;
        }

        // Test region map
        if context.contains_pos_for(pos, self.region_rect) {

            let left_offset = (self.region_rect.2 % self.region_tile_size) / 2;
            let top_offset = (self.region_rect.3 % self.region_tile_size) / 2;

            let x = self.region_offset.0 + ((pos.0 - self.region_rect.0 - left_offset) / self.region_tile_size) as isize;
            let y = self.region_offset.1 + ((pos.1 - self.region_rect.1 - top_offset) / self.region_tile_size) as isize;
            //println!("{} {}", x, y);
            if let Some(region) = context.data.regions.get(&context.data.regions_ids[self.curr_region_index]) {
                self.clicked_region_id = Some((region.data.id.clone(), x, y));
            }
            return true;
        }
        false
    }
/// Check if one of the atom widgets was clicked
Check if one of the atom widgets was clicked
Check if one of the atom widgets was clicked
pub fn mouse_down(&mut self, pos: (usize, usize), asset: &mut Asset, context: &mut ScreenContext) -> bool {
        for atom_widget in &mut self.widgets {
            if atom_widget.mouse_down(pos, asset, context) {
                self.dirty = true;
                self.clicked = true;
                self.clicked_id = atom_widget.behavior_id.clone();
                return true;
            }
        }
        // Test widget resizing
        if context.contains_pos_for(pos, (0, self.size.1 - 20, 30, 20)) {
            self.drag_size = Some(self.size.clone());
            context.target_fps = 60;
            return true;
        }
        // Test region map
        if context.contains_pos_for(pos, self.region_rect) {
            let left_offset = (self.region_rect.2 % self.region_tile_size) / 2;
            let top_offset = (self.region_rect.3 % self.region_tile_size) / 2;
            let x = self.region_offset.0 + ((pos.0 - self.region_rect.0 - left_offset) / self.region_tile_size) as isize;
            let y = self.region_offset.1 + ((pos.1 - self.region_rect.1 - top_offset) / self.region_tile_size) as isize;
            //println!("{} {}", x, y);
            if let Some(region) = context.data.regions.get(&context.data.regions_ids[self.curr_region_index]) {
                self.clicked_region_id = Some((region.data.id.clone(), x, y));
            }
            return true;
        }
        false
    }
pub fn mouse_down ( & mut self , pos : ( usize , usize ) , asset : & mut Asset , context : & mut ScreenContext ) -> bool { for atom_widget in & mut self . widgets { if atom_widget . mouse_down ( pos , asset , context ) { self . dirty = true ; self . clicked = true ; self . clicked_id = atom_widget . behavior_id . clone ( ) ; return true ; } } // Test widget resizing if context . contains_pos_for ( pos , ( 0 , self . size . 1 - 20 , 30 , 20 ) ) { self . drag_size = Some ( self . size . clone ( ) ) ; context . target_fps = 60 ; return true ; } // Test region map if context . contains_pos_for ( pos , self . region_rect ) { let left_offset = ( self . region_rect . 2 % self . region_tile_size ) / 2 ; let top_offset = ( self . region_rect . 3 % self . region_tile_size ) / 2 ; let x = self . region_offset . 0 + ( ( pos . 0 - self . region_rect . 0 - left_offset ) / self . region_tile_size ) as isize ; let y = self . region_offset . 1 + ( ( pos . 1 - self . region_rect . 1 - top_offset ) / self . region_tile_size ) as isize ; //println!("{} {}", x, y); if let Some ( region ) = context . data . regions . get ( & context . data . regions_ids [ self . curr_region_index ] ) { self . clicked_region_id = Some ( ( region . data . id . clone ( ) , x , y ) ) ; } return true ; } false }
Check if one of the atom widgets was clicked
Check if one of the atom widgets was clicked
&mut self
pos
(usize, usize)
asset
&mut Asset
context
&mut ScreenContext
&mut self
pos
(usize, usize)
asset
&mut Asset
context
&mut ScreenContext