diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index 4b9601430..f1e91bd0b 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -1235,10 +1235,14 @@ void GUIFormSpecMenu::parseTable(parserData* data, const std::string &element) item = wide_to_utf8(unescape_translate(utf8_to_wide(unescape_string(item)))); } - //now really show table GUITable *e = new GUITable(Environment, data->current_parent, spec.fid, rect, m_tsrc); + // Apply styling before calculating the cell sizes + auto style = getDefaultStyleForElement("table", name); + e->setNotClipped(style.getBool(StyleSpec::NOCLIP, false)); + e->setOverrideFont(style.getFont()); + if (spec.fname == m_focused_element) { Environment->setFocus(e); } @@ -1252,10 +1256,6 @@ void GUIFormSpecMenu::parseTable(parserData* data, const std::string &element) if (!str_initial_selection.empty() && str_initial_selection != "0") e->setSelected(stoi(str_initial_selection)); - 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); } diff --git a/src/gui/guiTable.h b/src/gui/guiTable.h index 7dbf17a51..2ade0ee3e 100644 --- a/src/gui/guiTable.h +++ b/src/gui/guiTable.h @@ -85,7 +85,7 @@ public: void setTextList(const std::vector &content, bool transparent); - /* Set generic table options, columns and content */ + /** Set generic table options, columns and content, calculate cell sizes */ // Adds empty strings to end of content if there is an incomplete row void setTable(const TableOptions &options, const TableColumns &columns,