summaryrefslogtreecommitdiff
path: root/Editor/Scripting/Window/GUIWindow.bind.cpp
blob: 604c26ab4c1ae2f81df794a3ed3fedb8c33a05df (plain)
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
#include "Editor/GUI/EditorWindows.h"
#include "Runtime/Math/Math.h"

LUA_BIND_REGISTRY(GUIWindow)
{
    LUA_BIND_REGISTER_METHODS(state,
        { "DoPaint", _DoPaint },
        { "Focus", _Focus },
        { "SetContainerWindow", _SetContainerWindow },
        { "SetPosition", _SetPosition },
        { "New", _New }
    );
}

LUA_BIND_POSTPROCESS(GUIWindow)
{
}

// GUIWindow.New([script])
LUA_BIND_IMPL_METHOD(GUIWindow, _New)
{
	LUA_BIND_STATE(L, GUIWindow);
	LUA_BIND_CHECK(L, "T");

	GUIWindow* wnd = new GUIWindow(state.GetVM());

	if (LuaHelper::IsType(state, "GameLab.Editor.Window.GUIWindow", -1))
		wnd->SetMemberRef(state, wnd->m_Script, -1);

	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;
}