From 0478817040bf546dd3446dbc0c15263fb7a53127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 7 Feb 2017 11:02:29 +0100 Subject: [PATCH] [apps/shared] Move apps/graph/list/function_expression_cell in shared folder to be used by sequence Change-Id: I4a019c322cc7cb864479b200ee56d05234f5491c --- apps/graph/Makefile | 1 - apps/graph/list/list_controller.cpp | 12 +++++------ apps/graph/list/list_controller.h | 6 +++--- apps/shared/Makefile | 1 + .../function_expression_cell.cpp} | 20 +++++++++---------- .../function_expression_cell.h} | 12 +++++------ 6 files changed, 26 insertions(+), 26 deletions(-) rename apps/{graph/list/function_expression_view.cpp => shared/function_expression_cell.cpp} (64%) rename apps/{graph/list/function_expression_view.h => shared/function_expression_cell.h} (70%) diff --git a/apps/graph/Makefile b/apps/graph/Makefile index 70cc0177c..5daad1a07 100644 --- a/apps/graph/Makefile +++ b/apps/graph/Makefile @@ -9,7 +9,6 @@ app_objs += $(addprefix apps/graph/,\ graph/graph_controller.o\ graph/graph_view.o\ graph/initialisation_parameter_controller.o\ - list/function_expression_view.o\ list/new_function_cell.o\ list/list_controller.o\ values/abscissa_parameter_controller.o\ diff --git a/apps/graph/list/list_controller.cpp b/apps/graph/list/list_controller.cpp index 42258ae29..459adbf36 100644 --- a/apps/graph/list/list_controller.cpp +++ b/apps/graph/list/list_controller.cpp @@ -123,7 +123,7 @@ void ListController::configureFunction(Function * function) { stack->push(&m_parameterController); } -void ListController::editExpression(FunctionExpressionView * functionCell, Ion::Events::Event event) { +void ListController::editExpression(FunctionExpressionCell * functionCell, Ion::Events::Event event) { char * initialText = nullptr; char initialTextContent[255]; if (event == Ion::Events::OK) { @@ -134,8 +134,8 @@ void ListController::editExpression(FunctionExpressionView * functionCell, Ion:: InputViewController * inputController = myApp->inputViewController(); inputController->edit(this, event, functionCell, initialText, [](void * context, void * sender){ - FunctionExpressionView * myCell = (FunctionExpressionView *) context; - Function * myFunction = myCell->function(); + FunctionExpressionCell * myCell = (FunctionExpressionCell *) context; + Shared::Function * myFunction = myCell->function(); InputViewController * myInputViewController = (InputViewController *)sender; const char * textBody = myInputViewController->textBody(); myFunction->setContent(textBody); @@ -160,7 +160,7 @@ bool ListController::handleEvent(Ion::Events::Event event) { || m_selectableTableView.selectedRow() == numberOfRows() - 1) { return false; } - FunctionExpressionView * functionCell = (FunctionExpressionView *)(m_selectableTableView.cellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow())); + FunctionExpressionCell * functionCell = (FunctionExpressionCell *)(m_selectableTableView.cellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow())); editExpression(functionCell, event); return true; } @@ -188,7 +188,7 @@ bool ListController::handleEnter() { // Add a warning to tell the user there is no more space for new functions return false; } - FunctionExpressionView * functionCell = (FunctionExpressionView *)(m_selectableTableView.cellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow())); + FunctionExpressionCell * functionCell = (FunctionExpressionCell *)(m_selectableTableView.cellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow())); editExpression(functionCell, Ion::Events::OK); return true; } @@ -241,7 +241,7 @@ void ListController::willDisplayCellAtLocation(TableViewCell * cell, int i, int KDColor functionNameColor = function->isActive() ? function->color() : Palette::GreyDark; myFunctionCell->setColor(functionNameColor); } else { - FunctionExpressionView * myCell = (FunctionExpressionView *)cell; + FunctionExpressionCell * myCell = (FunctionExpressionCell *)cell; myCell->setFunction(m_functionStore->functionAtIndex(j)); } } diff --git a/apps/graph/list/list_controller.h b/apps/graph/list/list_controller.h index c917656b5..01fe388af 100644 --- a/apps/graph/list/list_controller.h +++ b/apps/graph/list/list_controller.h @@ -4,7 +4,7 @@ #include #include "../function_store.h" #include "../function_title_cell.h" -#include "function_expression_view.h" +#include "../../shared/function_expression_cell.h" #include "new_function_cell.h" #include "../../shared/list_parameter_controller.h" @@ -32,7 +32,7 @@ public: int reusableCellCount(int type) override; int typeAtLocation(int i, int j) override; void configureFunction(Function * function); - void editExpression(FunctionExpressionView * functionCell, Ion::Events::Event event); + void editExpression(Shared::FunctionExpressionCell * functionCell, Ion::Events::Event event); private: static constexpr KDCoordinate k_functionNameWidth = 65; @@ -43,7 +43,7 @@ private: // !!! CAUTION: The order here is important // The cells should be initialized *before* the TableView! FunctionTitleCell m_functionTitleCells[k_maxNumberOfRows]; - FunctionExpressionView m_expressionCells[k_maxNumberOfRows]; + Shared::FunctionExpressionCell m_expressionCells[k_maxNumberOfRows]; EvenOddCell m_emptyCell; NewFunctionCell m_addNewFunction; SelectableTableView m_selectableTableView; diff --git a/apps/shared/Makefile b/apps/shared/Makefile index f30fbd156..de87510f7 100644 --- a/apps/shared/Makefile +++ b/apps/shared/Makefile @@ -9,6 +9,7 @@ app_objs += $(addprefix apps/shared/,\ float_pair_store.o\ float_parameter_controller.o\ function.o\ + function_expression_cell.o\ function_store.o\ interactive_curve_view_controller.o\ interactive_curve_view_range.o\ diff --git a/apps/graph/list/function_expression_view.cpp b/apps/shared/function_expression_cell.cpp similarity index 64% rename from apps/graph/list/function_expression_view.cpp rename to apps/shared/function_expression_cell.cpp index 6343c6265..abbe9795a 100644 --- a/apps/graph/list/function_expression_view.cpp +++ b/apps/shared/function_expression_cell.cpp @@ -1,21 +1,21 @@ -#include "function_expression_view.h" +#include "function_expression_cell.h" #include -namespace Graph { +namespace Shared { -FunctionExpressionView::FunctionExpressionView() : +FunctionExpressionCell::FunctionExpressionCell() : EvenOddCell(), m_function(nullptr), m_expressionView(ExpressionView()) { } -void FunctionExpressionView::setFunction(Function * f) { +void FunctionExpressionCell::setFunction(Function * f) { m_function = f; m_expressionView.setExpression(m_function->layout()); } -void FunctionExpressionView::reloadCell() { +void FunctionExpressionCell::reloadCell() { EvenOddCell::reloadCell(); m_expressionView.setBackgroundColor(backgroundColor()); if (m_function) { @@ -25,25 +25,25 @@ void FunctionExpressionView::reloadCell() { } } -Function * FunctionExpressionView::function() { +Function * FunctionExpressionCell::function() { return m_function; } -int FunctionExpressionView::numberOfSubviews() const { +int FunctionExpressionCell::numberOfSubviews() const { return 1; } -View * FunctionExpressionView::subviewAtIndex(int index) { +View * FunctionExpressionCell::subviewAtIndex(int index) { assert(index == 0); return &m_expressionView; } -void FunctionExpressionView::layoutSubviews() { +void FunctionExpressionCell::layoutSubviews() { KDRect expressionFrame(k_separatorThickness, 0, bounds().width() - k_separatorThickness, bounds().height()); m_expressionView.setFrame(expressionFrame); } -void FunctionExpressionView::drawRect(KDContext * ctx, KDRect rect) const { +void FunctionExpressionCell::drawRect(KDContext * ctx, KDRect rect) const { EvenOddCell::drawRect(ctx, rect); // Color the separator ctx->fillRect(KDRect(0, 0, k_separatorThickness, bounds().height()), Palette::GreyBright); diff --git a/apps/graph/list/function_expression_view.h b/apps/shared/function_expression_cell.h similarity index 70% rename from apps/graph/list/function_expression_view.h rename to apps/shared/function_expression_cell.h index 9d1f8e681..691d521dd 100644 --- a/apps/graph/list/function_expression_view.h +++ b/apps/shared/function_expression_cell.h @@ -1,14 +1,14 @@ -#ifndef GRAPH_FUNCTION_EXPRESSION_H -#define GRAPH_FUNCTION_EXPRESSION_H +#ifndef SHARED_FUNCTION_EXPRESSION_CELL_H +#define SHARED_FUNCTION_EXPRESSION_CELL_H #include -#include "../function.h" +#include "function.h" -namespace Graph { +namespace Shared { -class FunctionExpressionView : public EvenOddCell { +class FunctionExpressionCell : public EvenOddCell { public: - FunctionExpressionView(); + FunctionExpressionCell(); void setFunction(Function * f); Function * function(); void reloadCell() override;