void HKWidgetRenderer::Render(const HKWidget &widget, const MFMatrix &worldTransform)
{
	MFVector widgetColour = widget.GetColour();
	MFVector size = widget.GetSize();
	size.x -= padding.x + padding.z;
	size.y -= padding.y + padding.w;

	if(colour.w > 0.f)
	{
		float borderWidth = border.x + border.z;
		float borderHeight = border.y + border.w;
		MFPrimitive_DrawUntexturedQuad(padding.x + border.x, padding.y + border.y, size.x - borderWidth, size.y - borderHeight, colour*widgetColour, worldTransform);
	}

	if(border.x > 0.f) // left
		MFPrimitive_DrawUntexturedQuad(padding.x, padding.y, border.x, size.y, borderColour*widgetColour, worldTransform);
	if(border.y > 0.f) // top
		MFPrimitive_DrawUntexturedQuad(padding.x, padding.y, size.x, border.y, borderColour*widgetColour, worldTransform);
	if(border.z > 0.f) // right
		MFPrimitive_DrawUntexturedQuad(size.x - border.z + padding.x, padding.y, border.z, size.y, borderColour*widgetColour, worldTransform);
	if(border.w > 0.f) // bottom
		MFPrimitive_DrawUntexturedQuad(padding.x, padding.y + size.y - border.w, size.x, border.w, borderColour*widgetColour, worldTransform);

	if(pImage)
	{
		if(margin9Cell > 0.f)
		{
			// 9 cell stuff...
		}
		else
		{
			// draw the background image centered in the box
			MFMaterial_SetMaterial(pImage);

			float offset = 0;
			float tc = MFRenderer_GetTexelCenterOffset();
			if(tc > 0.f)
			{
				if(size.x == texWidth && size.y == texHeight)
					offset = tc;
			}

			MFPrimitive_DrawQuad(padding.x - offset, padding.y - offset, size.x, size.y, widgetColour, 0, 0, 1, 1, worldTransform);
		}
	}
}
Exemple #2
0
void HKWidgetRendererLabel::Render(const HKWidget &widget, const MFMatrix &worldTransform)
{
	HKWidgetRenderer::Render(widget, worldTransform);

	HKWidgetLabel &label = (HKWidgetLabel&)widget;

	MFString l = label.GetText();
	if(!l.IsEmpty())
	{
		MFFont *pFont = label.GetFont();
		float height = label.GetTextHeight();
		float shadowDepth = label.GetShadowDepth();
		const MFVector &size = widget.GetSize();
		const MFVector &colour = widget.GetColour();
		const MFVector &textColour = label.GetTextColour();
		MFFontJustify j = label.GetTextJustification();
		const char *pString = l.CStr();

		if(shadowDepth > 0.f)
			MFFont_DrawTextJustified(pFont, pString, MakeVector(shadowDepth, shadowDepth), size.x, size.y, j, height, MFVector::black, -1, worldTransform);
		MFFont_DrawTextJustified(pFont, pString, MFVector::zero, size.x, size.y, j, height, textColour * colour, -1, worldTransform);
	}
}