mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-25 16:50:50 +01:00
[escher/code] Cleaned Toolbox rowHeight().
Now it is set in escher/toolbox.h, with value 40 and no differentiation Node/Leaf. Change-Id: I0809d87a5df5b8bffe201c9faf72ff901430cbe5
This commit is contained in:
@@ -247,8 +247,7 @@ bool Toolbox::handleEvent(Ion::Events::Event event) {
|
||||
}
|
||||
|
||||
KDCoordinate Toolbox::rowHeight(int j) {
|
||||
if (typeAtLocation(0, j) == ::Toolbox::LeafCellType) {
|
||||
if (m_messageTreeModel->label() != I18n::Message::IfStatementMenu) {
|
||||
if (typeAtLocation(0, j) == ::Toolbox::LeafCellType && m_messageTreeModel->label() == I18n::Message::IfStatementMenu) {
|
||||
/* To get the exact height needed for each cell, we have to compute its
|
||||
* text size, which means scan the text char by char to look for '\n'
|
||||
* chars. This is very costly and ruins the speed performance when
|
||||
@@ -258,12 +257,10 @@ KDCoordinate Toolbox::rowHeight(int j) {
|
||||
* We thus decided to compute the real height only for the ifStatement
|
||||
* children of the toolbox, which is the only menu that has special height
|
||||
* rows. */
|
||||
return k_leafRowHeight;
|
||||
}
|
||||
const ToolboxMessageTree * messageTree = static_cast<const ToolboxMessageTree *>(m_messageTreeModel->children(j));
|
||||
return KDText::stringSize(I18n::translate(messageTree->label()), k_fontSize).height() + 2*Metric::TableCellLabelTopMargin + (messageTree->text() == I18n::Message::Default ? 0 : k_leafRowHeight);
|
||||
return KDText::stringSize(I18n::translate(messageTree->label()), k_fontSize).height() + 2*Metric::TableCellLabelTopMargin + (messageTree->text() == I18n::Message::Default ? 0 : ::Toolbox::rowHeight(j));
|
||||
}
|
||||
return k_nodeRowHeight;
|
||||
return ::Toolbox::rowHeight(j);
|
||||
}
|
||||
|
||||
bool Toolbox::selectLeaf(ToolboxMessageTree * selectedMessageTree) {
|
||||
|
||||
@@ -27,8 +27,6 @@ protected:
|
||||
// 13 = minimal string height size
|
||||
// 3 = vertical margins
|
||||
private:
|
||||
constexpr static KDCoordinate k_nodeRowHeight = 40;
|
||||
constexpr static KDCoordinate k_leafRowHeight = 40;
|
||||
constexpr static KDText::FontSize k_fontSize = KDText::FontSize::Small;
|
||||
void scrollToLetter(char letter);
|
||||
void scrollToAndSelectChild(int i);
|
||||
|
||||
@@ -102,13 +102,6 @@ MathToolbox::MathToolbox() : Toolbox(nullptr, I18n::translate(rootModel()->label
|
||||
{
|
||||
}
|
||||
|
||||
KDCoordinate MathToolbox::rowHeight(int j) {
|
||||
if (typeAtLocation(0, j) == Toolbox::LeafCellType) {
|
||||
return k_leafRowHeight;
|
||||
}
|
||||
return k_nodeRowHeight;
|
||||
}
|
||||
|
||||
TextField * MathToolbox::sender() {
|
||||
return (TextField *)Toolbox::sender();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ class MathToolbox : public Toolbox {
|
||||
public:
|
||||
MathToolbox();
|
||||
protected:
|
||||
KDCoordinate rowHeight(int j) override;
|
||||
TextField * sender() override;
|
||||
bool selectLeaf(ToolboxMessageTree * selectedMessageTree) override;
|
||||
const ToolboxMessageTree * rootModel() override;
|
||||
@@ -18,8 +17,6 @@ protected:
|
||||
int maxNumberOfDisplayedRows() override;
|
||||
constexpr static int k_maxNumberOfDisplayedRows = 6; // = 240/40
|
||||
private:
|
||||
constexpr static KDCoordinate k_nodeRowHeight = 40;
|
||||
constexpr static KDCoordinate k_leafRowHeight = 40;
|
||||
MessageTableCellWithMessage m_leafCells[k_maxNumberOfDisplayedRows];
|
||||
MessageTableCellWithChevron m_nodeCells[k_maxNumberOfDisplayedRows];
|
||||
};
|
||||
|
||||
@@ -60,13 +60,6 @@ void SequenceToolbox::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||
}
|
||||
}
|
||||
|
||||
KDCoordinate SequenceToolbox::rowHeight(int j) {
|
||||
if (typeAtLocation(0, j) == 2) {
|
||||
return k_addedRowHeight;
|
||||
}
|
||||
return MathToolbox::rowHeight(mathToolboxIndex(j));
|
||||
}
|
||||
|
||||
int SequenceToolbox::typeAtLocation(int i, int j) {
|
||||
if (stackDepth() == 0 && j < m_numberOfAddedCells) {
|
||||
return 2;
|
||||
|
||||
@@ -17,13 +17,11 @@ public:
|
||||
int numberOfRows() override;
|
||||
HighlightCell * reusableCell(int index, int type) override;
|
||||
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||
KDCoordinate rowHeight(int j) override;
|
||||
int typeAtLocation(int i, int j) override;
|
||||
void setExtraCells(const char * sequenceName, int recurrenceDepth);
|
||||
private:
|
||||
bool selectAddedCell(int selectedRow);
|
||||
int mathToolboxIndex(int index);
|
||||
constexpr static KDCoordinate k_addedRowHeight = 20;
|
||||
ExpressionTableCell m_addedCells[k_maxNumberOfDisplayedRows];
|
||||
Poincare::ExpressionLayout * m_addedCellLayout[k_maxNumberOfDisplayedRows];
|
||||
int m_numberOfAddedCells;
|
||||
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
void viewDidDisappear() override;
|
||||
|
||||
//ListViewDataSource
|
||||
virtual KDCoordinate rowHeight(int j) override;
|
||||
int numberOfRows() override;
|
||||
HighlightCell * reusableCell(int index, int type) override;
|
||||
int reusableCellCount(int type) override;
|
||||
@@ -67,6 +68,7 @@ protected:
|
||||
|
||||
static constexpr int LeafCellType = 0;
|
||||
static constexpr int NodeCellType = 1;
|
||||
static constexpr KDCoordinate sToolboxRowHeight = 40;
|
||||
int stackDepth();
|
||||
bool handleEventForRow(Ion::Events::Event event, int selectedRow);
|
||||
bool selectSubMenu(ToolboxMessageTree * selectedMessageTree);
|
||||
|
||||
@@ -118,6 +118,10 @@ void Toolbox::viewDidDisappear() {
|
||||
m_selectableTableView.deselectTable();
|
||||
}
|
||||
|
||||
KDCoordinate Toolbox::rowHeight(int j) {
|
||||
return sToolboxRowHeight;
|
||||
}
|
||||
|
||||
int Toolbox::numberOfRows() {
|
||||
if (m_messageTreeModel == nullptr) {
|
||||
m_messageTreeModel = (ToolboxMessageTree *)rootModel();
|
||||
|
||||
Reference in New Issue
Block a user