Merge branch 'SaisieJolieMerge10Apr' into SaisieJolieMerge11Apr (master)

Change-Id: I06732115ee37ffd9a037a8412e1c57751dfb3e0f
This commit is contained in:
Léa Saviot
2018-04-11 17:18:00 +02:00
216 changed files with 7366 additions and 1537 deletions

View File

@@ -10,7 +10,7 @@ using namespace Poincare;
VariableBoxController::ContentViewController::ContentViewController(Responder * parentResponder, GlobalContext * context) :
ViewController(parentResponder),
m_context(context),
m_textFieldCaller(nullptr),
m_sender(nullptr),
m_firstSelectedRow(0),
m_previousSelectedRow(0),
m_currentPage(Page::RootMenu),
@@ -18,14 +18,13 @@ VariableBoxController::ContentViewController::ContentViewController(Responder *
{
}
const char * VariableBoxController::ContentViewController::title() {
return I18n::translate(I18n::Message::Variables);
}
View * VariableBoxController::ContentViewController::view() {
return &m_selectableTableView;
}
const char * VariableBoxController::ContentViewController::title() {
return I18n::translate(I18n::Message::Variables);
}
void VariableBoxController::ContentViewController::didBecomeFirstResponder() {
m_selectableTableView.reloadData();
m_selectableTableView.scrollToCell(0,0);
@@ -65,7 +64,7 @@ bool VariableBoxController::ContentViewController::handleEvent(Ion::Events::Even
char label[3];
putLabelAtIndexInBuffer(selectedRow(), label);
const char * editedText = label;
m_textFieldCaller->handleEventWithText(editedText);
m_insertTextAction(m_sender, editedText);
#if MATRIX_VARIABLES
m_selectableTableView.deselectTable();
m_currentPage = Page::RootMenu;
@@ -196,34 +195,31 @@ int VariableBoxController::ContentViewController::typeAtLocation(int i, int j) {
return 0;
}
const Expression * VariableBoxController::ContentViewController::expressionForIndex(int index) {
if (m_currentPage == Page::Scalar) {
const Symbol symbol = Symbol('A'+index);
return m_context->expressionForSymbol(&symbol);
}
if (m_currentPage == Page::Matrix) {
const Symbol symbol = Symbol::matrixSymbol('0'+(char)index);
return m_context->expressionForSymbol(&symbol);
}
#if LIST_VARIABLES
if (m_currentPage == Page::List) {
return nullptr;
}
#endif
return nullptr;
void VariableBoxController::ContentViewController::setTextFieldSender(TextField * textField) {
m_sender = textField;
m_insertTextAction = &insertTextInTextInput;
}
ExpressionLayout * VariableBoxController::ContentViewController::expressionLayoutForIndex(int index) {
if (m_currentPage == Page::Matrix) {
const Symbol symbol = Symbol::matrixSymbol('0'+(char)index);
return m_context->expressionLayoutForSymbol(&symbol);
}
#if LIST_VARIABLES
if (m_currentPage == Page::List) {
return nullptr;
}
void VariableBoxController::ContentViewController::setScrollableExpressionViewWithCursorSender(ScrollableExpressionViewWithCursor * scrollableExpressionViewWithCursor) {
m_sender = scrollableExpressionViewWithCursor;
m_insertTextAction = &insertTextInScrollableExpressionViewWithCursor;
}
void VariableBoxController::ContentViewController::reloadData() {
m_selectableTableView.reloadData();
}
void VariableBoxController::ContentViewController::resetPage() {
#if MATRIX_VARIABLES
m_currentPage = Page::RootMenu;
#else
m_currentPage = Page::Scalar;
#endif
return nullptr;
}
void VariableBoxController::ContentViewController::viewDidDisappear() {
m_selectableTableView.deselectTable();
ViewController::viewDidDisappear();
}
VariableBoxController::ContentViewController::Page VariableBoxController::ContentViewController::pageAtIndex(int index) {
@@ -264,25 +260,47 @@ I18n::Message VariableBoxController::ContentViewController::nodeLabelAtIndex(int
return labels[index];
}
void VariableBoxController::ContentViewController::setTextFieldCaller(TextField * textField) {
m_textFieldCaller = textField;
}
void VariableBoxController::ContentViewController::reloadData() {
m_selectableTableView.reloadData();
}
void VariableBoxController::ContentViewController::resetPage() {
#if MATRIX_VARIABLES
m_currentPage = Page::RootMenu;
#else
m_currentPage = Page::Scalar;
const Expression * VariableBoxController::ContentViewController::expressionForIndex(int index) {
if (m_currentPage == Page::Scalar) {
const Symbol symbol = Symbol('A'+index);
return m_context->expressionForSymbol(&symbol);
}
if (m_currentPage == Page::Matrix) {
const Symbol symbol = Symbol::matrixSymbol('0'+(char)index);
return m_context->expressionForSymbol(&symbol);
}
#if LIST_VARIABLES
if (m_currentPage == Page::List) {
return nullptr;
}
#endif
return nullptr;
}
void VariableBoxController::ContentViewController::viewDidDisappear() {
m_selectableTableView.deselectTable();
ViewController::viewDidDisappear();
ExpressionLayout * VariableBoxController::ContentViewController::expressionLayoutForIndex(int index) {
if (m_currentPage == Page::Matrix) {
const Symbol symbol = Symbol::matrixSymbol('0'+(char)index);
return m_context->expressionLayoutForSymbol(&symbol);
}
#if LIST_VARIABLES
if (m_currentPage == Page::List) {
return nullptr;
}
#endif
return nullptr;
}
void VariableBoxController::ContentViewController::insertTextInTextInput(void * sender, const char * textToInsert) {
TextInput * textInput = static_cast<TextInput *>(sender);
textInput->handleEventWithText(textToInsert);
}
void VariableBoxController::ContentViewController::insertTextInScrollableExpressionViewWithCursor(void * sender, const char * textToInsert) {
ScrollableExpressionViewWithCursor * scrollableExpressionViewWithCursor = static_cast<ScrollableExpressionViewWithCursor *>(sender);
if (!scrollableExpressionViewWithCursor->isEditing()) {
scrollableExpressionViewWithCursor->setEditing(true);
}
scrollableExpressionViewWithCursor->insertLayoutFromTextAtCursor(textToInsert);
}
VariableBoxController::VariableBoxController(GlobalContext * context) :
@@ -295,8 +313,12 @@ void VariableBoxController::didBecomeFirstResponder() {
app()->setFirstResponder(&m_contentViewController);
}
void VariableBoxController::setTextFieldCaller(TextField * textField) {
m_contentViewController.setTextFieldCaller(textField);
void VariableBoxController::setTextFieldSender(TextField * textField) {
m_contentViewController.setTextFieldSender(textField);
}
void VariableBoxController::setScrollableExpressionViewWithCursorSender(ScrollableExpressionViewWithCursor * scrollableExpressionViewWithCursor) {
m_contentViewController.setScrollableExpressionViewWithCursorSender(scrollableExpressionViewWithCursor);
}
void VariableBoxController::viewWillAppear() {