[apps/settings] Factorize layout font sizes

This commit is contained in:
Léa Saviot
2019-03-26 11:59:53 +01:00
committed by Émilie Feral
parent 7cfeac8387
commit f3675d83df
2 changed files with 15 additions and 13 deletions

View File

@@ -49,55 +49,55 @@ int PreferencesController::reusableCellCount(int type) {
return k_totalNumberOfCell;
}
Layout layoutForPreferences(I18n::Message message) {
Layout PreferencesController::layoutForPreferences(I18n::Message message) {
switch (message) {
// Angle Unit
case I18n::Message::Degres:
{
const char * degEx = "90°";
return LayoutHelper::String("90°", strlen(degEx), KDFont::SmallFont);
return LayoutHelper::String("90°", strlen(degEx), k_layoutFont);
}
case I18n::Message::Radian:
{
const char * pi = "π";
return FractionLayout::Builder(
LayoutHelper::String(pi, sizeof(pi), KDFont::SmallFont),
LayoutHelper::String("2", 1, KDFont::SmallFont)
LayoutHelper::String(pi, sizeof(pi), k_layoutFont),
LayoutHelper::String("2", 1, k_layoutFont)
);
}
// Display Mode format
case I18n::Message::Decimal:
return LayoutHelper::String("12.34", 5, KDFont::SmallFont);
return LayoutHelper::String("12.34", 5, k_layoutFont);
case I18n::Message::Scientific:
{
const char * text = "1.234ᴇ1";
return LayoutHelper::String(text, strlen(text), KDFont::SmallFont);
return LayoutHelper::String(text, strlen(text), k_layoutFont);
}
// Edition mode
case I18n::Message::Edition2D:
return HorizontalLayout::Builder(
LayoutHelper::String("1+", 2, KDFont::SmallFont),
FractionLayout::Builder(LayoutHelper::String("2", 1, KDFont::SmallFont), LayoutHelper::String("3", 1, KDFont::SmallFont))
LayoutHelper::String("1+", 2, k_layoutFont),
FractionLayout::Builder(LayoutHelper::String("2", 1, k_layoutFont), LayoutHelper::String("3", 1, k_layoutFont))
);
case I18n::Message::EditionLinear:
return LayoutHelper::String("1+2/3", 5, KDFont::SmallFont);
return LayoutHelper::String("1+2/3", 5, k_layoutFont);
// Complex format
case I18n::Message::Real:
{
return CodePointLayout::Builder('x', KDFont::SmallFont);
return CodePointLayout::Builder('x', k_layoutFont);
}
case I18n::Message::Cartesian:
{
const char * text = "a+𝐢b";
return LayoutHelper::String(text, strlen(text), KDFont::SmallFont);
return LayoutHelper::String(text, strlen(text), k_layoutFont);
}
case I18n::Message::Polar:
{
const char * base = "r";
const char * superscript = "𝐢θ";
return HorizontalLayout::Builder(
LayoutHelper::String(base, strlen(base), KDFont::SmallFont),
VerticalOffsetLayout::Builder(LayoutHelper::String(superscript, strlen(superscript), KDFont::SmallFont), VerticalOffsetLayoutNode::Type::Superscript)
LayoutHelper::String(base, strlen(base), k_layoutFont),
VerticalOffsetLayout::Builder(LayoutHelper::String(superscript, strlen(superscript), k_layoutFont), VerticalOffsetLayoutNode::Type::Superscript)
);
}
default:

View File

@@ -17,6 +17,8 @@ public:
protected:
constexpr static int k_totalNumberOfCell = 3;
private:
constexpr static const KDFont * k_layoutFont = KDFont::SmallFont;
Poincare::Layout layoutForPreferences(I18n::Message message);
void setPreferenceWithValueIndex(I18n::Message message, int valueIndex);
int valueIndexForPreference(I18n::Message message);
MessageTableCellWithExpression m_cells[k_totalNumberOfCell];