mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[escher] In pointer text view (future message text view) implement
minimal size for optimal display to ensure to be able to display all languages Change-Id: Id3c81185fa44017bc4fcca5db0c8d0a6c115f6fb
This commit is contained in:
@@ -356,4 +356,8 @@ const char * translate(Message m, Language l) {
|
||||
return messages[(int)m][languageIndex-1];
|
||||
}
|
||||
|
||||
int numberOfLanguages() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace I18n {
|
||||
enum class Message : uint16_t;
|
||||
enum class Language : uint16_t;
|
||||
const char * translate(Message m, Language l = (Language)0);
|
||||
int numberOfLanguages();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,6 +11,7 @@ public:
|
||||
void setText(const char * text) override;
|
||||
void setMessage(I18n::Message message);
|
||||
const char * text() const override;
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
private:
|
||||
I18n::Message m_message;
|
||||
};
|
||||
|
||||
@@ -22,12 +22,12 @@ protected:
|
||||
#if ESCHER_VIEW_LOGGING
|
||||
const char * className() const override;
|
||||
#endif
|
||||
KDText::FontSize m_fontSize;
|
||||
private:
|
||||
float m_horizontalAlignment;
|
||||
float m_verticalAlignment;
|
||||
KDColor m_textColor;
|
||||
KDColor m_backgroundColor;
|
||||
KDText::FontSize m_fontSize;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,3 +20,13 @@ void PointerTextView::setMessage(I18n::Message message) {
|
||||
m_message = message;
|
||||
markRectAsDirty(bounds());
|
||||
}
|
||||
|
||||
KDSize PointerTextView::minimalSizeForOptimalDisplay() const {
|
||||
KDCoordinate width = 0;
|
||||
for (int l = 0; l < I18n::numberOfLanguages(); l++) {
|
||||
KDCoordinate newWidth = KDText::stringSize(I18n::translate(m_message, (I18n::Language)l), m_fontSize).width();
|
||||
width = width > newWidth ? width : newWidth;
|
||||
l++;
|
||||
}
|
||||
return KDSize(width, KDText::stringSize(text(), m_fontSize).height());
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
TextView::TextView(KDText::FontSize size, float horizontalAlignment, float verticalAlignment,
|
||||
KDColor textColor, KDColor backgroundColor) :
|
||||
View(),
|
||||
m_fontSize(size),
|
||||
m_horizontalAlignment(horizontalAlignment),
|
||||
m_verticalAlignment(verticalAlignment),
|
||||
m_textColor(textColor),
|
||||
m_backgroundColor(backgroundColor),
|
||||
m_fontSize(size)
|
||||
m_backgroundColor(backgroundColor)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -6,5 +6,9 @@ const char * translate(Message m, Language l) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int numberOfLanguages() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user