Skip to content

Commit e08da0f

Browse files
author
rdeioris
committed
fixed SFilePathPicker
1 parent 4908e63 commit e08da0f

File tree

6 files changed

+99
-0
lines changed

6 files changed

+99
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#include "UnrealEnginePythonPrivatePCH.h"
2+
3+
#include "UEPySVectorInputBox.h"
4+
5+
#define sw_vector_input_box StaticCastSharedRef<SVectorInputBox>(self->s_compound_widget.s_widget.s_widget)
6+
7+
8+
static PyMethodDef ue_PySVectorInputBox_methods[] = {
9+
{ NULL } /* Sentinel */
10+
};
11+
12+
PyTypeObject ue_PySVectorInputBoxType = {
13+
PyVarObject_HEAD_INIT(NULL, 0)
14+
"unreal_engine.SVectorInputBox", /* tp_name */
15+
sizeof(ue_PySVectorInputBox), /* tp_basicsize */
16+
0, /* tp_itemsize */
17+
0, /* tp_dealloc */
18+
0, /* tp_print */
19+
0, /* tp_getattr */
20+
0, /* tp_setattr */
21+
0, /* tp_reserved */
22+
0, /* tp_repr */
23+
0, /* tp_as_number */
24+
0, /* tp_as_sequence */
25+
0, /* tp_as_mapping */
26+
0, /* tp_hash */
27+
0, /* tp_call */
28+
0, /* tp_str */
29+
0, /* tp_getattro */
30+
0, /* tp_setattro */
31+
0, /* tp_as_buffer */
32+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
33+
"Unreal Engine SVectorInputBox", /* tp_doc */
34+
0, /* tp_traverse */
35+
0, /* tp_clear */
36+
0, /* tp_richcompare */
37+
0, /* tp_weaklistoffset */
38+
0, /* tp_iter */
39+
0, /* tp_iternext */
40+
ue_PySVectorInputBox_methods, /* tp_methods */
41+
};
42+
43+
static int ue_py_svector_input_box_init(ue_PySVectorInputBox *self, PyObject *args, PyObject *kwargs) {
44+
ue_py_slate_setup_farguments(SVectorInputBox);
45+
46+
ue_py_slate_farguments_optional_bool("allow_responsive_layout", AllowResponsiveLayout);
47+
ue_py_slate_farguments_optional_bool("color_axis_labels", bColorAxisLabels);
48+
ue_py_slate_farguments_struct("font", Font, FSlateFontInfo);
49+
ue_py_slate_farguments_event("on_x_changed", OnXChanged, FOnFloatValueChanged, OnFloatChanged);
50+
ue_py_slate_farguments_event("on_y_changed", OnYChanged, FOnFloatValueChanged, OnFloatChanged);
51+
ue_py_slate_farguments_event("on_z_changed", OnZChanged, FOnFloatValueChanged, OnFloatChanged);
52+
ue_py_slate_farguments_event("on_x_committed", OnXCommitted, FOnFloatValueCommitted, OnFloatCommitted);
53+
ue_py_slate_farguments_event("on_y_committed", OnYCommitted, FOnFloatValueCommitted, OnFloatCommitted);
54+
ue_py_slate_farguments_event("on_z_committed", OnZCommitted, FOnFloatValueCommitted, OnFloatCommitted);
55+
ue_py_slate_farguments_tfloat("x", X);
56+
ue_py_slate_farguments_tfloat("y", Y);
57+
ue_py_slate_farguments_tfloat("z", Z);
58+
59+
ue_py_snew(SVectorInputBox, s_compound_widget.s_widget);
60+
return 0;
61+
}
62+
63+
void ue_python_init_svector_input_box(PyObject *ue_module) {
64+
65+
ue_PySVectorInputBoxType.tp_init = (initproc)ue_py_svector_input_box_init;
66+
67+
ue_PySVectorInputBoxType.tp_base = &ue_PySCompoundWidgetType;
68+
69+
if (PyType_Ready(&ue_PySVectorInputBoxType) < 0)
70+
return;
71+
72+
Py_INCREF(&ue_PySVectorInputBoxType);
73+
PyModule_AddObject(ue_module, "SVectorInputBox", (PyObject *)&ue_PySVectorInputBoxType);
74+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#include "UnrealEnginePython.h"
4+
5+
6+
#include "UEPySCompoundWidget.h"
7+
8+
#include "Runtime/Slate/Public/Widgets/Input/SVectorInputBox.h"
9+
10+
extern PyTypeObject ue_PySVectorInputBoxType;
11+
12+
typedef struct {
13+
ue_PySCompoundWidget s_compound_widget;
14+
/* Type-specific fields go here. */
15+
} ue_PySVectorInputBox;
16+
17+
void ue_python_init_svector_input_box(PyObject *);

Source/UnrealEnginePython/Private/Slate/UEPySWidget.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ static void ue_PySWidgett_dealloc(ue_PySWidget *self) {
194194
}
195195
// decref content (if any)
196196
Py_XDECREF(self->py_swidget_content);
197+
for (PyObject *item : self->py_refs) {
198+
Py_DECREF(item);
199+
}
197200
ue_py_unregister_swidget(&self->s_widget.Get());
198201
// decrement widget reference count
199202
// but only if python vm is still fully active (hack to avoid crashes on editor shutdown)

Source/UnrealEnginePython/Private/Slate/UEPySWidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ struct ue_PySWidget{
2020
ue_PySWidget *py_swidget_content;
2121

2222
TArray<ue_PySWidget *> py_swidget_slots;
23+
24+
TArray<PyObject *> py_refs;
2325
};
2426

2527
void ue_python_init_swidget(PyObject *);

Source/UnrealEnginePython/Private/Slate/UEPySlate.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ void ue_py_setup_swidget(ue_PySWidget *self) {
485485
new(&self->s_widget) TSharedRef<SWidget>(SNullWidget::NullWidget);
486486
new(&self->delegates) TArray<UPythonSlateDelegate *>();
487487
new(&self->py_swidget_slots) TArray<ue_PySWidget *>();
488+
new(&self->py_refs) TArray<PyObject *>();
488489
self->py_swidget_content = nullptr;
489490
}
490491

Source/UnrealEnginePython/Private/Slate/UEPySlate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ ue_PySWidget *ue_py_get_swidget(TSharedRef<SWidget> s_widget);
235235
#define ue_py_slate_farguments_optional_struct_ptr(param, attribute, _type) { PyObject *value = ue_py_dict_get_item(kwargs, param);\
236236
if (value) {\
237237
if (_type *u_struct = ue_py_check_struct<_type>(value)) {\
238+
Py_INCREF(value);\
239+
((ue_PySWidget *)self)->py_refs.Add(value);\
238240
arguments.attribute((_type *)u_struct); \
239241
}\
240242
else {\

0 commit comments

Comments
 (0)