Example #1
0
void zerokernel::Checkbox::render()
{
    if (option && *option)
    {
        renderBorder(*color_border);
        auto cb = bb.getContentBox();
        if (**option)
            draw::Rectangle(cb.x, cb.y, cb.width, cb.height, *color_checked);
        else if (isHovered())
            draw::Rectangle(cb.x, cb.y, cb.width, cb.height, *color_hover);
    }
    else
    {
        renderBorder(*style::colors::error);
    }
}
Example #2
0
void GuiTextEditCtrl::onRender( Point2I offset, const RectI &updateRect )
{
   RectI ctrlRect( offset, getExtent() );

   //if opaque, fill the update rect with the fill color
   if ( mProfile->mOpaque )
   {
      if ( !mTextValid )
         GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColorERR );
      else if ( isFirstResponder() )
         GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColorHL );
      else
         GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColor );
   }

   //if there's a border, draw the border
   if ( mProfile->mBorder )
   {
      renderBorder( ctrlRect, mProfile );
      if ( !mTextValid )
         GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColorERR );
   }

   drawText( ctrlRect, isFirstResponder() );
}
void GuiConsoleTextCtrl::onRender( Point2I offset, const RectI &updateRect )
{
   RectI ctrlRect( offset, getExtent() );

   // if opaque, fill the update rect with the fill color
   if ( mProfile->mOpaque )
      GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColor );

   // if there's a border, draw the border
   if ( mProfile->mBorder )
      renderBorder( ctrlRect, mProfile );

   // If we have text to render.
   if ( mResult.isNotEmpty() )
   {
      GFont *font = mProfile->mFont;      
      
      GFX->getDrawUtil()->setBitmapModulation( mProfile->mFontColor );

      for ( U32 i = 0; i < mLineLen.size(); i++ )
      {      
         Point2I tempOffset = offset; 
         tempOffset += mProfile->mTextOffset;
         tempOffset.y += i * font->getHeight();
         
         const UTF8 *line = mResult.c_str() + mStartLineOffset[i];
         U32 lineLen = mLineLen[i];
         GFX->getDrawUtil()->drawTextN( font, tempOffset, line, lineLen, mProfile->mFontColors );
      }
   }

   // render the child controlsmResult
   renderChildControls(offset, updateRect);
}
Example #4
0
QImage GLImageDrawable::applyBorder(const QImage& sourceImg)
{
	if(renderBorder() && 
	   m_borderWidth > 0.001)
	{
		QSizeF originalSizeWithBorder = sourceImg.size();

		double x = m_borderWidth * 2;
		originalSizeWithBorder.rwidth()  += x;
		originalSizeWithBorder.rheight() += x;
		
		QImage cache(originalSizeWithBorder.toSize(),QImage::Format_ARGB32_Premultiplied);
		memset(cache.scanLine(0),0,cache.byteCount());
		QPainter p(&cache);
		
		int bw = (int)(m_borderWidth / 2);
		p.drawImage(bw,bw,sourceImg); //drawImage(bw,bw,sourceImg);
		p.setPen(QPen(m_borderColor,m_borderWidth));
		p.drawRect(sourceImg.rect().adjusted(bw,bw,bw,bw)); //QRectF(sourceImg.rect()).adjusted(-bw,-bw,bw,bw));
		
		m_imageWithBorder = cache;
		return cache;
	}
	
	if(!m_imageWithBorder.isNull())
		m_imageWithBorder = QImage();
	
	return sourceImg;
}
Example #5
0
void ColorSelector::render()
{
    renderBorder(variable ? *border : *style::colors::error);
    if (variable)
    {
        auto pb = bb.getContentBox();
        draw::Rectangle(pb.left(), pb.top(), pb.width, pb.height, **variable);
    }
}
Example #6
0
void zerokernel::WindowCloseButton::render()
{
    auto cb = bb.getBorderBox();
    if (isHovered())
        draw::Rectangle(cb.left(), cb.top(), cb.width, cb.height - 1, *background_hover);
    // glez::draw::line(cb.left(), cb.top(), 0, cb.height, *color_border, 1);
    renderBorder(*color_border);
    draw::RectangleTextured(cb.x + 1, cb.y, cb.width, cb.height, colors::white, cross, 0, 0, 14, 14, 0);
}
Example #7
0
void GuiRolloutCtrl::onRender( Point2I offset, const RectI &updateRect )
{
   if( !mProfile || mProfile->mFont == NULL )
      return;

   // Calculate actual world bounds for rendering
   RectI worldBounds( offset, getExtent() );

   // if opaque, fill the update rect with the fill color
   if ( mProfile->mOpaque )
      GFX->getDrawUtil()->drawRectFill( worldBounds, mProfile->mFillColor );

   if ( mProfile->mBitmapArrayRects.size() >= NumBitmaps )
   {
      GFX->getDrawUtil()->clearBitmapModulation();

      // Draw Rollout From Skin
      if ( !mIsExpanded && !mIsAnimating )
         renderFixedBitmapBordersFilled( worldBounds, 1, mProfile );
      else if ( mHideHeader )
         renderSizableBitmapBordersFilledIndex( worldBounds, MidPageLeft, mProfile );
      else
         renderSizableBitmapBordersFilledIndex( worldBounds, TopLeftHeader, mProfile );
   }

   if ( !(mIsExpanded && mHideHeader ) )
   {
      // Draw Caption ( Vertically Centered )
      ColorI currColor;
      GFX->getDrawUtil()->getBitmapModulation( &currColor );
      Point2I textPosition = mHeader.point + offset + mProfile->mTextOffset;
      GFX->getDrawUtil()->setBitmapModulation( mProfile->mFontColor );
      renderJustifiedText( textPosition, mHeader.extent, mCaption );
      GFX->getDrawUtil()->setBitmapModulation( currColor );
   }

   // If we're collapsed we contain the first child as our content
   // thus we don't render it when collapsed.  but to support modified
   // rollouts with custom header buttons etc we still render our other
   // children. -JDD
   GuiControl *pChild = dynamic_cast<GuiControl*>( at(0) );
   if ( pChild )
   {
      if ( !mIsExpanded && !mIsAnimating && pChild->isVisible() )
	  {
         pChild->setVisible( false );
	  }
      else if ( (mIsExpanded || mIsAnimating) && !pChild->isVisible() )
	  {
         pChild->setVisible( true );
	  }
   }
   renderChildControls( offset, updateRect );

   // Render our border should we have it specified in our profile.
   renderBorder(worldBounds, mProfile);
}
Example #8
0
void View::render()
{
	clearSurface(screenSurface);
	clearSurface(overlaySurface);
	renderBorder();
	renderOverlay();
	renderMerged();
	SDL_Flip(screenSurface);
}
Example #9
0
void zerokernel::Select::render()
{
    if (variable)
    {
        option *found{ nullptr };
        for (auto &p : options)
        {
            if (p.value == variable->toString())
            {
                found = &p;
                break;
            }
        }

        renderBorder(*color_border);
        text.set(found ? found->name : "<?>");
        text.render();
    }
    else
        renderBorder(*style::colors::error);

    BaseMenuObject::render();
}
Example #10
0
void zerokernel::TextInput::render()
{
    if (draw_border)
        renderBorder(is_input_active ? *color_border_active : *color_border);

    if (is_input_active)
    {
        text_object.setColorText(&*color_text_active);
        text_object.set(current_text);
    }
    else
    {
        text_object.setColorText(&*color_text);
        text_object.set(getValue());
    }
    text_object.render();
}
Example #11
0
void GuiInspectorField::onRender( Point2I offset, const RectI &updateRect )
{
   RectI ctrlRect(offset, getExtent());
   
   // Render fillcolor...
   if ( mProfile->mOpaque )
      GFX->getDrawUtil()->drawRectFill(ctrlRect, mProfile->mFillColor);   

   // Render caption...
   if ( mCaption && mCaption[0] )
   {      
      // Backup current ClipRect
      RectI clipBackup = GFX->getClipRect();

      RectI clipRect = updateRect;

      // The rect within this control in which our caption must fit.
      RectI rect( offset + mCaptionRect.point + mProfile->mTextOffset, mCaptionRect.extent + Point2I(1,1) - Point2I(5,0) );

      // Now clipRect is the amount of our caption rect that is actually visible.
      bool hit = clipRect.intersect( rect );

      if ( hit )
      {
         GFX->setClipRect( clipRect );
         GFXDrawUtil *drawer = GFX->getDrawUtil();

         // Backup modulation color
         ColorI currColor;
         drawer->getBitmapModulation( &currColor );

         // Draw caption background...
         if( !isActive() )
            GFX->getDrawUtil()->drawRectFill( clipRect, mProfile->mFillColorNA );
         else if ( mHighlighted )         
            GFX->getDrawUtil()->drawRectFill( clipRect, mProfile->mFillColorHL );             

         // Draw caption text...

         drawer->setBitmapModulation( !isActive() ? mProfile->mFontColorNA : mHighlighted ? mProfile->mFontColorHL : mProfile->mFontColor );
         
         // Clip text with '...' if too long to fit
         String clippedText( mCaption );
         clipText( clippedText, clipRect.extent.x );

         renderJustifiedText( offset + mProfile->mTextOffset, getExtent(), clippedText );

         // Restore modulation color
         drawer->setBitmapModulation( currColor );

         // Restore previous ClipRect
         GFX->setClipRect( clipBackup );
      }
   }

   // Render Children...
   renderChildControls(offset, updateRect);

   // Render border...
   if ( mProfile->mBorder )
      renderBorder(ctrlRect, mProfile);   

   // Render divider...
   Point2I worldPnt = mEditCtrlRect.point + offset;
   GFX->getDrawUtil()->drawLine( worldPnt.x - 5,
      worldPnt.y, 
      worldPnt.x - 5,
      worldPnt.y + getHeight(),
      !isActive() ? mProfile->mBorderColorNA : mHighlighted ? mProfile->mBorderColorHL : mProfile->mBorderColor );
}
Example #12
0
void GuiFormCtrl::onRender(Point2I offset, const RectI &updateRect)
{
   // Fill in the control's child area
   RectI boundsRect(offset, getExtent());
   boundsRect.point.y += mThumbSize.y;
   boundsRect.extent.y -= mThumbSize.y;

   // draw the border of the form if specified
   if (mProfile->mOpaque)
      GFX->getDrawUtil()->drawRectFill(boundsRect, mProfile->mFillColor);

   if (mProfile->mBorder)
      renderBorder(boundsRect, mProfile);

   // If we don't have a child, put some text in the child area
   if( empty() )
   {
      GFX->getDrawUtil()->setBitmapModulation(ColorI(0,0,0));
      renderJustifiedText(boundsRect.point, boundsRect.extent, "[none]");
   }

   S32 textWidth = 0;

   // Draw our little bar, too
   if (mProfile->mBitmapArrayRects.size() >= 5)
   {
      //GFX->getDrawUtil()->clearBitmapModulation();     // Copyright (C) 2013 WinterLeaf Entertainment LLC.

      S32 barStart = offset.x + textWidth;
      S32 barTop   = mThumbSize.y / 2 + offset.y - mProfile->mBitmapArrayRects[3].extent.y / 2;

      Point2I barOffset(barStart, barTop);

      // Draw the start of the bar...
      GFX->getDrawUtil()->drawBitmapStretchSR(mProfile->mTextureObject ,RectI(barOffset, mProfile->mBitmapArrayRects[2].extent), mProfile->mBitmapArrayRects[2] );

      // Now draw the middle...
      barOffset.x += mProfile->mBitmapArrayRects[2].extent.x;

      S32 barMiddleSize = (getExtent().x - (barOffset.x - offset.x)) - mProfile->mBitmapArrayRects[4].extent.x + 1;

      if (barMiddleSize > 0)
      {
         // We have to do this inset to prevent nasty stretching artifacts
         RectI foo = mProfile->mBitmapArrayRects[3];
         foo.inset(1,0);

         GFX->getDrawUtil()->drawBitmapStretchSR(
            mProfile->mTextureObject,
            RectI(barOffset, Point2I(barMiddleSize, mProfile->mBitmapArrayRects[3].extent.y)),
            foo
            );
      }

      // And the end
      barOffset.x += barMiddleSize;

      GFX->getDrawUtil()->drawBitmapStretchSR( mProfile->mTextureObject, RectI(barOffset, mProfile->mBitmapArrayRects[4].extent),
         mProfile->mBitmapArrayRects[4]);

      GFX->getDrawUtil()->setBitmapModulation((mMouseOver ? mProfile->mFontColorHL : mProfile->mFontColor));
      renderJustifiedText(Point2I(mThumbSize.x, 0) + offset, Point2I(getWidth() - mThumbSize.x - mProfile->mBitmapArrayRects[4].extent.x, mThumbSize.y), (mUseSmallCaption ? mSmallCaption : mCaption) );

   }

   // Render the children
   renderChildControls(offset, updateRect);
}