mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 19:44:54 +02:00
display window on screen center
This commit is contained in:
@@ -120,6 +120,7 @@ void Application::registerLuaFunctions()
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getMarginLeft", &UIWidget::getMarginLeft);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getLastFocusReason", &UIWidget::getLastFocusReason);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getStyle", &UIWidget::getStyle);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getStyleName", &UIWidget::getStyleName);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getChildren", &UIWidget::getChildren);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getFocusedChild", &UIWidget::getFocusedChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("getChildAfter", &UIWidget::getChildAfter);
|
||||
@@ -233,6 +234,7 @@ void Application::registerLuaFunctions()
|
||||
g_lua.bindClassStaticFunction("g_window", "setIcon", std::bind(&PlatformWindow::setIcon, &g_window, _1));
|
||||
g_lua.bindClassStaticFunction("g_window", "getMousePos", std::bind(&PlatformWindow::getMousePos, &g_window));
|
||||
g_lua.bindClassStaticFunction("g_window", "getSize", std::bind(&PlatformWindow::getSize, &g_window));
|
||||
g_lua.bindClassStaticFunction("g_window", "getDisplaySize", std::bind(&PlatformWindow::getDisplaySize, &g_window));
|
||||
g_lua.bindClassStaticFunction("g_window", "getPlatformType", std::bind(&PlatformWindow::getPlatformType, &g_window));
|
||||
|
||||
// Logger
|
||||
|
@@ -34,7 +34,6 @@ void UIManager::init()
|
||||
// creates root widget
|
||||
m_rootWidget = UIWidget::create<UIWidget>();
|
||||
m_rootWidget->setId("root");
|
||||
m_rootWidget->resize(g_window.getSize());
|
||||
m_mouseReceiver = m_rootWidget;
|
||||
m_keyboardReceiver = m_rootWidget;
|
||||
}
|
||||
@@ -134,8 +133,9 @@ OTMLNodePtr UIManager::getStyle(const std::string& styleName)
|
||||
|
||||
// styles starting with UI are automatically defined
|
||||
if(boost::starts_with(styleName, "UI")) {
|
||||
OTMLNodePtr node = OTMLNode::create();
|
||||
OTMLNodePtr node = OTMLNode::create(styleName);
|
||||
node->writeAt("__class", styleName);
|
||||
m_styles[styleName] = node;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
@@ -155,6 +155,7 @@ void UIWidget::setStyle(const std::string& styleName)
|
||||
}
|
||||
applyStyle(styleNode);
|
||||
m_style = styleNode;
|
||||
assert(getStyleName() != "");
|
||||
updateStyle();
|
||||
}
|
||||
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "declarations.h"
|
||||
#include <framework/luascript/luaobject.h>
|
||||
#include <framework/graphics/declarations.h>
|
||||
#include <framework/otml/otmlnode.h>
|
||||
|
||||
class UIWidget : public LuaObject
|
||||
{
|
||||
@@ -128,6 +129,7 @@ public:
|
||||
int getMarginLeft() { return m_marginLeft; }
|
||||
Fw::FocusReason getLastFocusReason() { return m_lastFocusReason; }
|
||||
OTMLNodePtr getStyle() { return m_style; }
|
||||
std::string getStyleName() { return m_style->tag(); }
|
||||
|
||||
UIWidgetList getChildren() { return m_children; }
|
||||
UIWidgetPtr getFocusedChild() { return m_focusedChild; }
|
||||
|
Reference in New Issue
Block a user