mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-04 04:11:09 +02:00
CTextBox: try to fix getMaxLineWidth() methode
If found no linebreak, return value could be too small.
Space char simulates a line termination as a workaround to get
largest possible width.
Origin commit data
------------------
Branch: ni/coolstream
Commit: cddf1835b5
Author: Thilo Graf <dbt@novatux.de>
Date: 2016-12-09 (Fri, 09 Dec 2016)
------------------
This commit was generated by Migit
This commit is contained in:
@@ -890,11 +890,17 @@ int CTextBox::getLines(const std::string& text)
|
|||||||
|
|
||||||
int CTextBox::getMaxLineWidth(const std::string& text, Font* font)
|
int CTextBox::getMaxLineWidth(const std::string& text, Font* font)
|
||||||
{
|
{
|
||||||
// if found no linebreak, return pure size only
|
std::string txt = text;
|
||||||
if (text.find('\n', 0) == std::string::npos)
|
if (txt.find('\n', 0) == std::string::npos){
|
||||||
return font->getRenderWidth(text.c_str());
|
/* If found no linebreak, return pure size with additional space char.
|
||||||
|
* Space char simulates a line termination as a workaround to get
|
||||||
|
* largest possible width.
|
||||||
|
*/
|
||||||
|
txt += ' ';
|
||||||
|
return font->getRenderWidth(txt.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
std::stringstream in (text);
|
std::stringstream in (txt);
|
||||||
if (!in)
|
if (!in)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user