Example #1
0
void GuiSwatchButtonCtrl::onRender( Point2I offset, const RectI &updateRect )
{
   bool highlight = mMouseOver;

   ColorI borderColor = mActive ? ( highlight ? mProfile->mBorderColorHL : mProfile->mBorderColor ) : mProfile->mBorderColorNA;

   RectI renderRect( offset, getExtent() );
   if ( !highlight )
      renderRect.inset( 1, 1 );      

   GFXDrawUtil *drawer = GFX->getDrawUtil();
   drawer->clearBitmapModulation();

   // Draw background transparency grid texture...
   if ( mGrid.isValid() )
      drawer->drawBitmapStretch( mGrid, renderRect );

   // Draw swatch color as fill...
   if (!mUseSRGB)
      drawer->drawRectFill( renderRect, mSwatchColor.toGamma() );
   else
      drawer->drawRectFill(renderRect, mSwatchColor);

   // Draw any borders...
   drawer->drawRect( renderRect, borderColor );
}
void GuiRiverEditorCtrl::_drawRiverControlNodes( River *river, const ColorI &color )
{
   if ( !River::smShowSpline )
      return;

   RectI bounds = getBounds();

   GFXDrawUtil *drawer = GFX->getDrawUtil();

   bool isSelected = ( river == mSelRiver );
   bool isHighlighted = ( river == mHoverRiver );

   for ( U32 i = 0; i < river->mNodes.size(); i++ )
   {
      if ( false && isSelected && mSelNode == i  )
         continue;

      const Point3F &wpos = river->mNodes[i].point;

      Point3F spos;
      project( wpos, &spos );                  

      if ( spos.z > 1.0f )
         continue;

      Point2I posi;
      posi.x = spos.x;
      posi.y = spos.y;

      if ( !bounds.pointInRect( posi ) )
         continue;

      ColorI theColor = color;
      Point2I nodeHalfSize = mNodeHalfSize;

      if ( isHighlighted && mHoverNode == i )
      {
         //theColor = mHoverNodeColor;
         nodeHalfSize += Point2I(2,2);
      }

      if ( isSelected )
      {   
         if ( mSelNode == i )
         {
            theColor.set(0,0,255);
         }
         else if ( i == 0 )
         {
            theColor.set(0,255,0);
         }
         else if ( i == river->mNodes.size() - 1 )
         {
            theColor.set(255,0,0);
         }         
      }

      drawer->drawRectFill( posi - nodeHalfSize, posi + nodeHalfSize, theColor );
   }
}
void renderSlightlyRaisedBox( const RectI &bounds, GuiControlProfile *profile )
{
   S32 l = bounds.point.x + 1, r = bounds.point.x + bounds.extent.x - 1;
   S32 t = bounds.point.y + 1, b = bounds.point.y + bounds.extent.y - 1;

   GFXDrawUtil *drawer = GFX->getDrawUtil();
   drawer->drawRectFill( bounds, profile->mFillColor);
   drawer->drawLine(l, t, l, b, profile->mBorderColor);
   drawer->drawLine(l, t, r, t, profile->mBorderColor);
   drawer->drawLine(l + 1, b, r, b, profile->mBorderColor);
   drawer->drawLine(r, t + 1, r, b - 1, profile->mBorderColor);
}
void GuiDecalEditorCtrl::renderGui( Point2I offset, const RectI &updateRect )
{
   Parent::renderGui( offset, updateRect );

   PROFILE_SCOPE( GuiDecalEditorCtrl_renderGui );

   // Show the pixelSize of the selected decal as a text overlay.
   if ( smRenderDecalPixelSize && mSELDecal != NULL )
   {
      const F32 pixelSize = mSELDecal->calcPixelSize( mSaveViewport.extent.y, mLastCameraQuery.cameraMatrix.getPosition(), mSaveWorldToScreenScale.y );
      
      // Find position onscreen to render the text.
      Point3F screenPos;
      bool onScreen = project( mSELDecal->mPosition, &screenPos );

      if ( onScreen )
      {
         // It is extremely annoying to require the GuiProfile to have a font
         // or to create one within the decal editor for only this single use,
         // so we instead rely on the fact that we already have a Gizmo, that
         // all Gizmo's have a GizmoProfile, and that GizmoProfile has a font.
         GFont *font = mGizmo->getProfile()->font;

         // Might as well use some colors defined in GizmoProfile too instead
         // of just hardcoding it here.
         const ColorI bgColor = mGizmo->getProfile()->inActiveColor;
         const ColorI textColor = mGizmo->getProfile()->activeColor;

         // Note: This mostly mirrors the way WorldEditor renders popupText for
         // the gizmo during a drag operation, consider unifying this into a utility method.

         char buf[256];
         dSprintf( buf, 256, "%0.3f", pixelSize );

         const U32 width = font->getStrWidth((const UTF8 *)buf);;
         const Point2I posi( (U32)screenPos.x, (U32)screenPos.y + 12 );   
         const Point2I minPt(posi.x - width / 2 - 2, posi.y - 1);
         const Point2I maxPt(posi.x + width / 2 + 2, posi.y + font->getHeight() + 1);

         GFXDrawUtil *drawer = GFX->getDrawUtil();
         drawer->drawRectFill( minPt, maxPt, bgColor );
	      GFX->getDrawUtil()->setBitmapModulation( textColor );
         GFX->getDrawUtil()->drawText( mProfile->mFont, Point2I( posi.x - width / 2, posi.y ), buf );
      }      
   }
}
void renderRaisedBox( const RectI &bounds, GuiControlProfile *profile )
{
   S32 l = bounds.point.x, r = bounds.point.x + bounds.extent.x - 1;
   S32 t = bounds.point.y, b = bounds.point.y + bounds.extent.y - 1;

   GFXDrawUtil* drawUtil = GFX->getDrawUtil();

   drawUtil->drawRectFill( bounds, profile->mFillColor);
   drawUtil->drawLine(l, t, l, b - 1, colorWhite);
   drawUtil->drawLine(l, t, r - 1, t, colorWhite);

   drawUtil->drawLine(l, b, r, b, colorBlack);
   drawUtil->drawLine(r, b - 1, r, t, colorBlack);

   drawUtil->drawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColor);
   drawUtil->drawLine(r - 1, b - 2, r - 1, t + 1, profile->mBorderColor);
}