Ejemplo n.º 1
0
void Gui::render(  )
{
  List<UpdateWidget*>& l = Widget::updatedWidgets();
  if ( l.count() <= 0 ) return;
  int i = l.count() - 1;
  Widget* o = NULL;
  List<Widget*> tmpL;
  l.sort( &objectsListSortCallback );
  while( i >= 0 ){

    o = l.get( i )->o;
    Rect r = l.get( i )->r;

    if ( pFgFrame != NULL )
      fgFrame().getWidgetsInRect( tmpL, r );
    if ( pTopFrame != NULL )
      topFrame().getWidgetsInRect( tmpL, r );

    tmpL.sort( &objectListSortCallback );

    int i2 = 0;
    bool skip = false;
//    int before = tmpL.count();

    while ( (i2 < tmpL.count()) && ( o != NULL ) ) {

      Widget* o2 = tmpL.get( i2 );
			Rect r2( o2->absoluteXPos(), o2->absoluteYPos(), o2->width(), o2->height() );
      if ( o2->border() != NULL ) {
        if ( o2->border()->drawmode() != DM_OPAQUE )
          r2.applyBorder( o2->border() );
      }
			if ( (r2.encloses( r )) && ( o2->drawmode() == DM_OPAQUE ) && ( o2->visible() ) ) {
        if ( o2->zIndex() > o->zIndex() ) {

          skip = true;
          break;
        } else {
          while ( i2+1 < tmpL.count() ) {

            tmpL.remove( i2+1 );
          }
          break;
        }
      }
      i2++;
    }


    if ( !skip ) {

      for( int i2 = tmpL.count() - 1; i2 >= 0; i2-- ){

        Rect r2 = Rect( tmpL.get( i2 )->absoluteXPos(),
                        tmpL.get( i2 )->absoluteYPos(),
                        tmpL.get( i2 )->width(), tmpL.get( i2 )->height() );
        r2.crop( r );

        screen().pushClipRect( r2 );
        screen().pushClipRect( tmpL.get( i2 )->getClipRect() );
        screen().setRelativePoint( tmpL.get( i2 )->absoluteXPos(), tmpL.get( i2 )->absoluteYPos() );

        tmpL.get( i2 )->renderBorder( screen() );

        screen().setRelativePoint( tmpL.get( i2 )->absoluteXPos() + tmpL.get( i2 )->borderLeft(),
                                  tmpL.get( i2 )->absoluteYPos() + tmpL.get( i2 )->borderTop() );
        Rect r3( r2.left - tmpL.get( i2 )->absoluteXPos() - tmpL.get( i2 )->borderLeft(), r2.top - tmpL.get( i2 )->absoluteYPos() - tmpL.get( i2 )->borderTop(), r2.width, r2.height );
        tmpL.get( i2 )->render( screen(), r3 );

        screen().popClipRect();
        screen().popClipRect();
        screen().setRelativePoint( 0, 0 );

      }

      for( int i = 0; i < pPopups.count(); i++ ) {
        Popup* p = pPopups.get( i );
        r.crop( p->getRect() );
        if ( r.area() > 0 ) {
          Rect r = p->getRect();
          r.crop( r );
          p->render( r );
        }
      }
    } else {

    }
    tmpL.clear();
    i--;
  }

  Widget::clearUpdatedWidgets();

}