Default text wrapping in label widget

It should make no more text rendered out of area as stated in forum.
This commit is contained in:
Benau
2015-10-12 01:16:17 +08:00
parent 73ae81554d
commit 23e1f8fb3e
2 changed files with 9 additions and 3 deletions

View File

@@ -537,7 +537,9 @@ void LayoutManager::doCalculateLayout(PtrVector<Widget>& widgets, AbstractTopLev
align.c_str(), widgets[n].m_properties[PROP_ID].c_str());
}
widgets[n].m_w = (int)(left_space*fraction);
//Used to get text in label widget wrapped better
int padding = (int)(irr_driver->getFrameSize().Width*0.05f);
widgets[n].m_w = (int)(left_space*fraction) - padding;
if (widgets[n].m_properties[PROP_MAX_WIDTH].size() > 0)
{
const int max_width = atoi_p( widgets[n].m_properties[PROP_MAX_WIDTH].c_str() );
@@ -552,7 +554,7 @@ void LayoutManager::doCalculateLayout(PtrVector<Widget>& widgets, AbstractTopLev
widgets[n].m_w = 1;
}
x += widgets[n].m_w;
x += widgets[n].m_w + padding;
}
else
{

View File

@@ -60,7 +60,11 @@ LabelWidget::LabelWidget(bool title, bool bright) : Widget(WTYPE_LABEL)
void LabelWidget::add()
{
rect<s32> widget_size = rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h);
const bool word_wrap = m_properties[PROP_WORD_WRAP] == "true";
bool word_wrap; //Enable text wrapping unless explicitly stated not to
if (m_properties[PROP_WORD_WRAP] == "false")
word_wrap = false;
else
word_wrap = true;
stringw message = getText();
EGUI_ALIGNMENT align = EGUIA_UPPERLEFT;