Changeset View
Changeset View
Standalone View
Standalone View
source/gui/CInput.cpp
Show First 20 Lines • Show All 1,148 Lines • ▼ Show 20 Lines | void CInput::Draw() | ||||
else | else | ||||
// should always be visible | // should always be visible | ||||
m_CursorVisState = true; | m_CursorVisState = true; | ||||
// First call draw on ScrollBarOwner | // First call draw on ScrollBarOwner | ||||
if (m_ScrollBar && m_MultiLine) | if (m_ScrollBar && m_MultiLine) | ||||
IGUIScrollBarOwner::Draw(); | IGUIScrollBarOwner::Draw(); | ||||
CStrIntern font_name(m_Font.ToUTF8()); | |||||
wchar_t mask_char = L'*'; | wchar_t mask_char = L'*'; | ||||
if (m_Mask && m_MaskChar.length() > 0) | if (m_Mask && m_MaskChar.length() > 0) | ||||
mask_char = m_MaskChar[0]; | mask_char = m_MaskChar[0]; | ||||
m_pGUI.DrawSprite(m_Sprite, m_CellID, bz, m_CachedActualSize); | m_pGUI.DrawSprite(m_Sprite, m_CellID, bz, m_CachedActualSize); | ||||
float scroll = 0.f; | float scroll = 0.f; | ||||
if (m_ScrollBar && m_MultiLine) | if (m_ScrollBar && m_MultiLine) | ||||
scroll = GetScrollBar(0).GetPos(); | scroll = GetScrollBar(0).GetPos(); | ||||
CFontMetrics font(font_name); | CFontMetrics font(m_Font); | ||||
// We'll have to setup clipping manually, since we're doing the rendering manually. | // We'll have to setup clipping manually, since we're doing the rendering manually. | ||||
CRect cliparea(m_CachedActualSize); | CRect cliparea(m_CachedActualSize); | ||||
// First we'll figure out the clipping area, which is the cached actual size | // First we'll figure out the clipping area, which is the cached actual size | ||||
// substracted by an optional scrollbar | // substracted by an optional scrollbar | ||||
if (m_ScrollBar) | if (m_ScrollBar) | ||||
{ | { | ||||
Show All 35 Lines | void CInput::Draw() | ||||
// Get the height of this font. | // Get the height of this font. | ||||
float h = (float)font.GetHeight(); | float h = (float)font.GetHeight(); | ||||
float ls = (float)font.GetLineSpacing(); | float ls = (float)font.GetLineSpacing(); | ||||
CShaderTechniquePtr tech = g_Renderer.GetShaderManager().LoadEffect(str_gui_text); | CShaderTechniquePtr tech = g_Renderer.GetShaderManager().LoadEffect(str_gui_text); | ||||
CTextRenderer textRenderer(tech->GetShader()); | CTextRenderer textRenderer(tech->GetShader()); | ||||
textRenderer.Font(font_name); | textRenderer.Font(m_Font); | ||||
// Set the Z to somewhat more, so we can draw a selected area between the | // Set the Z to somewhat more, so we can draw a selected area between the | ||||
// the control and the text. | // the control and the text. | ||||
textRenderer.Translate( | textRenderer.Translate( | ||||
(float)(int)(m_CachedActualSize.left) + m_BufferZone, | (float)(int)(m_CachedActualSize.left) + m_BufferZone, | ||||
(float)(int)(m_CachedActualSize.top+h) + m_BufferZone, | (float)(int)(m_CachedActualSize.top+h) + m_BufferZone, | ||||
bz+0.1f); | bz+0.1f); | ||||
▲ Show 20 Lines • Show All 243 Lines • ▼ Show 20 Lines | void CInput::Draw() | ||||
if (cliparea != CRect()) | if (cliparea != CRect()) | ||||
glDisable(GL_SCISSOR_TEST); | glDisable(GL_SCISSOR_TEST); | ||||
tech->EndPass(); | tech->EndPass(); | ||||
} | } | ||||
void CInput::UpdateText(int from, int to_before, int to_after) | void CInput::UpdateText(int from, int to_before, int to_after) | ||||
{ | { | ||||
CStrIntern font_name(m_Font.ToUTF8()); | |||||
wchar_t mask_char = L'*'; | wchar_t mask_char = L'*'; | ||||
if (m_Mask && m_MaskChar.length() > 0) | if (m_Mask && m_MaskChar.length() > 0) | ||||
mask_char = m_MaskChar[0]; | mask_char = m_MaskChar[0]; | ||||
// Ensure positions are valid after caption changes | // Ensure positions are valid after caption changes | ||||
m_iBufferPos = std::min(m_iBufferPos, static_cast<int>(m_Caption.size())); | m_iBufferPos = std::min(m_iBufferPos, static_cast<int>(m_Caption.size())); | ||||
m_iBufferPos_Tail = std::min(m_iBufferPos_Tail, static_cast<int>(m_Caption.size())); | m_iBufferPos_Tail = std::min(m_iBufferPos_Tail, static_cast<int>(m_Caption.size())); | ||||
UpdateBufferPositionSetting(); | UpdateBufferPositionSetting(); | ||||
if (font_name.empty()) | if (m_Font.empty()) | ||||
{ | { | ||||
// Destroy everything stored, there's no font, so there can be no data. | // Destroy everything stored, there's no font, so there can be no data. | ||||
m_CharacterPositions.clear(); | m_CharacterPositions.clear(); | ||||
return; | return; | ||||
} | } | ||||
SRow row; | SRow row; | ||||
row.m_ListStart = 0; | row.m_ListStart = 0; | ||||
int to = 0; // make sure it's initialized | int to = 0; // make sure it's initialized | ||||
if (to_before == -1) | if (to_before == -1) | ||||
to = static_cast<int>(m_Caption.length()); | to = static_cast<int>(m_Caption.length()); | ||||
CFontMetrics font(font_name); | CFontMetrics font(m_Font); | ||||
std::list<SRow>::iterator current_line; | std::list<SRow>::iterator current_line; | ||||
// Used to ... TODO | // Used to ... TODO | ||||
int check_point_row_start = -1; | int check_point_row_start = -1; | ||||
int check_point_row_end = -1; | int check_point_row_end = -1; | ||||
// Reset | // Reset | ||||
▲ Show 20 Lines • Show All 322 Lines • ▼ Show 20 Lines | int CInput::GetMouseHoveringTextPosition() const | ||||
if (m_MultiLine) | if (m_MultiLine) | ||||
{ | { | ||||
float scroll = 0.f; | float scroll = 0.f; | ||||
if (m_ScrollBar) | if (m_ScrollBar) | ||||
scroll = GetScrollBarPos(0); | scroll = GetScrollBarPos(0); | ||||
// Now get the height of the font. | // Now get the height of the font. | ||||
// TODO: Get the real font | // TODO: Get the real font | ||||
CFontMetrics font(CStrIntern(m_Font.ToUTF8())); | CFontMetrics font(m_Font); | ||||
float spacing = (float)font.GetLineSpacing(); | float spacing = (float)font.GetLineSpacing(); | ||||
// Change mouse position relative to text. | // Change mouse position relative to text. | ||||
mouse -= m_CachedActualSize.TopLeft(); | mouse -= m_CachedActualSize.TopLeft(); | ||||
mouse.x -= m_BufferZone; | mouse.x -= m_BufferZone; | ||||
mouse.y += scroll - m_BufferZone; | mouse.y += scroll - m_BufferZone; | ||||
int row = (int)((mouse.y) / spacing); | int row = (int)((mouse.y) / spacing); | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | void CInput::UpdateAutoScroll() | ||||
{ | { | ||||
if (!m_ScrollBar) | if (!m_ScrollBar) | ||||
return; | return; | ||||
const float scroll = GetScrollBar(0).GetPos(); | const float scroll = GetScrollBar(0).GetPos(); | ||||
// Now get the height of the font. | // Now get the height of the font. | ||||
// TODO: Get the real font | // TODO: Get the real font | ||||
CFontMetrics font(CStrIntern(m_Font.ToUTF8())); | CFontMetrics font(m_Font); | ||||
float spacing = (float)font.GetLineSpacing(); | float spacing = (float)font.GetLineSpacing(); | ||||
//float height = font.GetHeight(); | //float height = font.GetHeight(); | ||||
// TODO Gee (2004-11-21): Okay, I need a 'std::list' for some reasons, but I would really like to | // TODO Gee (2004-11-21): Okay, I need a 'std::list' for some reasons, but I would really like to | ||||
// be able to get the specific element here. This is hopefully a temporary hack. | // be able to get the specific element here. This is hopefully a temporary hack. | ||||
std::list<SRow>::iterator current = m_CharacterPositions.begin(); | std::list<SRow>::iterator current = m_CharacterPositions.begin(); | ||||
int row = 0; | int row = 0; | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator