Repository navigation
Expand file tree
/
Copy pathUEPySBorder.cpp
More file actions
178 lines (144 loc) · 5.23 KB
/
Copy pathUEPySBorder.cpp
File metadata and controls
178 lines (144 loc) · 5.23 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#include "UEPySBorder.h"
static PyObject *py_ue_sborder_clear_content(ue_PySBorder *self, PyObject * args)
{
ue_py_slate_cast(SBorder);
py_SBorder->ClearContent();
Py_RETURN_NONE;
}
static PyObject *py_ue_sborder_set_content(ue_PySBorder *self, PyObject * args)
{
ue_py_slate_cast(SBorder);
PyObject *py_content;
if (!PyArg_ParseTuple(args, "O:set_content", &py_content))
{
return nullptr;
}
TSharedPtr<SWidget> child = py_ue_is_swidget<SWidget>(py_content);
if (!child.IsValid())
return nullptr;
py_SBorder->SetContent(child.ToSharedRef());
Py_RETURN_SLATE_SELF;
}
static PyObject *py_ue_sborder_set_padding(ue_PySBorder *self, PyObject * args)
{
ue_py_slate_cast(SBorder);
PyObject *py_padding;
if (!PyArg_ParseTuple(args, "O:set_padding", &py_padding))
{
return nullptr;
}
FMargin *margin = ue_py_check_struct<FMargin>(py_padding);
if (!margin)
{
if (!PyNumber_Check(py_padding))
{
return PyErr_Format(PyExc_Exception, "argument is not a FMargin or a number");
}
PyObject *py_float = PyNumber_Float(py_padding);
FMargin new_margin(PyFloat_AsDouble(py_float));
margin = &new_margin;
Py_DECREF(py_float);
}
py_SBorder->SetPadding(*margin);
Py_RETURN_SLATE_SELF;
}
static PyObject *py_ue_sborder_set_h_align(ue_PySBorder *self, PyObject * args)
{
ue_py_slate_cast(SBorder);
int align;
if (!PyArg_ParseTuple(args, "i:set_h_align", &align))
{
return nullptr;
}
py_SBorder->SetHAlign((EHorizontalAlignment)align);
Py_RETURN_SLATE_SELF;
}
static PyObject *py_ue_sborder_set_v_align(ue_PySBorder *self, PyObject * args)
{
ue_py_slate_cast(SBorder);
int align;
if (!PyArg_ParseTuple(args, "i:set_v_align", &align))
{
return nullptr;
}
py_SBorder->SetVAlign((EVerticalAlignment)align);
Py_RETURN_SLATE_SELF;
}
static PyObject *py_ue_sborder_set_border_image(ue_PySBorder *self, PyObject * args)
{
ue_py_slate_cast(SBorder);
PyObject *py_brush;
if (!PyArg_ParseTuple(args, "O:set_border_image", &py_brush))
{
return NULL;
}
FSlateBrush *brush = ue_py_check_struct<FSlateBrush>(py_brush);
if (!brush)
return PyErr_Format(PyExc_Exception, "argument is not a FSlateBrush");
py_SBorder->SetBorderImage(brush);
Py_RETURN_SLATE_SELF;
}
static PyMethodDef ue_PySBorder_methods[] = {
{ "clear_content", (PyCFunction)py_ue_sborder_clear_content, METH_VARARGS, "" },
{ "set_content", (PyCFunction)py_ue_sborder_set_content, METH_VARARGS, "" },
{ "set_padding", (PyCFunction)py_ue_sborder_set_padding, METH_VARARGS, "" },
{ "set_h_align", (PyCFunction)py_ue_sborder_set_h_align, METH_VARARGS, "" },
{ "set_v_align", (PyCFunction)py_ue_sborder_set_v_align, METH_VARARGS, "" },
{ "set_border_image", (PyCFunction)py_ue_sborder_set_border_image, METH_VARARGS, "" },
{ NULL } /* Sentinel */
};
PyTypeObject ue_PySBorderType = {
PyVarObject_HEAD_INIT(NULL, 0)
"unreal_engine.SBorder", /* tp_name */
sizeof(ue_PySBorder), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
"Unreal Engine SBorder", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
ue_PySBorder_methods, /* tp_methods */
};
static int ue_py_sborder_init(ue_PySBorder *self, PyObject *args, PyObject *kwargs)
{
ue_py_slate_setup_farguments(SBorder);
ue_py_slate_farguments_struct("border_background_color", BorderBackgroundColor, FSlateColor);
ue_py_slate_farguments_flinear_color("color_and_opacity", ColorAndOpacity);
ue_py_slate_farguments_optional_struct_ptr("border_image", BorderImage, FSlateBrush);
ue_py_slate_farguments_optional_enum("h_align", HAlign, EHorizontalAlignment);
ue_py_slate_farguments_optional_enum("v_align", VAlign, EVerticalAlignment);
ue_py_slate_farguments_padding("padding", Padding);
ue_py_slate_farguments_struct("foreground_color", ForegroundColor, FSlateColor);
ue_py_slate_farguments_fvector2d("content_scale", ContentScale);
ue_py_slate_farguments_fvector2d("desired_size_scale", DesiredSizeScale);
ue_py_snew(SBorder);
return 0;
}
void ue_python_init_sborder(PyObject *ue_module)
{
ue_PySBorderType.tp_init = (initproc)ue_py_sborder_init;
ue_PySBorderType.tp_call = (ternaryfunc)py_ue_sborder_set_content;
ue_PySBorderType.tp_base = &ue_PySCompoundWidgetType;
if (PyType_Ready(&ue_PySBorderType) < 0)
return;
Py_INCREF(&ue_PySBorderType);
PyModule_AddObject(ue_module, "SBorder", (PyObject *)&ue_PySBorderType);
}