Пример #1
0
//! draws the element and its children
void ListBox::draw( gfx::Engine& painter )
{
  if ( !visible() )
		return;

  if( isFlag( drawBackground ) )
  {
    if( _d->background.valid() )
      painter.draw( _d->background, &absoluteClippingRectRef() );
    else
      painter.draw( _d->backgroundNb, absoluteRect().lefttop(), &absoluteClippingRectRef() );
  }

  Point scrollBarOffset( 0, -_d->scrollBar->value() );
  Rect frameRect = _itemsRect();
  frameRect += _d->margin.lefttop();
  frameRect.rbottom() = frameRect.top() + _d->itemHeight;
  const Point& widgetLeftup = absoluteRect().lefttop();

  Rect clipRect = absoluteClippingRectRef();
  clipRect.UpperLeftCorner += Point( 3, 3 );
  clipRect.LowerRightCorner -= Point( 3, 3 );

  for( unsigned int i = 0; i < _d->items.size();  i++ )
  {
    ListBoxItem& refItem = _d->items[ i ];

    int mnY = frameRect.bottom() - _d->scrollBar->value();
    int mxY = frameRect.top() - _d->scrollBar->value();

    mnY += std::max( 0, refItem.icon().height() - frameRect.height() );

    bool overBorder = (mnY < 0 && mxY < 0 ) || (mnY > (int)height() && mxY > (int)height() );
    if( !overBorder )
    {
      if( refItem.icon().isValid() )
      {
        _drawItemIcon( painter, refItem, widgetLeftup + frameRect.lefttop() + scrollBarOffset, &clipRect );
      }

      if( refItem.picture().isValid() )
      {
        _drawItemText( painter, refItem, widgetLeftup + frameRect.lefttop() + scrollBarOffset, &clipRect  );
      }

     /* if( !refItem.url().empty() )
      {
        Point r = frameRect.rightbottom();
        r += Point( 0, -_d->scrollBar->value() );
        //_d->background->fill( currentFont.color(), textRect + Point( 0, -_d->scrollBar->position() ) + refItem.offset() );
        Point offset = localToScreen( lefttop() );
        painter.drawLine( 0xff00ff00, r - Point( frameRect.width(), 0 ) + offset, r + offset );
      } */
    }

    frameRect += Point( 0, _d->itemHeight );
  }

	Widget::draw( painter );
}
Пример #2
0
void WalkerDebugInfo::showPath( WalkerPtr walker, gfx::Engine& engine, gfx::Camera* camera )
{
  Point camOffset = camera->offset();
  const Pathway& pathway = walker->pathway();

  const TilesArray& tiles = pathway.allTiles();

  Point pos = walker->mappos();
  if( pathway.isReverse() )
  {
    int rStart = pathway.length() - pathway.curStep();
    for( int step=rStart-1; step >= 0; step-- )
    {
      engine.drawLine(  0xff0000ff, pos + camOffset, tiles[ step ]->mappos() + camOffset + Point( 30, 0 ) );
      pos = tiles[ step ]->mappos() + Point( 30, 0 );
    }
  }
  else
  {
    for( unsigned int step=pathway.curStep()+1; step < tiles.size(); step++ )
    {
      Tile* tile = tiles[ step ];
      engine.drawLine(  0xff00ff00, pos + camOffset, tile->mappos() + camOffset + Point( 30, 0 ) );
      pos = tile->mappos() + Point( 30, tile->height() * 15 );
    }
  }
}
Пример #3
0
/* here will be helper functions for minimap generation */
void Menu::draw(gfx::Engine& painter)
{
    if( !visible() )
        return;

    if( _d->bg.batch.valid() )
        painter.draw( _d->bg.batch, &absoluteClippingRectRef() );
    else
        painter.draw( _d->bg.pics, absoluteRect().lefttop(), &absoluteClippingRectRef() );

    Widget::draw( painter );
}
Пример #4
0
void TopMenu::draw(gfx::Engine& engine )
{
  if( !visible() )
    return;

  _d->updateDate();

  if( _d->background.valid() )
    engine.draw( _d->background, &absoluteClippingRectRef() );
  else
    engine.draw( _d->backgroundNb, absoluteRect().lefttop(), &absoluteClippingRectRef() );

  MainMenu::draw( engine );
}
Пример #5
0
//! draws the element and its children
void GroupBox::draw(gfx::Engine& painter )
{
  if (!visible())
      return;

  if( _d->backgroundImage.isValid() )
  {
    painter.draw( _d->backgroundImage, absoluteRect().UpperLeftCorner, &absoluteClippingRectRef() );
  }
  else
  {
    painter.draw( _d->background, absoluteRect().UpperLeftCorner, &absoluteClippingRectRef() );
  }

  Widget::draw( painter );
}
Пример #6
0
//! draws the element and its children
void PushButton::draw( gfx::Engine& painter )
{
  if (!visible())
    return;

  __D_REF(_d,PushButton);
  // todo:	move sprite up and text down if the pressed state has a sprite
  //			  draw sprites for focused and mouse-over
  const ButtonState& state = _d.buttonStates[_d.state.current];

  if (isBodyVisible()) {
    DrawState pipe(painter, absoluteRect().lefttop(), &absoluteClippingRectRef());
    pipe.draw(state.background)
        .fallback(state.batch.body)
        .fallback(state.batch.fallback);
  }

  if (_d.text.visible && _d.text.picture.isValid()) {
    painter.draw(_d.text.picture, screenLeft(), screenTop(), &absoluteClippingRectRef());
  }

  drawIcon(painter);

  Widget::draw(painter);
}
Пример #7
0
void LegionTargetWindow::draw(gfx::Engine& engine )
{
  EmpireMapWindow::draw( engine );

  if( _d->location.x() > 0 )
  {
    engine.draw( _d->locationPic, _d->location + _offset() );
  }
}
Пример #8
0
void TopMenu::draw(gfx::Engine& engine )
{
  if( !visible() )
    return;

  _d->updateDate();

  engine.draw( _d->background, absoluteRect().UpperLeftCorner, &absoluteClippingRectRef() );

  MainMenu::draw( engine );
}
Пример #9
0
void PushButton::drawIcon(gfx::Engine& painter)
{
  __D_REF(_d,PushButton);
  const ButtonState& bstate = _d.buttonStates[ _d.state.current ];

  if (!bstate.icon.picture.isValid())
      return;

  Point pos = localToScreen(_d.iconRect).lefttop();
  MaskState lock(painter, _d.iconMask);
  painter.draw(bstate.icon.picture, pos + bstate.icon.offset);
}
Пример #10
0
void WalkerDebugInfo::showPath( WalkerPtr walker, gfx::Engine& engine, gfx::Camera* camera, NColor color )
{
  Point camOffset = camera->offset();
  const Pathway& pathway = walker->pathway();

  const TilesArray& tiles = pathway.allTiles();   

  NColor pathColor = color;

  if( color == 0)
  {
    if( walker->agressive() > 0 )
    {
      pathColor = DefaultColors::red;
    }
    else
    {
      pathColor = pathway.isReverse() ? DefaultColors::blue : DefaultColors::green;
    }
  }

  Point pos = walker->mappos();
  Point xOffset( tilemap::cellSize().width(), 0 );
  PointsArray points;
  if( pathway.isReverse() )
  {
    int rStart = pathway.length() - pathway.curStep();
    for( int step=rStart-1; step >= 0; step-- )
    {      
      pos = tiles[ step ]->mappos() + camOffset + xOffset;
      points.push_back( pos );
    }    
  }
  else
  {
    for( unsigned int step=pathway.curStep()+1; step < tiles.size(); step++ )
    {
      pos = tiles[ step ]->mappos() + camOffset + xOffset;
      points.push_back( pos );
    }
  }

  engine.drawLines( pathColor, points );
}
void WindowMessageStack::beforeDraw(gfx::Engine& painter)
{
  Widget::Widgets wds = children();
  unsigned int myWidth = width();
  int speed = std::max<int>( 20, 2 * myWidth / (painter.fps()+1) );

  for( auto widget : wds )
  {
    unsigned int wd = widget->width();
    if( wd != myWidth )
    {
      Point center = widget->center();
      widget->setWidth( math::clamp<unsigned int>( wd+speed, 0, myWidth ) );
      widget->setCenter( center );
    }
  }

  Widget::beforeDraw( painter );
}
Пример #12
0
void Console::draw( gfx::Engine& painter )
{
  if( !font().isValid() )
  {
    Widget::draw( painter );
    return;
  }

  if( visible() )															// render only if the console is visible
  {
    if( toggle_visible_ != NONE )
    {
      if( toggle_visible_ == DOWNLIGTH )
      {
        if (_opacity > 5) _opacity -= 9;
        else setVisible(false);
        _d->dirty = true;
      }
      else
      {
        if (_opacity < 0xff)	_opacity += 3;
        else toggle_visible_ = NONE;
        _d->dirty = true;
      }
    }

    Rect textRect, shellRect;										//we calculate where the message log shall be printed and where the prompt shall be printed
    calculatePrintRects(textRect,shellRect);

    if(_d->dirty)
    {
      Decorator::drawLines(_d->bg, ColorList::red, relativeRect().lines());
      _d->bg.fill(ColorList::blue);

      unsigned int maxLines, lineHeight;											//now, render the messages
      int fontHeight=0;
      if (!calculateLimits(maxLines,lineHeight,fontHeight))
      {
        return;
      }

      Rect lineRect( textRect.left(),						//calculate the line rectangle
                     textRect.top(),
                     textRect.right(),
                     textRect.bottom() + lineHeight);

      for (unsigned int index = 0; index < console_messages_.size(); index++)
      {
        unsigned int rindex = (_d->curIndex + index) % console_messages_.size();
        const std::string& line = console_messages_[rindex];
        font().draw(_d->bg, line, lineRect.lefttop(), false, false);
        lineRect += Point(0, lineHeight);						//update line rectangle
      }

      std::string shellText = "$>" + currentCommand_;

      font().draw( _d->bg, shellText, shellRect.lefttop(), false, false);	//draw the prompt string

      _d->dirty = false;
      _d->bg.update();
      _d->bg.setAlpha(_opacity/3*2);
    }

    painter.draw( _d->bg, absoluteRect().lefttop() );

    if( DateTime::elapsedTime() % 700 < 350 )
    {
      NColor color = ColorList::white;
      color.setAlpha(_opacity/2);
      painter.fillRect( color, Rect(0, 0, _d->commandCursorWidth,shellRect.height()*0.8)
                        +absoluteRect().leftbottom() + Point(_d->commandTextSize.width(), -shellRect.height()) );
    }
  }

  Widget::draw( painter );
}