Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_wm.c
| Show First 20 Lines • Show All 455 Lines • ▼ Show 20 Lines | |||||
| }; | }; | ||||
| #ifdef RNA_RUNTIME | #ifdef RNA_RUNTIME | ||||
| #include <assert.h> | #include <assert.h> | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "ED_screen.h" | |||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "BKE_global.h" | |||||
| #include "BKE_idprop.h" | #include "BKE_idprop.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #ifdef WITH_PYTHON | |||||
| # include "BPY_extern.h" | |||||
| #endif | |||||
| static wmOperator *rna_OperatorProperties_find_operator(PointerRNA *ptr) | static wmOperator *rna_OperatorProperties_find_operator(PointerRNA *ptr) | ||||
| { | { | ||||
| wmWindowManager *wm = ptr->id.data; | wmWindowManager *wm = ptr->id.data; | ||||
| if (wm) { | if (wm) { | ||||
| IDProperty *properties = (IDProperty *)ptr->data; | IDProperty *properties = (IDProperty *)ptr->data; | ||||
| for (wmOperator *op = wm->operators.last; op; op = op->prev) { | for (wmOperator *op = wm->operators.last; op; op = op->prev) { | ||||
| if (op->properties == properties) { | if (op->properties == properties) { | ||||
| ▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | static PointerRNA rna_PieMenu_layout_get(PointerRNA *ptr) | ||||
| uiLayout *layout = UI_pie_menu_layout(pie); | uiLayout *layout = UI_pie_menu_layout(pie); | ||||
| PointerRNA rptr; | PointerRNA rptr; | ||||
| RNA_pointer_create(ptr->id.data, &RNA_UILayout, layout, &rptr); | RNA_pointer_create(ptr->id.data, &RNA_UILayout, layout, &rptr); | ||||
| return rptr; | return rptr; | ||||
| } | } | ||||
| static void rna_Window_screen_set(PointerRNA *ptr, PointerRNA value) | static void rna_Window_scene_set(PointerRNA *ptr, PointerRNA value) | ||||
| { | { | ||||
| wmWindow *win = (wmWindow *)ptr->data; | wmWindow *win = ptr->data; | ||||
| /* disallow ID-browsing away from temp screens */ | if (value.data == NULL) { | ||||
| if (win->screen->temp) { | |||||
| return; | return; | ||||
| } | } | ||||
| if (value.data == NULL) | win->new_scene = value.data; | ||||
| return; | } | ||||
| static void rna_Window_scene_update(bContext *C, PointerRNA *ptr) | |||||
| { | |||||
| Main *bmain = CTX_data_main(C); | |||||
| wmWindow *win = ptr->data; | |||||
| /* exception: must use context so notifier gets to the right window */ | |||||
| if (win->new_scene) { | |||||
| #ifdef WITH_PYTHON | |||||
| BPy_BEGIN_ALLOW_THREADS; | |||||
| #endif | |||||
| WM_window_change_active_scene(bmain, C, win, win->new_scene); | |||||
| #ifdef WITH_PYTHON | |||||
| BPy_END_ALLOW_THREADS; | |||||
| #endif | |||||
| WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, win->new_scene); | |||||
| if (G.debug & G_DEBUG) | |||||
| printf("scene set %p\n", win->new_scene); | |||||
| /* exception: can't set screens inside of area/region handlers */ | win->new_scene = NULL; | ||||
| win->newscreen = value.data; | } | ||||
| } | } | ||||
| static int rna_Window_screen_assign_poll(PointerRNA *UNUSED(ptr), PointerRNA value) | static void rna_Window_workspace_set(PointerRNA *ptr, PointerRNA value) | ||||
| { | { | ||||
| bScreen *screen = (bScreen *)value.id.data; | wmWindow *win = (wmWindow *)ptr->data; | ||||
| return !screen->temp; | /* disallow ID-browsing away from temp screens */ | ||||
| if (WM_window_is_temp_screen(win)) { | |||||
| return; | |||||
| } | |||||
| if (value.data == NULL) { | |||||
| return; | |||||
| } | } | ||||
| /* exception: can't set workspaces inside of area/region handlers */ | |||||
| win->new_workspace = value.data; | |||||
| } | |||||
| static void rna_Window_screen_update(bContext *C, PointerRNA *ptr) | static void rna_Window_workspace_update(bContext *C, PointerRNA *ptr) | ||||
| { | { | ||||
| wmWindow *win = (wmWindow *)ptr->data; | wmWindow *win = ptr->data; | ||||
| /* exception: can't set screens inside of area/region handlers, | /* exception: can't set screens inside of area/region handlers, | ||||
| * and must use context so notifier gets to the right window */ | * and must use context so notifier gets to the right window */ | ||||
| if (win->newscreen) { | if (win->new_workspace) { | ||||
| WM_event_add_notifier(C, NC_SCREEN | ND_SCREENBROWSE, win->newscreen); | WM_event_add_notifier(C, NC_WORKSPACE | ND_WORKSPACE_SET, win->new_workspace); | ||||
| win->newscreen = NULL; | win->new_workspace = NULL; | ||||
| } | } | ||||
| } | } | ||||
| static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr) | static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr) | ||||
| { | { | ||||
| wmKeyMapItem *kmi = ptr->data; | wmKeyMapItem *kmi = ptr->data; | ||||
| if (kmi->ptr) | if (kmi->ptr) | ||||
| ▲ Show 20 Lines • Show All 285 Lines • ▼ Show 20 Lines | static void rna_Operator_unregister(struct Main *bmain, StructRNA *type) | ||||
| /* update while blender is running */ | /* update while blender is running */ | ||||
| wm = bmain->wm.first; | wm = bmain->wm.first; | ||||
| if (wm) { | if (wm) { | ||||
| WM_operator_stack_clear(wm); | WM_operator_stack_clear(wm); | ||||
| WM_operator_handlers_clear(wm, ot); | WM_operator_handlers_clear(wm, ot); | ||||
| } | } | ||||
| WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); | WM_main_add_notifier(NC_WORKSPACE | NA_EDITED, NULL); | ||||
| RNA_struct_free_extension(type, &ot->ext); | RNA_struct_free_extension(type, &ot->ext); | ||||
| idname = ot->idname; | idname = ot->idname; | ||||
| WM_operatortype_remove_ptr(ot); | WM_operatortype_remove_ptr(ot); | ||||
| MEM_freeN((void *)idname); | MEM_freeN((void *)idname); | ||||
| /* not to be confused with the RNA_struct_free that WM_operatortype_remove calls, they are 2 different srna's */ | /* not to be confused with the RNA_struct_free that WM_operatortype_remove calls, they are 2 different srna's */ | ||||
| ▲ Show 20 Lines • Show All 290 Lines • ▼ Show 20 Lines | static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void *data, const char *identifier, | ||||
| dummyot.check = (have_function[2]) ? operator_check : NULL; | dummyot.check = (have_function[2]) ? operator_check : NULL; | ||||
| dummyot.invoke = (have_function[3]) ? operator_invoke : NULL; | dummyot.invoke = (have_function[3]) ? operator_invoke : NULL; | ||||
| dummyot.modal = (have_function[4]) ? operator_modal : NULL; | dummyot.modal = (have_function[4]) ? operator_modal : NULL; | ||||
| dummyot.ui = (have_function[5]) ? operator_draw : NULL; | dummyot.ui = (have_function[5]) ? operator_draw : NULL; | ||||
| dummyot.cancel = (have_function[6]) ? operator_cancel : NULL; | dummyot.cancel = (have_function[6]) ? operator_cancel : NULL; | ||||
| WM_operatortype_append_ptr(operator_wrapper, (void *)&dummyot); | WM_operatortype_append_ptr(operator_wrapper, (void *)&dummyot); | ||||
| /* update while blender is running */ | /* update while blender is running */ | ||||
| WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); | WM_main_add_notifier(NC_WORKSPACE | NA_EDITED, NULL); | ||||
| return dummyot.ext.srna; | return dummyot.ext.srna; | ||||
| } | } | ||||
| static void **rna_Operator_instance(PointerRNA *ptr) | static void **rna_Operator_instance(PointerRNA *ptr) | ||||
| { | { | ||||
| wmOperator *op = ptr->data; | wmOperator *op = ptr->data; | ||||
| return &op->py_instance; | return &op->py_instance; | ||||
| ▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | static StructRNA *rna_MacroOperator_register(Main *bmain, ReportList *reports, void *data, const char *identifier, | ||||
| dummyot.ext.free = free; | dummyot.ext.free = free; | ||||
| dummyot.pyop_poll = (have_function[0]) ? operator_poll : NULL; | dummyot.pyop_poll = (have_function[0]) ? operator_poll : NULL; | ||||
| dummyot.ui = (have_function[3]) ? operator_draw : NULL; | dummyot.ui = (have_function[3]) ? operator_draw : NULL; | ||||
| WM_operatortype_append_macro_ptr(macro_wrapper, (void *)&dummyot); | WM_operatortype_append_macro_ptr(macro_wrapper, (void *)&dummyot); | ||||
| /* update while blender is running */ | /* update while blender is running */ | ||||
| WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); | WM_main_add_notifier(NC_WORKSPACE | NA_EDITED, NULL); | ||||
| return dummyot.ext.srna; | return dummyot.ext.srna; | ||||
| } | } | ||||
| #endif /* WITH_PYTHON */ | #endif /* WITH_PYTHON */ | ||||
| static StructRNA *rna_Operator_refine(PointerRNA *opr) | static StructRNA *rna_Operator_refine(PointerRNA *opr) | ||||
| { | { | ||||
| wmOperator *op = (wmOperator *)opr->data; | wmOperator *op = (wmOperator *)opr->data; | ||||
| ▲ Show 20 Lines • Show All 538 Lines • ▼ Show 20 Lines | static void rna_def_window(BlenderRNA *brna) | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| srna = RNA_def_struct(brna, "Window", NULL); | srna = RNA_def_struct(brna, "Window", NULL); | ||||
| RNA_def_struct_ui_text(srna, "Window", "Open window"); | RNA_def_struct_ui_text(srna, "Window", "Open window"); | ||||
| RNA_def_struct_sdna(srna, "wmWindow"); | RNA_def_struct_sdna(srna, "wmWindow"); | ||||
| rna_def_window_stereo3d(brna); | rna_def_window_stereo3d(brna); | ||||
| prop = RNA_def_property(srna, "screen", PROP_POINTER, PROP_NONE); | prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE); | ||||
| RNA_def_property_flag(prop, PROP_NEVER_NULL); | RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); | ||||
| RNA_def_property_struct_type(prop, "Screen"); | RNA_def_property_pointer_funcs(prop, NULL, "rna_Window_scene_set", NULL, NULL); | ||||
| RNA_def_property_ui_text(prop, "Screen", "Active screen showing in the window"); | RNA_def_property_ui_text(prop, "Scene", "Active scene to be edited in the window"); | ||||
| RNA_def_property_flag(prop, PROP_EDITABLE); | |||||
| RNA_def_property_pointer_funcs(prop, NULL, "rna_Window_screen_set", NULL, "rna_Window_screen_assign_poll"); | |||||
| RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | ||||
| RNA_def_property_update(prop, 0, "rna_Window_screen_update"); | RNA_def_property_update(prop, 0, "rna_Window_scene_update"); | ||||
| prop = RNA_def_property(srna, "workspace", PROP_POINTER, PROP_NONE); | |||||
| RNA_def_property_flag(prop, PROP_NEVER_NULL); | |||||
| RNA_def_property_struct_type(prop, "WorkSpace"); | |||||
| RNA_def_property_ui_text(prop, "Workspace", "Active workspace showing in the window"); | |||||
| RNA_def_property_pointer_funcs(prop, NULL, "rna_Window_workspace_set", NULL, NULL); | |||||
| RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); | |||||
| RNA_def_property_update(prop, 0, "rna_Window_workspace_update"); | |||||
| prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE); | prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE); | ||||
| RNA_def_property_int_sdna(prop, NULL, "posx"); | RNA_def_property_int_sdna(prop, NULL, "posx"); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_ui_text(prop, "X Position", "Horizontal location of the window"); | RNA_def_property_ui_text(prop, "X Position", "Horizontal location of the window"); | ||||
| prop = RNA_def_property(srna, "y", PROP_INT, PROP_NONE); | prop = RNA_def_property(srna, "y", PROP_INT, PROP_NONE); | ||||
| RNA_def_property_int_sdna(prop, NULL, "posy"); | RNA_def_property_int_sdna(prop, NULL, "posy"); | ||||
| ▲ Show 20 Lines • Show All 356 Lines • Show Last 20 Lines | |||||