mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/graph] Increase name column width to max when editing function name
This commit is contained in:
@@ -33,6 +33,11 @@ const char * StorageListController::title() {
|
||||
void StorageListController::renameSelectedFunction() {
|
||||
assert(selectedColumn() == 0);
|
||||
assert(selectedRow() >= 0 && selectedRow() < numberOfRows()-1); // TODO change if sometimes the addFunction row is not displayed
|
||||
|
||||
// Increase the size of the name column
|
||||
computeTitlesColumnWidth(true);
|
||||
selectableTableView()->reloadData();
|
||||
|
||||
static_cast<AppsContainer *>(const_cast<Container *>(app()->container()))->setShiftAlphaStatus(Ion::Events::ShiftAlphaStatus::AlphaLock);
|
||||
TextFieldFunctionTitleCell * selectedTitleCell = (TextFieldFunctionTitleCell *)(selectableTableView()->selectedCell());
|
||||
app()->setFirstResponder(selectedTitleCell);
|
||||
@@ -107,6 +112,9 @@ bool StorageListController::textFieldDidFinishEditing(TextField * textField, con
|
||||
}
|
||||
|
||||
bool StorageListController::textFieldDidAbortEditing(TextField * textField) {
|
||||
// Put the name column back to normal size
|
||||
computeTitlesColumnWidth();
|
||||
selectableTableView()->reloadData();
|
||||
ExpiringPointer<StorageFunction> function = modelStore()->modelForRecord(modelStore()->recordAtIndex(selectedRow()));
|
||||
setFunctionNameInTextField(function, textField);
|
||||
m_selectableTableView.selectedCell()->setHighlighted(true);
|
||||
|
||||
@@ -279,9 +279,13 @@ void StorageFunctionListController::configureFunction(Ion::Storage::Record recor
|
||||
stack->push(parameterController());
|
||||
}
|
||||
|
||||
void StorageFunctionListController::computeTitlesColumnWidth() {
|
||||
void StorageFunctionListController::computeTitlesColumnWidth(bool forceMax) {
|
||||
if (forceMax) {
|
||||
m_titlesColumnWidth = nameWidth(StorageFunction::k_maxNameWithArgumentSize - 1)+k_functionTitleSumOfMargins;
|
||||
return;
|
||||
}
|
||||
KDCoordinate maxTitleWidth = maxFunctionNameWidth()+k_functionTitleSumOfMargins;
|
||||
m_titlesColumnWidth = maxTitleWidth < k_minTitleColumnWidth ? k_minTitleColumnWidth : maxTitleWidth;
|
||||
m_titlesColumnWidth = max(maxTitleWidth, k_minTitleColumnWidth);
|
||||
}
|
||||
|
||||
TabViewController * StorageFunctionListController::tabController() const {
|
||||
@@ -308,7 +312,7 @@ KDCoordinate StorageFunctionListController::maxFunctionNameWidth() {
|
||||
assert(dotPosition != nullptr);
|
||||
maxNameLength = max(maxNameLength, dotPosition-functionName);
|
||||
}
|
||||
return (maxNameLength + StorageFunction::k_parenthesedArgumentLength) * titleCells(0)->font()->glyphSize().width();
|
||||
return nameWidth(maxNameLength + StorageFunction::k_parenthesedArgumentLength);
|
||||
}
|
||||
|
||||
void StorageFunctionListController::didChangeModelsList() {
|
||||
@@ -355,4 +359,9 @@ void StorageFunctionListController::shiftMemoization(bool newCellIsUnder) {
|
||||
StorageExpressionModelListController::shiftMemoization(newCellIsUnder);
|
||||
}
|
||||
|
||||
KDCoordinate StorageFunctionListController::nameWidth(int nameLength) const {
|
||||
assert(nameLength >= 0);
|
||||
return nameLength * const_cast<StorageFunctionListController *>(this)->titleCells(0)->font()->glyphSize().width();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
protected:
|
||||
StackViewController * stackController() const;
|
||||
void configureFunction(Ion::Storage::Record record);
|
||||
void computeTitlesColumnWidth();
|
||||
void computeTitlesColumnWidth(bool forceMax = false);
|
||||
StorageFunctionStore * modelStore() override;
|
||||
KDCoordinate baseline(int j);
|
||||
void resetMemoizationForIndex(int index) override;
|
||||
@@ -61,7 +61,7 @@ protected:
|
||||
SelectableTableView m_selectableTableView;
|
||||
private:
|
||||
static constexpr KDCoordinate k_minTitleColumnWidth = 65;
|
||||
static constexpr KDCoordinate k_functionTitleSumOfMargins = 2*Metric::HistoryHorizontalMargin;
|
||||
static constexpr KDCoordinate k_functionTitleSumOfMargins = 15;
|
||||
TabViewController * tabController() const;
|
||||
InputViewController * inputController() override;
|
||||
KDCoordinate maxFunctionNameWidth();
|
||||
@@ -73,6 +73,7 @@ private:
|
||||
virtual HighlightCell * expressionCells(int index) = 0;
|
||||
virtual void willDisplayTitleCellAtIndex(HighlightCell * cell, int j) = 0;
|
||||
virtual KDCoordinate privateBaseline(int j) const = 0;
|
||||
KDCoordinate nameWidth(int nameLength) const;
|
||||
EvenOddCell m_emptyCell;
|
||||
Button m_plotButton;
|
||||
Button m_valuesButton;
|
||||
|
||||
Reference in New Issue
Block a user