[expression_editor] Use ExpressionEditorView.

Change-Id: Ib4080fd76f7040be6ad8ebfda10d2e2070c7381c
This commit is contained in:
Léa Saviot
2017-12-14 15:23:21 +01:00
parent 1c6d18afd9
commit 23d49f768f
5 changed files with 31 additions and 41 deletions

View File

@@ -2,29 +2,26 @@
namespace ExpressionEditor {
Controller::ContentView::ContentView(ExpressionAndLayout * expressionAndLayout) :
SolidColorView(KDColorWhite),
m_expressionView()
{
m_expressionView.setExpressionLayout(expressionAndLayout->expressionLayout());
}
void Controller::ContentView::layoutSubviews() {
m_expressionView.setFrame(KDRect(
k_margin,
k_margin,
bounds().width() - 2 * k_margin,
bounds().height() - 2 * k_margin));
}
KDSize Controller::ContentView::minimalSizeForOptimalDisplay() const {
return m_expressionView.minimalSizeForOptimalDisplay();
}
Controller::Controller(Responder * parentResponder, ExpressionAndLayout * expressionAndLayout) :
Controller::Controller(Responder * parentResponder, Poincare::ExpressionLayout * expressionLayout) :
ViewController(parentResponder),
m_view(expressionAndLayout)
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) {