Skip to content

Commit 36b140b

Browse files
author
Roberto De Ioris
committed
added splitter and headerrow
1 parent 58601f3 commit 36b140b

File tree

12 files changed

+565
-0
lines changed

12 files changed

+565
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#if WITH_EDITOR
2+
3+
#include "UnrealEnginePythonPrivatePCH.h"
4+
5+
#include "UEPySHeaderRow.h"
6+
7+
#define GET_s_header_row SHeaderRow *s_header_row =(SHeaderRow *)self->s_border.s_compound_widget.s_widget.s_widget
8+
9+
static PyObject *ue_PySHeaderRow_str(ue_PySButton *self)
10+
{
11+
return PyUnicode_FromFormat("<unreal_engine.SButton '%p'>",
12+
self->s_border.s_compound_widget.s_widget.s_widget);
13+
}
14+
15+
16+
static PyMethodDef ue_PySHeaderRow_methods[] = {
17+
{ NULL } /* Sentinel */
18+
};
19+
20+
PyTypeObject ue_PySHeaderRowType = {
21+
PyVarObject_HEAD_INIT(NULL, 0)
22+
"unreal_engine.SHeaderRow", /* tp_name */
23+
sizeof(ue_PySHeaderRow), /* tp_basicsize */
24+
0, /* tp_itemsize */
25+
0, /* tp_dealloc */
26+
0, /* tp_print */
27+
0, /* tp_getattr */
28+
0, /* tp_setattr */
29+
0, /* tp_reserved */
30+
0, /* tp_repr */
31+
0, /* tp_as_number */
32+
0, /* tp_as_sequence */
33+
0, /* tp_as_mapping */
34+
0, /* tp_hash */
35+
0, /* tp_call */
36+
(reprfunc)ue_PySHeaderRow_str, /* tp_str */
37+
0, /* tp_getattro */
38+
0, /* tp_setattro */
39+
0, /* tp_as_buffer */
40+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
41+
"Unreal Engine SHeaderRow", /* tp_doc */
42+
0, /* tp_traverse */
43+
0, /* tp_clear */
44+
0, /* tp_richcompare */
45+
0, /* tp_weaklistoffset */
46+
0, /* tp_iter */
47+
0, /* tp_iternext */
48+
ue_PySHeaderRow_methods, /* tp_methods */
49+
};
50+
51+
static int ue_py_sheader_row_init(ue_PySHeaderRow *self, PyObject *args, PyObject *kwargs) {
52+
ue_py_snew(SHeaderRow, s_border.s_compound_widget.s_widget);
53+
return 0;
54+
}
55+
56+
void ue_python_init_sheader_row(PyObject *ue_module) {
57+
ue_PySButtonType.tp_new = PyType_GenericNew;
58+
59+
ue_PySButtonType.tp_init = (initproc)ue_py_sheader_row_init;
60+
61+
ue_PySButtonType.tp_base = &ue_PySBorderType;
62+
63+
if (PyType_Ready(&ue_PySHeaderRowType) < 0)
64+
return;
65+
66+
Py_INCREF(&ue_PySHeaderRowType);
67+
PyModule_AddObject(ue_module, "SHeaderRow", (PyObject *)&ue_PySHeaderRowType);
68+
}
69+
70+
71+
#endif
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
3+
#include "UnrealEnginePython.h"
4+
5+
#if WITH_EDITOR
6+
7+
#include "UEPySBorder.h"
8+
9+
#include "Runtime/Slate/Public/Widgets/Views/SHeaderRow.h"
10+
11+
extern PyTypeObject ue_PySHeaderRowType;
12+
13+
typedef struct {
14+
ue_PySBorder s_border;
15+
/* Type-specific fields go here. */
16+
} ue_PySHeaderRow;
17+
18+
void ue_python_init_sheader_row(PyObject *);
19+
20+
#endif
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#if WITH_EDITOR
2+
3+
#include "UnrealEnginePythonPrivatePCH.h"
4+
5+
#include "UEPySListView.h"
6+
7+
8+
#define GET_s_list_view SListView<TSharedPtr<PyObject>> *s_list_view = (SListView<TSharedPtr<PyObject>> *)self->s_table_view_base.s_compound_widget.s_widget.s_widget
9+
10+
static PyObject *ue_PySListView_str(ue_PySListView *self)
11+
{
12+
return PyUnicode_FromFormat("<unreal_engine.SListView '%p'>",
13+
self->s_table_view_base.s_compound_widget.s_widget.s_widget);
14+
}
15+
16+
static PyMethodDef ue_PySListView_methods[] = {
17+
{ NULL } /* Sentinel */
18+
};
19+
20+
PyTypeObject ue_PySListViewType = {
21+
PyVarObject_HEAD_INIT(NULL, 0)
22+
"unreal_engine.SListView", /* tp_name */
23+
sizeof(ue_PySListView), /* tp_basicsize */
24+
0, /* tp_itemsize */
25+
0, /* tp_dealloc */
26+
0, /* tp_print */
27+
0, /* tp_getattr */
28+
0, /* tp_setattr */
29+
0, /* tp_reserved */
30+
0, /* tp_repr */
31+
0, /* tp_as_number */
32+
0, /* tp_as_sequence */
33+
0, /* tp_as_mapping */
34+
0, /* tp_hash */
35+
0, /* tp_call */
36+
(reprfunc)ue_PySListView_str, /* tp_str */
37+
0, /* tp_getattro */
38+
0, /* tp_setattro */
39+
0, /* tp_as_buffer */
40+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
41+
"Unreal Engine SListView", /* tp_doc */
42+
0, /* tp_traverse */
43+
0, /* tp_clear */
44+
0, /* tp_richcompare */
45+
0, /* tp_weaklistoffset */
46+
0, /* tp_iter */
47+
0, /* tp_iternext */
48+
ue_PySListView_methods, /* tp_methods */
49+
};
50+
51+
52+
void ue_python_init_slist_view(PyObject *ue_module) {
53+
ue_PySListViewType.tp_new = PyType_GenericNew;
54+
55+
ue_PySListViewType.tp_base = &ue_PySTableViewBaseType;
56+
57+
if (PyType_Ready(&ue_PySListViewType) < 0)
58+
return;
59+
60+
Py_INCREF(&ue_PySListViewType);
61+
PyModule_AddObject(ue_module, "SListView", (PyObject *)&ue_PySListViewType);
62+
}
63+
64+
65+
#endif
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
3+
#include "UnrealEnginePython.h"
4+
5+
#if WITH_EDITOR
6+
7+
#include "UEPySTableViewBase.h"
8+
9+
#include "Runtime/Slate/Public/Widgets/Views/SListView.h"
10+
11+
extern PyTypeObject ue_PySListViewType;
12+
13+
typedef struct {
14+
ue_PySTableViewBase s_table_view_base;
15+
/* Type-specific fields go here. */
16+
} ue_PySListView;
17+
18+
void ue_python_init_slist_view(PyObject *);
19+
20+
#endif
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#if WITH_EDITOR
2+
3+
#include "UnrealEnginePythonPrivatePCH.h"
4+
5+
#include "Runtime/Slate/Public/Widgets/Views/SListView.h"
6+
7+
#include "UEPySPythonListView.h"
8+
9+
10+
#define GET_s_python_list_view SPythonListView *s_python_list_view = (SPythonListView *)self->s_list_view.s_table_view_base.s_compound_widget.s_widget.s_widget
11+
12+
static PyObject *py_ue_spython_list_view_is_item_visible(ue_PySPythonListView *self, PyObject * args) {
13+
PyObject *py_item;
14+
if (!PyArg_ParseTuple(args, "O:is_item_visible", &py_item)) {
15+
return NULL;
16+
}
17+
18+
GET_s_python_list_view;
19+
20+
if (s_python_list_view->IsItemVisible(TSharedPtr<PyObject>(py_item))) {
21+
Py_INCREF(Py_True);
22+
return Py_True;
23+
}
24+
else {
25+
Py_INCREF(Py_False);
26+
return Py_False;
27+
}
28+
}
29+
30+
static PyObject *ue_PySPythonListView_str(ue_PySPythonListView *self)
31+
{
32+
return PyUnicode_FromFormat("<unreal_engine.SPythonListView '%p'>",
33+
self->s_list_view.s_table_view_base.s_compound_widget.s_widget.s_widget);
34+
}
35+
36+
static PyMethodDef ue_PySPythonListView_methods[] = {
37+
{ "is_item_visible", (PyCFunction)py_ue_spython_list_view_is_item_visible, METH_VARARGS, "" },
38+
{ NULL } /* Sentinel */
39+
};
40+
41+
PyTypeObject ue_PySPythonListViewType = {
42+
PyVarObject_HEAD_INIT(NULL, 0)
43+
"unreal_engine.SPythonListView", /* tp_name */
44+
sizeof(ue_PySPythonListView), /* tp_basicsize */
45+
0, /* tp_itemsize */
46+
0, /* tp_dealloc */
47+
0, /* tp_print */
48+
0, /* tp_getattr */
49+
0, /* tp_setattr */
50+
0, /* tp_reserved */
51+
0, /* tp_repr */
52+
0, /* tp_as_number */
53+
0, /* tp_as_sequence */
54+
0, /* tp_as_mapping */
55+
0, /* tp_hash */
56+
0, /* tp_call */
57+
(reprfunc)ue_PySPythonListView_str, /* tp_str */
58+
0, /* tp_getattro */
59+
0, /* tp_setattro */
60+
0, /* tp_as_buffer */
61+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
62+
"Unreal Engine SPythonListView", /* tp_doc */
63+
0, /* tp_traverse */
64+
0, /* tp_clear */
65+
0, /* tp_richcompare */
66+
0, /* tp_weaklistoffset */
67+
0, /* tp_iter */
68+
0, /* tp_iternext */
69+
ue_PySPythonListView_methods, /* tp_methods */
70+
};
71+
72+
static int ue_py_spython_list_view_init(ue_PySPythonListView *self, PyObject *args, PyObject *kwargs) {
73+
PyObject *py_iterable;
74+
PyObject *py_callable;
75+
if (!PyArg_ParseTuple(args, "OO", &py_iterable, &py_callable)) {
76+
return -1;
77+
}
78+
79+
py_iterable = PyObject_GetIter(py_iterable);
80+
81+
if (!py_iterable || !PyIter_Check(py_iterable)) {
82+
PyErr_SetString(PyExc_Exception, "argument is not an iterable");
83+
return -1;
84+
}
85+
86+
if (!PyCallable_Check(py_callable)) {
87+
PyErr_SetString(PyExc_Exception, "argument is not a callable");
88+
return -1;
89+
}
90+
91+
TArray<TSharedPtr<PyObject>> items;
92+
93+
while (PyObject *item = PyIter_Next(py_iterable)) {
94+
Py_INCREF(item);
95+
items.Add(TSharedPtr<PyObject>(item));
96+
}
97+
98+
Py_DECREF(py_iterable);
99+
100+
SPythonListView::FOnGenerateRow handler;
101+
UPythonSlateDelegate *py_delegate = NewObject<UPythonSlateDelegate>();
102+
py_delegate->SetPyCallable(py_callable);
103+
py_delegate->AddToRoot();
104+
handler.BindUObject(py_delegate, &UPythonSlateDelegate::GenerateWidgetForList);
105+
106+
self->s_list_view.s_table_view_base.s_compound_widget.s_widget.s_widget_owned = SNew(SPythonListView).ListItemsSource(&items).OnGenerateRow(handler);
107+
self->s_list_view.s_table_view_base.s_compound_widget.s_widget.s_widget = &self->s_list_view.s_table_view_base.s_compound_widget.s_widget.s_widget_owned.Get();
108+
return 0;
109+
}
110+
111+
void ue_python_init_spython_list_view(PyObject *ue_module) {
112+
ue_PySPythonListViewType.tp_new = PyType_GenericNew;
113+
114+
ue_PySPythonListViewType.tp_init = (initproc)ue_py_spython_list_view_init;
115+
116+
ue_PySPythonListViewType.tp_base = &ue_PySListViewType;
117+
118+
if (PyType_Ready(&ue_PySPythonListViewType) < 0)
119+
return;
120+
121+
Py_INCREF(&ue_PySListViewType);
122+
PyModule_AddObject(ue_module, "SPythonListView", (PyObject *)&ue_PySPythonListViewType);
123+
}
124+
125+
126+
#endif
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#pragma once
2+
3+
#include "UnrealEnginePython.h"
4+
5+
#if WITH_EDITOR
6+
7+
#include "UEPySListView.h"
8+
9+
extern PyTypeObject ue_PySPythonListViewType;
10+
11+
class SPythonListView : public SListView<TSharedPtr<PyObject>> {
12+
public:
13+
void SetPyCallable(PyObject *py_obj) {
14+
Py_INCREF(py_obj);
15+
py_callable = py_obj;
16+
}
17+
protected:
18+
PyObject *py_items;
19+
PyObject *py_callable;
20+
};
21+
22+
typedef struct {
23+
ue_PySListView s_list_view;
24+
/* Type-specific fields go here. */
25+
} ue_PySPythonListView;
26+
27+
void ue_python_init_spython_list_view(PyObject *);
28+
29+
#endif

0 commit comments

Comments
 (0)