Exemplo n.º 1
0
void VScrollPortal::Draw()
{
	PROFILE_SCOPED()
	SetScissor(true);

	float size[2];
	GetSize(size);

	m_scrollY = vscrollAdjust.GetValue();

	float toScroll = m_childSizeY - size[1];
	if (toScroll < 0) toScroll = 0;

	float scale[2];
	Screen::GetCoords2Pixels(scale);

	Graphics::Renderer *r = Gui::Screen::GetRenderer();
	Graphics::Renderer::MatrixTicket ticket(r, Graphics::MatrixMode::MODELVIEW);

	// scroll to whole pixel locations whatever the resolution
	r->Translate(0, floor((-m_scrollY*toScroll)/scale[1])*scale[1], 0);
	Container::Draw();

	SetScissor(false);
}
Exemplo n.º 2
0
void TextEntry::Draw()
{
	PROFILE_SCOPED()
	m_justFocused = false;

	Graphics::Renderer *pRenderer = Screen::GetRenderer();

	float size[2];
	GetSize(size);

	// find cursor position
	float curs_x, curs_y;
	Gui::Screen::MeasureCharacterPos(m_text, m_cursPos, curs_x, curs_y, m_font.Get());

	if (curs_x - m_scroll > size[0]*0.75f) {
		m_scroll += int(size[0]*0.25f);
	} else if (curs_x - m_scroll < size[0]*0.25f) {
		m_scroll -= int(size[0]*0.25f);
		if (m_scroll < 0) m_scroll = 0;
	}

	//background
	if(!m_background) {
		m_background.reset( new Graphics::Drawables::Rect(pRenderer, vector2f(0.f), vector2f(size[0], size[1]), Color(0,0,0,192), Screen::alphaBlendState));
	}
	m_background->Draw(pRenderer);

	//outline
	const Color c = IsFocused() ? Color::WHITE : Color(192, 192, 192, 255);
	const vector3f boxVts[] = {
		vector3f(0.f, 0.f, 0.f),
		vector3f(size[0],0.f, 0.f),
		vector3f(size[0],size[1], 0.f),
		vector3f(0,size[1], 0.f)
	};
	m_outlines.SetData(2, &boxVts[0], c);
	m_outlines.Draw(pRenderer, Screen::alphaBlendState, Graphics::LINE_LOOP);

	//text
	SetScissor(true);
	Gui::Screen::RenderStringBuffer(m_vb, m_text, 1.0f - m_scroll, 0.0f, c, m_font.Get());
	SetScissor(false);

	//cursor
	const vector3f cursorVts[] = {
		vector3f(curs_x + 1.0f - m_scroll, curs_y + Gui::Screen::GetFontDescender(m_font.Get()) - Gui::Screen::GetFontHeight(m_font.Get()), 0.f),
		vector3f(curs_x + 1.0f - m_scroll, curs_y + Gui::Screen::GetFontDescender(m_font.Get()), 0.f),
	};
	m_cursorLines.SetData(2, &cursorVts[0], Color(128, 128, 128));
	m_cursorLines.Draw(pRenderer, Screen::alphaBlendState);
}
Exemplo n.º 3
0
void TextEntry::Draw()
{
	PROFILE_SCOPED()
	m_justFocused = false;

	float size[2];
	GetSize(size);

	// find cursor position
	float curs_x, curs_y;
	Gui::Screen::MeasureCharacterPos(m_text, m_cursPos, curs_x, curs_y, m_font.Get());

	if (curs_x - m_scroll > size[0]*0.75f) {
		m_scroll += int(size[0]*0.25f);
	} else if (curs_x - m_scroll < size[0]*0.25f) {
		m_scroll -= int(size[0]*0.25f);
		if (m_scroll < 0) m_scroll = 0;
	}

	glColor3f(0,0,0);
	glBegin(GL_TRIANGLE_FAN);
		glVertex2f(0,size[1]);
		glVertex2f(size[0],size[1]);
		glVertex2f(size[0],0);
		glVertex2f(0,0);
	glEnd();

	Color c = IsFocused() ? Color::WHITE : Color(0.75f,0.75f,0.75f,1.0f);

	glColor4fv(c);
	glBegin(GL_LINE_LOOP);
		glVertex2f(0,0);
		glVertex2f(size[0],0);
		glVertex2f(size[0],size[1]);
		glVertex2f(0,size[1]);
	glEnd();


	SetScissor(true);

	Gui::Screen::RenderString(m_text, 1.0f - m_scroll, 0.0f, c, m_font.Get());

	/* Cursor */
	glColor3f(0.5f,0.5f,0.5f);
	glBegin(GL_LINES);
		glVertex2f(curs_x + 1.0f - m_scroll, curs_y + Gui::Screen::GetFontDescender(m_font.Get()) - Gui::Screen::GetFontHeight(m_font.Get()));
		glVertex2f(curs_x + 1.0f - m_scroll, curs_y + Gui::Screen::GetFontDescender(m_font.Get()));
	glEnd();

	SetScissor(false);
}
Exemplo n.º 4
0
bool GLVideo::SetScissor(const math::Rect2D& rect)
{
	SetScissor(true);
	GLint posY;
	TexturePtr target = m_currentTarget.lock();
	if (target)
	{
		posY = static_cast<GLint>(rect.pos.y);
	}
	else
	{
		posY = static_cast<GLint>(GetScreenSize().y) - static_cast<GLint>(rect.pos.y + rect.size.y);
	}

	if (m_scissor != rect)
	{
		m_scissor = rect;
		glScissor(static_cast<GLint>(rect.pos.x), posY,
				  static_cast<GLsizei>(rect.size.x), static_cast<GLsizei>(rect.size.y));
	}
	return true;
}
Exemplo n.º 5
0
void GLVideo::UnsetScissor()
{
	SetScissor(false);
}