Skip to content

Commit 2f7f26f

Browse files
author
Roberto De Ioris
committed
slate boxes
1 parent f5733bf commit 2f7f26f

14 files changed

+629
-6
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#if WITH_EDITOR
2+
3+
#include "UnrealEnginePythonPrivatePCH.h"
4+
5+
#include "UEPySBoxPanel.h"
6+
7+
8+
#define GET_s_box_panel TSharedRef<SBoxPanel> s_box_panel = StaticCastSharedRef<SBoxPanel>(self->s_panel.s_widget.s_widget)
9+
10+
static PyObject *py_ue_sbox_panel_clear_children(ue_PySGridPanel *self, PyObject * args) {
11+
GET_s_box_panel;
12+
13+
s_box_panel->ClearChildren();
14+
15+
Py_INCREF(Py_None);
16+
return Py_None;
17+
}
18+
19+
static PyObject *ue_PySBoxPanel_str(ue_PySBoxPanel *self)
20+
{
21+
return PyUnicode_FromFormat("<unreal_engine.SBoxPanel '%p'>",
22+
&self->s_panel.s_widget.s_widget.Get());
23+
}
24+
25+
static PyMethodDef ue_PySBoxPanel_methods[] = {
26+
{ "clear_children", (PyCFunction)py_ue_sbox_panel_clear_children, METH_VARARGS, "" },
27+
{ NULL } /* Sentinel */
28+
};
29+
30+
PyTypeObject ue_PySBoxPanelType = {
31+
PyVarObject_HEAD_INIT(NULL, 0)
32+
"unreal_engine.SBoxPanel", /* tp_name */
33+
sizeof(ue_PySBoxPanel), /* tp_basicsize */
34+
0, /* tp_itemsize */
35+
0, /* tp_dealloc */
36+
0, /* tp_print */
37+
0, /* tp_getattr */
38+
0, /* tp_setattr */
39+
0, /* tp_reserved */
40+
0, /* tp_repr */
41+
0, /* tp_as_number */
42+
0, /* tp_as_sequence */
43+
0, /* tp_as_mapping */
44+
0, /* tp_hash */
45+
0, /* tp_call */
46+
(reprfunc)ue_PySBoxPanel_str, /* tp_str */
47+
0, /* tp_getattro */
48+
0, /* tp_setattro */
49+
0, /* tp_as_buffer */
50+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
51+
"Unreal Engine SBoxPanel", /* tp_doc */
52+
0, /* tp_traverse */
53+
0, /* tp_clear */
54+
0, /* tp_richcompare */
55+
0, /* tp_weaklistoffset */
56+
0, /* tp_iter */
57+
0, /* tp_iternext */
58+
ue_PySBoxPanel_methods, /* tp_methods */
59+
};
60+
61+
void ue_python_init_sbox_panel(PyObject *ue_module) {
62+
ue_PySBoxPanelType.tp_new = PyType_GenericNew;
63+
64+
ue_PySBoxPanelType.tp_base = &ue_PySPanelType;
65+
66+
if (PyType_Ready(&ue_PySBoxPanelType) < 0)
67+
return;
68+
69+
Py_INCREF(&ue_PySGridPanelType);
70+
PyModule_AddObject(ue_module, "SBoxPanel", (PyObject *)&ue_PySBoxPanelType);
71+
}
72+
73+
74+
#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 "UEPySPanel.h"
8+
9+
#include "Runtime/SlateCore/Public/Widgets/SBoxPanel.h"
10+
11+
extern PyTypeObject ue_PySBoxPanelType;
12+
13+
typedef struct {
14+
ue_PySPanel s_panel;
15+
/* Type-specific fields go here. */
16+
} ue_PySBoxPanel;
17+
18+
void ue_python_init_sbox_panel(PyObject *);
19+
20+
#endif

