MCPcopy Create free account
hub / github.com/OpenMW/openmw / createWidget

Function createWidget

components/lua_ui/element.cpp:195–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193 }
194
195 WidgetExtension* createWidget(const sol::table& layout, bool isRoot, uint64_t depth)
196 {
197 static auto widgetTypeMap = widgetTypeToName();
198 std::string type = widgetType(layout);
199 if (widgetTypeMap.find(type) == widgetTypeMap.end())
200 throw std::logic_error(std::string("Invalid widget type ") += type);
201
202 std::string name = layout.get_or(LayoutKeys::name, std::string());
203 MyGUI::Widget* widget
204 = MyGUI::Gui::getInstancePtr()->createWidgetT(type, {}, {}, MyGUI::Align::Default, {}, name);
205
206 WidgetExtension* ext = dynamic_cast<WidgetExtension*>(widget);
207 if (!ext)
208 throw std::runtime_error("Invalid widget!");
209 ext->initialize(layout.lua_state(), widget, isRoot);
210
211 updateWidget(ext, layout, depth);
212 return ext;
213 }
214
215 void updateWidget(WidgetExtension* ext, const sol::table& layout, uint64_t depth)
216 {

Callers 3

updateContentFunction · 0.85
createMethod · 0.85
updateMethod · 0.85

Calls 7

widgetTypeFunction · 0.85
updateWidgetFunction · 0.85
findMethod · 0.45
endMethod · 0.45
get_orMethod · 0.45
initializeMethod · 0.45
lua_stateMethod · 0.45

Tested by

no test coverage detected