Exemple #1
0
void GxDrawImp::PushScissorRect(int x, int y, int w, int h)
{
	Flush();

	GxRenderInterface* renderer = GxRenderInterface::Get();

	if(myScissorStack.size() < 256)
	{
		if(w < 0 || h < 0)
		{
			GxLog(LOG_TAG, GX_LT_WARNING, "PushScissorRect() was called with a negative width or height.");
		}
		if(!myScissorStack.empty())
		{
			GxRecti last = myScissorStack.back();
			int nx = GxMax(last.x, x);
			int ny = GxMax(last.y, y);
			int nw = GxMax(0, GxMin(last.x+last.w, x+w) - nx);
			int nh = GxMax(0, GxMin(last.y+last.h, y+h) - ny);
			myScissorStack.push_back(GxRecti(nx, ny, nw, nh));
			renderer->SetScissorRect(nx, ny, nw, nh);
		}
		else
		{
			myScissorStack.push_back(GxRecti(x, y, w, h));
			renderer->EnableScissorRect(true);
			renderer->SetScissorRect(x, y, w, h);
		}
	}
	else
	{
		GxLog(LOG_TAG, GX_LT_WARNING, "The ScissorRect stack is overflowing, ignoring push.");
	}
}
Exemple #2
0
GxRecti GxText::DrawHighlight(int x, int y, GxStringArg text) const
{
	GxTextRenderer* renderer = GxTextRenderer::singleton;
	if(!renderer) return GxRecti(x, y, 0, 0);
	renderer->SetText(*this, text.ptr);
	return renderer->DrawHighlight(x, y);	
}
Exemple #3
0
GxRecti GxText::GetCharRect(int x, int y, int charIndex, GxStringArg text) const
{
	GxTextRenderer* renderer = GxTextRenderer::singleton;
	if(!renderer) return GxRecti(x, y, 0, 0);
	renderer->SetText(*this, text.ptr);
	return renderer->GetCharRect(x, y, charIndex);	
}
Exemple #4
0
GxRecti GxTextRenderer::DrawHighlight(int x, int y)
{
	y += GetOffsetY(myAlignV, myTextH);
	myDrawHighlight((float)x, (float)y);
	x += GetOffsetX(myAlignH, myTextW);
	return GxRecti(x, y, myTextW, myTextH);
}
Exemple #5
0
GxRecti GxDrawImp::GetScissorRect()
{
	if(myScissorStack.empty())
	{
		GxRenderInterface* renderer = GxRenderInterface::Get();
		GxVec2i size = renderer->GetViewSize();
		return GxRecti(0, 0, size.x, size.y);
	}
	return myScissorStack.back();
}
Exemple #6
0
GxRecti GxSelectList::myGetListRect() const
{
	if(myScrollbar->IsHidden())
	{
		GxRecti r = myRect; r.Shrink(2);
		return r;
	}

	const int ofs = 2 - GxInt(myScrollbar->GetValue());
	return GxRecti(myRect.x + 2, myRect.y + ofs, myRect.w - 20, myItems.Size() * 16);
}
Exemple #7
0
GxRecti GxTextRenderer::myGetCharRect(float x, float y, int charIndex)
{
	// Empty string.
	if(myLines.empty())
		return GxRecti((int)x, (int)y, 0, myFont->fontSize);

	// Find the correct line number.
	int lineIndex = 0;
	for(int l=0; l<(int)myLines.size() && myLines[l].begin <= charIndex; ++l)
		lineIndex = l;

	// Process the line on which the character resides.
	const Line& line = myLines[lineIndex];
	const float ox = x + GetOffsetX(myAlignH, line.width);
	const float oy = y + (float)(lineIndex * myFont->fontSize);

	// If the index is before begin, we can return the position of the first character.
	if(charIndex < line.begin)
		return GxRecti((int)ox, (int)oy, 0, myFont->fontSize);

	// Go through the line until we reach the character at the index.
	Pen pen = { 0, 0, line.spacemul };
	myResetPos();
	mySkipTo(line.begin);
	while(myReadPos < line.end)
	{
		const Glyph& glyph = myNextChar();
		myAdvance(pen, glyph);
		if(myPos == charIndex)
			return GxRecti((int)(ox + pen.x), (int)oy, (int)pen.advance, myFont->fontSize);
	}

	// If the final line ends with a line feed, we return the start of the next line.
	if(myReadPos == myLen && myStr[myPos] == C_LINE_FEED)
		return GxRecti((int)ox, (int)oy + myFont->fontSize, 0, myFont->fontSize);

	// If not, we just return the end of the final line.
	return GxRecti((int)(ox + pen.x + pen.advance), (int)oy, 0, myFont->fontSize);
}
Exemple #8
0
GxRecti GxTextRenderer::GetTextRect(int x, int y)
{
	y += GetOffsetY(myAlignV, myTextH);
	x += GetOffsetX(myAlignH, myTextW);
	return GxRecti(x, y, myTextW, myTextH);
}
Exemple #9
0
GxRecti GxSliderAbstract::myGetBarRect() const
{
	bool isV = IsVertical();
	if(isV) return GxRecti(myRect.x, myRect.y+myRect.h-4, myRect.w, -myRect.h+8);
	return GxRecti(myRect.x+4, myRect.y, myRect.w-8, myRect.h);
}