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 "BKE_workspace.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 = ptr->data; | |||||
| if (value.data == NULL) { | |||||
| return; | |||||
| } | |||||
| win->new_scene = value.data; | |||||
| } | |||||
| 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); | |||||
| win->new_scene = NULL; | |||||
| } | |||||
| } | |||||
| static PointerRNA rna_Window_workspace_get(PointerRNA *ptr) | |||||
| { | |||||
| wmWindow *win = ptr->data; | |||||
| return rna_pointer_inherit_refine(ptr, &RNA_WorkSpace, BKE_workspace_active_get(win->workspace_hook)); | |||||
| } | |||||
| static void rna_Window_workspace_set(PointerRNA *ptr, PointerRNA value) | |||||
| { | { | ||||
| wmWindow *win = (wmWindow *)ptr->data; | wmWindow *win = (wmWindow *)ptr->data; | ||||
| /* disallow ID-browsing away from temp screens */ | /* disallow ID-browsing away from temp screens */ | ||||
| if (win->screen->temp) { | if (WM_window_is_temp_screen(win)) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (value.data == NULL) { | |||||
| return; | |||||
| } | |||||
| /* exception: can't set workspaces inside of area/region handlers */ | |||||
| BKE_workspace_temp_store_set(win->workspace_hook, value.data); | |||||
| } | |||||
| static void rna_Window_workspace_update(bContext *C, PointerRNA *ptr) | |||||
| { | |||||
| wmWindow *win = ptr->data; | |||||
| WorkSpace *new_workspace = BKE_workspace_temp_store_get(win->workspace_hook); | |||||
| /* exception: can't set screens inside of area/region handlers, | |||||
| * and must use context so notifier gets to the right window */ | |||||
| if (new_workspace) { | |||||
| WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_SET, new_workspace); | |||||
| BKE_workspace_temp_store_set(win->workspace_hook, NULL); | |||||
| } | |||||
| } | |||||
| PointerRNA rna_Window_screen_get(PointerRNA *ptr) | |||||
| { | |||||
| wmWindow *win = ptr->data; | |||||
| return rna_pointer_inherit_refine(ptr, &RNA_Screen, BKE_workspace_active_screen_get(win->workspace_hook)); | |||||
| } | |||||
| static void rna_Window_screen_set(PointerRNA *ptr, PointerRNA value) | |||||
| { | |||||
| wmWindow *win = ptr->data; | |||||
| WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook); | |||||
| WorkSpaceLayout *layout_new; | |||||
| const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); | |||||
| if (value.data == NULL) | /* disallow ID-browsing away from temp screens */ | ||||
| if (screen->temp) { | |||||
| return; | |||||
| } | |||||
| if (value.data == NULL) { | |||||
| return; | return; | ||||
| } | |||||
| /* exception: can't set screens inside of area/region handlers */ | /* exception: can't set screens inside of area/region handlers */ | ||||
| win->newscreen = value.data; | layout_new = BKE_workspace_layout_find(workspace, value.data); | ||||
| BKE_workspace_temp_layout_store_set(win->workspace_hook, layout_new); | |||||
| } | } | ||||
| static int rna_Window_screen_assign_poll(PointerRNA *UNUSED(ptr), PointerRNA value) | static int rna_Window_screen_assign_poll(PointerRNA *UNUSED(ptr), PointerRNA value) | ||||
| { | { | ||||
| bScreen *screen = (bScreen *)value.id.data; | bScreen *screen = value.id.data; | ||||
| return !screen->temp; | return !screen->temp; | ||||
| } | } | ||||
| static void rna_workspace_screen_update(bContext *C, PointerRNA *ptr) | |||||
| static void rna_Window_screen_update(bContext *C, PointerRNA *ptr) | |||||
| { | { | ||||
| wmWindow *win = (wmWindow *)ptr->data; | wmWindow *win = ptr->data; | ||||
| WorkSpaceLayout *layout_new = BKE_workspace_temp_layout_store_get(win->workspace_hook); | |||||
| /* 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 (layout_new) { | ||||
| WM_event_add_notifier(C, NC_SCREEN | ND_SCREENBROWSE, win->newscreen); | WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTBROWSE, layout_new); | ||||
| win->newscreen = NULL; | BKE_workspace_temp_layout_store_set(win->workspace_hook, 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 1,240 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_EDITABLE | PROP_NEVER_NULL); | |||||
| RNA_def_property_pointer_funcs(prop, NULL, "rna_Window_scene_set", NULL, NULL); | |||||
| RNA_def_property_ui_text(prop, "Scene", "Active scene to be edited in the window"); | |||||
| RNA_def_property_flag(prop, PROP_CONTEXT_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_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, "rna_Window_workspace_get", "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, "screen", PROP_POINTER, PROP_NONE); | |||||
| RNA_def_property_struct_type(prop, "Screen"); | RNA_def_property_struct_type(prop, "Screen"); | ||||
| RNA_def_property_ui_text(prop, "Screen", "Active screen showing in the window"); | RNA_def_property_ui_text(prop, "Screen", "Active workspace screen showing in the window"); | ||||
| RNA_def_property_flag(prop, PROP_EDITABLE); | RNA_def_property_pointer_funcs(prop, "rna_Window_screen_get", "rna_Window_screen_set", NULL, | ||||
| RNA_def_property_pointer_funcs(prop, NULL, "rna_Window_screen_set", NULL, "rna_Window_screen_assign_poll"); | "rna_Window_screen_assign_poll"); | ||||
| RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | RNA_def_property_flag(prop, PROP_NEVER_NULL | PROP_EDITABLE | PROP_CONTEXT_UPDATE); | ||||
| RNA_def_property_update(prop, 0, "rna_Window_screen_update"); | RNA_def_property_update(prop, 0, "rna_workspace_screen_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 | |||||