void TextEntry::Draw() { 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); glColor3f(1,0,0); if (curs_x - m_scroll > size[0]*0.75f) { m_scroll += size[0]*0.25f; } else if (curs_x - m_scroll < size[0]*0.25f) { m_scroll -= 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(); if (IsFocused()) glColor3f(1,1,1); else glColor3f(.75f, .75f, .75f); glBegin(GL_LINE_LOOP); glVertex2f(0,0); glVertex2f(size[0],0); glVertex2f(size[0],size[1]); glVertex2f(0,size[1]); glEnd(); SetClipping(size[0], size[1]); Gui::Screen::RenderString(m_text, 1.0f - m_scroll, 1.0f, m_font); /* Cursor */ glColor3f(0.5,0.5,0.5); glBegin(GL_LINES); glVertex2f(curs_x + 1.0f - m_scroll, curs_y - Gui::Screen::GetFontHeight(m_font) - 1.0); glVertex2f(curs_x + 1.0f - m_scroll, curs_y + 1.0); glEnd(); EndClipping(); }
void VScrollPortal::Draw() { float size[2]; GetSize(size); SetClipping(size[0], size[1]); m_scrollY = vscrollAdjust.GetValue(); float toScroll = m_childSizeY - size[1]; if (toScroll < 0) toScroll = 0; float scale[2]; Screen::GetCoords2Pixels(scale); glPushMatrix(); // scroll to whole pixel locations whatever the resolution glTranslatef(0, floor((-m_scrollY*toScroll)/scale[1])*scale[1], 0); Container::Draw(); glPopMatrix(); EndClipping(); }