[code/python] Fixed the Kandinsky module in Python.

User can draw on the 320*220 drawing screen.

Change-Id: I25034b05f21aacc35608358fdb7a4d9924dd22e8
This commit is contained in:
Léa Saviot
2017-11-20 11:14:08 +01:00
parent 2aa1cb0256
commit a9f4da92c0
11 changed files with 93 additions and 14 deletions

View File

@@ -11,15 +11,31 @@ extern "C" {
namespace Code {
ConsoleController::ContentView::ContentView(SelectableTableView * selectabletableView) :
m_selectableTableView(selectabletableView)
{
}
void ConsoleController::ContentView::layoutSubviews() {
m_selectableTableView->setFrame(bounds());
}
void ConsoleController::ContentView::markAsDirty() {
markRectAsDirty(bounds());
}
ConsoleController::ConsoleController(Responder * parentResponder, ScriptStore * scriptStore) :
ViewController(parentResponder),
SelectableTableViewDataSource(),
TextFieldDelegate(),
MicroPython::ExecutionEnvironment(),
m_rowHeight(KDText::charSize(k_fontSize).height()),
m_selectableTableView(this, this, 0, 1, 0, Metric::CommonRightMargin, 0, Metric::TitleBarExternHorizontalMargin, this, this, true, true, KDColorWhite),
m_editCell(this, this),
m_pythonHeap(nullptr),
m_scriptStore(scriptStore)
m_scriptStore(scriptStore),
m_view(&m_selectableTableView)
{
for (int i = 0; i < k_numberOfLineCells; i++) {
m_cells[i].setParentResponder(&m_selectableTableView);
@@ -254,6 +270,10 @@ void ConsoleController::printText(const char * text, size_t length) {
}
}
void ConsoleController::redraw() {
m_view.markAsDirty();
}
void ConsoleController::autoImportScriptAtIndex(int index) {
const char * importCommand1 = "from ";
const char * importCommand2 = " import *";