diff --git a/apps/banner_view.cpp b/apps/banner_view.cpp index 7202e62e1..34ab7ea68 100644 --- a/apps/banner_view.cpp +++ b/apps/banner_view.cpp @@ -18,7 +18,7 @@ void BannerView::setLegendAtIndex(char * text, int index) { } KDSize BannerView::minimalSizeForOptimalDisplay() { - return KDSize(0, KDText::stringSize(" ").height()*numberOfLines()); + return KDSize(0, KDText::stringSize(" ", KDText::FontSize::Small).height()*numberOfLines()); } int BannerView::numberOfSubviews() const { @@ -73,7 +73,7 @@ int BannerView::numberOfLines() { KDCoordinate usedWidth = 0; KDCoordinate lineNumber = 0; for (int i = 0; i < numberOfSubviews(); i++) { - KDCoordinate textWidth = KDText::stringSize(textViewAtIndex(i)->text()).width(); + KDCoordinate textWidth = KDText::stringSize(textViewAtIndex(i)->text(), KDText::FontSize::Small).width(); if (usedWidth+textWidth > width) { usedWidth = textWidth; lineNumber++; diff --git a/apps/calculation/text_field.cpp b/apps/calculation/text_field.cpp index 3f0e999e8..e47e5e89a 100644 --- a/apps/calculation/text_field.cpp +++ b/apps/calculation/text_field.cpp @@ -3,7 +3,7 @@ namespace Calculation { TextField::TextField(Responder * parentResponder, char * textBuffer, size_t textBufferSize, TextFieldDelegate * delegate) : - ::TextField(parentResponder, textBuffer, textBuffer, textBufferSize, delegate) + ::TextField(parentResponder, textBuffer, textBuffer, textBufferSize, KDText::FontSize::Large, delegate) { m_isEditing = true; } diff --git a/apps/curve_view.cpp b/apps/curve_view.cpp index 9fc25662e..9c4245a92 100644 --- a/apps/curve_view.cpp +++ b/apps/curve_view.cpp @@ -99,7 +99,7 @@ void CurveView::drawLabels(KDContext * ctx, KDRect rect, Axis axis, bool shiftOr float end = max(axis); int i = 0; for (float x = start; x < end; x += 2.0f*step) { - KDSize textSize = KDText::stringSize(label(axis, i)); + KDSize textSize = KDText::stringSize(label(axis, i), KDText::FontSize::Small); KDPoint origin(floatToPixel(Axis::Horizontal, x) - textSize.width()/2, floatToPixel(Axis::Vertical, 0.0f) + k_labelMargin); if (axis == Axis::Vertical) { origin = KDPoint(floatToPixel(Axis::Horizontal, 0.0f) + k_labelMargin, floatToPixel(Axis::Vertical, x) - textSize.height()/2); @@ -107,8 +107,8 @@ void CurveView::drawLabels(KDContext * ctx, KDRect rect, Axis axis, bool shiftOr if (-step < x && x < step && shiftOrigin) { origin = KDPoint(floatToPixel(Axis::Horizontal, 0.0f) + k_labelMargin, floatToPixel(Axis::Vertical, 0.0f) + k_labelMargin); } - if (rect.intersects(KDRect(origin, KDText::stringSize(label(axis, i))))) { - ctx->blendString(label(axis, i), origin, KDColorBlack); + if (rect.intersects(KDRect(origin, KDText::stringSize(label(axis, i), KDText::FontSize::Small)))) { + ctx->blendString(label(axis, i), KDText::FontSize::Small, origin, KDColorBlack); } i++; } diff --git a/apps/graph/function_title_cell.cpp b/apps/graph/function_title_cell.cpp index 08116dcff..415777318 100644 --- a/apps/graph/function_title_cell.cpp +++ b/apps/graph/function_title_cell.cpp @@ -3,9 +3,9 @@ namespace Graph { -FunctionTitleCell::FunctionTitleCell(Orientation orientation) : +FunctionTitleCell::FunctionTitleCell(Orientation orientation, KDText::FontSize size) : EvenOddCell(), - m_bufferTextView(0.5f, 0.5f), + m_bufferTextView(size, 0.5f, 0.5f), m_orientation(orientation) { } diff --git a/apps/graph/function_title_cell.h b/apps/graph/function_title_cell.h index 05cf15d5d..956f360b9 100644 --- a/apps/graph/function_title_cell.h +++ b/apps/graph/function_title_cell.h @@ -10,7 +10,7 @@ public: HorizontalIndicator, VerticalIndicator }; - FunctionTitleCell(Orientation orientation); + FunctionTitleCell(Orientation orientation, KDText::FontSize size); void setColor(KDColor color); void setText(const char * textContent); void drawRect(KDContext * ctx, KDRect rect) const override; diff --git a/apps/graph/graph/banner_view.cpp b/apps/graph/graph/banner_view.cpp index 3f214f8e5..2a20ba498 100644 --- a/apps/graph/graph/banner_view.cpp +++ b/apps/graph/graph/banner_view.cpp @@ -3,9 +3,9 @@ namespace Graph { BannerView::BannerView() : - m_abscissaView(0.5f, 0.5f), - m_functionView(0.5f, 0.5f), - m_derivativeView(0.5f, 0.5f), + m_abscissaView(KDText::FontSize::Small, 0.5f, 0.5f), + m_functionView(KDText::FontSize::Small, 0.5f, 0.5f), + m_derivativeView(KDText::FontSize::Small, 0.5f, 0.5f), m_displayDerivative(false) { } diff --git a/apps/graph/list/list_controller.cpp b/apps/graph/list/list_controller.cpp index 8bba76947..d190bd4e1 100644 --- a/apps/graph/list/list_controller.cpp +++ b/apps/graph/list/list_controller.cpp @@ -7,8 +7,8 @@ namespace Graph { ListController::ListController(Responder * parentResponder, FunctionStore * functionStore, HeaderViewController * header) : ViewController(parentResponder), HeaderViewDelegate(header), - m_functionTitleCells{FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), - FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator)}, + m_functionTitleCells{FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator, KDText::FontSize::Large), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator, KDText::FontSize::Large), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator, KDText::FontSize::Large), + FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator, KDText::FontSize::Large), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator, KDText::FontSize::Large), FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator, KDText::FontSize::Large)}, m_selectableTableView(SelectableTableView(this, this)), m_functionStore(functionStore), m_parameterController(ParameterController(this, functionStore)) diff --git a/apps/graph/list/new_function_cell.cpp b/apps/graph/list/new_function_cell.cpp index 2d5ec470f..466ee6c08 100644 --- a/apps/graph/list/new_function_cell.cpp +++ b/apps/graph/list/new_function_cell.cpp @@ -5,7 +5,7 @@ namespace Graph { NewFunctionCell::NewFunctionCell() : EvenOddCell(), - m_pointerTextView(PointerTextView("Ajouter une fonction", 0.5f, 0.5f)) + m_pointerTextView(PointerTextView(KDText::FontSize::Large, "Ajouter une fonction", 0.5f, 0.5f)) { } diff --git a/apps/graph/values/values_controller.cpp b/apps/graph/values/values_controller.cpp index 903c27ce0..2c2ed295b 100644 --- a/apps/graph/values/values_controller.cpp +++ b/apps/graph/values/values_controller.cpp @@ -9,10 +9,11 @@ namespace Graph { ValuesController::ValuesController(Responder * parentResponder, FunctionStore * functionStore, HeaderViewController * header) : EditableCellTableViewController(parentResponder, k_topMargin, k_rightMargin, k_bottomMargin, k_leftMargin), HeaderViewDelegate(header), - m_functionTitleCells{FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator), - FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator)}, - m_abscissaCells{EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer),EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), - EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer)}, + m_abscissaTitleCell(EvenOddPointerTextCell(KDText::FontSize::Small)), + m_functionTitleCells{FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small), + FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small)}, + m_abscissaCells{EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), + EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small)}, m_functionStore(functionStore), m_intervalParameterController(IntervalParameterController(this, &m_interval)), m_abscissaParameterController(AbscissaParameterController(this, &m_intervalParameterController)), @@ -22,7 +23,7 @@ ValuesController::ValuesController(Responder * parentResponder, FunctionStore * ValuesController * valuesController = (ValuesController *) context; StackViewController * stack = ((StackViewController *)valuesController->stackController()); stack->push(valuesController->intervalParameterController()); - }, this))) + }, this), KDText::FontSize::Small)) { m_interval.setStart(0); m_interval.setEnd(10); diff --git a/apps/home/app_cell.cpp b/apps/home/app_cell.cpp index c02ac0f11..3f134885b 100644 --- a/apps/home/app_cell.cpp +++ b/apps/home/app_cell.cpp @@ -5,6 +5,7 @@ namespace Home { AppCell::AppCell() : TableViewCell(), + m_nameView(PointerTextView(KDText::FontSize::Small)), m_visible(true) { } diff --git a/apps/interactive_curve_view_controller.cpp b/apps/interactive_curve_view_controller.cpp index 55c1a482f..0aa258262 100644 --- a/apps/interactive_curve_view_controller.cpp +++ b/apps/interactive_curve_view_controller.cpp @@ -13,17 +13,17 @@ InteractiveCurveViewController::InteractiveCurveViewController(Responder * paren InteractiveCurveViewController * graphController = (InteractiveCurveViewController *) context; StackViewController * stack = graphController->stackController(); stack->push(graphController->rangeParameterController()); - }, this)), + }, this), KDText::FontSize::Small), m_zoomButton(this, "Zoom", Invocation([](void * context, void * sender) { InteractiveCurveViewController * graphController = (InteractiveCurveViewController *) context; StackViewController * stack = graphController->stackController(); stack->push(graphController->zoomParameterController()); - }, this)), + }, this), KDText::FontSize::Small), m_defaultInitialisationButton(this, "Initialisation", Invocation([](void * context, void * sender) { InteractiveCurveViewController * graphController = (InteractiveCurveViewController *) context; StackViewController * stack = graphController->stackController(); stack->push(graphController->initialisationParameterController()); - }, this)) + }, this), KDText::FontSize::Small) { } diff --git a/apps/probability/calculation/finite_integral_calculation.cpp b/apps/probability/calculation/finite_integral_calculation.cpp index 4038ffd8c..e935cf640 100644 --- a/apps/probability/calculation/finite_integral_calculation.cpp +++ b/apps/probability/calculation/finite_integral_calculation.cpp @@ -20,12 +20,12 @@ int FiniteIntegralCalculation::numberOfParameters() { const char * FiniteIntegralCalculation::legendForParameterAtIndex(int index) { assert(index >= 0 && index < 3); if (index == 0) { - return "P( "; + return "P("; } if (index == 1) { - return " <= X <= "; + return "<=X<="; } - return " )= "; + return ")="; } void FiniteIntegralCalculation::setParameterAtIndex(float f, int index) { diff --git a/apps/probability/calculation/left_integral_calculation.cpp b/apps/probability/calculation/left_integral_calculation.cpp index 2b245e747..2f1217ebc 100644 --- a/apps/probability/calculation/left_integral_calculation.cpp +++ b/apps/probability/calculation/left_integral_calculation.cpp @@ -19,9 +19,9 @@ int LeftIntegralCalculation::numberOfParameters() { const char * LeftIntegralCalculation::legendForParameterAtIndex(int index) { assert(index >= 0 && index < 2); if (index == 0) { - return "P(X <= "; + return "P(X<="; } - return ") = "; + return ")="; } void LeftIntegralCalculation::setParameterAtIndex(float f, int index) { diff --git a/apps/probability/calculation/right_integral_calculation.cpp b/apps/probability/calculation/right_integral_calculation.cpp index fbc5acb4f..6e30bd883 100644 --- a/apps/probability/calculation/right_integral_calculation.cpp +++ b/apps/probability/calculation/right_integral_calculation.cpp @@ -19,9 +19,9 @@ int RightIntegralCalculation::numberOfParameters() { const char * RightIntegralCalculation::legendForParameterAtIndex(int index) { assert(index >= 0 && index < 2); if (index == 0) { - return "P( "; + return "P("; } - return " <= X ) = "; + return "<=X)="; } void RightIntegralCalculation::setParameterAtIndex(float f, int index) { diff --git a/apps/probability/calculation_controller.cpp b/apps/probability/calculation_controller.cpp index 25d03132e..20526d06a 100644 --- a/apps/probability/calculation_controller.cpp +++ b/apps/probability/calculation_controller.cpp @@ -11,9 +11,10 @@ namespace Probability { CalculationController::ContentView::ContentView(Responder * parentResponder, CalculationController * calculationController, Calculation * calculation) : m_lawCurveView(LawCurveView()), m_imageTableView(ImageTableView(parentResponder, calculation, calculationController)), - m_calculationCell{EditableTextCell(parentResponder, calculationController, m_draftTextBuffer), - EditableTextCell(parentResponder, calculationController, m_draftTextBuffer), - EditableTextCell(parentResponder, calculationController, m_draftTextBuffer)}, + m_text{PointerTextView(KDText::FontSize::Large), PointerTextView(KDText::FontSize::Large), PointerTextView(KDText::FontSize::Large)}, + m_calculationCell{EditableTextCell(parentResponder, calculationController, m_draftTextBuffer, KDText::FontSize::Large), + EditableTextCell(parentResponder, calculationController, m_draftTextBuffer, KDText::FontSize::Large), + EditableTextCell(parentResponder, calculationController, m_draftTextBuffer, KDText::FontSize::Large)}, m_calculation(calculation) { } @@ -69,24 +70,25 @@ void CalculationController::ContentView::willDisplayEditableCellAtIndex(int inde void CalculationController::ContentView::layoutSubviews() { markRectAsDirty(bounds()); + KDSize charSize = KDText::stringSize(" ", KDText::FontSize::Large); KDCoordinate xCoordinate = 0; m_lawCurveView.setFrame(KDRect(0, ImageTableView::k_imageHeight, bounds().width(), bounds().height() - ImageTableView::k_imageHeight)); m_imageTableView.setFrame(KDRect(xCoordinate, 0, ImageTableView::k_imageWidth, 3*ImageTableView::k_imageHeight)); xCoordinate += ImageTableView::k_imageWidth + k_textMargin; KDCoordinate numberOfCharacters = strlen(m_calculation->legendForParameterAtIndex(0)); - m_text[0].setFrame(KDRect(xCoordinate, 0, numberOfCharacters*k_charWidth, ImageTableView::k_imageHeight)); - xCoordinate += numberOfCharacters*k_charWidth + k_textMargin; + m_text[0].setFrame(KDRect(xCoordinate, 0, numberOfCharacters*charSize.width(), ImageTableView::k_imageHeight)); + xCoordinate += numberOfCharacters*charSize.width() + k_textMargin; m_calculationCell[0].setFrame(KDRect(xCoordinate, 0, k_textFieldWidth, ImageTableView::k_imageHeight)); xCoordinate += k_textFieldWidth + k_textMargin; numberOfCharacters = strlen(m_calculation->legendForParameterAtIndex(1)); - m_text[1].setFrame(KDRect(xCoordinate, 0, numberOfCharacters*k_charWidth, ImageTableView::k_imageHeight)); - xCoordinate += numberOfCharacters*k_charWidth + k_textMargin; + m_text[1].setFrame(KDRect(xCoordinate, 0, numberOfCharacters*charSize.width(), ImageTableView::k_imageHeight)); + xCoordinate += numberOfCharacters*charSize.width() + k_textMargin; m_calculationCell[1].setFrame(KDRect(xCoordinate, 0, k_textFieldWidth, ImageTableView::k_imageHeight)); xCoordinate += k_textFieldWidth + k_textMargin; if (m_calculation->numberOfParameters() > 2) { numberOfCharacters = strlen(m_calculation->legendForParameterAtIndex(2));; - m_text[2].setFrame(KDRect(xCoordinate, 0, numberOfCharacters*k_charWidth, ImageTableView::k_imageHeight)); - xCoordinate += numberOfCharacters*k_charWidth + k_textMargin; + m_text[2].setFrame(KDRect(xCoordinate, 0, numberOfCharacters*charSize.width(), ImageTableView::k_imageHeight)); + xCoordinate += numberOfCharacters*charSize.width() + k_textMargin; m_calculationCell[2].setFrame(KDRect(xCoordinate, 0, k_textFieldWidth, ImageTableView::k_imageHeight)); } for (int k = 0; k < m_calculation->numberOfParameters(); k++) { diff --git a/apps/probability/calculation_controller.h b/apps/probability/calculation_controller.h index a038ff393..377dcea1a 100644 --- a/apps/probability/calculation_controller.h +++ b/apps/probability/calculation_controller.h @@ -38,7 +38,6 @@ private: constexpr static int k_maxNumberOfEditableFields = 3; private: constexpr static KDCoordinate k_textFieldWidth = 50; - constexpr static KDCoordinate k_charWidth = 7; constexpr static KDCoordinate k_textMargin = 5; int numberOfSubviews() const override; View * subviewAtIndex(int index) override; diff --git a/apps/probability/cell.cpp b/apps/probability/cell.cpp index a9a4116b1..44d7ae3c6 100644 --- a/apps/probability/cell.cpp +++ b/apps/probability/cell.cpp @@ -5,7 +5,7 @@ namespace Probability { Cell::Cell() : TableViewCell(), - m_labelView(PointerTextView(nullptr, 0, 0.5, KDColorBlack, Palette::CellBackgroundColor)) + m_labelView(PointerTextView(KDText::FontSize::Large, nullptr, 0, 0.5, KDColorBlack, Palette::CellBackgroundColor)) { } diff --git a/apps/probability/parameters_controller.cpp b/apps/probability/parameters_controller.cpp index 9bf8476a4..c9c7af318 100644 --- a/apps/probability/parameters_controller.cpp +++ b/apps/probability/parameters_controller.cpp @@ -16,9 +16,9 @@ ParametersController::ContentView::ContentView(Responder * parentResponder, Sele StackViewController * stack = parameterController->stackController(); stack->updateTitle(); stack->push(calculationController); - }, parentResponder))), - m_firstParameterDefinition(PointerTextView(nullptr, 0.5f, 0.5f, KDColorBlack, Palette::BackgroundColor)), - m_secondParameterDefinition(PointerTextView(nullptr, 0.5f, 0.5f, KDColorBlack, Palette::BackgroundColor)), + }, parentResponder), KDText::FontSize::Large)), + m_firstParameterDefinition(PointerTextView(KDText::FontSize::Small, nullptr, 0.5f, 0.5f, KDColorBlack, Palette::BackgroundColor)), + m_secondParameterDefinition(PointerTextView(KDText::FontSize::Small, nullptr, 0.5f, 0.5f, KDColorBlack, Palette::BackgroundColor)), m_selectableTableView(selectableTableView) { } diff --git a/apps/regression/banner_view.cpp b/apps/regression/banner_view.cpp index b3ee8ba87..17725701a 100644 --- a/apps/regression/banner_view.cpp +++ b/apps/regression/banner_view.cpp @@ -3,11 +3,11 @@ namespace Regression { BannerView::BannerView() : - m_regressionTypeView(nullptr, 0.5f, 0.5f), - m_slopeView(0.5f, 0.5f), - m_yInterceptView(0.5f, 0.5f), - m_xView(0.5f, 0.5f), - m_yView(0.5f, 0.5f) + m_regressionTypeView(KDText::FontSize::Small, nullptr, 0.5f, 0.5f), + m_slopeView(KDText::FontSize::Small, 0.5f, 0.5f), + m_yInterceptView(KDText::FontSize::Small, 0.5f, 0.5f), + m_xView(KDText::FontSize::Small, 0.5f, 0.5f), + m_yView(KDText::FontSize::Small, 0.5f, 0.5f) { } diff --git a/apps/regression/calculation_controller.cpp b/apps/regression/calculation_controller.cpp index 576eae009..c8287fb44 100644 --- a/apps/regression/calculation_controller.cpp +++ b/apps/regression/calculation_controller.cpp @@ -7,10 +7,13 @@ namespace Regression { CalculationController::CalculationController(Responder * parentResponder, Store * store) : ViewController(parentResponder), + m_titleCells{EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small), + EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small)}, + m_columnTitleCell(EvenOddDoubleBufferTextCell(&m_selectableTableView)), + m_calculationCells{EvenOddBufferTextCell(KDText::FontSize::Small), EvenOddBufferTextCell(KDText::FontSize::Small), EvenOddBufferTextCell(KDText::FontSize::Small), EvenOddBufferTextCell(KDText::FontSize::Small), EvenOddBufferTextCell(KDText::FontSize::Small)}, m_selectableTableView(SelectableTableView(this, this, Metric::TopMargin, Metric::RightMargin, Metric::BottomMargin, Metric::LeftMargin, this)), m_store(store) { - m_columnTitleCell.setParentResponder(&m_selectableTableView); for (int k = 0; k < k_maxNumberOfDisplayableRows/2; k++) { m_calculationCells[k].setTextColor(Palette::DesactiveTextColor); m_doubleCalculationCells[k].setTextColor(Palette::DesactiveTextColor); diff --git a/apps/regression/even_odd_double_buffer_text_cell.cpp b/apps/regression/even_odd_double_buffer_text_cell.cpp index 8564c1129..5eafc1551 100644 --- a/apps/regression/even_odd_double_buffer_text_cell.cpp +++ b/apps/regression/even_odd_double_buffer_text_cell.cpp @@ -5,8 +5,8 @@ EvenOddDoubleBufferTextCell::EvenOddDoubleBufferTextCell(Responder * parentRespo EvenOddCell(), Responder(parentResponder), m_firstTextSelected(true), - m_firstBufferTextView(EvenOddBufferTextCell()), - m_secondBufferTextView(EvenOddBufferTextCell()) + m_firstBufferTextView(EvenOddBufferTextCell(KDText::FontSize::Small)), + m_secondBufferTextView(EvenOddBufferTextCell(KDText::FontSize::Small)) { } diff --git a/apps/statistics/box_banner_view.cpp b/apps/statistics/box_banner_view.cpp index 1e5a3a0f6..0f2fc1cd5 100644 --- a/apps/statistics/box_banner_view.cpp +++ b/apps/statistics/box_banner_view.cpp @@ -3,8 +3,8 @@ namespace Statistics { BoxBannerView::BoxBannerView() : - m_calculationName(nullptr, 0.0f, 0.5f), - m_calculationValue(1.0f, 0.5f) + m_calculationName(KDText::FontSize::Small, nullptr, 0.0f, 0.5f), + m_calculationValue(KDText::FontSize::Small, 1.0f, 0.5f) { } diff --git a/apps/statistics/calculation_controller.cpp b/apps/statistics/calculation_controller.cpp index 3bfb3aa9c..b9fe7fe58 100644 --- a/apps/statistics/calculation_controller.cpp +++ b/apps/statistics/calculation_controller.cpp @@ -7,6 +7,10 @@ namespace Statistics { CalculationController::CalculationController(Responder * parentResponder, Store * store) : ViewController(parentResponder), + m_titleCells{EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small), + EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small), EvenOddPointerTextCell(KDText::FontSize::Small)}, + m_calculationCells{EvenOddBufferTextCell(KDText::FontSize::Small), EvenOddBufferTextCell(KDText::FontSize::Small), EvenOddBufferTextCell(KDText::FontSize::Small), EvenOddBufferTextCell(KDText::FontSize::Small), EvenOddBufferTextCell(KDText::FontSize::Small), + EvenOddBufferTextCell(KDText::FontSize::Small), EvenOddBufferTextCell(KDText::FontSize::Small), EvenOddBufferTextCell(KDText::FontSize::Small), EvenOddBufferTextCell(KDText::FontSize::Small), EvenOddBufferTextCell(KDText::FontSize::Small)}, m_selectableTableView(SelectableTableView(this, this, Metric::TopMargin, Metric::RightMargin, Metric::BottomMargin, Metric::LeftMargin)), m_store(store) { diff --git a/apps/statistics/histogram_banner_view.cpp b/apps/statistics/histogram_banner_view.cpp index 787d782b2..f5dcc54f7 100644 --- a/apps/statistics/histogram_banner_view.cpp +++ b/apps/statistics/histogram_banner_view.cpp @@ -6,9 +6,9 @@ namespace Statistics { HistogramBannerView::HistogramBannerView() : - m_intervalView(0.5f, 0.5f), - m_sizeView(0.5f, 0.5f), - m_frequencyView(0.5f, 0.5f) + m_intervalView(KDText::FontSize::Small, 0.5f, 0.5f), + m_sizeView(KDText::FontSize::Small, 0.5f, 0.5f), + m_frequencyView(KDText::FontSize::Small, 0.5f, 0.5f) { } diff --git a/apps/statistics/histogram_controller.cpp b/apps/statistics/histogram_controller.cpp index b9bbf60d3..da8d2ddaa 100644 --- a/apps/statistics/histogram_controller.cpp +++ b/apps/statistics/histogram_controller.cpp @@ -10,11 +10,11 @@ HistogramController::HistogramController(Responder * parentResponder, HeaderView HeaderViewDelegate(headerViewController), m_bannerView(HistogramBannerView()), m_view(HistogramView(store, &m_bannerView)), - m_settingButton(Button(this, "Reglages de l'histogramme",Invocation([](void * context, void * sender) { + m_settingButton(Button(this, "Reglages de l'histogramme", Invocation([](void * context, void * sender) { HistogramController * histogramController = (HistogramController *) context; StackViewController * stack = ((StackViewController *)histogramController->stackController()); stack->push(histogramController->histogramParameterController()); - }, this))), + }, this), KDText::FontSize::Small)), m_store(store), m_cursor(CurveViewCursor()), m_histogramParameterController(nullptr, store) diff --git a/apps/store_controller.cpp b/apps/store_controller.cpp index 6a411fcad..1bb3b02a6 100644 --- a/apps/store_controller.cpp +++ b/apps/store_controller.cpp @@ -5,10 +5,11 @@ StoreController::StoreController(Responder * parentResponder, FloatPairStore * store) : EditableCellTableViewController(parentResponder, Metric::TopMargin, Metric::RightMargin, Metric::BottomMargin, Metric::LeftMargin), - m_editableCells{EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), - EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), - EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), - EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer)}, + m_editableCells{EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), + EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), + EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), + EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Large)}, + m_titleCells{EvenOddPointerTextCell(KDText::FontSize::Large), EvenOddPointerTextCell(KDText::FontSize::Large)}, m_store(store), m_storeParameterController(this, store) { diff --git a/apps/toolbox_leaf_cell.cpp b/apps/toolbox_leaf_cell.cpp index 8d0a069b3..13708f428 100644 --- a/apps/toolbox_leaf_cell.cpp +++ b/apps/toolbox_leaf_cell.cpp @@ -3,8 +3,8 @@ ToolboxLeafCell::ToolboxLeafCell() : TableViewCell(), - m_labelView(PointerTextView(nullptr, 0, 0.5, KDColorBlack, Palette::CellBackgroundColor)), - m_subtitleView(PointerTextView(nullptr, 0, 0.5, Palette::DesactiveTextColor, Palette::CellBackgroundColor)) + m_labelView(PointerTextView(KDText::FontSize::Small, nullptr, 0, 0.5, KDColorBlack, Palette::CellBackgroundColor)), + m_subtitleView(PointerTextView(KDText::FontSize::Small, nullptr, 0, 0.5, Palette::DesactiveTextColor, Palette::CellBackgroundColor)) { } diff --git a/apps/variable_box_leaf_cell.cpp b/apps/variable_box_leaf_cell.cpp index d1907735e..380ae0189 100644 --- a/apps/variable_box_leaf_cell.cpp +++ b/apps/variable_box_leaf_cell.cpp @@ -3,8 +3,8 @@ VariableBoxLeafCell::VariableBoxLeafCell() : TableViewCell(), - m_labelView(BufferTextView(0, 0.5, KDColorBlack, Palette::CellBackgroundColor)), - m_subtitleView(BufferTextView(0, 0.5, Palette::DesactiveTextColor, Palette::CellBackgroundColor)), + m_labelView(BufferTextView(KDText::FontSize::Small, 0, 0.5, KDColorBlack, Palette::CellBackgroundColor)), + m_subtitleView(BufferTextView(KDText::FontSize::Small, 0, 0.5, Palette::DesactiveTextColor, Palette::CellBackgroundColor)), m_displayExpression(false) { } diff --git a/apps/zoom_parameter_controller.cpp b/apps/zoom_parameter_controller.cpp index 06613f953..b595203d2 100644 --- a/apps/zoom_parameter_controller.cpp +++ b/apps/zoom_parameter_controller.cpp @@ -90,20 +90,14 @@ CurveView * ZoomParameterController::ContentView::curveView() { /* Legend View */ -ZoomParameterController::ContentView::LegendView::LegendView() +ZoomParameterController::ContentView::LegendView::LegendView() : + m_legends{PointerTextView(KDText::FontSize::Small, "ZOOM+", 0.0f, 0.5f, KDColorBlack, k_legendBackgroundColor), + PointerTextView(KDText::FontSize::Small, "HAUT", 0.0f, 0.5f, KDColorBlack, k_legendBackgroundColor), + PointerTextView(KDText::FontSize::Small, "GAUCHE", 0.0f, 0.5f, KDColorBlack, k_legendBackgroundColor), + PointerTextView(KDText::FontSize::Small, "ZOOM-", 1.0f, 0.5f, KDColorBlack, k_legendBackgroundColor), + PointerTextView(KDText::FontSize::Small, "BAS", 1.0f, 0.5f, KDColorBlack, k_legendBackgroundColor), + PointerTextView(KDText::FontSize::Small, "DROITE", 1.0f, 0.5f, KDColorBlack, k_legendBackgroundColor)} { - m_legends[0].setText("ZOOM+"); - m_legends[1].setText("HAUT"); - m_legends[2].setText("GAUCHE"); - m_legends[3].setText("ZOOM-"); - m_legends[4].setText("BAS"); - m_legends[5].setText("DROITE"); - for (int row = 0; row < 3; row++) { - m_legends[row].setAlignment(0.0f, 0.5f); - m_legends[3+row].setAlignment(1.0f, 0.5f); - m_legends[row].setBackgroundColor(k_legendBackgroundColor); - m_legends[3+row].setBackgroundColor(k_legendBackgroundColor); - } } void ZoomParameterController::ContentView::LegendView::drawRect(KDContext * ctx, KDRect rect) const { diff --git a/escher/include/escher/buffer_text_view.h b/escher/include/escher/buffer_text_view.h index 0c095c956..aaee0bb7e 100644 --- a/escher/include/escher/buffer_text_view.h +++ b/escher/include/escher/buffer_text_view.h @@ -5,7 +5,7 @@ class BufferTextView : public TextView { public: - BufferTextView(float horizontalAlignment = 0.5f, float verticalAlignment = 0.5f, + BufferTextView(KDText::FontSize size, float horizontalAlignment = 0.5f, float verticalAlignment = 0.5f, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); void setText(const char * text) override; const char * text() const override; diff --git a/escher/include/escher/button.h b/escher/include/escher/button.h index 223dda744..8caa6864d 100644 --- a/escher/include/escher/button.h +++ b/escher/include/escher/button.h @@ -8,7 +8,7 @@ class Button : public View, public Responder { public: - Button(Responder * parentResponder, const char * textBody, Invocation invocation); + Button(Responder * parentResponder, const char * textBody, Invocation invocation, KDText::FontSize size); void drawRect(KDContext * ctx, KDRect rect) const override; bool handleEvent(Ion::Events::Event event) override; void setBackgroundColor(KDColor backgroundColor); diff --git a/escher/include/escher/editable_text_cell.h b/escher/include/escher/editable_text_cell.h index 6550f3944..31b0e9e39 100644 --- a/escher/include/escher/editable_text_cell.h +++ b/escher/include/escher/editable_text_cell.h @@ -8,7 +8,7 @@ class EditableTextCell : public TableViewCell, public Responder { public: - EditableTextCell(Responder * parentResponder, TextFieldDelegate * delegate, char * draftTextBuffer, + EditableTextCell(Responder * parentResponder, TextFieldDelegate * delegate, char * draftTextBuffer, KDText::FontSize size, float horizontalAlignment = 0.0f, float verticalAlignment = 0.5f, KDColor textColor = KDColorBlack, KDColor = KDColorWhite); TextField * textField(); void reloadCell() override; diff --git a/escher/include/escher/editable_text_menu_list_cell.h b/escher/include/escher/editable_text_menu_list_cell.h index 69abecf72..fb82c646c 100644 --- a/escher/include/escher/editable_text_menu_list_cell.h +++ b/escher/include/escher/editable_text_menu_list_cell.h @@ -18,8 +18,7 @@ public: void setTextColor(KDColor color) override; constexpr static int k_bufferLength = 255; private: - constexpr static KDCoordinate k_textWidth = 7*7; - constexpr static KDCoordinate k_textHeight = 12; + constexpr static int k_maxNumberOfEditableCharacters = 14; TextField m_textField; char m_textBody[k_bufferLength]; }; diff --git a/escher/include/escher/even_odd_buffer_text_cell.h b/escher/include/escher/even_odd_buffer_text_cell.h index 88adadcef..446359404 100644 --- a/escher/include/escher/even_odd_buffer_text_cell.h +++ b/escher/include/escher/even_odd_buffer_text_cell.h @@ -6,7 +6,7 @@ class EvenOddBufferTextCell : public EvenOddCell { public: - EvenOddBufferTextCell(); + EvenOddBufferTextCell(KDText::FontSize size = KDText::FontSize::Small); void reloadCell() override; void setText(const char * textContent); void setTextColor(KDColor textColor); diff --git a/escher/include/escher/even_odd_editable_text_cell.h b/escher/include/escher/even_odd_editable_text_cell.h index e63331567..b250307af 100644 --- a/escher/include/escher/even_odd_editable_text_cell.h +++ b/escher/include/escher/even_odd_editable_text_cell.h @@ -7,7 +7,7 @@ class EvenOddEditableTextCell : public EvenOddCell, public Responder { public: - EvenOddEditableTextCell(Responder * parentResponder, TextFieldDelegate * delegate, char * draftTextBuffer); + EvenOddEditableTextCell(Responder * parentResponder, TextFieldDelegate * delegate, char * draftTextBuffer, KDText::FontSize size); EditableTextCell * editableTextCell(); void reloadCell() override; const char * text() const; diff --git a/escher/include/escher/even_odd_pointer_text_cell.h b/escher/include/escher/even_odd_pointer_text_cell.h index 040bd5daf..58f2e1bc0 100644 --- a/escher/include/escher/even_odd_pointer_text_cell.h +++ b/escher/include/escher/even_odd_pointer_text_cell.h @@ -6,7 +6,7 @@ class EvenOddPointerTextCell : public EvenOddCell { public: - EvenOddPointerTextCell(); + EvenOddPointerTextCell(KDText::FontSize size); void reloadCell() override; void setText(const char * textContent, KDColor textColor = KDColorBlack); void setAlignment(float horizontalAlignment, float verticalAlignment); diff --git a/escher/include/escher/pointer_text_view.h b/escher/include/escher/pointer_text_view.h index d3675d201..d60a0dff2 100644 --- a/escher/include/escher/pointer_text_view.h +++ b/escher/include/escher/pointer_text_view.h @@ -5,7 +5,7 @@ class PointerTextView : public TextView { public: - PointerTextView(const char * text = nullptr, float horizontalAlignment = 0.0f, float verticalAlignment = 0.0f, + PointerTextView(KDText::FontSize size, const char * text = nullptr, float horizontalAlignment = 0.0f, float verticalAlignment = 0.0f, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); void setText(const char * text) override; protected: diff --git a/escher/include/escher/text_field.h b/escher/include/escher/text_field.h index d21c1eb2a..54d166d1d 100644 --- a/escher/include/escher/text_field.h +++ b/escher/include/escher/text_field.h @@ -8,8 +8,9 @@ class TextField : public View, public Responder { public: - TextField(Responder * parentResponder, char * textBuffer, char * draftTextBuffer, size_t textBufferSize, TextFieldDelegate * delegate = nullptr, - float horizontalAlignment = 0.0f, float verticalAlignment = 0.5f, KDColor textColor = KDColorBlack, KDColor = KDColorWhite); + TextField(Responder * parentResponder, char * textBuffer, char * draftTextBuffer, size_t textBufferSize, + KDText::FontSize size, TextFieldDelegate * delegate = nullptr, float horizontalAlignment = 0.0f, + float verticalAlignment = 0.5f, KDColor textColor = KDColorBlack, KDColor = KDColorWhite); // View void drawRect(KDContext * ctx, KDRect rect) const override; // Responder @@ -48,6 +49,7 @@ private: float m_verticalAlignment; KDColor m_textColor; KDColor m_backgroundColor; + KDText::FontSize m_fontSize; }; #endif diff --git a/escher/include/escher/text_view.h b/escher/include/escher/text_view.h index 9a5adca65..150f88384 100644 --- a/escher/include/escher/text_view.h +++ b/escher/include/escher/text_view.h @@ -9,7 +9,7 @@ public: // alignment = 0 -> align left or top // alignment = 0.5 -> align center // alignment = 1.0 -> align right or bottom - TextView(float horizontalAlignment = 0.0f, float verticalAlignment = 0.0f, + TextView(KDText::FontSize size, float horizontalAlignment = 0.0f, float verticalAlignment = 0.0f, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); void drawRect(KDContext * ctx, KDRect rect) const override; void setBackgroundColor(KDColor backgroundColor); @@ -27,6 +27,7 @@ private: float m_verticalAlignment; KDColor m_textColor; KDColor m_backgroundColor; + KDText::FontSize m_fontSize; }; #endif diff --git a/escher/src/alternate_empty_view_controller.cpp b/escher/src/alternate_empty_view_controller.cpp index 9406406bf..4193ef075 100644 --- a/escher/src/alternate_empty_view_controller.cpp +++ b/escher/src/alternate_empty_view_controller.cpp @@ -6,7 +6,7 @@ /* ContentView */ AlternateEmptyViewController::ContentView::ContentView(ViewController * mainViewController, AlternateEmptyViewDelegate * delegate) : - m_message(PointerTextView(nullptr, 0.5f, 0.5f, KDColorBlack, Palette::BackgroundColor)), + m_message(PointerTextView(KDText::FontSize::Small, nullptr, 0.5f, 0.5f, KDColorBlack, Palette::BackgroundColor)), m_mainViewController(mainViewController), m_delegate(delegate) { diff --git a/escher/src/buffer_text_view.cpp b/escher/src/buffer_text_view.cpp index 848f6230a..d372edff2 100644 --- a/escher/src/buffer_text_view.cpp +++ b/escher/src/buffer_text_view.cpp @@ -2,9 +2,9 @@ #include #include -BufferTextView::BufferTextView(float horizontalAlignment, float verticalAlignment, +BufferTextView::BufferTextView(KDText::FontSize size, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) : - TextView(horizontalAlignment, verticalAlignment, textColor, backgroundColor) + TextView(size, horizontalAlignment, verticalAlignment, textColor, backgroundColor) { } diff --git a/escher/src/button.cpp b/escher/src/button.cpp index 1e6fa7952..54a86e63f 100644 --- a/escher/src/button.cpp +++ b/escher/src/button.cpp @@ -1,9 +1,9 @@ #include #include -Button::Button(Responder * parentResponder, const char * textBody, Invocation invocation) : +Button::Button(Responder * parentResponder, const char * textBody, Invocation invocation, KDText::FontSize size) : Responder(parentResponder), - m_pointerTextView(PointerTextView(textBody, 0.5f, 0.5f)), + m_pointerTextView(PointerTextView(size, textBody, 0.5f, 0.5f)), m_invocation(invocation), m_backgroundColor(KDColorWhite) { diff --git a/escher/src/editable_text_cell.cpp b/escher/src/editable_text_cell.cpp index b9bcdd3f7..d672b9396 100644 --- a/escher/src/editable_text_cell.cpp +++ b/escher/src/editable_text_cell.cpp @@ -4,10 +4,10 @@ #include EditableTextCell::EditableTextCell(Responder * parentResponder, TextFieldDelegate * delegate, char * draftTextBuffer, - float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) : + KDText::FontSize size, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) : TableViewCell(), Responder(parentResponder), - m_textField(TextField(this, m_textBody, draftTextBuffer, 255, delegate, horizontalAlignment, verticalAlignment, textColor, backgroundColor)) + m_textField(TextField(this, m_textBody, draftTextBuffer, 255, size, delegate, horizontalAlignment, verticalAlignment, textColor, backgroundColor)) { } diff --git a/escher/src/editable_text_menu_list_cell.cpp b/escher/src/editable_text_menu_list_cell.cpp index 4b0304407..95967a194 100644 --- a/escher/src/editable_text_menu_list_cell.cpp +++ b/escher/src/editable_text_menu_list_cell.cpp @@ -4,7 +4,7 @@ EditableTextMenuListCell::EditableTextMenuListCell(Responder * parentResponder, TextFieldDelegate * textFieldDelegate, char * draftTextBuffer, char * label) : Responder(parentResponder), MenuListCell(label), - m_textField(TextField(this, m_textBody, draftTextBuffer, 255, textFieldDelegate)) + m_textField(TextField(this, m_textBody, draftTextBuffer, 255, KDText::FontSize::Large, textFieldDelegate, 1.0f, 0.5f)) { } @@ -20,7 +20,9 @@ void EditableTextMenuListCell::layoutSubviews() { MenuListCell::layoutSubviews(); KDCoordinate width = bounds().width(); KDCoordinate height = bounds().height(); - m_textField.setFrame(KDRect(width - k_textWidth - k_separatorThickness, (height - k_textHeight)/2, k_textWidth - k_separatorThickness, k_textHeight)); + KDSize charSize = KDText::stringSize(" ", KDText::FontSize::Large); + KDCoordinate textWidth = k_maxNumberOfEditableCharacters*charSize.width(); + m_textField.setFrame(KDRect(width - textWidth - k_separatorThickness, (height - charSize.height())/2, textWidth - k_separatorThickness, charSize.height())); } void EditableTextMenuListCell::didBecomeFirstResponder() { diff --git a/escher/src/even_odd_buffer_text_cell.cpp b/escher/src/even_odd_buffer_text_cell.cpp index 28611afb0..a6970c0dc 100644 --- a/escher/src/even_odd_buffer_text_cell.cpp +++ b/escher/src/even_odd_buffer_text_cell.cpp @@ -1,9 +1,9 @@ #include #include -EvenOddBufferTextCell::EvenOddBufferTextCell() : +EvenOddBufferTextCell::EvenOddBufferTextCell(KDText::FontSize size) : EvenOddCell(), - m_bufferTextView(BufferTextView(1.0f, 0.5f)) + m_bufferTextView(BufferTextView(size, 1.0f, 0.5f)) { } diff --git a/escher/src/even_odd_editable_text_cell.cpp b/escher/src/even_odd_editable_text_cell.cpp index bb7c28637..95b47d460 100644 --- a/escher/src/even_odd_editable_text_cell.cpp +++ b/escher/src/even_odd_editable_text_cell.cpp @@ -2,10 +2,10 @@ #include #include -EvenOddEditableTextCell::EvenOddEditableTextCell(Responder * parentResponder, TextFieldDelegate * delegate, char * draftTextBuffer) : +EvenOddEditableTextCell::EvenOddEditableTextCell(Responder * parentResponder, TextFieldDelegate * delegate, char * draftTextBuffer, KDText::FontSize size) : EvenOddCell(), Responder(parentResponder), - m_editableCell(this, delegate, draftTextBuffer, 1.0f, 0.5f, KDColorBlack, KDColorWhite) + m_editableCell(this, delegate, draftTextBuffer, size, 1.0f, 0.5f, KDColorBlack, KDColorWhite) { } diff --git a/escher/src/even_odd_pointer_text_cell.cpp b/escher/src/even_odd_pointer_text_cell.cpp index ec2b4f387..4e49c6778 100644 --- a/escher/src/even_odd_pointer_text_cell.cpp +++ b/escher/src/even_odd_pointer_text_cell.cpp @@ -1,9 +1,9 @@ #include #include -EvenOddPointerTextCell::EvenOddPointerTextCell() : +EvenOddPointerTextCell::EvenOddPointerTextCell(KDText::FontSize size) : EvenOddCell(), - m_pointerTextView(nullptr, 0.5f, 0.5f) + m_pointerTextView(size, nullptr, 0.5f, 0.5f) { } diff --git a/escher/src/input_view_controller.cpp b/escher/src/input_view_controller.cpp index efe57a296..d96f2c573 100644 --- a/escher/src/input_view_controller.cpp +++ b/escher/src/input_view_controller.cpp @@ -4,7 +4,7 @@ InputViewController::TextFieldController::TextFieldController(Responder * parentResponder, TextFieldDelegate * textFieldDelegate) : ViewController(parentResponder), - m_textField(parentResponder, m_textBody, m_textBody, 255, textFieldDelegate) + m_textField(parentResponder, m_textBody, m_textBody, 255, KDText::FontSize::Large, textFieldDelegate) { m_textBody[0] = 0; } diff --git a/escher/src/menu_list_cell.cpp b/escher/src/menu_list_cell.cpp index 49637d694..07c3e7ae4 100644 --- a/escher/src/menu_list_cell.cpp +++ b/escher/src/menu_list_cell.cpp @@ -5,7 +5,7 @@ constexpr KDCoordinate MenuListCell::k_separatorThickness; MenuListCell::MenuListCell(char * label) : TableViewCell(), - m_pointerTextView(PointerTextView(label, 0, 0.5, KDColorBlack, Palette::CellBackgroundColor)) + m_pointerTextView(PointerTextView(KDText::FontSize::Small, label, 0, 0.5, KDColorBlack, Palette::CellBackgroundColor)) { } diff --git a/escher/src/pointer_text_view.cpp b/escher/src/pointer_text_view.cpp index 40fc7e0b6..ba1cd61d3 100644 --- a/escher/src/pointer_text_view.cpp +++ b/escher/src/pointer_text_view.cpp @@ -1,8 +1,8 @@ #include -PointerTextView::PointerTextView(const char * text, float horizontalAlignment, float verticalAlignment, +PointerTextView::PointerTextView(KDText::FontSize size, const char * text, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) : - TextView(horizontalAlignment, verticalAlignment, textColor, backgroundColor), + TextView(size, horizontalAlignment, verticalAlignment, textColor, backgroundColor), m_textPointer(text) { } diff --git a/escher/src/stack_view.cpp b/escher/src/stack_view.cpp index deb4d9595..7b7e1c8a8 100644 --- a/escher/src/stack_view.cpp +++ b/escher/src/stack_view.cpp @@ -5,7 +5,7 @@ extern "C" { StackView::StackView() : View(), - m_textView(PointerTextView(nullptr, 0.5f, 0.5f)) + m_textView(PointerTextView(KDText::FontSize::Small, nullptr, 0.5f, 0.5f)) { } diff --git a/escher/src/tab_view_cell.cpp b/escher/src/tab_view_cell.cpp index e0aa8dac6..b5c634829 100644 --- a/escher/src/tab_view_cell.cpp +++ b/escher/src/tab_view_cell.cpp @@ -45,9 +45,9 @@ void TabViewCell::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(KDRect(0, 1, width, height-1), background); } // Write title - KDSize textSize = KDText::stringSize(m_name); + KDSize textSize = KDText::stringSize(m_name, KDText::FontSize::Small); KDPoint origin(0.5f*(m_frame.width() - textSize.width()),0.5f*(m_frame.height() - textSize.height())); - ctx->drawString(m_name, origin, text, background); + ctx->drawString(m_name, KDText::FontSize::Small, origin, text, background); } #if ESCHER_VIEW_LOGGING diff --git a/escher/src/text_field.cpp b/escher/src/text_field.cpp index bfc6f8520..b0f44f165 100644 --- a/escher/src/text_field.cpp +++ b/escher/src/text_field.cpp @@ -2,7 +2,7 @@ #include TextField::TextField(Responder * parentResponder, char * textBuffer, char * draftTextBuffer, - size_t textBufferSize, TextFieldDelegate * delegate, + size_t textBufferSize, KDText::FontSize size, TextFieldDelegate * delegate, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) : View(), Responder(parentResponder), @@ -16,7 +16,8 @@ TextField::TextField(Responder * parentResponder, char * textBuffer, char * draf m_horizontalAlignment(horizontalAlignment), m_verticalAlignment(verticalAlignment), m_textColor(textColor), - m_backgroundColor(backgroundColor) + m_backgroundColor(backgroundColor), + m_fontSize(size) { } @@ -29,10 +30,10 @@ const char * TextField::text() const { void TextField::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(rect, m_backgroundColor); - KDSize textSize = KDText::stringSize(text()); + KDSize textSize = KDText::stringSize(text(), m_fontSize); KDPoint origin(m_horizontalAlignment*(m_frame.width() - textSize.width()), m_verticalAlignment*(m_frame.height() - textSize.height())); - ctx->drawString(text(), origin, m_textColor, m_backgroundColor); + ctx->drawString(text(), m_fontSize, origin, m_textColor, m_backgroundColor); } #if ESCHER_VIEW_LOGGING @@ -58,7 +59,7 @@ void TextField::setAlignment(float horizontalAlignment, float verticalAlignment) } void TextField::reload() { - KDSize textSize = KDText::stringSize(text()); + KDSize textSize = KDText::stringSize(text(), m_fontSize); KDPoint origin(m_horizontalAlignment*(m_frame.width() - textSize.width()), m_verticalAlignment*(m_frame.height() - textSize.height())); KDRect dirtyZone(origin, textSize); @@ -168,7 +169,7 @@ void TextField::insertTextAtLocation(const char * text, int location) { } KDSize TextField::minimalSizeForOptimalDisplay() { - KDSize textSize = KDText::stringSize(m_draftTextBuffer); + KDSize textSize = KDText::stringSize(m_draftTextBuffer, m_fontSize); return KDSize(0, textSize.height()); } @@ -195,4 +196,4 @@ void TextField::reinitDraftTextBuffer() { setCursorLocation(0); m_draftTextBuffer[0] = 0; m_currentTextLength = 0; -} \ No newline at end of file +} diff --git a/escher/src/text_menu_list_cell.cpp b/escher/src/text_menu_list_cell.cpp index ea4f152a3..3e8faaeff 100644 --- a/escher/src/text_menu_list_cell.cpp +++ b/escher/src/text_menu_list_cell.cpp @@ -2,7 +2,7 @@ TextMenuListCell::TextMenuListCell(char * label) : MenuListCell(label), - m_accessoryView(BufferTextView(1.0f, 0.5f)) + m_accessoryView(BufferTextView(KDText::FontSize::Large, 1.0f, 0.5f)) { } diff --git a/escher/src/text_view.cpp b/escher/src/text_view.cpp index 47914fb3b..6b80fa8e9 100644 --- a/escher/src/text_view.cpp +++ b/escher/src/text_view.cpp @@ -1,12 +1,13 @@ #include -TextView::TextView(float horizontalAlignment, float verticalAlignment, +TextView::TextView(KDText::FontSize size, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) : View(), m_horizontalAlignment(horizontalAlignment), m_verticalAlignment(verticalAlignment), m_textColor(textColor), - m_backgroundColor(backgroundColor) + m_backgroundColor(backgroundColor), + m_fontSize(size) { } @@ -27,18 +28,18 @@ void TextView::setAlignment(float horizontalAlignment, float verticalAlignment) } KDSize TextView::minimalSizeForOptimalDisplay() { - return KDText::stringSize(text()); + return KDText::stringSize(text(), m_fontSize); } void TextView::drawRect(KDContext * ctx, KDRect rect) const { if (text() == nullptr) { return; } - KDSize textSize = KDText::stringSize(text()); + KDSize textSize = KDText::stringSize(text(), m_fontSize); KDPoint origin(m_horizontalAlignment*(m_frame.width() - textSize.width()), m_verticalAlignment*(m_frame.height() - textSize.height())); ctx->fillRect(bounds(), m_backgroundColor); - ctx->drawString(text(), origin, m_textColor, m_backgroundColor); + ctx->drawString(text(), m_fontSize, origin, m_textColor, m_backgroundColor); } #if ESCHER_VIEW_LOGGING diff --git a/escher/src/warning_controller.cpp b/escher/src/warning_controller.cpp index 10a726293..88cb3bea3 100644 --- a/escher/src/warning_controller.cpp +++ b/escher/src/warning_controller.cpp @@ -3,7 +3,7 @@ WarningController::ContentView::ContentView() : SolidColorView(KDColorBlack), - m_textView(PointerTextView("", 0.5f, 0.5f, KDColorWhite, KDColorBlack)) + m_textView(PointerTextView(KDText::FontSize::Small, "", 0.5f, 0.5f, KDColorWhite, KDColorBlack)) { } diff --git a/kandinsky/Makefile b/kandinsky/Makefile index abb9c238c..dbc0e7a02 100644 --- a/kandinsky/Makefile +++ b/kandinsky/Makefile @@ -6,12 +6,13 @@ objs += $(addprefix kandinsky/src/,\ context_pixel.o\ context_rect.o\ context_text.o\ - font.o\ framebuffer.o\ framebuffer_context.o\ ion_context.o\ + large_font.o\ point.o\ rect.o\ + small_font.o\ text.o\ ) tests += $(addprefix kandinsky/test/,\ @@ -24,30 +25,37 @@ FREETYPE_PATH := /usr/local/Cellar/freetype/2.6.3 # built w/o PNG support and simply won't output an image of the rasterization #LIBPNG_PATH := /usr/local/Cellar/libpng/1.6.21 -kandinsky/src/text.cpp: kandinsky/src/font.h -kandinsky/src/context_text.cpp: kandinsky/src/font.h +kandinsky/src/text.cpp: kandinsky/src/small_font.h kandinsky/src/large_font.h +kandinsky/src/context_text.cpp: kandinsky/src/small_font.h kandinsky/src/large_font.h -font_files = $(addprefix kandinsky/src/, font.h font.c) +small_font_files = $(addprefix kandinsky/src/, small_font.h small_font.c) +large_font_files = $(addprefix kandinsky/src/, large_font.h large_font.c) RASTERIZER_CFLAGS := -std=c99 `freetype-config --cflags` RASTERIZER_LDFLAGS := `freetype-config --libs` ifdef LIBPNG_PATH - font_files += kandinsky/src/font.png + small_font_files += kandinsky/src/small_font.png + large_font_files += kandinsky/src/large_font.png RASTERIZER_CFLAGS += -I$(LIBPNG_PATH)/include -DGENERATE_PNG=1 -L$(LIBPNG_PATH)/lib -lpng endif # Even though raster will generate both .c and .h files, we don't declare it as # such to make. If we did, "make -jN" with N>1 may call "raster" twice. -kandinsky/src/font.h: kandinsky/src/font.c -kandinsky/src/font.c: kandinsky/fonts/rasterizer - @echo "RASTER $(font_files)" - @$< kandinsky/fonts/ProggyClean.ttf 16 16 $(font_files) +kandinsky/src/small_font.h: kandinsky/src/small_font.c +kandinsky/src/small_font.c: kandinsky/fonts/rasterizer + @echo "RASTER $(small_font_files)" + @$< kandinsky/fonts/smallPixelFont.ttf 12 12 SmallFont $(small_font_files) + +kandinsky/src/large_font.h: kandinsky/src/large_font.c +kandinsky/src/large_font.c: kandinsky/fonts/rasterizer + @echo "RASTER $(large_font_files)" + @$< kandinsky/fonts/largePixelFont.ttf 16 16 LargeFont $(large_font_files) kandinsky/fonts/rasterizer: kandinsky/fonts/rasterizer.c @echo "HOSTCC $@" - @$(HOSTCC) -std=c99 $(RASTERIZER_CFLAGS) $< $(RASTERIZER_LDFLAGS) -o $@ + @$(HOSTCC) -std=c99 $(RASTERIZER_CFLAGS) $< $(RASTERIZER_LDFLAGS) -o$@ -products += $(font_files) kandinsky/fonts/rasterizer +products += $(small_font_files) $(large_font_files) kandinsky/fonts/rasterizer diff --git a/kandinsky/fonts/largePixelFont.ttf b/kandinsky/fonts/largePixelFont.ttf new file mode 100644 index 000000000..778a46dc7 Binary files /dev/null and b/kandinsky/fonts/largePixelFont.ttf differ diff --git a/kandinsky/fonts/rasterizer.c b/kandinsky/fonts/rasterizer.c index dc73f9bad..4730f5079 100644 --- a/kandinsky/fonts/rasterizer.c +++ b/kandinsky/fonts/rasterizer.c @@ -46,7 +46,6 @@ void writeImageToPNGFile(image_t * image, char * filename); #error Grid too small. Consider increasing GRID_WIDTH or GRID_HEIGHT #endif - void drawGlyphInImage(FT_Bitmap * glyphBitmap, image_t * image, int x, int y); int main(int argc, char * argv[]) { @@ -54,19 +53,20 @@ int main(int argc, char * argv[]) { FT_Face face; image_t bitmap_image; - int expectedNumberOfArguments = 6; + int expectedNumberOfArguments = 7; #ifdef GENERATE_PNG - expectedNumberOfArguments = 7; + expectedNumberOfArguments = 8; #endif if (argc != expectedNumberOfArguments) { #ifdef GENERATE_PNG - fprintf(stderr, "Usage: %s font_file glyph_width glyph_height output_header output_implementation output_png\n", argv[0]); + fprintf(stderr, "Usage: %s font_file glyph_width glyph_height font_name output_header output_implementation output_png\n", argv[0]); #else - fprintf(stderr, "Usage: %s font_file glyph_width glyph_height output_header output_implementation\n", argv[0]); + fprintf(stderr, "Usage: %s font_file glyph_width glyph_height font_name output_header output_implementation\n", argv[0]); #endif fprintf(stderr, " font_file: Path of the font file to load\n"); fprintf(stderr, " glyph_width: Width of bitmap glyphs, in pixels\n"); fprintf(stderr, " glyph_height: Height of bitmap glyphs, in pixels\n"); + fprintf(stderr, " font_name: name of the loaded font\n"); fprintf(stderr, " output_header: Name of the generated C header file\n"); fprintf(stderr, " output_implementation: Name of the generated C source file\n"); #ifdef GENERATE_PNG @@ -78,10 +78,11 @@ int main(int argc, char * argv[]) { char * font_file = argv[1]; int requested_glyph_width = atoi(argv[2]); int requested_glyph_height = atoi(argv[3]); - char * output_header = argv[4]; - char * output_implementation = argv[5]; + char * font_name = argv[4]; + char * output_header = argv[5]; + char * output_implementation = argv[6]; #ifdef GENERATE_PNG - char * output_png = argv[6]; + char * output_png = argv[7]; #endif ENSURE(!FT_Init_FreeType(&library), "Initializing library"); @@ -115,7 +116,7 @@ int main(int argc, char * argv[]) { } } - int glyph_width = maxWidth; + int glyph_width = maxWidth-1; int glyph_height = maxAboveBaseline+maxBelowBaseline; //printf("Actual glyph size = %dx%d\n", glyph_width, glyph_height); @@ -157,16 +158,16 @@ int main(int argc, char * argv[]) { FILE * headerFile = fopen(output_header, "w"); fprintf(headerFile, "/* Auto-generated by rasterizer */\n\n"); - fprintf(headerFile, "#define BITMAP_FONT_FIRST_CHARACTER 0x%2x\n", CHARACTER_RANGE_START); - fprintf(headerFile, "#define BITMAP_FONT_LAST_CHARACTER 0x%2x\n\n", CHARACTER_RANGE_END); - fprintf(headerFile, "#define BITMAP_FONT_CHARACTER_WIDTH %d\n", glyph_width); - fprintf(headerFile, "#define BITMAP_FONT_CHARACTER_HEIGHT %d\n\n", glyph_height); - fprintf(headerFile, "extern unsigned char bitmapFont[%d][%d][%d];\n", CHARACTER_RANGE_END-CHARACTER_RANGE_START+1, glyph_height, glyph_width); + fprintf(headerFile, "#define BITMAP_%s_FIRST_CHARACTER 0x%2x\n", font_name, CHARACTER_RANGE_START); + fprintf(headerFile, "#define BITMAP_%s_LAST_CHARACTER 0x%2x\n\n", font_name, CHARACTER_RANGE_END); + fprintf(headerFile, "#define BITMAP_%s_CHARACTER_WIDTH %d\n", font_name, glyph_width); + fprintf(headerFile, "#define BITMAP_%s_CHARACTER_HEIGHT %d\n\n", font_name, glyph_height); + fprintf(headerFile, "extern unsigned char bitmap%s[%d][%d][%d];\n", font_name, CHARACTER_RANGE_END-CHARACTER_RANGE_START+1, glyph_height, glyph_width); fclose(headerFile); FILE * sourceFile = fopen(output_implementation, "w"); fprintf(sourceFile, "/* Auto-generated by rasterizer */\n\n"); - fprintf(sourceFile, "unsigned char bitmapFont[%d][%d][%d] = {\n", CHARACTER_RANGE_END-CHARACTER_RANGE_START+1, glyph_height, glyph_width); + fprintf(sourceFile, "unsigned char bitmap%s[%d][%d][%d] = {\n", font_name, CHARACTER_RANGE_END-CHARACTER_RANGE_START+1, glyph_height, glyph_width); for (unsigned char character = CHARACTER_RANGE_START; character <= CHARACTER_RANGE_END; character++) { fprintf(sourceFile, " {\n"); int characterX = ((character-CHARACTER_RANGE_START)%GRID_WIDTH * (glyph_width+grid_size)); diff --git a/kandinsky/fonts/smallPixelFont.ttf b/kandinsky/fonts/smallPixelFont.ttf new file mode 100644 index 000000000..9f5671cc3 Binary files /dev/null and b/kandinsky/fonts/smallPixelFont.ttf differ diff --git a/kandinsky/include/kandinsky/context.h b/kandinsky/include/kandinsky/context.h index 805ed96d2..874ebc335 100644 --- a/kandinsky/include/kandinsky/context.h +++ b/kandinsky/include/kandinsky/context.h @@ -3,6 +3,7 @@ #include #include +#include class KDContext { public: @@ -14,10 +15,10 @@ public: KDColor getPixel(KDPoint p); // Text - void drawChar(char character, KDPoint p, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); - void drawString(const char * text, KDPoint p, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); - void blendChar(char character, KDPoint p, KDColor textColor = KDColorBlack); - void blendString(const char * text, KDPoint p, KDColor textColor = KDColorBlack); + void drawChar(char character, KDText::FontSize size, KDPoint p, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); + void drawString(const char * text, KDText::FontSize size, KDPoint p, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); + void blendChar(char character, KDText::FontSize size, KDPoint p, KDColor textColor = KDColorBlack); + void blendString(const char * text, KDText::FontSize size, KDPoint p, KDColor textColor = KDColorBlack); // Line. Not anti-aliased. void drawLine(KDPoint p1, KDPoint p2, KDColor c); diff --git a/kandinsky/include/kandinsky/text.h b/kandinsky/include/kandinsky/text.h index 69cd93b91..230ddc0d7 100644 --- a/kandinsky/include/kandinsky/text.h +++ b/kandinsky/include/kandinsky/text.h @@ -5,7 +5,11 @@ class KDText { public: - static KDSize stringSize(const char * text); + enum class FontSize { + Small, + Large + }; + static KDSize stringSize(const char * text, FontSize size); }; #endif diff --git a/kandinsky/src/context_text.cpp b/kandinsky/src/context_text.cpp index d4f8513ea..12e8819a2 100644 --- a/kandinsky/src/context_text.cpp +++ b/kandinsky/src/context_text.cpp @@ -1,50 +1,50 @@ #include -#include "font.h" +#include "small_font.h" +#include "large_font.h" -KDColor characterBuffer[BITMAP_FONT_CHARACTER_WIDTH*BITMAP_FONT_CHARACTER_HEIGHT]; +KDColor smallCharacterBuffer[BITMAP_SmallFont_CHARACTER_WIDTH*BITMAP_SmallFont_CHARACTER_HEIGHT]; +KDColor largeCharacterBuffer[BITMAP_LargeFont_CHARACTER_WIDTH*BITMAP_LargeFont_CHARACTER_HEIGHT]; -void KDContext::drawChar(char character, KDPoint p, KDColor textColor, KDColor backgroundColor) { - for (int j=0; j #include -#include "font.h" +#include "small_font.h" +#include "large_font.h" -KDSize KDText::stringSize(const char * text) { +KDSize KDText::stringSize(const char * text, FontSize size) { if (text == nullptr) { return KDSizeZero; } - return KDSize(BITMAP_FONT_CHARACTER_WIDTH*strlen(text), BITMAP_FONT_CHARACTER_HEIGHT); + if (size == FontSize::Large) { + return KDSize(BITMAP_LargeFont_CHARACTER_WIDTH*strlen(text), BITMAP_LargeFont_CHARACTER_HEIGHT); + } + return KDSize(BITMAP_SmallFont_CHARACTER_WIDTH*strlen(text), BITMAP_SmallFont_CHARACTER_HEIGHT); } diff --git a/poincare/src/layout/fraction_layout.cpp b/poincare/src/layout/fraction_layout.cpp index ca964d40c..900f59346 100644 --- a/poincare/src/layout/fraction_layout.cpp +++ b/poincare/src/layout/fraction_layout.cpp @@ -8,7 +8,7 @@ ExpressionLayout(), m_numerator_layout(numerator_layout), m_denominator_layout(d m_denominator_layout->setParent(this); m_baseline = m_numerator_layout->size().height() + k_fractionLineMargin - + KDText::stringSize(" ").height()/2; + + KDText::stringSize(" ", KDText::FontSize::Large).height()/2; } FractionLayout::~FractionLayout() { diff --git a/poincare/src/layout/matrix_layout.cpp b/poincare/src/layout/matrix_layout.cpp index 72a6de3d3..23c9a3b21 100644 --- a/poincare/src/layout/matrix_layout.cpp +++ b/poincare/src/layout/matrix_layout.cpp @@ -13,7 +13,7 @@ MatrixLayout::MatrixLayout(ExpressionLayout ** entryLayouts, int numberOfRows, i for (int i = 0; i < m_numberOfRows*m_numberOfColumns; i++) { m_entryLayouts[i]->setParent(this); } - m_baseline = height()/2 + KDText::stringSize(" ").height()/2; + m_baseline = height()/2 + KDText::stringSize(" ", KDText::FontSize::Large).height()/2; } MatrixLayout::~MatrixLayout() { diff --git a/poincare/src/layout/string_layout.cpp b/poincare/src/layout/string_layout.cpp index 6dfb687c3..86bcf4b70 100644 --- a/poincare/src/layout/string_layout.cpp +++ b/poincare/src/layout/string_layout.cpp @@ -8,7 +8,7 @@ ExpressionLayout() { memcpy(m_string, string, length); m_string[length] = 0; // Height of the font. - m_baseline = KDText::stringSize(" ").height(); + m_baseline = KDText::stringSize(" ", KDText::FontSize::Large).height(); } StringLayout::~StringLayout() { @@ -20,7 +20,7 @@ ExpressionLayout * StringLayout::child(uint16_t index) { } void StringLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { - ctx->drawString(m_string, p, expressionColor, backgroundColor); + ctx->drawString(m_string, KDText::FontSize::Large, p, expressionColor, backgroundColor); } KDPoint StringLayout::positionOfChild(ExpressionLayout * child) { @@ -29,5 +29,5 @@ KDPoint StringLayout::positionOfChild(ExpressionLayout * child) { } KDSize StringLayout::computeSize() { - return KDText::stringSize(m_string); + return KDText::stringSize(m_string, KDText::FontSize::Large); } diff --git a/quiz/src/runner.cpp b/quiz/src/runner.cpp index 7f249d510..da0c0fce5 100644 --- a/quiz/src/runner.cpp +++ b/quiz/src/runner.cpp @@ -6,8 +6,8 @@ void print(const char * message) { static int line_y = 0; KDContext * ctx = KDIonContext::sharedContext(); - int line_height = KDText::stringSize("M").height(); - ctx->drawString(message, KDPoint(0, line_y), KDColorBlack); + int line_height = KDText::stringSize("M", KDText::FontSize::Large).height(); + ctx->drawString(message, KDText::FontSize::Large, KDPoint(0, line_y), KDColorBlack); line_y += line_height; if (line_y > Ion::Display::Height) { line_y = 0;