display: Add convenient shorthand for win.request_properties()

Now instead of this:

    win.request_properties(WindowProperties(title="Test"))

You can directly do this:

    win.request_properties(title="Test")
This commit is contained in:
rdb 2021-12-12 14:54:47 +01:00
parent f79ef139ba
commit 650b958217
3 changed files with 24 additions and 1 deletions

View File

@ -55,7 +55,9 @@ PUBLISHED:
const WindowProperties get_requested_properties() const;
void clear_rejected_properties();
WindowProperties get_rejected_properties() const;
void request_properties(const WindowProperties &requested_properties);
EXTENSION(void request_properties(PyObject *args, PyObject *kwds));
INLINE bool is_closed() const;
virtual bool is_active() const;
INLINE bool is_fullscreen() const;
@ -100,6 +102,8 @@ PUBLISHED:
virtual void close_ime();
public:
void request_properties(const WindowProperties &requested_properties);
virtual void add_window_proc( const GraphicsWindowProc* wnd_proc_object ){};
virtual void remove_window_proc( const GraphicsWindowProc* wnd_proc_object ){};
virtual void clear_window_procs(){};

View File

@ -12,9 +12,26 @@
*/
#include "graphicsWindow_ext.h"
#include "windowProperties_ext.h"
#ifdef HAVE_PYTHON
/**
* Convenient shorthand for requesting properties.
*/
void Extension<GraphicsWindow>::
request_properties(PyObject *args, PyObject *kwds) {
extern struct Dtool_PyTypedObject Dtool_WindowProperties;
WindowProperties props;
PyObject *py_props = DTool_CreatePyInstance((void *)&props, Dtool_WindowProperties, false, false);
invoke_extension(&props).__init__(py_props, args, kwds);
_this->request_properties(props);
Py_DECREF(py_props);
}
/**
* Adds a python event handler to be called when a window event occurs.
*/

View File

@ -30,6 +30,8 @@
template<>
class Extension<GraphicsWindow> : public ExtensionBase<GraphicsWindow> {
public:
void request_properties(PyObject *args, PyObject *kwds);
void add_python_event_handler(PyObject* handler, PyObject* name);
void remove_python_event_handler(PyObject* name);
};