/// Insert a child at a given render list position.
///
/// If the child is already a child of another container, you must remove
/// it from that container before calling this method. If it's already a
/// member of this container, do not remove it, as we will need to take
/// care of that. In that case, note that all children after the old
/// position will be shifted back by one, which must be taken into account
/// when calculating future insertion IDs.
///
/// `parent` should be the display object that owns this container.
///
/// All children at or after the given ID will be shifted down in the
/// render list. The child will *not* be put onto the depth list.
Insert a child at a given render list position.
If the child is already a child of another container, you must remove
it from that container before calling this method. If it's already a
member of this container, do not remove it, as we will need to take
care of that. In that case, note that all children after the old
position will be shifted back by one, which must be taken into account
when calculating future insertion IDs.

`parent` should be the display object that owns this container.

All children at or after the given ID will be shifted down in the
render list. The child will *not* be put onto the depth list.
Insert a child at a given render list position . If the child is already a child of another container you must remove it from that container before calling this method . If it ' s already a member of this container do not remove it as we will need to take care of that . In that case note that all children after the old position will be shifted back by one which must be taken into account when calculating future insertion IDs . ` parent ` should be the display object that owns this container . All children at or after the given ID will be shifted down in the render list . The child will * not * be put onto the depth list .
pub fn insert_at_id(
        &mut self,
        context: &mut UpdateContext<'_, 'gc, '_>,
        child: DisplayObject<'gc>,
        id: usize,
    ) {
        if let Some(old_id) = self
            .render_list
            .iter()
            .position(|x| DisplayObject::ptr_eq(*x, child))
        {
            match old_id.cmp(&id) {
                Ordering::Less if id < self.render_list.len() => {
                    self.render_list[old_id..=id].rotate_left(1)
                }
                Ordering::Less => self.render_list[old_id..id].rotate_left(1),
                Ordering::Greater if old_id < self.render_list.len() => {
                    self.render_list[id..=old_id].rotate_right(1)
                }
                Ordering::Greater => self.render_list[id..old_id].rotate_right(1),
                Ordering::Equal => {}
            }
        } else {
            self.render_list.insert(id, child);
            self.add_child_to_exec_list(context.gc_context, child);
        }
    }
pub fn insert_at_id ( & mut self , context : & mut UpdateContext < ' _ , ' gc , ' _ > , child : DisplayObject < ' gc > , id : usize , ) { if let Some ( old_id ) = self . render_list . iter ( ) . position ( | x | DisplayObject :: ptr_eq ( * x , child ) ) { match old_id . cmp ( & id ) { Ordering :: Less if id < self . render_list . len ( ) => { self . render_list [ old_id ..= id ] . rotate_left ( 1 ) } Ordering :: Less => self . render_list [ old_id .. id ] . rotate_left ( 1 ) , Ordering :: Greater if old_id < self . render_list . len ( ) => { self . render_list [ id ..= old_id ] . rotate_right ( 1 ) } Ordering :: Greater => self . render_list [ id .. old_id ] . rotate_right ( 1 ) , Ordering :: Equal => { } } } else { self . render_list . insert ( id , child ) ; self . add_child_to_exec_list ( context . gc_context , child ) ; } }
Insert a child at a given render list position.
Insert a child at a given render list position .
&mut self
context
&mut UpdateContext<'_, 'gc, '_>
child
DisplayObject<'gc>
id
usize