diff --git a/apps/calculation/additional_outputs/illustrated_list_controller.cpp b/apps/calculation/additional_outputs/illustrated_list_controller.cpp index 80ea4f52a..432bf49c1 100644 --- a/apps/calculation/additional_outputs/illustrated_list_controller.cpp +++ b/apps/calculation/additional_outputs/illustrated_list_controller.cpp @@ -78,7 +78,7 @@ KDCoordinate IllustratedListController::rowHeight(int j) { return 0; } Shared::ExpiringPointer 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) { diff --git a/apps/calculation/calculation.cpp b/apps/calculation/calculation.cpp index b5da53efd..22c84be74 100644 --- a/apps/calculation/calculation.cpp +++ b/apps/calculation/calculation.cpp @@ -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. */ diff --git a/apps/calculation/calculation.h b/apps/calculation/calculation.h index 9746768a6..767fc1e67 100644 --- a/apps/calculation/calculation.h +++ b/apps/calculation/calculation.h @@ -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); diff --git a/apps/calculation/history_controller.cpp b/apps/calculation/history_controller.cpp index 292a6199e..7d763ec22 100644 --- a/apps/calculation/history_controller.cpp +++ b/apps/calculation/history_controller.cpp @@ -208,7 +208,7 @@ KDCoordinate HistoryController::rowHeight(int j) { return 0; } Shared::ExpiringPointer 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) { diff --git a/apps/calculation/history_view_cell.h b/apps/calculation/history_view_cell.h index 7d6c12b45..e4e4d8da8 100644 --- a/apps/calculation/history_view_cell.h +++ b/apps/calculation/history_view_cell.h @@ -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); diff --git a/escher/include/escher/metric.h b/escher/include/escher/metric.h index 0ac573c96..f514cb68c 100644 --- a/escher/include/escher/metric.h +++ b/escher/include/escher/metric.h @@ -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;