Skip to content

Commit 21df504

Browse files
author
Roberto De Ioris
committed
added SImage, OnMouseButtonDown still broken
1 parent 23b4320 commit 21df504

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#if WITH_EDITOR
2+
3+
#include "UnrealEnginePythonPrivatePCH.h"
4+
5+
#include "UEPySImage.h"
6+
7+
#define GET_s_image SImage *s_image = (SImage *)self->s_leaf_widget.s_widget.s_widget
8+
9+
static PyObject *py_ue_simage_set_brush(ue_PySImage *self, PyObject * args) {
10+
PyObject *py_brush;
11+
if (!PyArg_ParseTuple(args, "O:set_brush", &py_brush)) {
12+
return NULL;
13+
}
14+
15+
FSlateBrush *brush = ue_py_check_struct<FSlateBrush>(py_brush);
16+
if (!brush)
17+
return PyErr_Format(PyExc_Exception, "argument is not a FSlateBrush");
18+
19+
GET_s_image;
20+
21+
s_image->SetImage(brush);
22+
23+
Py_INCREF(self);
24+
return (PyObject *)self;
25+
}
26+
27+
static PyObject *ue_PySImage_str(ue_PySImage *self)
28+
{
29+
return PyUnicode_FromFormat("<unreal_engine.SImage '%p'>",
30+
self->s_leaf_widget.s_widget.s_widget);
31+
}
32+
33+
static PyMethodDef ue_PySImage_methods[] = {
34+
{ "set_brush", (PyCFunction)py_ue_simage_set_brush, METH_VARARGS, "" },
35+
{ "set_image", (PyCFunction)py_ue_simage_set_brush, METH_VARARGS, "" },
36+
{ NULL } /* Sentinel */
37+
};
38+
39+
PyTypeObject ue_PySImageType = {
40+
PyVarObject_HEAD_INIT(NULL, 0)
41+
"unreal_engine.SImage", /* tp_name */
42+
sizeof(ue_PySImage), /* tp_basicsize */
43+
0, /* tp_itemsize */
44+
0, /* tp_dealloc */
45+
0, /* tp_print */
46+
0, /* tp_getattr */
47+
0, /* tp_setattr */
48+
0, /* tp_reserved */
49+
0, /* tp_repr */
50+
0, /* tp_as_number */
51+
0, /* tp_as_sequence */
52+
0, /* tp_as_mapping */
53+
0, /* tp_hash */
54+
0, /* tp_call */
55+
(reprfunc)ue_PySImage_str, /* tp_str */
56+
0, /* tp_getattro */
57+
0, /* tp_setattro */
58+
0, /* tp_as_buffer */
59+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
60+
"Unreal Engine SImage", /* tp_doc */
61+
0, /* tp_traverse */
62+
0, /* tp_clear */
63+
0, /* tp_richcompare */
64+
0, /* tp_weaklistoffset */
65+
0, /* tp_iter */
66+
0, /* tp_iternext */
67+
ue_PySImage_methods, /* tp_methods */
68+
};
69+
70+
static int ue_py_simage_init(ue_PySImage *self, PyObject *args, PyObject *kwargs) {
71+
ue_py_snew(SImage, s_leaf_widget.s_widget);
72+
return 0;
73+
}
74+
75+
void ue_python_init_simage(PyObject *ue_module) {
76+
ue_PySImageType.tp_new = PyType_GenericNew;
77+
78+
ue_PySImageType.tp_init = (initproc)ue_py_simage_init;
79+
80+
ue_PySImageType.tp_base = &ue_PySLeafWidgetType;
81+
82+
if (PyType_Ready(&ue_PySImageType) < 0)
83+
return;
84+
85+
Py_INCREF(&ue_PySImageType);
86+
PyModule_AddObject(ue_module, "SImage", (PyObject *)&ue_PySImageType);
87+
}
88+
89+
90+
#endif
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma once
2+
3+
#include "UnrealEnginePython.h"
4+
5+
#if WITH_EDITOR
6+
7+
#include "UEPySLeafWidget.h"
8+
9+
#include "Runtime/Slate/Public/Widgets/Images/SImage.h"
10+
#include "Runtime/SlateCore/Public/Styling/SlateBrush.h"
11+
12+
extern PyTypeObject ue_PySImageType;
13+
14+
typedef struct {
15+
ue_PySLeafWidget s_leaf_widget;
16+
/* Type-specific fields go here. */
17+
} ue_PySImage;
18+
19+
void ue_python_init_simage(PyObject *);
20+
21+
#endif

Source/UnrealEnginePython/Private/Slate/UEPySlate.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
FReply UPythonSlateDelegate::OnMouseButtonDown(const FGeometry &geometry, const FPointerEvent &pointer_event) {
1212
FScopePythonGIL gil;
1313

14+
UE_LOG(LogPython, Warning, TEXT("MOUSE BUTTON DOWN"));
15+
1416
PyObject *ret = PyObject_CallFunction(py_callable, (char *)"OO", py_ue_new_uscriptstruct(FGeometry::StaticStruct(), (uint8 *)&geometry), py_ue_new_uscriptstruct(FPointerEvent::StaticStruct(), (uint8 *)&pointer_event));
1517
if (!ret) {
1618
unreal_engine_py_log_error();
@@ -88,6 +90,7 @@ void ue_python_init_slate(PyObject *module) {
8890
ue_python_init_sviewport(module);
8991
ue_python_init_seditor_viewport(module);
9092
ue_python_init_spython_editor_viewport(module);
93+
ue_python_init_simage(module);
9194
}
9295

9396
PyObject *py_unreal_engine_get_editor_window(PyObject *self, PyObject *args) {

Source/UnrealEnginePython/Private/Slate/UEPySlate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "UEPySViewport.h"
2727
#include "UEPySEditorViewport.h"
2828
#include "UEPySPythonEditorViewport.h"
29+
#include "UEPySImage.h"
2930

3031
#include "UEPySlate.generated.h"
3132

0 commit comments

Comments
 (0)