mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-23 07:40:42 +01:00
[expression_editor] Add fraction layouts (simple version).
Pressing the divide button adds an empty fraction layout without "absorbing" the neighbouring layouts. Change-Id: I46bdeadfcd80ec3c51c676ae62747e0823718645
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
#include "controller.h"
|
||||
#include <poincare/src/layout/char_layout.h> //TODO move from there.
|
||||
#include <poincare/src/layout/fraction_layout.h> //TODO move from there.
|
||||
#include <poincare/src/layout/empty_visible_layout.h> //TODO move from there.
|
||||
|
||||
using namespace Poincare;
|
||||
|
||||
namespace ExpressionEditor {
|
||||
|
||||
Controller::Controller(Responder * parentResponder, Poincare::ExpressionLayout * expressionLayout) :
|
||||
Controller::Controller(Responder * parentResponder, ExpressionLayout * expressionLayout) :
|
||||
ViewController(parentResponder),
|
||||
m_view(parentResponder, expressionLayout, &m_cursor),
|
||||
m_expressionLayout(expressionLayout)
|
||||
@@ -34,8 +38,19 @@ bool Controller::handleEvent(Ion::Events::Event event) {
|
||||
|| (event == Ion::Events::Down && m_cursor.moveDown()))
|
||||
{
|
||||
returnValue = true;
|
||||
}
|
||||
else if (event.hasText()) {
|
||||
} else if (event == Ion::Events::Division) {
|
||||
EmptyVisibleLayout * child1 = new EmptyVisibleLayout();
|
||||
EmptyVisibleLayout * child2 = new EmptyVisibleLayout();
|
||||
|
||||
FractionLayout * newChild = new FractionLayout(child1, child2, false);
|
||||
m_cursor.pointedExpressionLayout()->addBrother(&m_cursor, newChild);
|
||||
m_cursor.setPointedExpressionLayout(newChild);
|
||||
m_cursor.setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
m_cursor.setPositionInside(0);
|
||||
returnValue = true;
|
||||
m_expressionLayout->invalidAllSizesPositionsAndBaselines();
|
||||
m_view.layoutSubviews();
|
||||
} else if (event.hasText()) {
|
||||
insertTextAtCursor(event.text());
|
||||
returnValue = true;
|
||||
m_expressionLayout->invalidAllSizesPositionsAndBaselines();
|
||||
@@ -50,14 +65,14 @@ void Controller::insertTextAtCursor(const char * text) {
|
||||
if (textLength <= 0) {
|
||||
return;
|
||||
}
|
||||
Poincare::CharLayout * newChild = nullptr;
|
||||
CharLayout * newChild = nullptr;
|
||||
for (int i = 0; i < textLength; i++) {
|
||||
newChild = new Poincare::CharLayout(text[i]);
|
||||
newChild = new CharLayout(text[i]);
|
||||
m_cursor.pointedExpressionLayout()->addBrother(&m_cursor, newChild);
|
||||
}
|
||||
assert(newChild != nullptr);
|
||||
m_cursor.setPointedExpressionLayout(newChild);
|
||||
m_cursor.setPosition(Poincare::ExpressionLayoutCursor::Position::Right);
|
||||
m_cursor.setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
m_cursor.setPositionInside(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user