mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps] Define Font, Text/BackgroundColor BannerView static methods
This commit is contained in:
committed by
Émilie Feral
parent
339258a29d
commit
5ff19a2506
@@ -10,10 +10,10 @@ BannerView::BannerView(
|
||||
TextFieldDelegate * textFieldDelegate
|
||||
) :
|
||||
Shared::XYBannerView(parentResponder, inputEventHandlerDelegate, textFieldDelegate),
|
||||
m_derivativeView(KDFont::SmallFont, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_tangentEquationView(KDFont::SmallFont, I18n::Message::LinearRegressionFormula, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_aView(KDFont::SmallFont, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_bView(KDFont::SmallFont, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_derivativeView(Font(), 0.5f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_tangentEquationView(Font(), I18n::Message::LinearRegressionFormula, 0.0f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_aView(Font(), 0.5f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_bView(Font(), 0.5f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_numberOfSubviews(Shared::XYBannerView::k_numberOfSubviews)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ CalculationGraphController::CalculationGraphController(Responder * parentRespond
|
||||
m_bannerView(bannerView),
|
||||
m_graphRange(curveViewRange),
|
||||
m_record(),
|
||||
m_defaultBannerView(KDFont::SmallFont, defaultMessage, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_defaultBannerView(BannerView::Font(), defaultMessage, 0.5f, 0.5f, BannerView::TextColor(), BannerView::BackgroundColor()),
|
||||
m_isActive(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -3,22 +3,19 @@
|
||||
|
||||
namespace Regression {
|
||||
|
||||
constexpr KDColor BannerView::k_textColor;
|
||||
constexpr KDColor BannerView::k_backgroundColor;
|
||||
|
||||
BannerView::BannerView(
|
||||
Responder * parentResponder,
|
||||
InputEventHandlerDelegate * inputEventHandlerDelegate,
|
||||
TextFieldDelegate * textFieldDelegate
|
||||
) :
|
||||
Shared::XYBannerView(parentResponder, inputEventHandlerDelegate, textFieldDelegate),
|
||||
m_dotNameView(k_font, 0.0f, 0.5f, k_textColor, k_backgroundColor),
|
||||
m_regressionTypeView(k_font, (I18n::Message)0, 0.0f, 0.5f, k_textColor,k_backgroundColor),
|
||||
m_subText0(k_font, 0.5f, 0.5f, k_textColor, k_backgroundColor),
|
||||
m_subText1(k_font, 0.5f, 0.5f, k_textColor, k_backgroundColor),
|
||||
m_subText2(k_font, 0.5f, 0.5f, k_textColor, k_backgroundColor),
|
||||
m_subText3(k_font, 0.5f, 0.5f, k_textColor, k_backgroundColor),
|
||||
m_subText4(k_font, 0.5f, 0.5f, k_textColor, k_backgroundColor)
|
||||
m_dotNameView(Font(), 0.0f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_regressionTypeView(Font(), (I18n::Message)0, 0.0f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_subText0(Font(), 0.5f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_subText1(Font(), 0.5f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_subText2(Font(), 0.5f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_subText3(Font(), 0.5f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_subText4(Font(), 0.5f, 0.5f, TextColor(), BackgroundColor())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,7 @@ public:
|
||||
MessageTextView * regressionTypeView() { return &m_regressionTypeView; }
|
||||
BufferTextView * subTextAtIndex(int index);
|
||||
static constexpr int numberOfsubTexts() { return 5; }
|
||||
const KDFont * font() const { return k_font; }
|
||||
private:
|
||||
static constexpr const KDFont * k_font = KDFont::SmallFont;
|
||||
static constexpr KDColor k_textColor = KDColorBlack;
|
||||
static constexpr KDColor k_backgroundColor = Palette::GreyMiddle;
|
||||
static constexpr int k_numberOfSubviews = Shared::XYBannerView::k_numberOfSubviews + 7;
|
||||
int numberOfSubviews() const override { return k_numberOfSubviews; }
|
||||
View * subviewAtIndex(int index) override;
|
||||
|
||||
@@ -175,7 +175,7 @@ void GraphController::reloadBannerView() {
|
||||
}
|
||||
if (!coefficientsAreDefined) {
|
||||
// Force the "Data not suitable" message to be on the next line
|
||||
int numberOfCharToCompleteLine = maxInt(Ion::Display::Width/(m_bannerView.font()->glyphSize().width())- strlen(I18n::translate(formula)), 0);
|
||||
int numberOfCharToCompleteLine = maxInt(Ion::Display::Width / BannerView::Font()->glyphSize().width() - strlen(I18n::translate(formula)), 0);
|
||||
numberOfChar = 0;
|
||||
for (int i = 0; i < numberOfCharToCompleteLine-1; i++) {
|
||||
buffer[numberOfChar++] = ' ';
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
namespace Shared {
|
||||
|
||||
KDCoordinate BannerView::HeightGivenNumberOfLines(int linesCount) {
|
||||
return LineSpacing + (KDFont::SmallFont->glyphSize().height() + LineSpacing) * linesCount;
|
||||
return LineSpacing + (Font()->glyphSize().height() + LineSpacing) * linesCount;
|
||||
}
|
||||
|
||||
void BannerView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
const KDCoordinate frameHeight = minimalSizeForOptimalDisplay().height();
|
||||
const KDCoordinate lineHeight = KDFont::SmallFont->glyphSize().height() + LineSpacing;
|
||||
const KDCoordinate lineHeight = Font()->glyphSize().height() + LineSpacing;
|
||||
const KDCoordinate lineWidth = m_frame.width();
|
||||
for (KDCoordinate y = 0; y < frameHeight; y += lineHeight) {
|
||||
ctx->fillRect(KDRect(0, y, lineWidth, LineSpacing), Palette::GreyMiddle);
|
||||
ctx->fillRect(KDRect(0, y, lineWidth, LineSpacing), BackgroundColor());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ public:
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
void reload() { layoutSubviews(); }
|
||||
static constexpr const KDFont * Font() { return KDFont::SmallFont; }
|
||||
static constexpr KDColor TextColor() { return KDColorBlack; }
|
||||
static constexpr KDColor BackgroundColor() { return Palette::GreyMiddle; }
|
||||
private:
|
||||
static constexpr KDCoordinate LineSpacing = 2;
|
||||
int numberOfSubviews() const override = 0;
|
||||
|
||||
@@ -8,8 +8,8 @@ XYBannerView::XYBannerView(
|
||||
InputEventHandlerDelegate * inputEventHandlerDelegate,
|
||||
TextFieldDelegate * textFieldDelegate
|
||||
) :
|
||||
m_abscissaView(KDFont::SmallFont, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_ordinateView(KDFont::SmallFont, 0.5f, 0.5f, KDColorBlack, Palette::GreyMiddle)
|
||||
m_abscissaView(Font(), 0.5f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_ordinateView(Font(), 0.5f, 0.5f, TextColor(), BackgroundColor())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
namespace Statistics {
|
||||
|
||||
BoxBannerView::BoxBannerView() :
|
||||
m_seriesName(KDFont::SmallFont, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_calculationName(KDFont::SmallFont, I18n::Message::Minimum, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_calculationValue(KDFont::SmallFont, 1.0f, 0.5f, KDColorBlack, Palette::GreyMiddle)
|
||||
m_seriesName(Font(), 0.0f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_calculationName(Font(), I18n::Message::Minimum, 0.0f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_calculationValue(Font(), 1.0f, 0.5f, TextColor(), BackgroundColor())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
namespace Statistics {
|
||||
|
||||
HistogramBannerView::HistogramBannerView() :
|
||||
m_intervalLegendView(KDFont::SmallFont, I18n::Message::Interval, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_intervalView(KDFont::SmallFont, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_sizeLegendView(KDFont::SmallFont, I18n::Message::Size, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_sizeView(KDFont::SmallFont, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_frequencyLegendView(KDFont::SmallFont, I18n::Message::Frequency, 1.0f, 0.5f, KDColorBlack, Palette::GreyMiddle),
|
||||
m_frequencyView(KDFont::SmallFont, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle)
|
||||
m_intervalLegendView(Font(), I18n::Message::Interval, 0.0f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_intervalView(Font(), 0.0f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_sizeLegendView(Font(), I18n::Message::Size, 0.0f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_sizeView(Font(), 0.0f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_frequencyLegendView(Font(), I18n::Message::Frequency, 1.0f, 0.5f, TextColor(), BackgroundColor()),
|
||||
m_frequencyView(Font(), 0.0f, 0.5f, TextColor(), BackgroundColor())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user