mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[kandinsky] Introduce two fonts: small font and large font
Change-Id: I502dfa88d627b09ac5af76155140af63547025cd
This commit is contained in:
@@ -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++;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Home {
|
||||
|
||||
AppCell::AppCell() :
|
||||
TableViewCell(),
|
||||
m_nameView(PointerTextView(KDText::FontSize::Small)),
|
||||
m_visible(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <escher/button.h>
|
||||
#include <assert.h>
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
#include <assert.h>
|
||||
|
||||
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))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <escher/even_odd_buffer_text_cell.h>
|
||||
#include <assert.h>
|
||||
|
||||
EvenOddBufferTextCell::EvenOddBufferTextCell() :
|
||||
EvenOddBufferTextCell::EvenOddBufferTextCell(KDText::FontSize size) :
|
||||
EvenOddCell(),
|
||||
m_bufferTextView(BufferTextView(1.0f, 0.5f))
|
||||
m_bufferTextView(BufferTextView(size, 1.0f, 0.5f))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
#include <escher/app.h>
|
||||
#include <assert.h>
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <escher/even_odd_pointer_text_cell.h>
|
||||
#include <assert.h>
|
||||
|
||||
EvenOddPointerTextCell::EvenOddPointerTextCell() :
|
||||
EvenOddPointerTextCell::EvenOddPointerTextCell(KDText::FontSize size) :
|
||||
EvenOddCell(),
|
||||
m_pointerTextView(nullptr, 0.5f, 0.5f)
|
||||
m_pointerTextView(size, nullptr, 0.5f, 0.5f)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <escher/pointer_text_view.h>
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#include <escher/text_view.h>
|
||||
|
||||
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
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
BIN
kandinsky/fonts/largePixelFont.ttf
Normal file
BIN
kandinsky/fonts/largePixelFont.ttf
Normal file
Binary file not shown.
@@ -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));
|
||||
|
||||
BIN
kandinsky/fonts/smallPixelFont.ttf
Normal file
BIN
kandinsky/fonts/smallPixelFont.ttf
Normal file
Binary file not shown.
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <kandinsky/color.h>
|
||||
#include <kandinsky/rect.h>
|
||||
#include <kandinsky/text.h>
|
||||
|
||||
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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,50 +1,50 @@
|
||||
#include <kandinsky/context.h>
|
||||
#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<BITMAP_FONT_CHARACTER_HEIGHT;j++) {
|
||||
for (int i=0; i<BITMAP_FONT_CHARACTER_WIDTH;i++) {
|
||||
uint8_t intensity = bitmapFont[character-BITMAP_FONT_FIRST_CHARACTER][j][i];
|
||||
void KDContext::drawChar(char character, KDText::FontSize size, KDPoint p, KDColor textColor, KDColor backgroundColor) {
|
||||
int firstCharacter = size == KDText::FontSize::Large ? BITMAP_LargeFont_FIRST_CHARACTER : BITMAP_SmallFont_FIRST_CHARACTER;
|
||||
int characterHeight = size == KDText::FontSize::Large ? BITMAP_LargeFont_CHARACTER_HEIGHT : BITMAP_SmallFont_CHARACTER_HEIGHT;
|
||||
int characterWidth = size == KDText::FontSize::Large ? BITMAP_LargeFont_CHARACTER_WIDTH : BITMAP_SmallFont_CHARACTER_WIDTH;
|
||||
KDColor * characterBuffer = size == KDText::FontSize::Large ? largeCharacterBuffer : smallCharacterBuffer;
|
||||
for (int j=0; j<characterHeight;j++) {
|
||||
for (int i=0; i<characterWidth;i++) {
|
||||
uint8_t intensity = 0;
|
||||
if (size == KDText::FontSize::Large) {
|
||||
intensity = bitmapLargeFont[character-firstCharacter][j][i];
|
||||
} else {
|
||||
intensity = bitmapSmallFont[character-firstCharacter][j][i];
|
||||
}
|
||||
KDColor color = KDColor::blend(textColor, backgroundColor, intensity);
|
||||
//characterBuffer[j*BITMAP_FONT_CHARACTER_WIDTH+i] = color;
|
||||
characterBuffer[j*BITMAP_FONT_CHARACTER_WIDTH+i] = color;
|
||||
characterBuffer[j*characterWidth+i] = color;
|
||||
}
|
||||
}
|
||||
fillRectWithPixels(KDRect(p, BITMAP_FONT_CHARACTER_WIDTH, BITMAP_FONT_CHARACTER_HEIGHT),
|
||||
fillRectWithPixels(KDRect(p, characterWidth, characterHeight),
|
||||
characterBuffer,
|
||||
characterBuffer);
|
||||
}
|
||||
#if 0
|
||||
void KDContext::drawChar(char character, KDPoint p, uint8_t inverse) {
|
||||
for (int j=0; j<BITMAP_FONT_CHARACTER_HEIGHT;j++) {
|
||||
for (int i=0; i<BITMAP_FONT_CHARACTER_WIDTH;i++) {
|
||||
uint8_t intensity = inverse ?
|
||||
bitmapFont[character-BITMAP_FONT_FIRST_CHARACTER][j][i] :
|
||||
(0xFF-bitmapFont[character-BITMAP_FONT_FIRST_CHARACTER][j][i]);
|
||||
KDColor color(intensity * 0x010101);
|
||||
characterBuffer[j*BITMAP_FONT_CHARACTER_WIDTH+i] = color;
|
||||
}
|
||||
}
|
||||
fillRectWithPixels(KDRect(p, BITMAP_FONT_CHARACTER_WIDTH, BITMAP_FONT_CHARACTER_HEIGHT),
|
||||
characterBuffer,
|
||||
characterBuffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
void KDContext::drawString(const char * text, KDPoint p, KDColor textColor, KDColor backgroundColor) {
|
||||
void KDContext::drawString(const char * text, KDText::FontSize size, KDPoint p, KDColor textColor, KDColor backgroundColor) {
|
||||
KDPoint position = p;
|
||||
KDPoint characterSize(BITMAP_FONT_CHARACTER_WIDTH, 0);
|
||||
int characterWidth = size == KDText::FontSize::Large ? BITMAP_LargeFont_CHARACTER_WIDTH : BITMAP_SmallFont_CHARACTER_WIDTH;
|
||||
KDPoint characterSize(characterWidth, 0);
|
||||
while(*text != 0) {
|
||||
drawChar(*text, position, textColor, backgroundColor);
|
||||
drawChar(*text, size, position, textColor, backgroundColor);
|
||||
text++;
|
||||
position = position.translatedBy(characterSize);
|
||||
}
|
||||
}
|
||||
|
||||
void KDContext::blendChar(char character, KDPoint p, KDColor textColor) {
|
||||
KDRect absoluteRect = absoluteFillRect(KDRect(p, BITMAP_FONT_CHARACTER_WIDTH, BITMAP_FONT_CHARACTER_HEIGHT));
|
||||
void KDContext::blendChar(char character, KDText::FontSize size, KDPoint p, KDColor textColor) {
|
||||
int firstCharacter = size == KDText::FontSize::Large ? BITMAP_LargeFont_FIRST_CHARACTER : BITMAP_SmallFont_FIRST_CHARACTER;
|
||||
int characterHeight = size == KDText::FontSize::Large ? BITMAP_LargeFont_CHARACTER_HEIGHT : BITMAP_SmallFont_CHARACTER_HEIGHT;
|
||||
int characterWidth = size == KDText::FontSize::Large ? BITMAP_LargeFont_CHARACTER_WIDTH : BITMAP_SmallFont_CHARACTER_WIDTH;
|
||||
KDColor * characterBuffer = size == KDText::FontSize::Large ? largeCharacterBuffer : smallCharacterBuffer;
|
||||
|
||||
KDRect absoluteRect = absoluteFillRect(KDRect(p, characterWidth, characterHeight));
|
||||
pullRect(absoluteRect, characterBuffer);
|
||||
KDCoordinate startingI = m_clippingRect.x() - p.translatedBy(m_origin).x();
|
||||
KDCoordinate startingJ = m_clippingRect.y() - p.translatedBy(m_origin).y();
|
||||
@@ -53,18 +53,24 @@ void KDContext::blendChar(char character, KDPoint p, KDColor textColor) {
|
||||
for (KDCoordinate j=0; j<absoluteRect.height(); j++) {
|
||||
for (KDCoordinate i=0; i<absoluteRect.width(); i++) {
|
||||
KDColor * currentPixelAdress = characterBuffer + i + absoluteRect.width()*j;
|
||||
uint8_t intensity = bitmapFont[character-BITMAP_FONT_FIRST_CHARACTER][j + startingJ][i +startingI];
|
||||
uint8_t intensity = 0;
|
||||
if (size == KDText::FontSize::Large) {
|
||||
intensity = bitmapLargeFont[character-firstCharacter][j + startingJ][i +startingI];
|
||||
} else {
|
||||
intensity = bitmapSmallFont[character-firstCharacter][j + startingJ][i +startingI];
|
||||
}
|
||||
*currentPixelAdress = KDColor::blend(textColor, *currentPixelAdress, intensity);
|
||||
}
|
||||
}
|
||||
pushRect(absoluteRect, characterBuffer);
|
||||
}
|
||||
|
||||
void KDContext::blendString(const char * text, KDPoint p, KDColor textColor) {
|
||||
void KDContext::blendString(const char * text, KDText::FontSize size, KDPoint p, KDColor textColor) {
|
||||
KDPoint position = p;
|
||||
KDPoint characterSize(BITMAP_FONT_CHARACTER_WIDTH, 0);
|
||||
int characterWidth = size == KDText::FontSize::Large ? BITMAP_LargeFont_CHARACTER_WIDTH : BITMAP_SmallFont_CHARACTER_WIDTH;
|
||||
KDPoint characterSize(characterWidth, 0);
|
||||
while(*text != 0) {
|
||||
blendChar(*text, position, textColor);
|
||||
blendChar(*text, size, position, textColor);
|
||||
text++;
|
||||
position = position.translatedBy(characterSize);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#include <kandinsky/text.h>
|
||||
#include <string.h>
|
||||
#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);
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user