diff options
author | fuzzard <fuzzard@users.noreply.github.com> | 2023-12-28 07:08:36 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-28 07:08:36 +1000 |
commit | 1c56279137eb24a8c19a357a00f7e690b61d2061 (patch) | |
tree | f77c29d3a61abd6fb2d00c33aa10b0824116c24e | |
parent | fc02e80d33a225544b6c0a3bf62a95bbc912e860 (diff) | |
parent | 128d86171a5d9d4145a4f7f5158dcad055c7e077 (diff) |
Merge pull request #24315 from CastagnaIT/fix_gui_control_style
[guilib][GUITextBox] Use vecText to determine text width
-rw-r--r-- | xbmc/guilib/GUITextBox.cpp | 2 | ||||
-rw-r--r-- | xbmc/guilib/GUITextLayout.cpp | 17 | ||||
-rw-r--r-- | xbmc/guilib/GUITextLayout.h | 5 |
3 files changed, 9 insertions, 15 deletions
diff --git a/xbmc/guilib/GUITextBox.cpp b/xbmc/guilib/GUITextBox.cpp index 9e2551b43a..62b00723e7 100644 --- a/xbmc/guilib/GUITextBox.cpp +++ b/xbmc/guilib/GUITextBox.cpp @@ -252,7 +252,7 @@ void CGUITextBox::Render() { // We need to adjust the posX in similar way the CGUILabel recalculate the render rect // see CGUILabel::UpdateRenderRect() - linePosX -= GetTextWidth(lineString.GetAsWstring()); + linePosX -= GetTextWidth(lineString.m_text); } m_font->DrawText(linePosX, posY, m_colors, m_label.shadowColor, lineString.m_text, align, diff --git a/xbmc/guilib/GUITextLayout.cpp b/xbmc/guilib/GUITextLayout.cpp index 3d48d52b93..1a300f4bb2 100644 --- a/xbmc/guilib/GUITextLayout.cpp +++ b/xbmc/guilib/GUITextLayout.cpp @@ -29,18 +29,6 @@ std::string CGUIString::GetAsString() const return text; } -std::wstring CGUIString::GetAsWstring() const -{ - std::wstring text; - text.reserve(m_text.size()); - // Get text without style - for (const auto& it : m_text) - { - text += static_cast<wchar_t>(it & 0xffff); - } - return text; -} - CGUITextLayout::CGUITextLayout(CGUIFont *font, bool wrap, float fHeight, CGUIFont *borderFont) { m_varFont = m_font = font; @@ -696,6 +684,11 @@ float CGUITextLayout::GetTextWidth(const std::wstring &text) const return m_font->GetTextWidth(utf32); } +float CGUITextLayout::GetTextWidth(const vecText& text) const +{ + return m_font->GetTextWidth(text); +} + std::string CGUITextLayout::GetText() const { if (m_lastUpdateW) diff --git a/xbmc/guilib/GUITextLayout.h b/xbmc/guilib/GUITextLayout.h index 7bd8957b3b..be365469d8 100644 --- a/xbmc/guilib/GUITextLayout.h +++ b/xbmc/guilib/GUITextLayout.h @@ -44,7 +44,6 @@ public: CGUIString(iString start, iString end, bool carriageReturn); std::string GetAsString() const; - std::wstring GetAsWstring() const; // The text is UTF-16 and the data stored in a character_t hold multiple informations by bits: // <16 bits: are unicode code bits @@ -99,7 +98,9 @@ public: float GetTextWidth() const { return m_textWidth; } float GetTextWidth(const std::wstring &text) const; - + + float GetTextWidth(const vecText& text) const; + /*! \brief Returns the precalculated height of the text to be rendered (in constant time). \return height of text */ |