void CGUIDialogKeyboardGeneric::UpdateLabel() // FIXME seems to be called twice for one USB SDL keyboard action/character { CGUILabelControl* pEdit = ((CGUILabelControl*)GetControl(CTL_LABEL_EDIT)); if (pEdit) { CStdStringW edit = m_strEdit; pEdit->SetHighlight(0, 0); pEdit->SetSelection(0, 0); if (m_hiddenInput) { // convert to *'s edit.clear(); if (m_lastRemoteClickTime + REMOTE_SMS_DELAY > CTimeUtils::GetFrameTime() && m_iCursorPos > 0) { // using the remove to input, so display the last key input edit.append(m_iCursorPos - 1, L'*'); edit.append(1, m_strEdit[m_iCursorPos - 1]); } else edit.append(m_strEdit.size(), L'*'); } else if (!m_strEditing.empty()) { edit.insert(m_iCursorPos, m_strEditing); pEdit->SetHighlight(m_iCursorPos, m_iCursorPos + m_strEditing.size()); if (m_iEditingLength > 0) pEdit->SetSelection(m_iCursorPos + m_iEditingOffset, m_iCursorPos + m_iEditingOffset + m_iEditingLength); } // convert back to utf8 CStdString utf8Edit; g_charsetConverter.wToUTF8(edit, utf8Edit); pEdit->SetLabel(utf8Edit); // Send off a search message unsigned int now = CTimeUtils::GetFrameTime(); // don't send until the REMOTE_SMS_DELAY has passed if (m_lastRemoteClickTime && m_lastRemoteClickTime + REMOTE_SMS_DELAY >= now) return; if (m_pCharCallback) { // do not send editing text comes from system input method if (!m_hiddenInput && !m_strEditing.empty()) g_charsetConverter.wToUTF8(m_strEdit, utf8Edit); m_pCharCallback(this, utf8Edit); } } }
void CGUIEditControl::ProcessText(unsigned int currentTime) { if (m_smsTimer.GetElapsedMilliseconds() > smsDelay) UpdateText(); if (m_bInvalidated) { m_label.SetMaxRect(m_posX, m_posY, m_width, m_height); m_label.SetText(m_info.GetLabel(GetParentID())); RecalcLabelPosition(); } bool changed = false; m_clipRect.x1 = m_label.GetRenderRect().x1; m_clipRect.x2 = m_clipRect.x1 + m_label.GetMaxWidth(); m_clipRect.y1 = m_posY; m_clipRect.y2 = m_posY + m_height; // start by rendering the normal text float leftTextWidth = m_label.GetRenderRect().Width(); if (leftTextWidth > 0) { // render the text on the left changed |= m_label.SetColor(GetTextColor()); changed |= m_label.Process(currentTime); m_clipRect.x1 += leftTextWidth + spaceWidth; } if (g_graphicsContext.SetClipRegion(m_clipRect.x1, m_clipRect.y1, m_clipRect.Width(), m_clipRect.Height())) { uint32_t align = m_label.GetLabelInfo().align & XBFONT_CENTER_Y; // start aligned left if (m_label2.GetTextWidth() < m_clipRect.Width()) { // align text as our text fits if (leftTextWidth > 0) { // right align as we have 2 labels align |= XBFONT_RIGHT; } else { // align by whatever the skinner requests align |= (m_label2.GetLabelInfo().align & 3); } } CStdStringW text = GetDisplayedText(); // add the cursor if we're focused if (HasFocus() && m_inputType != INPUT_TYPE_READONLY) { CStdStringW col; if ((m_focusCounter % 64) > 32) col = L"|"; else col = L"[COLOR 00FFFFFF]|[/COLOR]"; text.insert(m_cursorPos, col); } changed |= m_label2.SetMaxRect(m_clipRect.x1 + m_textOffset, m_posY, m_clipRect.Width() - m_textOffset, m_height); if (text.empty()) changed |= m_label2.SetText(m_hintInfo.GetLabel(GetParentID())); else changed |= m_label2.SetTextW(text); changed |= m_label2.SetAlign(align); changed |= m_label2.SetColor(GetTextColor()); changed |= m_label2.SetOverflow(CGUILabel::OVER_FLOW_CLIP); changed |= m_label2.Process(currentTime); g_graphicsContext.RestoreClipRegion(); } if (changed) MarkDirtyRegion(); }