summaryrefslogtreecommitdiff
path: root/Editor/Scripting/Window/ContainerWindow.bind.cpp
blob: f3a8cc74d36eeab3483fa48d0bd876a3c97a9540 (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
71
72
73
74
75
#include "Editor/GUI/EditorWindows.h"
#include "Runtime/Math/Math.h"

using namespace LuaBind;

LUA_BIND_REGISTRY(ContainerWindow)
{
	LUA_BIND_REGISTER_METHODS(state,
		{ "New", _New },
        { "SetTitle", _SetTitle },
        { "SetIcon", _SetIcon },
        { "DoPaint", _DoPaint },
		{ "GetSize", _GetSize }
    );
}

LUA_BIND_POSTPROCESS(ContainerWindow)
{
}

// self, position, showMode, min, max
LUA_BIND_IMPL_METHOD(ContainerWindow, ContainerWindow::_New)
{
	LUA_BIND_STATE(L, ContainerWindow);
	LUA_BIND_CHECK(L, "TTNTT");

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

	wnd->SetMemberRef(state, wnd->m_Script, 1);
	Rect rect = state.GetValue<Rect>(2, Rect());
	int showMode = state.GetValue<int>(3, 0);
	Vector2 min = state.GetValue<Vector2>(4, Vector2(50, 50));
	Vector2 max = state.GetValue<Vector2>(5, Vector2(10000, 10000));

	wnd->Init(rect, showMode, min, max);
	wnd->PushUserdata(state);

	return 1;
}

LUA_BIND_IMPL_METHOD(ContainerWindow, _SetTitle)
{
    LUA_BIND_PREPARE(L, ContainerWindow);

    cc8* title = state.GetValue<cc8*>(2, "");
    self->SetTitle(title);

    return 0;
}

LUA_BIND_IMPL_METHOD(ContainerWindow, _SetIcon)
{
    LUA_BIND_PREPARE(L, ContainerWindow);

    cc8* path = state.GetValue<cc8*>(2, "");
    self->SetIcon(path);

    return 0;
}

LUA_BIND_IMPL_METHOD(ContainerWindow, _GetSize)
{
	LUA_BIND_PREPARE(L, ContainerWindow);

	state.PushLuaObject<Vector2f>(self->GetSize());

	return 1;
}

LUA_BIND_IMPL_METHOD(ContainerWindow, _DoPaint)
{
    LUA_BIND_PREPARE(L, ContainerWindow);
    self->DoPaint();
    return 0;
}