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];
|
return messages[(int)m][languageIndex-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int numberOfLanguages() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace I18n {
|
|||||||
enum class Message : uint16_t;
|
enum class Message : uint16_t;
|
||||||
enum class Language : uint16_t;
|
enum class Language : uint16_t;
|
||||||
const char * translate(Message m, Language l = (Language)0);
|
const char * translate(Message m, Language l = (Language)0);
|
||||||
|
int numberOfLanguages();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public:
|
|||||||
void setText(const char * text) override;
|
void setText(const char * text) override;
|
||||||
void setMessage(I18n::Message message);
|
void setMessage(I18n::Message message);
|
||||||
const char * text() const override;
|
const char * text() const override;
|
||||||
|
KDSize minimalSizeForOptimalDisplay() const override;
|
||||||
private:
|
private:
|
||||||
I18n::Message m_message;
|
I18n::Message m_message;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ protected:
|
|||||||
#if ESCHER_VIEW_LOGGING
|
#if ESCHER_VIEW_LOGGING
|
||||||
const char * className() const override;
|
const char * className() const override;
|
||||||
#endif
|
#endif
|
||||||
|
KDText::FontSize m_fontSize;
|
||||||
private:
|
private:
|
||||||
float m_horizontalAlignment;
|
float m_horizontalAlignment;
|
||||||
float m_verticalAlignment;
|
float m_verticalAlignment;
|
||||||
KDColor m_textColor;
|
KDColor m_textColor;
|
||||||
KDColor m_backgroundColor;
|
KDColor m_backgroundColor;
|
||||||
KDText::FontSize m_fontSize;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -20,3 +20,13 @@ void PointerTextView::setMessage(I18n::Message message) {
|
|||||||
m_message = message;
|
m_message = message;
|
||||||
markRectAsDirty(bounds());
|
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,
|
TextView::TextView(KDText::FontSize size, float horizontalAlignment, float verticalAlignment,
|
||||||
KDColor textColor, KDColor backgroundColor) :
|
KDColor textColor, KDColor backgroundColor) :
|
||||||
View(),
|
View(),
|
||||||
|
m_fontSize(size),
|
||||||
m_horizontalAlignment(horizontalAlignment),
|
m_horizontalAlignment(horizontalAlignment),
|
||||||
m_verticalAlignment(verticalAlignment),
|
m_verticalAlignment(verticalAlignment),
|
||||||
m_textColor(textColor),
|
m_textColor(textColor),
|
||||||
m_backgroundColor(backgroundColor),
|
m_backgroundColor(backgroundColor)
|
||||||
m_fontSize(size)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,5 +6,9 @@ const char * translate(Message m, Language l) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int numberOfLanguages() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user