Removed the old tab hack from scalable font. (Could someone check if done correctly?) and made it possible for table entries to have both left-aligned and centered content.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13221 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a0b20697d2
commit
567f6302ed
@ -500,15 +500,12 @@ void ScalableFont::draw(const core::stringw& text,
|
||||
core::position2d<s32> offset = position.UpperLeftCorner;
|
||||
core::dimension2d<s32> text_dimension;
|
||||
|
||||
// When we use the "tab" hack, disable right-alignment, it messes up everything
|
||||
bool has_tab = (text.findFirst(L'\t') != -1);
|
||||
|
||||
if ((m_rtl && !has_tab) || hcenter || vcenter || clip)
|
||||
if (m_rtl || hcenter || vcenter || clip)
|
||||
{
|
||||
text_dimension = getDimension(text.c_str());
|
||||
|
||||
if (hcenter) offset.X += (position.getWidth() - text_dimension.Width) / 2;
|
||||
else if (m_rtl && !has_tab) offset.X += (position.getWidth() - text_dimension.Width);
|
||||
if (hcenter) offset.X += (position.getWidth() - text_dimension.Width) / 2;
|
||||
else if (m_rtl) offset.X += (position.getWidth() - text_dimension.Width);
|
||||
|
||||
if (vcenter) offset.Y += (position.getHeight() - text_dimension.Height) / 2;
|
||||
if (clip)
|
||||
@ -519,14 +516,6 @@ void ScalableFont::draw(const core::stringw& text,
|
||||
}
|
||||
}
|
||||
|
||||
if (m_rtl && has_tab)
|
||||
{
|
||||
const int where = text.findFirst(L'\t');
|
||||
core::stringw substr = text.subString(0, where-1);
|
||||
text_dimension = getDimension(substr.c_str()) + getDimension(L"XX");
|
||||
offset.X += (int)(position.getWidth()*m_tab_stop-text_dimension.Width);
|
||||
}
|
||||
|
||||
// ---- collect character locations
|
||||
const unsigned int text_size = text.size();
|
||||
core::array<s32> indices(text_size);
|
||||
|
@ -488,7 +488,7 @@ void CGUISTKListBox::draw()
|
||||
{
|
||||
total_proportion += Items[i].m_contents[x].m_proportion;
|
||||
}
|
||||
int part_size = textRect.getWidth() / total_proportion;
|
||||
int part_size = (int)(textRect.getWidth() / float(total_proportion));
|
||||
|
||||
for(int x = 0; x < Items[i].m_contents.size(); ++x)
|
||||
{
|
||||
@ -532,7 +532,7 @@ void CGUISTKListBox::draw()
|
||||
textRect,
|
||||
hasItemOverrideColor(i, EGUI_LBC_TEXT_HIGHLIGHT) ?
|
||||
getItemOverrideColor(i, EGUI_LBC_TEXT_HIGHLIGHT) : getItemDefaultColor(EGUI_LBC_TEXT_HIGHLIGHT),
|
||||
false, true, &clientClip);
|
||||
Items[i].m_contents[x].m_center, true, &clientClip);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -540,7 +540,7 @@ void CGUISTKListBox::draw()
|
||||
Items[i].m_contents[x].m_text.c_str(),
|
||||
textRect,
|
||||
hasItemOverrideColor(i, EGUI_LBC_TEXT) ? getItemOverrideColor(i, EGUI_LBC_TEXT) : getItemDefaultColor(EGUI_LBC_TEXT),
|
||||
false, true, &clientClip);
|
||||
Items[i].m_contents[x].m_center, true, &clientClip);
|
||||
}
|
||||
//Position back to inital pos
|
||||
textRect.UpperLeftCorner.X -= ItemsIconWidth+6;
|
||||
|
@ -32,12 +32,14 @@ namespace irr
|
||||
irr::core::stringw m_text;
|
||||
int m_proportion;
|
||||
s32 m_icon;
|
||||
bool m_center;
|
||||
|
||||
ListCell(irr::core::stringw text, s32 icon = -1, int proportion = 1)
|
||||
ListCell(irr::core::stringw text, s32 icon = -1, int proportion = 1, bool center = false)
|
||||
{
|
||||
m_text = text;
|
||||
m_proportion = proportion;
|
||||
m_icon = icon;
|
||||
m_center = center;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -182,12 +182,13 @@ void ListWidget::clear()
|
||||
|
||||
void ListWidget::addItem( const std::string& internal_name,
|
||||
const irr::core::stringw &name,
|
||||
const int icon)
|
||||
const int icon,
|
||||
bool center)
|
||||
{
|
||||
// May only be called AFTER this widget has been add()ed
|
||||
assert(m_element != NULL);
|
||||
|
||||
ListCell cell(name, icon);
|
||||
ListCell cell(name, icon, 1, center);
|
||||
ListItem newItem;
|
||||
newItem.m_internal_name = internal_name;
|
||||
newItem.m_contents.push_back(cell);
|
||||
|
@ -122,7 +122,8 @@ namespace GUIEngine
|
||||
*/
|
||||
void addItem( const std::string& internal_name,
|
||||
const irr::core::stringw &name,
|
||||
const int icon=-1);
|
||||
const int icon=-1,
|
||||
bool center = false);
|
||||
|
||||
void addItem( const std::string& internal_name,
|
||||
PtrVector<ListCell> * contents);
|
||||
|
@ -104,7 +104,7 @@ void AddonsScreen::beforeAddingWidget()
|
||||
getWidget<GUIEngine::ListWidget>("list_addons");
|
||||
assert(w_list != NULL);
|
||||
w_list->clearColumns();
|
||||
w_list->addColumn( _("Add-on name"), 2 );
|
||||
w_list->addColumn( _("Add-on name"), 3 );
|
||||
w_list->addColumn( _("Updated date"), 1 );
|
||||
|
||||
GUIEngine::SpinnerWidget* w_filter_date =
|
||||
@ -358,8 +358,8 @@ void AddonsScreen::loadList()
|
||||
}
|
||||
|
||||
PtrVector<GUIEngine::ListWidget::ListCell> * row = new PtrVector<GUIEngine::ListWidget::ListCell>;
|
||||
row->push_back(new GUIEngine::ListWidget::ListCell(s.c_str(),icon,2));
|
||||
row->push_back(new GUIEngine::ListWidget::ListCell(addon->getDateAsString().c_str(),-1,1));
|
||||
row->push_back(new GUIEngine::ListWidget::ListCell(s.c_str(), icon, 3, false));
|
||||
row->push_back(new GUIEngine::ListWidget::ListCell(addon->getDateAsString().c_str(), -1, 1, true));
|
||||
w_list->addItem(addon->getId(), row);
|
||||
|
||||
// Highlight if it's not approved in artists debug mode.
|
||||
|
@ -109,7 +109,7 @@ void ServerSelection::loadList(bool refresh)
|
||||
num_players.append(StringUtils::toWString(server->getMaxPlayers()));
|
||||
PtrVector<GUIEngine::ListWidget::ListCell> * row = new PtrVector<GUIEngine::ListWidget::ListCell>;
|
||||
row->push_back(new GUIEngine::ListWidget::ListCell(server->getName(),-1,3));
|
||||
row->push_back(new GUIEngine::ListWidget::ListCell(num_players,-1,1));
|
||||
row->push_back(new GUIEngine::ListWidget::ListCell(num_players,-1,1,true));
|
||||
m_server_list_widget->addItem("server", row);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user