diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-09-07 02:54:22 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-09-07 02:54:22 +0400 |
commit | 2c688788e6d5508f3138371fc4c818041d66f392 (patch) | |
tree | 88194bcaa9c33271830207d9ad986c8c255cc2df | |
parent | 35cd649c6625b55aad277fdbeaa87cc5d21b65ce (diff) |
wrap cursor setting so python can make use of it, eg:
- win.cursor_set('WAIT')
- win.cursor_modal_set('TEXT')
- win.cursor_modal_restore()
-rw-r--r-- | source/blender/makesrna/RNA_enum_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_wm_api.c | 47 |
4 files changed, 52 insertions, 0 deletions
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 86d043b839a..d33d3df8a5e 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -169,6 +169,8 @@ extern EnumPropertyItem linestyle_alpha_modifier_type_items[]; extern EnumPropertyItem linestyle_thickness_modifier_type_items[]; extern EnumPropertyItem linestyle_geometry_modifier_type_items[]; +extern EnumPropertyItem window_cursor_items[]; + struct bContext; struct PointerRNA; struct PropertyRNA; diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 72985f7b6e6..f1e1569c87d 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -278,6 +278,7 @@ void RNA_api_scene_render(struct StructRNA *srna); void RNA_api_sequence_strip(StructRNA *srna); void RNA_api_text(struct StructRNA *srna); void RNA_api_ui_layout(struct StructRNA *srna); +void RNA_api_window(struct StructRNA *srna); void RNA_api_wm(struct StructRNA *srna); void RNA_api_sensor(struct StructRNA *srna); void RNA_api_controller(struct StructRNA *srna); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 0d1c684e6a1..8e0e948f040 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -1735,6 +1735,8 @@ static void rna_def_window(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "sizey"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Height", "Window height"); + + RNA_api_window(srna); } /* curve.splines */ diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index f9fe49956af..5c6916a2335 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -41,8 +41,31 @@ #include "DNA_space_types.h" #include "DNA_windowmanager_types.h" +#include "wm_cursors.h" + #include "rna_internal.h" /* own include */ +/* confusingm 2 enums mixed up here */ +EnumPropertyItem window_cursor_items[] = { + {CURSOR_STD, "DEFAULT", 0, "Default", ""}, + {CURSOR_NONE, "NONE", 0, "None", ""}, + {CURSOR_WAIT, "WAIT", 0, "Wait", ""}, + {CURSOR_EDIT, "CROSSHAIR", 0, "Crosshair", ""}, + {CURSOR_X_MOVE, "MOVE_X", 0, "Move-X", ""}, + {CURSOR_Y_MOVE, "MOVE_Y", 0, "Move-Y", ""}, + + /* new */ + {BC_KNIFECURSOR, "KNIFE", 0, "Knife", ""}, + {BC_TEXTEDITCURSOR, "TEXT", 0, "Text", ""}, + {BC_PAINTBRUSHCURSOR, "PAINT_BRUSH", 0, "Paint Brush", ""}, + {BC_HANDCURSOR, "HAND", 0, "Hand", ""}, + {BC_EW_SCROLLCURSOR, "SCROLL_X", 0, "Scroll-X", ""}, + {BC_NS_SCROLLCURSOR, "SCROLL_Y", 0, "Scroll-Y", ""}, + {BC_NSEW_SCROLLCURSOR, "SCROLL_XY", 0, "Scroll-XY", ""}, + {BC_EYEDROPPER_CURSOR, "EYEDROPPER", 0, "Eyedropper", ""}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME #include "UI_interface.h" @@ -299,6 +322,30 @@ static void rna_generic_op_invoke(FunctionRNA *func, int flag) } } +void RNA_api_window(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + (void)func; + (void)parm; + + func = RNA_def_function(srna, "cursor_set", "WM_cursor_set"); + parm = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(parm, window_cursor_items); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_function_ui_description(func, "Set the cursor"); + + func = RNA_def_function(srna, "cursor_modal_set", "WM_cursor_modal_set"); + parm = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(parm, window_cursor_items); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_function_ui_description(func, "Set the cursor, so the previous cursor can be restored"); + + RNA_def_function(srna, "cursor_modal_restore", "WM_cursor_modal_restore"); + RNA_def_function_ui_description(func, "Restore the previous cursor after calling ``cursor_modal_set``"); +} + void RNA_api_wm(StructRNA *srna) { FunctionRNA *func; |