[apps/code] Use TextFieldWithExtension in the list controller

This commit is contained in:
Léa Saviot
2018-10-17 10:18:49 +02:00
committed by Émilie Feral
parent 6facfbbf7a
commit 974519f61a
7 changed files with 103 additions and 13 deletions

View File

@@ -0,0 +1,40 @@
#include "script_name_cell.h"
#include "app.h"
#include <assert.h>
namespace Code {
void ScriptNameCell::setEven(bool even) {
EvenOddCell::setEven(even);
m_textField.setBackgroundColor(backgroundColor());
}
void ScriptNameCell::setHighlighted(bool highlight) {
EvenOddCell::setHighlighted(highlight);
m_textField.setBackgroundColor(backgroundColor());
}
const char * ScriptNameCell::text() const {
if (!m_textField.isEditing()) {
return m_textField.text();
}
return nullptr;
}
KDSize ScriptNameCell::minimalSizeForOptimalDisplay() const {
return m_textField.minimalSizeForOptimalDisplay();
}
void ScriptNameCell::didBecomeFirstResponder() {
app()->setFirstResponder(&m_textField);
}
void ScriptNameCell::layoutSubviews() {
KDRect cellBounds = bounds();
m_textField.setFrame(KDRect(cellBounds.x() + k_leftMargin,
cellBounds.y(),
cellBounds.width() - k_leftMargin,
cellBounds.height()));
}
}