[escher] Just replace the layout when clearing it in LayoutField

This commit is contained in:
Léa Saviot
2018-09-14 11:20:04 +02:00
parent 230bb91374
commit 985f310b1c
7 changed files with 18 additions and 19 deletions

View File

@@ -13,7 +13,7 @@ namespace Calculation {
EditExpressionController::ContentView::ContentView(Responder * parentResponder, TableView * subview, TextFieldDelegate * textFieldDelegate, LayoutFieldDelegate * layoutFieldDelegate) :
View(),
m_mainView(subview),
m_expressionField(parentResponder, m_textBody, k_bufferLength, Poincare::HorizontalLayoutRef(), textFieldDelegate, layoutFieldDelegate)
m_expressionField(parentResponder, m_textBody, k_bufferLength, textFieldDelegate, layoutFieldDelegate)
{
m_textBody[0] = 0;
}

View File

@@ -9,7 +9,7 @@
class ExpressionField : public Responder, public View {
public:
ExpressionField(Responder * parentResponder, char * textBuffer, int textBufferLength, Poincare::LayoutRef layout, TextFieldDelegate * textFieldDelegate, LayoutFieldDelegate * layoutFieldDelegate);
ExpressionField(Responder * parentResponder, char * textBuffer, int textBufferLength, TextFieldDelegate * textFieldDelegate, LayoutFieldDelegate * layoutFieldDelegate);
void setEditing(bool isEditing, bool reinitDraftBuffer = true);
bool isEditing() const;

View File

@@ -47,7 +47,6 @@ private:
ExpressionField * expressionField() { return &m_expressionField; }
private:
static constexpr int k_bufferLength = TextField::maxBufferSize();
Poincare::LayoutRef m_layout;
char m_textBuffer[k_bufferLength];
ExpressionField m_expressionField;
};

View File

@@ -12,9 +12,9 @@
class LayoutField : public ScrollableView, public ScrollViewDataSource {
public:
LayoutField(Responder * parentResponder, Poincare::LayoutRef layoutR, LayoutFieldDelegate * delegate = nullptr) :
LayoutField(Responder * parentResponder, LayoutFieldDelegate * delegate = nullptr) :
ScrollableView(parentResponder, &m_contentView, this),
m_contentView(layoutR),
m_contentView(),
m_delegate(delegate)
{}
void setDelegate(LayoutFieldDelegate * delegate) { m_delegate = delegate; }
@@ -65,15 +65,7 @@ private:
class ContentView : public View {
public:
ContentView(Poincare::LayoutRef layoutR) :
m_cursor(layoutR, Poincare::LayoutCursor::Position::Right),
m_expressionView(0.0f, 0.5f, KDColorBlack, KDColorWhite),
m_cursorView(),
m_isEditing(false)
{
m_expressionView.setLayoutRef(layoutR);
}
ContentView();
bool isEditing() const { return m_isEditing; }
void setEditing(bool isEditing) {
m_isEditing = isEditing;

View File

@@ -2,11 +2,11 @@
#include <poincare/preferences.h>
#include <assert.h>
ExpressionField::ExpressionField(Responder * parentResponder, char * textBuffer, int textBufferLength, Poincare::LayoutRef layout, TextFieldDelegate * textFieldDelegate, LayoutFieldDelegate * layoutFieldDelegate) :
ExpressionField::ExpressionField(Responder * parentResponder, char * textBuffer, int textBufferLength, TextFieldDelegate * textFieldDelegate, LayoutFieldDelegate * layoutFieldDelegate) :
Responder(parentResponder),
View(),
m_textField(parentResponder, textBuffer, textBuffer, textBufferLength, textFieldDelegate, false, KDText::FontSize::Large, 0.0f, 0.5f, KDColorBlack, KDColorWhite),
m_layoutField(parentResponder, layout, layoutFieldDelegate),
m_layoutField(parentResponder, layoutFieldDelegate),
m_textBuffer(textBuffer),
m_textBufferLength(textBufferLength)
{

View File

@@ -1,13 +1,11 @@
#include <escher/input_view_controller.h>
#include <escher/app.h>
#include <escher/palette.h>
#include <poincare/horizontal_layout_node.h>
#include <assert.h>
InputViewController::ExpressionFieldController::ExpressionFieldController(Responder * parentResponder, TextFieldDelegate * textFieldDelegate, LayoutFieldDelegate * layoutFieldDelegate) :
ViewController(parentResponder),
m_layout(Poincare::HorizontalLayoutRef()),
m_expressionField(this, m_textBuffer, k_bufferLength, m_layout, textFieldDelegate, layoutFieldDelegate)
m_expressionField(this, m_textBuffer, k_bufferLength, textFieldDelegate, layoutFieldDelegate)
{
m_textBuffer[0] = 0;
}

View File

@@ -3,11 +3,21 @@
#include <escher/clipboard.h>
#include <escher/text_field.h>
#include <poincare/expression.h>
#include <poincare/horizontal_layout_node.h>
#include <assert.h>
#include <string.h>
using namespace Poincare;
LayoutField::ContentView::ContentView() :
m_cursor(),
m_expressionView(0.0f, 0.5f, KDColorBlack, KDColorWhite),
m_cursorView(),
m_isEditing(false)
{
clearLayout();
}
void LayoutField::ContentView::layoutCursorSubview() {
if (!m_isEditing) {
m_cursorView.setFrame(KDRectZero);