void pawsStdTreeDecorator::GetCollapseSignFrame(pawsTreeNode* node, csRect &rect)
{
    csRect nodeFrame = node->GetScreenFrame();
    rect.SetPos(nodeFrame.xmin - collSpacing - 2,
                nodeFrame.ymin + nodeFrame.Height()/2 - 4);
    rect.SetSize(10, 10);
}
Example #2
0
void csGLRender2TextureFramebuf::SetClipRect (const csRect& clipRect)
{
  GLRENDER3D_OUTPUT_LOCATION_MARKER;
  GLint vp[4];
  glGetIntegerv (GL_VIEWPORT, vp);
  glScissor (vp[0] + clipRect.xmin, vp[1] + txt_h - clipRect.ymax, clipRect.Width(),
    clipRect.Height());
}
Example #3
0
void csRectRegion::nkSplit (csRect &r1, csRect &r2)
{
  r2.Intersect (r1);

  if (r1.ymin < r2.ymin) // upper stripe
  {
    region.Push (csRect(r1.xmin,r1.ymin, r1.xmax, r2.ymin));
  }

  if (r1.xmin < r2.xmin) // left stripe
  {
    region.Push (csRect(r1.xmin,r2.ymin, r2.xmin, r2.ymax));
  }

  if (r1.xmax > r2.xmax) // right stripe
  {
    //region.Push (csRect(r2.xmin, r2.ymin, r1.xmax, r2.ymax));
    region.Push( csRect(r2.xmax, r2.ymin, r1.xmax, r2.ymax) );
  }

  if (r1.ymax > r2.ymax) // lower stripe
  {
    region.Push (csRect(r1.xmin, r2.ymax, r1.xmax, r1.ymax));
  }
}
Example #4
0
// The purpose of this function is to take r1 and fragment it around r2,
// removing the area that overlaps.  This function can be used by either
// Include() or Exclude(), since it simply fragments r1 (but always checks
// for swapping!)  For Exclusion, r2 is ALWAYS the excluding rect!
void csRectRegion::fragmentRect (csRect &r1, csRect &r2, int mode)
{
  // We may have to fragment r1 into three pieces if an entire edge of r2 is
  // inside r1.
  if (r1.Intersects (r2))
  {
    // Since fragment rect already test for all cases, the ideal method here
    // is to call fragment rect on the intersection of r1 and r2 with r1
    // as the fragmentee.  This creates a properly fragmented system.
    //
    // We know that rect1 is already good, so we simply fragment rect2 and
    // gather it's fragments into the fragment buffer for further consideration.
    //
    // In exclude mode, we don't want to remove parts of r2 from r1, whereas
    // in include mode we want to perform an optimal merge of the two, or
    // remove parts of r1 from r2.
    csRect ri (r1);
    ri.Intersect (r2);

    if (mode == MODE_INCLUDE)
    {
      if (r1.Area () < r2.Area ())
      {
        csRect temp (r1);
        r1.Set (r2);
        r2.Set (temp);
      }

      // Push r1 back into the regions list
      region.Push (r1);

      // Perform fragment and gather.
      markForGather ();
      fragmentContainedRect (r2, ri);
      gatherFragments ();
    }
    else
    {
      // Fragment inclusion rect around intersection (keep)
      fragmentContainedRect (r1, ri);
    }
    return;
  }
}
Example #5
0
void csRectRegionDebug::ClipTo(const csRect &clip)
{
  for(int i = 0; i < CS_RECT_REG_SIZE; i++)
  {
    for(int j = 0; j < CS_RECT_REG_SIZE; j++)
    {
      if(!clip.Contains(i,j))
        area[i][j] = false;
    }
  }
}
Example #6
0
void pawsProgressBar::DrawProgressBar(
    const csRect &rect, iGraphics3D* graphics3D, float percent,
    int start_r, int start_g, int start_b,
    int diff_r,  int diff_g,  int diff_b, int alpha)
{
    csSimpleRenderMesh mesh;
    static uint indices[4] = {0, 1, 2, 3};
    csVector3 verts[4];
    csVector4 colors[4];
    float fr1 = start_r / 255.0f;
    float fg1 = start_g / 255.0f;
    float fb1 = start_b / 255.0f;
    float fr2 = fr1 + percent * (diff_r / 255.0f);
    float fg2 = fg1 + percent * (diff_g / 255.0f);
    float fb2 = fb1 + percent * (diff_b / 255.0f);
    float fa = alpha / 255.0f;

    mesh.meshtype = CS_MESHTYPE_QUADS;
    mesh.indexCount = 4;
    mesh.indices = indices;
    mesh.vertexCount = 4;
    mesh.vertices = verts;
    mesh.colors = colors;
    mesh.mixmode = CS_FX_COPY;
    mesh.alphaType.autoAlphaMode = false;
    mesh.alphaType.alphaType = csAlphaMode::alphaSmooth;

    verts[0].Set(rect.xmin, rect.ymin, 0);
    colors[0].Set(fr1, fg1, fb1, fa);

    verts[1].Set(rect.xmin + (rect.Width() * percent), rect.ymin, 0);
    colors[1].Set(fr2, fg2, fb2, fa);

    verts[2].Set(rect.xmin + (rect.Width() * percent), rect.ymax, 0);
    colors[2].Set(fr2, fg2, fb2, fa);

    verts[3].Set(rect.xmin, rect.ymax, 0);
    colors[3].Set(fr1, fg1, fb1, fa);

    graphics3D->DrawSimpleMesh(mesh, csSimpleMeshScreenspace);
}
Example #7
0
csLockedMaterialMap csTerrainCell::LockMaterialMap (const csRect& rectangle)
{
  csLockedMaterialMap data;
  
  if (!materialMapPersistent)
  {
    materialmap.SetSize (rectangle.Width () * rectangle.Height ());

    data.data = materialmap.GetArray ();
    data.pitch = rectangle.Width ();
  }
  else
  {
    data.data = materialmap.GetArray () + materialMapWidth * rectangle.ymin +
      rectangle.xmin;
    data.pitch = materialMapWidth;
  }

  lockedMaterialMapRect = rectangle;

  return data;
}
void pawsTitle::SetWindowRect(const csRect & windowRect)
{
	size_t a;
	int winWidth = windowRect.Width();
	int w = (int)width;
	if (scaleWidth)
		w = (int)(winWidth * width);

	int deltaX = screenFrame.xmin;
	int deltaY = screenFrame.ymin;
	screenFrame.xmin = windowRect.xmin + (winWidth - w) / 2;
	screenFrame.ymin = windowRect.ymin - height / 2;
	screenFrame.SetSize(w, height);
	deltaX = screenFrame.xmin - deltaX;
	deltaY = screenFrame.ymin - deltaY;

	for (a=0; a<children.GetSize(); ++a)
		children[a]->Resize();

	for (a=0; a<titleButtons.GetSize(); ++a)
	{
		switch (titleButtons[a].align)
		{
		case PTA_LEFT:
			titleButtons[a].buttonWidget->MoveTo(screenFrame.xmin + titleButtons[a].offsetx, screenFrame.ymin + titleButtons[a].offsety);
			break;
		case PTA_CENTER:
			titleButtons[a].buttonWidget->MoveTo(screenFrame.xmin + (screenFrame.Width() - titleButtons[a].buttonWidget->ScreenFrame().Width())/2 + titleButtons[a].offsetx, screenFrame.ymin + titleButtons[a].offsety);
			break;
		case PTA_RIGHT:
			titleButtons[a].buttonWidget->MoveTo(screenFrame.xmax - titleButtons[a].buttonWidget->ScreenFrame().Width() + titleButtons[a].offsetx, screenFrame.ymin + titleButtons[a].offsety);
			break;
        case PTA_COUNT:
            break;
		}
	}
}
Example #9
0
void ProctexPDLight::PDMap::ComputeValueBounds (const csRect& area, 
                                                csRGBcolor& maxValue, 
                                                csRect& nonNullArea)
{
  const int width = imageW;
  maxValue.Set (0, 0, 0);
  nonNullArea.Set (INT_MAX, INT_MAX, INT_MIN, INT_MIN);
  
  int mapPitch = width - area.Width ();
  if (imageData->IsGray())
  {
    const uint8* map = 
      static_cast<LumelBufferGray*> ((LumelBufferBase*)imageData)->GetData() 
      + area.ymin * width + area.xmin;
    for (int y = area.ymin; y < area.ymax; y++)
    {
      for (int x = area.xmin; x < area.xmax; x++)
      {
	uint8 v = *map++;
  
	if (v > maxValue.red)
          maxValue.Set (v, v, v);
  
	if (v > 0)
	{
	  nonNullArea.Extend (x, y);
	}
      }
      map += mapPitch;
    }
  }
  else
  {
    const Lumel* map = 
      static_cast<LumelBufferRGB*> ((LumelBufferBase*)imageData)->GetData() 
      + area.ymin * width + area.xmin;
    for (int y = area.ymin; y < area.ymax; y++)
    {
      for (int x = area.xmin; x < area.xmax; x++)
      {
	const Lumel& p = *map++;
  
	if (p.c.red > maxValue.red)
	  maxValue.red = p.c.red;
	if (p.c.green > maxValue.green)
	  maxValue.green = p.c.green;
	if (p.c.blue > maxValue.blue)
	  maxValue.blue = p.c.blue;
  
	if (p.c.red + p.c.green + p.c.blue > 0)
	{
	  nonNullArea.Extend (x, y);
	}
      }
      map += mapPitch;
    }
  }

  // Align line start+end on 2-pixel-boundary (for MMX)
  nonNullArea.xmin &= ~1;
  nonNullArea.xmax = (nonNullArea.xmax+1) & ~1;
}
Example #10
0
void pawsImageDrawable::Draw(csRect rect, int alpha)
{
    Draw(rect.xmin, rect.ymin, rect.Width(), rect.Height(), alpha);
}
Example #11
0
void csRectRegion::Exclude (const csRect &nrect)
{
  // Ignore an empty rect
  if (nrect.IsEmpty ())
    return;

  // If there are no rects in the region, just leave.
  if (region.IsEmpty())
    return;

  size_t i;
  csRect rect (nrect);

  /// Clear the fragment buffer
  for (i = 0; i < FRAGMENT_BUFFER_SIZE; ++i)
    fragment[i].MakeEmpty ();

  // Otherwise, we have to see if this rect overlaps or touches any other.
  for (i = 0; i < region.GetSize(); i++)
  {
    csRect r1 (region[i]);
    csRect r2 (rect);

    // Check to see if these even touch
    if (r2.Intersects (r1) == false) continue;

    // Check to see if the inclusion rect is totally dominated by the
    // exclusion rect.
    r1.Exclude (r2);
    if (r1.IsEmpty ())
    {
      region.DeleteIndex (i);
      i--;
      continue;
    }

    // Check to see if the exclusion rect is totally dominated by the
    // exclusion rect
    r1.Set (region[i]);
    r2.Exclude (r1);
    if (r2.IsEmpty ())
    {
      r2.Set (rect);
      region.DeleteIndex (i);
      fragmentContainedRect (r1, r2);
      i = 0;
      continue;
    }

    r2.Set (rect);

    // This part is similiar to Include, except that we are trying to remove
    // a portion.  Instead of calling chopEdgeIntersection, we actually have
    // to fragment rect1 and chop off an edge of the excluding rect.  This
    // code should be handled inside fragment rect.

    // Kill rect from list
    region.DeleteIndex (i);
    i--;

    // Fragment it
    fragmentRect (r1, r2, MODE_EXCLUDE);
  }
}
Example #12
0
void csRectRegion::Include (const csRect &nrect)
{
  // Ignore an empty rect
  if (nrect.IsEmpty ())
    return;

  // If there are no rects in the region, add this and leave.
  if (region.IsEmpty())
  {
    region.Push (nrect);
    return;
  }

  size_t i;
  bool no_fragments;
  csRect rect (nrect);

  /// Clear the fragment buffer
  for (i = 0; i < FRAGMENT_BUFFER_SIZE; ++i) fragment[i].MakeEmpty ();

  do
  {
    bool untouched = true;

    no_fragments = true;

    // Otherwise, we have to see if this rect creates a union with any other
    // rectangles.
    size_t last_to_consider = region.GetSize();
    for (i = 0; i < last_to_consider; i++)
    {
      csRect &r1 = region[i];
      csRect r2 (rect);

      // Check to see if these even touch, if not, next.
      if (r2.Intersects (r1) == false) continue;

      // If r1 totally contains rect, then we leave.
      r2.Exclude (r1);
      if (r2.IsEmpty ())
      {
        // Mark it so we don't add it in
        untouched = false;
        break;
      }

      // If rect totally contains r1, then we kill r1 from the list.
      r2.Set (r1);
      r2.Exclude (rect);

      if (r2.IsEmpty ())
      {
        // Kill from list
        region.DeleteIndex (i);
        i--;
        last_to_consider--;
        // Iterate
        continue;
      }

      /*
      // Otherwise we have to do the most irritating part: A full split
      // operation that may create other rects that need to be tested against
      // the database recursively.  For this algorithm, we fragment the
      // one that is already in the database, that way we don't cause more
      // tests: we already know that that rect is good.
      r2.Set (rect);

      // Kill rect from list
      region.DeleteIndex (i);

      // Fragment it
      fragmentRect (r1, r2, MODE_INCLUDE);
      */

      r2.Set (rect);
      nkSplit (r1, r2);
      region.DeleteIndex (i);
      i--;
      last_to_consider--;
      // Mark it
      //      untouched = true;
    } // end for

    // In the end, we need to put the rect on the stack
    if (!rect.IsEmpty () && untouched)
      region.Push (rect);

    // Check and see if we have fragments to consider
    for (i = 0; i < FRAGMENT_BUFFER_SIZE; ++i)
    {
      if (!(fragment[i].IsEmpty ()))
      {
        rect.Set (fragment[i]);
        fragment[i].MakeEmpty ();
        no_fragments = false;
        break;
      }
    }
  } while (!no_fragments);
}