Exemplo n.º 1
0
void UIDraggableBox::HandleMouseMove(const STPoint2& position)
{
    MouseState state = CurrentMouseState();
    if (state == OVER || state == DOWN)
    {
        STVector2 diff = GetRectangle().pMax - GetRectangle().pMin;
        STPoint2 lowerLeft = position - mRelativeMousePosition;
        SetRectangle(UIRectangle(lowerLeft, lowerLeft + diff));
    }
}
Exemplo n.º 2
0
void CSlideShowPic::UpdateVertices(float cur_x[4], float cur_y[4], const float new_x[4], const float new_y[4], CDirtyRegionList &dirtyregions)
{
  const size_t count = sizeof(float)*4;
  if(memcmp(cur_x, new_x, count)
  || memcmp(cur_y, new_y, count)
  || m_bIsDirty)
  {
    dirtyregions.push_back(GetRectangle(cur_x, cur_y));
    dirtyregions.push_back(GetRectangle(new_x, new_y));
    memcpy(cur_x, new_x, count);
    memcpy(cur_y, new_y, count);
  }
}
Exemplo n.º 3
0
void TextureLayout::WriteCacheFile(FILE* f)
{   
	int sr = GetNumRectangles();
	fwrite(&sr, sizeof(sr), 1, f);
	for (int i = 0; i < sr; ++i)
	{
		auto& rect = GetRectangle(i);

		TextureLayoutRectangleCache rectc;
		rectc.dimensions_x = rect.GetDimensions().x;
		rectc.dimensions_y = rect.GetDimensions().y;
		rectc.id = rect.GetId();
		rectc.texture_index = rect.GetTextureIndex();
		rectc.texture_position_x = rect.GetPosition().x;
		rectc.texture_position_y = rect.GetPosition().y;
		rectc.texture_stride = rect.GetTextureStride();

		fwrite(&rectc, sizeof(TextureLayoutRectangleCache), 1, f);
	}

	int sl = GetNumTextures();
	fwrite(&sl, sizeof(sl), 1, f);
	for (int i = 0; i < sl; ++i)
	{
		GetTexture(i).WriteCacheFile(f, &rectangles[0]);
	}
}
Exemplo n.º 4
0
void 
Region::Draw (cairo_t *cr)
{
	int count = GetRectangleCount ();

	for (int i = 0; i < count; i++)
		GetRectangle (i).Draw (cr);
}
//
// Display the box to the current OpenGL context.
//
void UIBox::Display()
{
    STColor4f c = mColor;
    UIRectangle r = GetRectangle();

    glColor4f(c.r, c.g, c.b, c.a);
    glRectf(r.pMin.x, r.pMin.y,
            r.pMax.x, r.pMax.y);
}
Exemplo n.º 6
0
//
// Display the label to the current OpenGL context.
//
void UILabel::Display()
{
    /** CS 148 TODO:
    *
    *   You must implement the display logic for your label widget.
    *   Look at the STFont class for ideas of how to do this.
    *
    *   You should render your label based on the rectangle
    *   of the widget, but you do not need to "cut off" any
    *   text that extends outside this rectangle.
    */
    
    glPushMatrix();
    
    glTranslatef(GetRectangle().pMin.x, GetRectangle().pMin.y - mFont->GetDescender(), 0);
    
    mFont->DrawString(mText, STColor4f(0, 1));
    
    glPopMatrix();
}
Exemplo n.º 7
0
SPEngine::SPRectangle SUIPictureBox::ImageSrcRect()
{
	if (isAbsoluteRender)
	{
		SPRectangle rect = GetRectangle();
		rect.X = -*properties.backgroundX;
		rect.Y = -*properties.backgroundY;
		return rect;
	}

	return picture->GetTarget()->SourceRectangle();
}
Exemplo n.º 8
0
void PersonTime_Add(double s1, double t1, double dt, PersonTime_Grid grid)
{
	double s2, t2; /*endpoint*/
	int i1, j1; /*grid rectangle containing point (s1, t1)*/
	int i2, j2; /*grid rectangle containing point (s2, t2)*/
	int i, j;
	
	s2 = s1 + dt;
	t2 = t1 + dt;
	assert(InsideGrid(s1, t1, grid));
	assert(InsideGrid(s2, t2, grid));
	
	GetRectangle(s1, t1, grid, &i1, &j1);
	GetRectangle(s2, t2, grid, &i2, &j2);
	
	for (i = i1; i <= i2; i++) {
		for (j = j1; j <= j2; j++) {
			AddToRectangle(s1, t1, s2, t2, &(grid->rect[i][j]));
		}
	}	
}
			void Scrollbar::SetPositionAndSize()
			{
				switch (orientation)
				{
					case ScrollbarSlider::Orientation::Horizontal:
					{
						SetRectangle(Math::Rectangle(panel.GetRectangle().x, panel.GetRectangle().y + panel.GetRectangle().height, panel.GetRectangle().width, GetRectangle().height));
						break;
					}
					case ScrollbarSlider::Orientation::Vertical:
					{
						SetRectangle(Math::Rectangle(panel.GetRectangle().x + panel.GetRectangle().width, panel.GetRectangle().y, GetRectangle().width, panel.GetRectangle().height));
						break;
					}
					default:
						break;
				}
			}
