[escher] optimize the redraw of text fields

Change-Id: Ia777cd9a4668e7bf582c3f76cd4cca30e5e900a5
This commit is contained in:
Émilie Feral
2016-10-04 12:15:47 +02:00
parent 3e239663f2
commit 5a410095fe

View File

@@ -26,18 +26,24 @@ const char * TextField::className() const {
bool TextField::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::Event::DELETE && m_currentTextLength > 0) {
KDSize sizePreviousText = KDText::stringSize(m_textBuffer);
m_currentTextLength--;
m_textBuffer[m_currentTextLength] = 0;
markRectAsDirty(bounds()); //TODO: Could be optimized
KDSize sizeText = KDText::stringSize(m_textBuffer);
KDRect dirtyZone(sizeText.width(), 0, sizePreviousText.width()-sizeText.width(), sizeText.height());
markRectAsDirty(dirtyZone);
return true;
}
if ((int)event >= 0x100) {
return false;
}
if (m_currentTextLength == 0 || m_currentTextLength-1 < m_textBufferSize) {
KDSize sizePreviousText = KDText::stringSize(m_textBuffer);
m_textBuffer[m_currentTextLength++] = (int)event;
m_textBuffer[m_currentTextLength] = 0;
markRectAsDirty(bounds()); //TODO: Could be optimized
KDSize sizeText = KDText::stringSize(m_textBuffer);
KDRect dirtyZone(sizePreviousText.width(), 0, sizeText.width()-sizePreviousText.width(), sizeText.height());
markRectAsDirty(dirtyZone);
}
return true;
}