diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-12-24 19:10:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-12-24 19:10:26 +0300 |
commit | 4dd3e6c36070e64d8b1d784a34d9881ae2c3eed8 (patch) | |
tree | b5797cbc48a2cffad1a50d07945c8e5b31b68e6c /source/blender/windowmanager | |
parent | 1d224ad692c8794500f4d6fd5257887db150a635 (diff) |
support for registering operators using the same internal rna api as panels, menus, headers & render engines since there was a fair bit of duplicate functionality.
will remove the old system and update scripts next.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 22 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 54 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_window.h | 5 |
3 files changed, 68 insertions, 13 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 8fe7ac39b35..d2b67142eb5 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -38,6 +38,8 @@ struct wmEventHandler; struct wmGesture; struct wmJob; struct wmNotifier; +struct wmOperatorType; +struct wmOperator; struct rcti; struct PointerRNA; struct EnumPropertyItem; @@ -185,16 +187,16 @@ int WM_operator_confirm_message(struct bContext *C, struct wmOperator *op, cha void WM_operator_free (struct wmOperator *op); void WM_operator_stack_clear(struct bContext *C); -wmOperatorType *WM_operatortype_find(const char *idnamem, int quiet); -wmOperatorType *WM_operatortype_exists(const char *idname); -wmOperatorType *WM_operatortype_first(void); -void WM_operatortype_append (void (*opfunc)(wmOperatorType*)); -void WM_operatortype_append_ptr (void (*opfunc)(wmOperatorType*, void *), void *userdata); -void WM_operatortype_append_macro_ptr (void (*opfunc)(wmOperatorType*, void *), void *userdata); +struct wmOperatorType *WM_operatortype_find(const char *idnamem, int quiet); +struct wmOperatorType *WM_operatortype_exists(const char *idname); +struct wmOperatorType *WM_operatortype_first(void); +void WM_operatortype_append (void (*opfunc)(struct wmOperatorType*)); +void WM_operatortype_append_ptr (void (*opfunc)(struct wmOperatorType*, void *), void *userdata); +void WM_operatortype_append_macro_ptr (void (*opfunc)(struct wmOperatorType*, void *), void *userdata); int WM_operatortype_remove(const char *idname); -wmOperatorType *WM_operatortype_append_macro(char *idname, char *name, int flag); -wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char *idname); +struct wmOperatorType *WM_operatortype_append_macro(char *idname, char *name, int flag); +struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname); int WM_operator_poll (struct bContext *C, struct wmOperatorType *ot); @@ -208,8 +210,8 @@ void WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring void WM_operator_properties_create_ptr(struct PointerRNA *ptr, struct wmOperatorType *ot); void WM_operator_properties_free(struct PointerRNA *ptr); void WM_operator_properties_filesel(struct wmOperatorType *ot, int filter, short type); -void WM_operator_properties_gesture_border(wmOperatorType *ot, int extend); -void WM_operator_properties_select_all(wmOperatorType *ot); +void WM_operator_properties_gesture_border(struct wmOperatorType *ot, int extend); +void WM_operator_properties_select_all(struct wmOperatorType *ot); /* MOVE THIS SOMEWHERE ELSE */ #define SEL_TOGGLE 0 diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 318945918e7..f0ccbed06c3 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -31,9 +31,13 @@ struct bContext; struct wmEvent; struct wmWindowManager; +struct uiLayout; +struct wmOperator; -/* exported types for WM */ +#include "RNA_types.h" +#include "DNA_listBase.h" +/* exported types for WM */ #include "wm_cursors.h" #include "wm_event_types.h" @@ -353,6 +357,54 @@ typedef struct wmTimer { } wmTimer; +typedef struct wmOperatorType { + struct wmOperatorType *next, *prev; + + char *name; /* text for ui, undo */ + char *idname; /* unique identifier */ + char *description; /* tooltips and python docs */ + + /* this callback executes the operator without any interactive input, + * parameters may be provided through operator properties. cannot use + * any interface code or input device state. + * - see defines below for return values */ + int (*exec)(struct bContext *, struct wmOperator *); + + /* for modal temporary operators, initially invoke is called. then + * any further events are handled in modal. if the operation is + * cancelled due to some external reason, cancel is called + * - see defines below for return values */ + int (*invoke)(struct bContext *, struct wmOperator *, struct wmEvent *); + int (*cancel)(struct bContext *, struct wmOperator *); + int (*modal)(struct bContext *, struct wmOperator *, struct wmEvent *); + + /* verify if the operator can be executed in the current context, note + * that the operator might still fail to execute even if this return true */ + int (*poll)(struct bContext *); + + /* optional panel for redo and repeat, autogenerated if not set */ + void (*ui)(struct bContext *, struct wmOperator *, struct uiLayout *); + + /* rna for properties */ + struct StructRNA *srna; + + /* struct wmOperatorTypeMacro */ + ListBase macro; + + short flag; + + /* pointer to modal keymap, do not free! */ + struct wmKeyMap *modalkeymap; + + /* only used for operators defined with python + * use to store pointers to python functions */ + void *pyop_data; + int (*pyop_poll)(struct bContext *, struct wmOperatorType *ot); + + /* RNA integration */ + ExtensionRNA ext; +} wmOperatorType; + /* **************** Paint Cursor ******************* */ typedef void (*wmPaintCursorDraw)(struct bContext *C, int, int, void *customdata); diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index 84e246937e4..28b12a93b18 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -30,6 +30,7 @@ #define WM_WINDOW_H struct bScreen; +struct wmOperator; /* *************** internal api ************** */ void wm_ghost_init (bContext *C); @@ -62,8 +63,8 @@ wmWindow *wm_window_copy (bContext *C, wmWindow *winorig); void wm_window_testbreak (void); /* *************** window operators ************** */ -int wm_window_duplicate_op (bContext *C, wmOperator *op); -int wm_window_fullscreen_toggle_op(bContext *C, wmOperator *op); +int wm_window_duplicate_op (bContext *C, struct wmOperator *op); +int wm_window_fullscreen_toggle_op(bContext *C, struct wmOperator *op); #endif /* WM_WINDOW_H */ |