-- The change in which a new piece is placed in the
-- design room.

class 
  PLACEMENT

inherit
  CHANGE

creation
  make

feature{NONE}

  make( is_fg : BOOLEAN ; p : palette_piece ; c : DESIGN_CELL ) is
  do
    is_foreground := is_fg
    piece := p
    cell := c
  end

feature

  is_foreground : BOOLEAN
  -- Is the piece that was moved a foreground piece?

  piece : PALETTE_PIECE
  -- Palette piece associated with the piece that was placed.

  cell : DESIGN_CELL
  -- Cell in which the piece was placed.

  undo is
  -- Remove the piece from the room
  require else
    is_foreground implies cell.foreground_piece_exists
    not is_foreground implies cell.background_piece_exists
  do
     if is_foreground then
       cell.foreground_piece.return
    else
       cell.background_piece.return
    end
  end

  redo is
  -- Place a new design piece in the cell.
  require else
    is_foreground implies not cell.foreground_piece_exists 
    not is_foreground implies not cell.background_piece_exists 
  do
     piece.target.accept( piece, cell )
  end

end 
