1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#include "Editor/GUI/EditorWindows.h"
#include "Runtime/Math/Math.h"
LUA_BIND_REGISTRY(GUIWindow)
{
LUA_BIND_REGISTER_METHODS(state,
{ "New", _New },
{ "DoPaint", _DoPaint },
{ "Focus", _Focus },
{ "SetContainerWindow", _SetContainerWindow },
{ "SetPosition", _SetPosition }
);
}
LUA_BIND_POSTPROCESS(GUIWindow)
{
}
// GUIWindow.New(script)
LUA_BIND_IMPL_METHOD(GUIWindow, _New)
{
LUA_BIND_STATE(L, GUIWindow);
LUA_BIND_CHECK(L, "T");
if (!LuaHelper::IsType(state, "GameLab.Editor.Window.GUIWindow", -1))
{
state.ErrorType(-1, "GameLab.Editor.Window.GUIWindow");
return 0;
}
GUIWindow* wnd = new GUIWindow(state.GetVM());
LuaBind::MemberRef script;
wnd->SetMemberRef(state, script, -1);
wnd->m_Script.owner = wnd;
wnd->m_Script.script = script;
wnd->PushUserdata(state);
return 1;
}
LUA_BIND_IMPL_METHOD(GUIWindow, _DoPaint)
{
LUA_BIND_PREPARE(L, GUIWindow);
self->DoPaint();
return 0;
}
LUA_BIND_IMPL_METHOD(GUIWindow, _Focus)
{
LUA_BIND_PREPARE(L, GUIWindow);
self->Focus();
return 0;
}
LUA_BIND_IMPL_METHOD(GUIWindow, _SetContainerWindow)
{
LUA_BIND_PREPARE(L, GUIWindow);
ContainerWindow* wnd = state.GetUserdata<ContainerWindow>(2);
self->SetContainerWindow(wnd);
return 0;
}
// GUIWindow.SetPosition(self, {x, y, width, height})
LUA_BIND_IMPL_METHOD(GUIWindow, _SetPosition)
{
LUA_BIND_PREPARE(L, GUIWindow);
if (!state.CheckParams(1, "UT"))
return 0;
Rect rect;
rect.x = state.GetField<float>(2, 1, 0);
rect.y = state.GetField<float>(2, 2, 0);
rect.width = state.GetField<float>(2, 3, 0);
rect.height = state.GetField<float>(2, 4, 0);
self->SetPosition(rect);
return 0;
}
|