mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps/calculation] Calculation::height takes verticalMargin argument
This commit is contained in:
committed by
EmilieNumworks
parent
7ccaf3fc50
commit
525290427a
@@ -78,7 +78,7 @@ KDCoordinate IllustratedListController::rowHeight(int j) {
|
||||
return 0;
|
||||
}
|
||||
Shared::ExpiringPointer<Calculation> calculation = m_calculationStore.calculationAtIndex(calculationIndex);
|
||||
return calculation->height(App::app()->localContext(), true, true) + 2 * Metric::CommonSmallMargin + Metric::CellSeparatorThickness;
|
||||
return calculation->height(App::app()->localContext(), Metric::CommonSmallMargin, true, true) + Metric::CellSeparatorThickness;
|
||||
}
|
||||
|
||||
int IllustratedListController::typeAtLocation(int i, int j) {
|
||||
|
||||
@@ -124,7 +124,7 @@ Layout Calculation::createApproximateOutputLayout(Context * context, bool * coul
|
||||
}
|
||||
}
|
||||
|
||||
KDCoordinate Calculation::height(Context * context, bool expanded, bool forceSingleLine) {
|
||||
KDCoordinate Calculation::height(Context * context, float verticalMargin, bool expanded, bool forceSingleLine) {
|
||||
KDCoordinate result = expanded ? m_expandedHeight : m_height;
|
||||
if (result >= 0) {
|
||||
// Height already computed
|
||||
@@ -135,8 +135,6 @@ KDCoordinate Calculation::height(Context * context, bool expanded, bool forceSin
|
||||
Layout inputLayout = createInputLayout();
|
||||
KDCoordinate inputHeight = inputLayout.layoutSize().height();
|
||||
KDCoordinate inputWidth = inputLayout.layoutSize().width();
|
||||
float singleMargin = 2 * Metric::CommonSmallMargin;
|
||||
float doubleMargin = 4 * Metric::CommonSmallMargin;
|
||||
KDCoordinate inputBaseline = inputLayout.baseline();
|
||||
|
||||
// Get exact output height if needed
|
||||
@@ -159,14 +157,13 @@ KDCoordinate Calculation::height(Context * context, bool expanded, bool forceSin
|
||||
if (displayOutput(context) == DisplayOutput::ExactOnly) {
|
||||
KDCoordinate exactOutputHeight = exactLayout.layoutSize().height();
|
||||
KDCoordinate exactOutputWidth = exactLayout.layoutSize().width();
|
||||
|
||||
bool singleLine = forceSingleLine || ((exactOutputWidth + inputWidth) < maxWidth - 2); //TODO LEA 2
|
||||
|
||||
if (singleLine) {
|
||||
KDCoordinate exactOutputBaseline = exactLayout.baseline();
|
||||
result = std::max(inputBaseline, exactOutputBaseline) + std::max(inputHeight - inputBaseline, exactOutputHeight-exactOutputBaseline) + singleMargin;
|
||||
result = std::max(inputBaseline, exactOutputBaseline) // Above the baseline
|
||||
+ std::max(inputHeight - inputBaseline, exactOutputHeight - exactOutputBaseline); // Below the baseline
|
||||
} else {
|
||||
result = inputHeight + exactOutputHeight + doubleMargin;
|
||||
result = inputHeight + verticalMargin + exactOutputHeight;
|
||||
}
|
||||
} else {
|
||||
// Create the approximate output layout
|
||||
@@ -194,9 +191,10 @@ KDCoordinate Calculation::height(Context * context, bool expanded, bool forceSin
|
||||
bool singleLine = forceSingleLine || ((approximateOutputWidth + inputWidth) < maxWidth); // TODO LEA 2
|
||||
if (singleLine) {
|
||||
KDCoordinate approximateOutputBaseline = approximateLayout.baseline();
|
||||
result = std::max(inputBaseline, approximateOutputBaseline) + std::max(inputHeight - inputBaseline, approximateOutputHeight-approximateOutputBaseline) + singleMargin;
|
||||
result = std::max(inputBaseline, approximateOutputBaseline) // Above the baseline
|
||||
+ std::max(inputHeight - inputBaseline, approximateOutputHeight - approximateOutputBaseline); // Below the baseline
|
||||
} else {
|
||||
result = inputHeight + approximateOutputHeight + doubleMargin;
|
||||
result = inputHeight + verticalMargin + approximateOutputHeight;
|
||||
}
|
||||
} else {
|
||||
assert(displayOutput(context) == DisplayOutput::ExactAndApproximate || (displayOutput(context) == DisplayOutput::ExactAndApproximateToggle && expanded));
|
||||
@@ -207,14 +205,21 @@ KDCoordinate Calculation::height(Context * context, bool expanded, bool forceSin
|
||||
KDCoordinate approximateOutputBaseline = approximateLayout.baseline();
|
||||
bool singleLine = forceSingleLine || ((inputWidth + exactOutputWidth + approximateOutputWidth) < (maxWidth - 30)); // the 30 represents the = sign (example: sin(30)) TODO LEA
|
||||
if (singleLine) {
|
||||
result = std::max(inputBaseline, std::max(exactOutputBaseline, approximateOutputBaseline)) + std::max(inputHeight - inputBaseline, std::max(exactOutputHeight - exactOutputBaseline, approximateOutputHeight-approximateOutputBaseline)) + singleMargin;
|
||||
result = std::max(inputBaseline, std::max(exactOutputBaseline, approximateOutputBaseline)) // Above the baseline
|
||||
+ std::max(inputHeight - inputBaseline, // Beloxw the baseline
|
||||
std::max(exactOutputHeight - exactOutputBaseline,
|
||||
approximateOutputHeight - approximateOutputBaseline));
|
||||
} else {
|
||||
KDCoordinate outputHeight = std::max(exactOutputBaseline, approximateOutputBaseline) + std::max(exactOutputHeight-exactOutputBaseline, approximateOutputHeight-approximateOutputBaseline);
|
||||
result = inputHeight + outputHeight + doubleMargin;
|
||||
KDCoordinate outputHeight = std::max(exactOutputBaseline, approximateOutputBaseline) // Above the baseline
|
||||
+ std::max(exactOutputHeight - exactOutputBaseline, approximateOutputHeight - approximateOutputBaseline); // Below the baseline
|
||||
result = inputHeight + verticalMargin + outputHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the top and bottom margins
|
||||
result += 2 * verticalMargin;
|
||||
|
||||
/* For all display outputs except ExactAndApproximateToggle, the selected
|
||||
* height and the usual height are identical. We update both heights in
|
||||
* theses cases. */
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
Poincare::Layout createApproximateOutputLayout(Poincare::Context * context, bool * couldNotCreateApproximateLayout);
|
||||
|
||||
// Memoization of height
|
||||
KDCoordinate height(Poincare::Context * context, bool expanded = false, bool forceSingleLine = false);
|
||||
KDCoordinate height(Poincare::Context * context, float verticalMargin, bool expanded, bool forceSingleLine);
|
||||
|
||||
// Displayed output
|
||||
DisplayOutput displayOutput(Poincare::Context * context);
|
||||
|
||||
@@ -208,7 +208,7 @@ KDCoordinate HistoryController::rowHeight(int j) {
|
||||
return 0;
|
||||
}
|
||||
Shared::ExpiringPointer<Calculation> calculation = calculationAtIndex(j);
|
||||
return calculation->height(App::app()->localContext(), j == selectedRow() && selectedSubviewType() == SubviewType::Output);
|
||||
return calculation->height(App::app()->localContext(), HistoryViewCell::k_verticalMargin, j == selectedRow() && selectedSubviewType() == SubviewType::Output, false);
|
||||
}
|
||||
|
||||
int HistoryController::typeAtLocation(int i, int j) {
|
||||
|
||||
@@ -31,6 +31,7 @@ private:
|
||||
|
||||
class HistoryViewCell : public ::EvenOddCell, public Responder {
|
||||
public:
|
||||
constexpr static KDCoordinate k_verticalMargin = Metric::CommonLargeMargin; //TODO LEA same as k_horizontalMargin?
|
||||
HistoryViewCell(Responder * parentResponder = nullptr);
|
||||
void cellDidSelectSubview(HistoryViewCellDataSource::SubviewType type, HistoryViewCellDataSource::SubviewType previousType = HistoryViewCellDataSource::SubviewType::None);
|
||||
void setEven(bool even) override;
|
||||
@@ -52,6 +53,7 @@ public:
|
||||
Shared::ScrollableTwoExpressionsView * outputView();
|
||||
Calculation::AdditionalInformationType additionalInformationType() const { return m_calculationAdditionInformation; }
|
||||
private:
|
||||
constexpr static KDCoordinate k_horizontalMargin = Metric::CommonSmallMargin;
|
||||
constexpr static KDCoordinate k_resultWidth = 80;
|
||||
void reloadScroll();
|
||||
void reloadOutputSelection(HistoryViewCellDataSource::SubviewType previousType);
|
||||
|
||||
@@ -10,8 +10,8 @@ public:
|
||||
constexpr static KDCoordinate CommonRightMargin = 20;
|
||||
constexpr static KDCoordinate CommonTopMargin = 15;
|
||||
constexpr static KDCoordinate CommonBottomMargin = 15;
|
||||
constexpr static KDCoordinate CommonLargeMargin = 12;
|
||||
constexpr static KDCoordinate CommonSmallMargin = 12;
|
||||
constexpr static KDCoordinate CommonLargeMargin = 10;
|
||||
constexpr static KDCoordinate CommonSmallMargin = 5;
|
||||
constexpr static KDCoordinate TitleBarExternHorizontalMargin = 5;
|
||||
constexpr static KDCoordinate TitleBarHeight = 18;
|
||||
constexpr static KDCoordinate ParameterCellHeight = 35;
|
||||
|
||||
Reference in New Issue
Block a user