Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add font styling options to tables and textlists (#10203)
- Loading branch information
Showing
with
34 additions
and
1 deletion.
-
+2
−0
src/gui/guiFormSpecMenu.cpp
-
+26
−1
src/gui/guiTable.cpp
-
+6
−0
src/gui/guiTable.h
|
@@ -1225,6 +1225,7 @@ void GUIFormSpecMenu::parseTable(parserData* data, const std::string &element) |
|
|
|
|
|
auto style = getDefaultStyleForElement("table", name); |
|
|
e->setNotClipped(style.getBool(StyleSpec::NOCLIP, false)); |
|
|
e->setOverrideFont(style.getFont()); |
|
|
|
|
|
m_tables.emplace_back(spec, e); |
|
|
m_fields.push_back(spec); |
|
@@ -1302,6 +1303,7 @@ void GUIFormSpecMenu::parseTextList(parserData* data, const std::string &element |
|
|
|
|
|
auto style = getDefaultStyleForElement("textlist", name); |
|
|
e->setNotClipped(style.getBool(StyleSpec::NOCLIP, false)); |
|
|
e->setOverrideFont(style.getFont()); |
|
|
|
|
|
m_tables.emplace_back(spec, e); |
|
|
m_fields.push_back(spec); |
|
|
|
@@ -56,7 +56,7 @@ GUITable::GUITable(gui::IGUIEnvironment *env, |
|
|
m_font = skin->getFont(); |
|
|
if (m_font) { |
|
|
m_font->grab(); |
|
|
m_rowheight = m_font->getDimension(L"A").Height + 4; |
|
|
m_rowheight = m_font->getDimension(L"Ay").Height + 4; |
|
|
m_rowheight = MYMAX(m_rowheight, 1); |
|
|
} |
|
|
|
|
@@ -586,6 +586,31 @@ void GUITable::setSelected(s32 index) |
|
|
} |
|
|
} |
|
|
|
|
|
void GUITable::setOverrideFont(IGUIFont *font) |
|
|
{ |
|
|
if (m_font == font) |
|
|
return; |
|
|
|
|
|
if (font == nullptr) |
|
|
font = Environment->getSkin()->getFont(); |
|
|
|
|
|
if (m_font) |
|
|
m_font->drop(); |
|
|
|
|
|
m_font = font; |
|
|
m_font->grab(); |
|
|
|
|
|
m_rowheight = m_font->getDimension(L"Ay").Height + 4; |
|
|
m_rowheight = MYMAX(m_rowheight, 1); |
|
|
|
|
|
updateScrollBar(); |
|
|
} |
|
|
|
|
|
IGUIFont *GUITable::getOverrideFont() const |
|
|
{ |
|
|
return m_font; |
|
|
} |
|
|
|
|
|
GUITable::DynamicData GUITable::getDynamicData() const |
|
|
{ |
|
|
DynamicData dyndata; |
|
|
|
@@ -123,6 +123,12 @@ class GUITable : public gui::IGUIElement |
|
|
// Autoscroll to make the selected row fully visible |
|
|
void setSelected(s32 index); |
|
|
|
|
|
//! Sets another skin independent font. If this is set to zero, the button uses the font of the skin. |
|
|
virtual void setOverrideFont(gui::IGUIFont *font = nullptr); |
|
|
|
|
|
//! Gets the override font (if any) |
|
|
virtual gui::IGUIFont *getOverrideFont() const; |
|
|
|
|
|
/* Get selection, scroll position and opened (sub)trees */ |
|
|
DynamicData getDynamicData() const; |
|
|
|
|
|