mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/graph] Adapt function name column width to names
This commit is contained in:
@@ -31,7 +31,7 @@ int StorageListController::maxNumberOfRows() {
|
||||
return k_maxNumberOfRows;
|
||||
}
|
||||
|
||||
HighlightCell * StorageListController::titleCells(int index) {
|
||||
FunctionTitleCell * StorageListController::titleCells(int index) {
|
||||
assert(index >= 0 && index < k_maxNumberOfRows);
|
||||
return &m_functionTitleCells[index];
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
private:
|
||||
Shared::StorageListParameterController<StorageCartesianFunction> * parameterController() override;
|
||||
int maxNumberOfRows() override;
|
||||
HighlightCell * titleCells(int index) override;
|
||||
Shared::FunctionTitleCell * titleCells(int index) override;
|
||||
HighlightCell * expressionCells(int index) override;
|
||||
void willDisplayTitleCellAtIndex(HighlightCell * cell, int j) override;
|
||||
void willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) override;
|
||||
|
||||
@@ -32,7 +32,7 @@ private:
|
||||
Shared::ExpressionFieldDelegateApp * expressionFieldDelegateApp() override;
|
||||
ListParameterController * parameterController() override;
|
||||
int maxNumberOfRows() override;
|
||||
HighlightCell * titleCells(int index) override;
|
||||
Shared::FunctionTitleCell * titleCells(int index) override;
|
||||
HighlightCell * expressionCells(int index) override;
|
||||
void willDisplayTitleCellAtIndex(HighlightCell * cell, int j) override;
|
||||
void willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) override;
|
||||
|
||||
@@ -13,6 +13,7 @@ public:
|
||||
void setColor(KDColor color) override;
|
||||
void setText(const char * textContent);
|
||||
void setFont(const KDFont * font) { m_bufferTextView.setFont(font); }
|
||||
KDFont * font() const override { return m_bufferTextView.font(); }
|
||||
const char * text() const override {
|
||||
return m_bufferTextView.text();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ public:
|
||||
void setOrientation(Orientation orientation);
|
||||
virtual void setColor(KDColor color);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
virtual KDText::FontSize fontSize() const = 0;
|
||||
protected:
|
||||
constexpr static KDCoordinate k_separatorThickness = 1;
|
||||
constexpr static KDCoordinate k_colorIndicatorThickness = 2;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define SHARED_STORAGE_FUNCTION_LIST_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "function_title_cell.h"
|
||||
#include "storage_function_store.h"
|
||||
#include "function_app.h"
|
||||
#include "storage_list_parameter_controller.h"
|
||||
@@ -43,12 +44,27 @@ public:
|
||||
KDCoordinate rowHeight(int j) override {
|
||||
return this->expressionRowHeight(j);
|
||||
}
|
||||
|
||||
KDCoordinate maxDiplayedFunctionNameWidth() {
|
||||
KDCoordinate columnWidth = k_minNameColumnWidth;
|
||||
int firstDisplayedIndex = m_selectableTableView.firstDisplayedRowIndex();
|
||||
int lastDisplayedIndex = firstDisplayedIndex+m_selectableTableView.numberOfDisplayableRows();
|
||||
for (int i = firstDisplayedIndex; i < lastDisplayedIndex; i++) {
|
||||
const char * currentName = titleCells(i)->text();
|
||||
KDText::FontSize fontSize = titleCells(i)->fontSize();
|
||||
KDCoordinate currentNameWidth = KDText::stringSize(currentName, fontSize).width();
|
||||
columnWidth = columnWidth < currentNameWidth ? currentNameWidth : columnWidth;
|
||||
}
|
||||
// TODO What if very big name?
|
||||
return columnWidth + k_functionNameSumOfMargins;
|
||||
}
|
||||
|
||||
KDCoordinate columnWidth(int i) override {
|
||||
switch (i) {
|
||||
case 0:
|
||||
return k_functionNameWidth;
|
||||
return maxDiplayedFunctionNameWidth();
|
||||
case 1:
|
||||
return selectableTableView()->bounds().width()-k_functionNameWidth;
|
||||
return selectableTableView()->bounds().width()-maxDiplayedFunctionNameWidth();
|
||||
default:
|
||||
assert(false);
|
||||
return 0;
|
||||
@@ -59,7 +75,7 @@ public:
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
return k_functionNameWidth;
|
||||
return maxDiplayedFunctionNameWidth();
|
||||
case 2:
|
||||
return selectableTableView()->bounds().width();
|
||||
default:
|
||||
@@ -68,7 +84,7 @@ public:
|
||||
}
|
||||
}
|
||||
int indexFromCumulatedWidth(KDCoordinate offsetX) override {
|
||||
if (offsetX <= k_functionNameWidth) {
|
||||
if (offsetX <= maxDiplayedFunctionNameWidth()) {
|
||||
return 0;
|
||||
} else {
|
||||
if (offsetX <= selectableTableView()->bounds().width())
|
||||
@@ -224,7 +240,8 @@ protected:
|
||||
}
|
||||
StorageFunctionStore<T> * m_functionStore;
|
||||
private:
|
||||
static constexpr KDCoordinate k_functionNameWidth = 65;
|
||||
static constexpr KDCoordinate k_minNameColumnWidth = 35;
|
||||
static constexpr KDCoordinate k_functionNameSumOfMargins = 2*Metric::HistoryHorizontalMargin;
|
||||
TabViewController * tabController() const {
|
||||
return (TabViewController *)(this->parentResponder()->parentResponder()->parentResponder()->parentResponder());
|
||||
}
|
||||
@@ -235,7 +252,7 @@ private:
|
||||
}
|
||||
virtual StorageListParameterController<T> * parameterController() = 0;
|
||||
virtual int maxNumberOfRows() = 0;
|
||||
virtual HighlightCell * titleCells(int index) = 0;
|
||||
virtual FunctionTitleCell * titleCells(int index) = 0;
|
||||
virtual HighlightCell * expressionCells(int index) = 0;
|
||||
virtual void willDisplayTitleCellAtIndex(HighlightCell * cell, int j) = 0;
|
||||
SelectableTableView m_selectableTableView;
|
||||
|
||||
@@ -11,6 +11,9 @@ public:
|
||||
void setFont(const KDFont * font) {
|
||||
m_bufferTextView.setFont(font);
|
||||
}
|
||||
KDText::FontSize fontSize() const {
|
||||
return m_bufferTextView.fontSize();
|
||||
}
|
||||
void setAlignment(float horizontalAlignment, float verticalAlignment) {
|
||||
m_bufferTextView.setAlignment(horizontalAlignment, verticalAlignment);
|
||||
}
|
||||
@@ -21,7 +24,8 @@ public:
|
||||
protected:
|
||||
int numberOfSubviews() const override;
|
||||
View * subviewAtIndex(int index) override;
|
||||
void layoutSubviews() override; BufferTextView m_bufferTextView;
|
||||
void layoutSubviews() override;
|
||||
BufferTextView m_bufferTextView;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,6 +12,10 @@ public:
|
||||
|
||||
void setHorizontalCellOverlap(KDCoordinate o) { m_contentView.setHorizontalCellOverlap(o); }
|
||||
void setVerticalCellOverlap(KDCoordinate o) { m_contentView.setVerticalCellOverlap(o); }
|
||||
int firstDisplayedRowIndex() const { return m_contentView.rowsScrollingOffset(); }
|
||||
int firstDisplayedColumnIndex() const { return m_contentView.columnsScrollingOffset(); }
|
||||
int numberOfDisplayableRows() const { return m_contentView.numberOfDisplayableRows(); }
|
||||
int numberOfDisplayableColumns() const { return m_contentView.numberOfDisplayableColumns(); }
|
||||
|
||||
virtual void scrollToCell(int i, int j);
|
||||
HighlightCell * cellAtLocation(int i, int j);
|
||||
@@ -36,6 +40,10 @@ protected:
|
||||
HighlightCell * cellAtLocation(int i, int j);
|
||||
void resizeToFitContent();
|
||||
TableViewDataSource * dataSource();
|
||||
int rowsScrollingOffset() const;
|
||||
int columnsScrollingOffset() const;
|
||||
int numberOfDisplayableRows() const;
|
||||
int numberOfDisplayableColumns() const;
|
||||
protected:
|
||||
#if ESCHER_VIEW_LOGGING
|
||||
const char * className() const override;
|
||||
@@ -57,10 +65,6 @@ protected:
|
||||
int absoluteRowNumberFromSubviewIndex(int index) const;
|
||||
int numberOfFullyDisplayableRows() const;
|
||||
int numberOfFullyDisplayableColumns() const;
|
||||
int numberOfDisplayableRows() const;
|
||||
int numberOfDisplayableColumns() const;
|
||||
int rowsScrollingOffset() const;
|
||||
int columnsScrollingOffset() const;
|
||||
int typeOfSubviewAtIndex(int index) const;
|
||||
/* This method transform a index (of subview for instance) into an index
|
||||
* refering to the set of cells of type "type". */
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
virtual const char * text() const = 0;
|
||||
virtual void setText(const char * text) = 0;
|
||||
KDFont * font() const { return m_font; }
|
||||
void setFont(const KDFont * font);
|
||||
protected:
|
||||
#if ESCHER_VIEW_LOGGING
|
||||
|
||||
Reference in New Issue
Block a user