summaryrefslogtreecommitdiff
path: root/Editor/Scripting/EditorGUI/ContainerWindow.bind.cpp
blob: 59067883ffcddd3e639bcc576e94517b625552f9 (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
#include "Editor/GUI/EditorWindows.h"

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

LUA_BIND_POSTPROCESS(ContainerWindow)
{
	LUA_BIND_REGISTER_ENUM(state, "EShowMode",
		{ "NormalWindow", ShowMode::kShowNormalWindow },
		{ "ShowPopupMenu", ShowMode::kShowPopupMenu },
		{ "Utility ", ShowMode::kShowUtility },
		{ "NoShadow", ShowMode::kShowNoShadow },
		{ "MainWindow", ShowMode::kShowMainWindow },
		{ "AuxWindow", ShowMode::kShowAuxWindow }
	);
}

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, _DoPaint)
{
    LUA_BIND_PREPARE(L, ContainerWindow);
    self->DoPaint();
    return 0;
}

LUA_BIND_IMPL_METHOD(ContainerWindow, ContainerWindow::_New)
{
    LUA_BIND_STATE(L, ContainerWindow);
    LUA_BIND_CHECK(L, "TNTT");

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

    Internal::Rect rect = state.GetValue<Internal::Rect>(state, Internal::Rect());
    int showMode = state.GetValue<int>(2, 0);
    Internal::Vector2 min = state.GetValue<Internal::Vector2>(state, Internal::Vector2());
    Internal::Vector2 max = state.GetValue<Internal::Vector2>(state, Internal::Vector2());

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

    wnd->PushUserdata(state);

    return 1;
}