Source/UnrealEnginePython/Private/Slate/UEPySEditableTextBox.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ static PyObject *py_ue_seditable_text_box_get_text(ue_PySEditableTextBox *self,
4242
return PyUnicode_FromString(TCHAR_TO_UTF8(*text.ToString()));
4343
}
4444

45+
static PyObject *py_ue_seditable_text_box_set_text(ue_PySEditableTextBox *self, PyObject * args) {
46+
char *text;
47+
if (!PyArg_ParseTuple(args, "s:set_text", &text)) {
48+
return NULL;
49+
}
50+
51+
GET_s_editable_text_box;
52+
53+
s_editable_text_box->SetText(FText::FromString(UTF8_TO_TCHAR(text)));
54+
55+
Py_INCREF(self);
56+
return (PyObject *)self;
57+
}
58+
4559
static PyObject *ue_PySEditableTextBox_str(ue_PySEditableTextBox *self)
4660
{
4761
return PyUnicode_FromFormat("<unreal_engine.SEditableTextBox '%p'>",
@@ -53,6 +67,7 @@ static PyMethodDef ue_PySEditableTextBox_methods[] = {
5367
{ "clear_selection", (PyCFunction)py_ue_seditable_text_box_clear_selection, METH_VARARGS, "" },
5468
{ "get_selected_text", (PyCFunction)py_ue_seditable_text_box_get_selected_text, METH_VARARGS, "" },
5569
{ "get_text", (PyCFunction)py_ue_seditable_text_box_get_text, METH_VARARGS, "" },
70+
{ "set_text", (PyCFunction)py_ue_seditable_text_box_set_text, METH_VARARGS, "" },
5671
{ NULL } /* Sentinel */
5772
};
5873

Source/UnrealEnginePython/Private/Slate/UEPySEditableTextBox.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
#if WITH_EDITOR
66

7-
#include "UEPySBorder.h"
7+
#include "UEPySWidget.h"
88

9-
#include "Runtime/Slate/Public/Widgets/Input/SEditableTextBox.h"
9+
#include "Runtime/Slate/Public/Widgets/Text/SMultiLineEditableText.h"
1010

11-
extern PyTypeObject ue_PySEditableTextBoxType;
11+
extern PyTypeObject ue_PySMultiLineEditableTextType;
1212

1313
typedef struct {
14-
ue_PySBorder s_border;
14+
ue_PySWidget s_widget;
1515
/* Type-specific fields go here. */
16-
} ue_PySEditableTextBox;
16+
} ue_PySMultiLineEditableText;
1717

18-
void ue_python_init_seditable_text_box(PyObject *);
18+
void ue_python_init_smulti_line_editable_text(PyObject *);
1919

2020
#endif
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#if WITH_EDITOR
2+
3+
#include "UnrealEnginePythonPrivatePCH.h"
4+
5+
#include "UEPySGridPanel.h"
6+
7+
8+
#define GET_s_grid_panel TSharedRef<SGridPanel> s_grid_panel = StaticCastSharedRef<SGridPanel>(self->s_panel.s_widget.s_widget)
9+
10+
static PyObject *py_ue_sgrid_panel_clear_children(ue_PySGridPanel *self, PyObject * args) {
11+
GET_s_grid_panel;
12+
13+
s_grid_panel->ClearChildren();
14+
15+
Py_INCREF(Py_None);
16+
return Py_None;
17+
}
18+
19+
static PyObject *py_ue_sgrid_panel_add_slot(ue_PySGridPanel *self, PyObject * args) {
20+
PyObject *py_content;
21+
int col;
22+
int row;
23+
int layer = 0;
24+
if (!PyArg_ParseTuple(args, "Oii|i:add_slot", &py_content, &col, &row, &layer)) {
25+
return NULL;
26+
}
27+
28+
ue_PySWidget *py_swidget = py_ue_is_swidget(py_content);
29+
if (!py_swidget) {
30+
return PyErr_Format(PyExc_Exception, "argument is not a SWidget");
31+
}
32+
// TODO: decrement reference when destroying parent
33+
Py_INCREF(py_swidget);
34+
35+
GET_s_grid_panel;
36+
37+
SGridPanel::FSlot &fslot = s_grid_panel->AddSlot(col, row, SGridPanel::Layer(layer));
38+
fslot.AttachWidget(py_swidget->s_widget);
39+
40+
Py_INCREF(self);
41+
return (PyObject *)self;
42+
}
43+
44+
static PyObject *ue_PySGridPanel_str(ue_PySGridPanel *self)
45+
{
46+
return PyUnicode_FromFormat("<unreal_engine.SGridPanel '%p'>",
47+
&self->s_panel.s_widget.s_widget.Get());
48+
}
49+
50+
static PyMethodDef ue_PySGridPanel_methods[] = {
51+
{ "clear_children", (PyCFunction)py_ue_sgrid_panel_clear_children, METH_VARARGS, "" },
52+
{ "add_slot", (PyCFunction)py_ue_sgrid_panel_add_slot, METH_VARARGS, "" },
53+
{ NULL } /* Sentinel */
54+
};
55+
56+
PyTypeObject ue_PySGridPanelType = {
57+
PyVarObject_HEAD_INIT(NULL, 0)
58+
"unreal_engine.SGridPanel", /* tp_name */
59+
sizeof(ue_PySGridPanel), /* tp_basicsize */
60+
0, /* tp_itemsize */
61+
0, /* tp_dealloc */
62+
0, /* tp_print */
63+
0, /* tp_getattr */
64+
0, /* tp_setattr */
65+
0, /* tp_reserved */
66+
0, /* tp_repr */
67+
0, /* tp_as_number */
68+
0, /* tp_as_sequence */
69+
0, /* tp_as_mapping */
70+
0, /* tp_hash */
71+
0, /* tp_call */
72+
(reprfunc)ue_PySGridPanel_str, /* tp_str */
73+
0, /* tp_getattro */
74+
0, /* tp_setattro */
75+
0, /* tp_as_buffer */
76+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
77+
"Unreal Engine SGridPanel", /* tp_doc */
78+
0, /* tp_traverse */
79+
0, /* tp_clear */
80+
0, /* tp_richcompare */
81+
0, /* tp_weaklistoffset */
82+
0, /* tp_iter */
83+
0, /* tp_iternext */
84+
ue_PySGridPanel_methods, /* tp_methods */
85+
};
86+
87+
static int ue_py_sgrid_panel_init(ue_PySGridPanel *self, PyObject *args, PyObject *kwargs) {
88+
self->s_panel.s_widget.s_widget = TSharedRef<SGridPanel>(SNew(SGridPanel));
89+
return 0;
90+
}
91+
92+
void ue_python_init_sgrid_panel(PyObject *ue_module) {
93+
ue_PySGridPanelType.tp_new = PyType_GenericNew;
94+
95+
ue_PySGridPanelType.tp_init = (initproc)ue_py_sgrid_panel_init;
96+
97+
ue_PySGridPanelType.tp_base = &ue_PySPanelType;
98+
99+
if (PyType_Ready(&ue_PySGridPanelType) < 0)
100+
return;
101+
102+
Py_INCREF(&ue_PySGridPanelType);
103+
PyModule_AddObject(ue_module, "SGridPanel", (PyObject *)&ue_PySGridPanelType);
104+
}
105+
106+
107+
#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 "UEPySPanel.h"
8+
9+
#include "Runtime/Slate/Public/Widgets/Layout/SGridPanel.h"
10+
11+
extern PyTypeObject ue_PySGridPanelType;
12+
13+
typedef struct {
14+
ue_PySPanel s_panel;
15+
/* Type-specific fields go here. */
16+
} ue_PySGridPanel;
17+
18+
void ue_python_init_sgrid_panel(PyObject *);
19+
20+
#endif

0 commit comments

Comments
 (0)