From a643969ee5c8896f72926c435308ff9c365bcef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 17 Oct 2016 15:42:12 +0200 Subject: [PATCH] [apps/graph/values] Enable to overwrite interval parameters by typing numerical values Change-Id: I2c19dde8f7e01cec1d0b31ec320209b77a97c43e --- .../values/values_parameter_controller.cpp | 18 ++++++++++++++---- .../graph/values/values_parameter_controller.h | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/apps/graph/values/values_parameter_controller.cpp b/apps/graph/values/values_parameter_controller.cpp index 3518ca1be..ee105ffe2 100644 --- a/apps/graph/values/values_parameter_controller.cpp +++ b/apps/graph/values/values_parameter_controller.cpp @@ -110,18 +110,28 @@ bool ValuesParameterController::handleEvent(Ion::Events::Event event) { setActiveCell(m_activeCell-1); return true; case Ion::Events::Event::ENTER: - editParameterInterval(); + editInterval(false); return true; default: - return false; + if ((int)event >= 0x100) { + return false; + } + editInterval(true, (char)event); + return true; } } -void ValuesParameterController::editParameterInterval() { +void ValuesParameterController::editInterval(bool overwrite, char initialDigit) { /* This code assumes that the active cell remains the one which is edited * until the invocation is performed. This could lead to concurrency issue in * other cases. */ - const char * initialTextContent = ListViewCellAtIndex(m_activeCell)->textContent(); + char initialTextContent[16]; + if (overwrite) { + initialTextContent[0] = initialDigit; + initialTextContent[1] = 0; + } else { + strlcpy(initialTextContent, ListViewCellAtIndex(m_activeCell)->textContent(), sizeof(initialTextContent)); + } App * myApp = (App *)app(); InputViewController * inputController = myApp->inputViewController(); inputController->edit(this, initialTextContent, this, diff --git a/apps/graph/values/values_parameter_controller.h b/apps/graph/values/values_parameter_controller.h index 56df38c75..69939a1f5 100644 --- a/apps/graph/values/values_parameter_controller.h +++ b/apps/graph/values/values_parameter_controller.h @@ -11,7 +11,7 @@ public: Interval * interval(); TextListViewCell * ListViewCellAtIndex(int index); int activeCell(); - void editParameterInterval(); + void editInterval(bool overwrite, char initialDigit = 0); void setIntervalParameterAtIndex(int parameterIndex, float f); View * view() override;