Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_screen.c
| Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #ifdef RNA_RUNTIME | #ifdef RNA_RUNTIME | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_depsgraph.h" | #include "BKE_depsgraph.h" | ||||
| #include "BKE_workspace.h" | |||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| # include "BPY_extern.h" | # include "BPY_extern.h" | ||||
| #endif | #endif | ||||
| static void rna_Screen_scene_set(PointerRNA *ptr, PointerRNA value) | |||||
| { | |||||
| bScreen *sc = (bScreen *)ptr->data; | |||||
| if (value.data == NULL) | static void rna_Screen_redraw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) | ||||
| return; | { | ||||
| bScreen *screen = (bScreen *)ptr->data; | |||||
| sc->newscene = value.data; | /* the settings for this are currently only available from a menu in the TimeLine, hence refresh=SPACE_TIME */ | ||||
| ED_screen_animation_timer_update(screen, screen->redraws_flag, SPACE_TIME); | |||||
| } | } | ||||
| static void rna_Screen_scene_update(bContext *C, PointerRNA *ptr) | static int rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr)) | ||||
| { | { | ||||
| bScreen *sc = (bScreen *)ptr->data; | /* can be NULL on file load, T42619 */ | ||||
| wmWindowManager *wm = G.main->wm.first; | |||||
| /* exception: must use context so notifier gets to the right window */ | return wm ? (ED_screen_animation_playing(wm) != NULL) : 0; | ||||
| if (sc->newscene) { | } | ||||
| #ifdef WITH_PYTHON | |||||
| BPy_BEGIN_ALLOW_THREADS; | |||||
| #endif | |||||
| ED_screen_set_scene(C, sc, sc->newscene); | static void rna_Screen_layout_name_get(PointerRNA *ptr, char *value) | ||||
| { | |||||
| bScreen *screen = ptr->data; | |||||
| #ifdef WITH_PYTHON | BKE_workspace_iter_begin(workspace, G.main->workspaces.first) | ||||
| BPy_END_ALLOW_THREADS; | { | ||||
| #endif | WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, screen); | ||||
| if (layout) { | |||||
| const char *name = BKE_workspace_layout_name_get(layout); | |||||
| BLI_strncpy(value, name, strlen(name) + 1); | |||||
| return; | |||||
| } | |||||
| } | |||||
| BKE_workspace_iter_end; | |||||
| WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, sc->newscene); | value[0] = '\0'; | ||||
| } | |||||
| if (G.debug & G_DEBUG) | static int rna_Screen_layout_name_length(PointerRNA *ptr) | ||||
| printf("scene set %p\n", sc->newscene); | { | ||||
| bScreen *screen = ptr->data; | |||||
| sc->newscene = NULL; | BKE_workspace_iter_begin(workspace, G.main->workspaces.first) | ||||
| { | |||||
| WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, screen); | |||||
| if (layout) { | |||||
| const char *name = BKE_workspace_layout_name_get(layout); | |||||
| return strlen(name); | |||||
| } | } | ||||
| } | } | ||||
| BKE_workspace_iter_end; | |||||
| static void rna_Screen_redraw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) | return 0; | ||||
| { | |||||
| bScreen *screen = (bScreen *)ptr->data; | |||||
| /* the settings for this are currently only available from a menu in the TimeLine, hence refresh=SPACE_TIME */ | |||||
| ED_screen_animation_timer_update(screen, screen->redraws_flag, SPACE_TIME); | |||||
| } | } | ||||
| static void rna_Screen_layout_name_set(PointerRNA *ptr, const char *value) | |||||
| { | |||||
| bScreen *screen = ptr->data; | |||||
| static int rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr)) | BKE_workspace_iter_begin(workspace, G.main->workspaces.first) | ||||
| { | { | ||||
| /* can be NULL on file load, T42619 */ | WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, screen); | ||||
| wmWindowManager *wm = G.main->wm.first; | if (layout) { | ||||
| return wm ? (ED_screen_animation_playing(wm) != NULL) : 0; | BKE_workspace_layout_name_set(workspace, layout, value); | ||||
| break; | |||||
| } | |||||
| } | |||||
| BKE_workspace_iter_end; | |||||
| } | } | ||||
| static int rna_Screen_fullscreen_get(PointerRNA *ptr) | static int rna_Screen_fullscreen_get(PointerRNA *ptr) | ||||
| { | { | ||||
| bScreen *sc = (bScreen *)ptr->data; | bScreen *sc = (bScreen *)ptr->data; | ||||
| return (sc->state == SCREENMAXIMIZED); | return (sc->state == SCREENMAXIMIZED); | ||||
| } | } | ||||
| Show All 23 Lines | |||||
| { | { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| wmWindow *win; | wmWindow *win; | ||||
| bScreen *sc = (bScreen *)ptr->id.data; | bScreen *sc = (bScreen *)ptr->id.data; | ||||
| ScrArea *sa = (ScrArea *)ptr->data; | ScrArea *sa = (ScrArea *)ptr->data; | ||||
| /* XXX this call still use context, so we trick it to work in the right context */ | /* XXX this call still use context, so we trick it to work in the right context */ | ||||
| for (win = wm->windows.first; win; win = win->next) { | for (win = wm->windows.first; win; win = win->next) { | ||||
| if (sc == win->screen) { | if (sc == WM_window_get_active_screen(win)) { | ||||
| wmWindow *prevwin = CTX_wm_window(C); | wmWindow *prevwin = CTX_wm_window(C); | ||||
| ScrArea *prevsa = CTX_wm_area(C); | ScrArea *prevsa = CTX_wm_area(C); | ||||
| ARegion *prevar = CTX_wm_region(C); | ARegion *prevar = CTX_wm_region(C); | ||||
| CTX_wm_window_set(C, win); | CTX_wm_window_set(C, win); | ||||
| CTX_wm_area_set(C, sa); | CTX_wm_area_set(C, sa); | ||||
| CTX_wm_region_set(C, NULL); | CTX_wm_region_set(C, NULL); | ||||
| ▲ Show 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | static void rna_def_screen(BlenderRNA *brna) | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| srna = RNA_def_struct(brna, "Screen", "ID"); | srna = RNA_def_struct(brna, "Screen", "ID"); | ||||
| RNA_def_struct_sdna(srna, "Screen"); /* it is actually bScreen but for 2.5 the dna is patched! */ | RNA_def_struct_sdna(srna, "Screen"); /* it is actually bScreen but for 2.5 the dna is patched! */ | ||||
| RNA_def_struct_ui_text(srna, "Screen", "Screen data-block, defining the layout of areas in a window"); | RNA_def_struct_ui_text(srna, "Screen", "Screen data-block, defining the layout of areas in a window"); | ||||
| RNA_def_struct_ui_icon(srna, ICON_SPLITSCREEN); | RNA_def_struct_ui_icon(srna, ICON_SPLITSCREEN); | ||||
| /* pointers */ | prop = RNA_def_property(srna, "layout_name", PROP_STRING, PROP_NONE); | ||||
| prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE); | RNA_def_property_string_funcs(prop, "rna_Screen_layout_name_get", "rna_Screen_layout_name_length", | ||||
| RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); | "rna_Screen_layout_name_set"); | ||||
| RNA_def_property_pointer_funcs(prop, NULL, "rna_Screen_scene_set", NULL, NULL); | RNA_def_property_ui_text(prop, "Layout Name", "The name of the layout that refers to the screen"); | ||||
| RNA_def_property_ui_text(prop, "Scene", "Active scene to be edited in the screen"); | RNA_def_struct_name_property(srna, prop); | ||||
| RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); | |||||
| RNA_def_property_update(prop, 0, "rna_Screen_scene_update"); | |||||
| /* collections */ | /* collections */ | ||||
| prop = RNA_def_property(srna, "areas", PROP_COLLECTION, PROP_NONE); | prop = RNA_def_property(srna, "areas", PROP_COLLECTION, PROP_NONE); | ||||
| RNA_def_property_collection_sdna(prop, NULL, "areabase", NULL); | RNA_def_property_collection_sdna(prop, NULL, "areabase", NULL); | ||||
| RNA_def_property_struct_type(prop, "Area"); | RNA_def_property_struct_type(prop, "Area"); | ||||
| RNA_def_property_ui_text(prop, "Areas", "Areas the screen is subdivided into"); | RNA_def_property_ui_text(prop, "Areas", "Areas the screen is subdivided into"); | ||||
| /* readonly status indicators */ | /* readonly status indicators */ | ||||
| ▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines | |||||