Files
Upsilon/apps/expression_editor/controller.cpp
Léa Saviot 23d49f768f [expression_editor] Use ExpressionEditorView.
Change-Id: Ib4080fd76f7040be6ad8ebfda10d2e2070c7381c
2018-01-15 11:58:01 +01:00

32 lines
1.1 KiB
C++

#include "controller.h"
namespace ExpressionEditor {
Controller::Controller(Responder * parentResponder, Poincare::ExpressionLayout * expressionLayout) :
ViewController(parentResponder),
m_view(parentResponder, expressionLayout, &m_cursor)
{
m_cursor.setPointedExpressionLayout(expressionLayout);
}
void Controller::didBecomeFirstResponder() {
m_view.layoutSubviews();
/* TODO We need the layout to be done in order to scroll to the cursor. We
* thus made ExpressionViewWithCursor's layoutSubviews() public, which is the
* solution used in ModalViewController for instance. A cleaner solution would
* be to split viewWillAppear into loadViewIfNeeded() and viewWillAppear(), in
* order to change App::didBecomeActive to:
* m_modalViewController.loadViewIfNeeded();
* window->setContentView(view);
* m_modalViewController.viewWillAppear();
* The scrolling could then be done in viewWillAppear(), without calling
* layoutSubviews() manually. */
m_view.scrollableExpressionViewWithCursor()->scrollToCursor();
}
bool Controller::handleEvent(Ion::Events::Event event) {
return false;
}
}