bool Place(Content<_T> content)
        {
            Sort();

            for( Coord::List::iterator itor = topLefts.begin(); itor != topLefts.end(); itor++ )
            {
                content.coord = *itor;

                if( Fits( content ) )
                {
                    Use( content );
                    topLefts.erase( itor );
                    return true;
                }
            }

            return false; // yvt: BitmapAtlasGenerator doesn't support rotated contents.

            // EXPERIMENTAL - TRY ROTATED?
        //    content.Rotate();
        //    for(Coord::List::iterator itor = topLefts.begin(); itor != topLefts.end(); itor++)
        //    {
        //        content.coord = *itor;

        //        if( Fits( content ) )
        //        {
        //            Use( content );
        //            topLefts.erase( itor );
        //            return true;
        //        }
        //    }
        //    ////////////////////////////////

        //    return false;
        }
Exemple #2
0
 bool Use(const Content<_T> &content) {
  
   const Size  &size = content.size;
   const Coord &coord = content.coord;
   
   topLefts.push_front	( Coord( coord.x + size.w, coord.y          ) );
   topLefts.push_back	( Coord( coord.x         , coord.y + size.h ) );
   
   contentVector.push_back( content );
   
   needToSort = true;
   
   return true;
 }
Exemple #3
0
 Canvas(int w, int h)
   : needToSort(false),
     w(w),
     h(h)
 {  
   topLefts.push_back( Coord(0,0) );
 }
Exemple #4
0
 void Sort() {
   
   if(!needToSort)
     return;
 
   topLefts.sort(TopToBottomLeftToRightSort());
   
   needToSort = false;
 }
Exemple #5
0
  bool Place(Content<_T> content) {
     
    Sort();
    
    for( Coord::List::iterator itor = topLefts.begin(); itor != topLefts.end(); itor++ ) {
      
      content.coord = *itor;
      
      if( Fits( content ) ) {
	
	Use( content );
	topLefts.erase( itor );
	return true;
      }
    }
    
    // EXPERIMENTAL - TRY ROTATED?
    content.Rotate();
    for( Coord::List::iterator itor = topLefts.begin(); itor != topLefts.end(); itor++ ) {
      
      content.coord = *itor;
      
      if( Fits( content ) ) {
	
	Use( content );
	topLefts.erase( itor );
	return true;
      }
    }
    ////////////////////////////////
    
    
    return false;
  }