Exemplo n.º 10
0
QRectF* QAttribute::GetTextRectangle() const
    {
        QRectF Rect = boundingRect();
        QRectF* Rect2 = GetRectangle();
        return  new QRectF(Rect.x(),Rect2->y()-25,Rect.width(),30);
    }
Exemplo n.º 11
0
void UIDraggableBox::HandleMouseDown(const STPoint2& position)
{
    UIWidget::HandleMouseDown(position);
    mRelativeMousePosition = position - GetRectangle().pMin;
}
 void MagicRect::Draw(QPainter *QP)
 {
     QP->drawRect(GetRectangle());
 }
Exemplo n.º 13
0
SRectangle SUIPictureBox::GetTexRect()
{
	if (!picture)
	{
		return SRectangle(*properties.x, *properties.y, *properties.width, *properties.height);
	}

	SRectangle rect;
	int imageWidth = picture->GetWidth();
	int imageHeight = picture->GetHeight();
	int boxWidth = *properties.width;
	int boxHeight = *properties.height;

	if (fillMode == Positioning)
	{
		rect.Width = imageWidth;
		rect.Height = imageHeight;

		switch(positionMode)
		{
		case TopLeft:
			rect.X = 0;
			rect.Y = 0;
			break;

		case TopRight:
			rect.X = boxWidth - imageWidth;
			rect.Y = 0;
			break;

		case TopCenter:
			rect.X = (boxWidth - imageWidth) / 2;
			rect.Y = 0;
			break;

		case BottomLeft:
			rect.X = 0;
			rect.Y = boxHeight - imageHeight;
			break;

		case BottomRight:
			rect.X = boxWidth - imageWidth;
			rect.Y = boxHeight - imageHeight;
			break;

		case BottomCenter:
			rect.X = (boxWidth - imageWidth) / 2;
			rect.Y = boxHeight - imageHeight;
			break;

		case CenterLeft:
			rect.X = 0;
			rect.Y = (boxHeight - imageHeight) / 2;
			break;

		case CenterRight:
			rect.X = boxWidth - imageWidth;
			rect.Y = (boxHeight - imageHeight) / 2;
			break;

		case CenterAll:
			rect.X = (boxWidth - imageWidth) / 2;
			rect.Y = (boxHeight - imageHeight) / 2;
			break;

		default:
			rect.X = imagePos.x;
			rect.Y = imagePos.y;
			break;
		}
		
		return rect;
	}

	switch(fillMode)
	{
	case Fill:
		rect = GetRectangle();
		rect.X = 0;
		rect.Y = 0;
		break;

	case FitWidth:
		rect.Width = boxWidth;
		rect.Height = (float)boxWidth / imageWidth * imageHeight;
		rect.X = 0;
		rect.Y = (boxHeight - rect.Height) / 2;
		break;

	case FitHeight:
		rect.Width = (float)boxHeight / imageHeight * imageWidth;
		rect.Height = boxHeight;
		rect.X = (boxWidth - rect.Width) / 2;
		rect.Y = 0;
		break;

	case FitMin:
		if ((float)boxWidth / imageWidth < 
			(float)boxHeight / imageHeight)
		{
			rect.Width = boxWidth;
			rect.Height = (float)boxWidth / imageWidth * imageHeight;
			rect.X = 0;
			rect.Y = (boxHeight - rect.Height) / 2;
		}
		else
		{
			rect.Width = (float)boxHeight / imageHeight * imageWidth;
			rect.Height = boxHeight;
			rect.X = (boxWidth - rect.Width) / 2;
			rect.Y = 0;
		}
		break;

	case FitMax:
		if ((float)boxWidth / imageWidth > 
			(float)boxHeight / imageHeight)
		{
			rect.Width = boxWidth;
			rect.Height = (float)boxWidth / imageWidth * imageHeight;
			rect.X = 0;
			rect.Y = (boxHeight - rect.Height) / 2;
		}
		else
		{
			rect.Width = (float)boxHeight / imageHeight * imageWidth;
			rect.Height = boxHeight;
			rect.X = (boxWidth - rect.Width) / 2;
			rect.Y = 0;
		}
		break;

	case ResizeBox:
		*properties.width = imageWidth;
		*properties.height = imageHeight;
		rect = GetRectangle();
		rect.X = 0;
		rect.Y = 0;
		break;
	}

	return rect;
}