mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps/graph] Hideable cells in values controller
This commit is contained in:
@@ -32,8 +32,36 @@ ValuesController::ValuesController(Responder * parentResponder, InputEventHandle
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
|
void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
|
||||||
Shared::ValuesController::willDisplayCellAtLocation(cell, i, j);
|
// Handle hidden cells
|
||||||
int typeAtLoc = typeAtLocation(i,j);
|
int typeAtLoc = typeAtLocation(i,j);
|
||||||
|
if (typeAtLoc == k_editableValueCellType) {
|
||||||
|
StoreCell * storeCell = (StoreCell *)cell;
|
||||||
|
storeCell->setSeparatorLeft(i > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const int numberOfElementsInCol = numberOfElementsInColumn(i);
|
||||||
|
if (j == numberOfElementsInCol+1) {
|
||||||
|
if (typeAtLoc == k_notEditableValueCellType) {
|
||||||
|
Shared::HideableEvenOddBufferTextCell * myCell = static_cast<Shared::HideableEvenOddBufferTextCell *>(cell);
|
||||||
|
myCell->setText("");
|
||||||
|
} else if (typeAtLoc == k_editableValueCellType) {
|
||||||
|
StoreCell * myCell = static_cast<StoreCell *>(cell);
|
||||||
|
myCell->editableTextCell()->textField()->setText("");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (j > numberOfElementsInCol + 1) {
|
||||||
|
if (typeAtLoc == k_notEditableValueCellType) {
|
||||||
|
Shared::HideableEvenOddBufferTextCell * myCell = static_cast<Shared::HideableEvenOddBufferTextCell *>(cell);
|
||||||
|
myCell->setHide(true);
|
||||||
|
} else if (typeAtLoc == k_editableValueCellType) {
|
||||||
|
StoreCell * myCell = static_cast<StoreCell *>(cell);
|
||||||
|
myCell->setHide(true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Shared::ValuesController::willDisplayCellAtLocation(cell, i, j);
|
||||||
if (typeAtLoc == k_abscissaTitleCellType) {
|
if (typeAtLoc == k_abscissaTitleCellType) {
|
||||||
AbscissaTitleCell * myTitleCell = (AbscissaTitleCell *)cell;
|
AbscissaTitleCell * myTitleCell = (AbscissaTitleCell *)cell;
|
||||||
Ion::Storage::Record record = recordAtColumn(i+1);
|
Ion::Storage::Record record = recordAtColumn(i+1);
|
||||||
@@ -58,10 +86,7 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in
|
|||||||
myFunctionCell->setColor(function->color());
|
myFunctionCell->setColor(function->color());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (typeAtLoc == k_editableValueCellType) {
|
|
||||||
StoreCell * storeCell = (StoreCell *)cell;
|
|
||||||
storeCell->setSeparatorLeft(i > 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ValuesController::typeAtLocation(int i, int j) {
|
int ValuesController::typeAtLocation(int i, int j) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "../cartesian_function_store.h"
|
#include "../cartesian_function_store.h"
|
||||||
#include "../../shared/buffer_function_title_cell.h"
|
#include "../../shared/buffer_function_title_cell.h"
|
||||||
|
#include "../../shared/hideable_even_odd_buffer_text_cell.h"
|
||||||
#include "../../shared/values_controller.h"
|
#include "../../shared/values_controller.h"
|
||||||
#include "../../shared/interval_parameter_controller.h"
|
#include "../../shared/interval_parameter_controller.h"
|
||||||
#include "../../shared/store_cell.h"
|
#include "../../shared/store_cell.h"
|
||||||
@@ -54,7 +55,7 @@ private:
|
|||||||
|
|
||||||
int m_numberOfColumnsForType[Shared::CartesianFunction::k_numberOfPlotTypes];
|
int m_numberOfColumnsForType[Shared::CartesianFunction::k_numberOfPlotTypes];
|
||||||
Shared::BufferFunctionTitleCell m_functionTitleCells[k_maxNumberOfFunctions];
|
Shared::BufferFunctionTitleCell m_functionTitleCells[k_maxNumberOfFunctions];
|
||||||
EvenOddBufferTextCell m_floatCells[k_maxNumberOfCells];
|
Shared::HideableEvenOddBufferTextCell m_floatCells[k_maxNumberOfCells];
|
||||||
AbscissaTitleCell m_abscissaTitleCells[Shared::CartesianFunction::k_numberOfPlotTypes];
|
AbscissaTitleCell m_abscissaTitleCells[Shared::CartesianFunction::k_numberOfPlotTypes];
|
||||||
Shared::StoreCell m_abscissaCells[k_maxNumberOfAbscissaCells];
|
Shared::StoreCell m_abscissaCells[k_maxNumberOfAbscissaCells];
|
||||||
FunctionParameterController m_functionParameterController;
|
FunctionParameterController m_functionParameterController;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ app_shared_src = $(addprefix apps/shared/,\
|
|||||||
function_store.cpp \
|
function_store.cpp \
|
||||||
function_title_cell.cpp \
|
function_title_cell.cpp \
|
||||||
go_to_parameter_controller.cpp \
|
go_to_parameter_controller.cpp \
|
||||||
|
hideable_even_odd_buffer_text_cell.cpp \
|
||||||
hideable_even_odd_cell.cpp \
|
hideable_even_odd_cell.cpp \
|
||||||
hideable_even_odd_editable_text_cell.cpp \
|
hideable_even_odd_editable_text_cell.cpp \
|
||||||
initialisation_parameter_controller.cpp \
|
initialisation_parameter_controller.cpp \
|
||||||
|
|||||||
20
apps/shared/hideable_even_odd_buffer_text_cell.cpp
Normal file
20
apps/shared/hideable_even_odd_buffer_text_cell.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#include "hideable_even_odd_buffer_text_cell.h"
|
||||||
|
|
||||||
|
namespace Shared {
|
||||||
|
|
||||||
|
KDColor HideableEvenOddBufferTextCell::backgroundColor() const {
|
||||||
|
if (hidden()) {
|
||||||
|
return hideColor();
|
||||||
|
}
|
||||||
|
return EvenOddBufferTextCell::backgroundColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HideableEvenOddBufferTextCell::setHide(bool hide) {
|
||||||
|
if (hidden() != hide) {
|
||||||
|
Hideable::setHide(hide);
|
||||||
|
m_bufferTextView.setBackgroundColor(backgroundColor());
|
||||||
|
reloadCell();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
22
apps/shared/hideable_even_odd_buffer_text_cell.h
Normal file
22
apps/shared/hideable_even_odd_buffer_text_cell.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef APPS_SHARED_HIDEABLE_EVEN_ODD_BUFFER_TEXT_CELL_H
|
||||||
|
#define APPS_SHARED_HIDEABLE_EVEN_ODD_BUFFER_TEXT_CELL_H
|
||||||
|
|
||||||
|
#include <escher/even_odd_buffer_text_cell.h>
|
||||||
|
#include <escher/palette.h>
|
||||||
|
#include "hideable.h"
|
||||||
|
|
||||||
|
namespace Shared {
|
||||||
|
|
||||||
|
class HideableEvenOddBufferTextCell : public EvenOddBufferTextCell, public Hideable {
|
||||||
|
public:
|
||||||
|
HideableEvenOddBufferTextCell() :
|
||||||
|
EvenOddBufferTextCell(),
|
||||||
|
Hideable()
|
||||||
|
{}
|
||||||
|
KDColor backgroundColor() const override;
|
||||||
|
void setHide(bool hide) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -15,11 +15,12 @@ int Interval::numberOfElements() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Interval::deleteElementAtIndex(int index) {
|
void Interval::deleteElementAtIndex(int index) {
|
||||||
m_numberOfElements--;
|
assert(!m_needCompute);
|
||||||
for (int k = index; k < m_numberOfElements; k++) {
|
assert(m_numberOfElements > 0);
|
||||||
|
for (int k = index; k < m_numberOfElements-1; k++) {
|
||||||
m_intervalBuffer[k] = m_intervalBuffer[k+1];
|
m_intervalBuffer[k] = m_intervalBuffer[k+1];
|
||||||
}
|
}
|
||||||
m_intervalBuffer[m_numberOfElements] = 0.0f;
|
m_numberOfElements--;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Interval::element(int i) {
|
double Interval::element(int i) {
|
||||||
@@ -70,7 +71,7 @@ void Interval::computeElements() {
|
|||||||
if (!m_needCompute) {
|
if (!m_needCompute) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( m_start > m_end) {
|
if (m_start > m_end) {
|
||||||
m_numberOfElements = 0;
|
m_numberOfElements = 0;
|
||||||
} else {
|
} else {
|
||||||
m_numberOfElements = m_step > 0 ? 1 + (m_end - m_start)/m_step : k_maxNumberOfElements;
|
m_numberOfElements = m_step > 0 ? 1 + (m_end - m_start)/m_step : k_maxNumberOfElements;
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ protected:
|
|||||||
virtual void updateNumberOfColumns();
|
virtual void updateNumberOfColumns();
|
||||||
virtual FunctionStore * functionStore() const;
|
virtual FunctionStore * functionStore() const;
|
||||||
virtual Ion::Storage::Record recordAtColumn(int i);
|
virtual Ion::Storage::Record recordAtColumn(int i);
|
||||||
|
int numberOfElementsInColumn(int columnIndex) override;
|
||||||
int m_numberOfColumns;
|
int m_numberOfColumns;
|
||||||
bool m_numberOfColumnsNeedUpdate;
|
bool m_numberOfColumnsNeedUpdate;
|
||||||
private:
|
private:
|
||||||
@@ -62,7 +63,6 @@ private:
|
|||||||
SelectableTableView * selectableTableView() override { return &m_selectableTableView; }
|
SelectableTableView * selectableTableView() override { return &m_selectableTableView; }
|
||||||
bool cellAtLocationIsEditable(int columnIndex, int rowIndex) override;
|
bool cellAtLocationIsEditable(int columnIndex, int rowIndex) override;
|
||||||
double dataAtLocation(int columnIndex, int rowIndex) override;
|
double dataAtLocation(int columnIndex, int rowIndex) override;
|
||||||
int numberOfElementsInColumn(int columnIndex) override;
|
|
||||||
virtual Interval * intervalAtColumn(int columnIndex) = 0;
|
virtual Interval * intervalAtColumn(int columnIndex) = 0;
|
||||||
int maxNumberOfElements() const override {
|
int maxNumberOfElements() const override {
|
||||||
return Interval::k_maxNumberOfElements;
|
return Interval::k_maxNumberOfElements;
|
||||||
|
|||||||
Reference in New Issue
Block a user