Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/context.c
| Show First 20 Lines • Show All 631 Lines • ▼ Show 20 Lines | bScreen *CTX_wm_screen(const bContext *C) | ||||
| return ctx_wm_python_context_get(C, "screen", &RNA_Screen, C->wm.screen); | return ctx_wm_python_context_get(C, "screen", &RNA_Screen, C->wm.screen); | ||||
| } | } | ||||
| ScrArea *CTX_wm_area(const bContext *C) | ScrArea *CTX_wm_area(const bContext *C) | ||||
| { | { | ||||
| return ctx_wm_python_context_get(C, "area", &RNA_Area, C->wm.area); | return ctx_wm_python_context_get(C, "area", &RNA_Area, C->wm.area); | ||||
| } | } | ||||
| /* Allows work to be done in different contexts */ | |||||
| void CTX_wm_switch_area(bContext *C, const char* dest) | |||||
| { | |||||
| bContext* copyC = CTX_copy(C); | |||||
| if (strcmp(copyC->wm.area->type->name, dest) != 0) | |||||
swerner: Since the size of copyC->wm.area->type->name is known (it's BKE_ST_MAXNAME), I'd habitually use… | |||||
| { | |||||
| while (copyC->wm.area->prev != NULL) | |||||
| { | |||||
| copyC->wm.area = copyC->wm.area->prev; | |||||
| } | |||||
| while (strcmp(copyC->wm.area->type->name, dest) != 0 && (copyC->wm.area->next != NULL)) | |||||
| { | |||||
| copyC->wm.area = copyC->wm.area->next; | |||||
| } | |||||
| } | |||||
| if (strcmp(copyC->wm.area->type->name, dest) == 0) | |||||
| C->wm.area = copyC->wm.area; | |||||
| CTX_free(copyC); | |||||
| } | |||||
| SpaceLink *CTX_wm_space_data(const bContext *C) | SpaceLink *CTX_wm_space_data(const bContext *C) | ||||
| { | { | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| return (sa) ? sa->spacedata.first : NULL; | return (sa) ? sa->spacedata.first : NULL; | ||||
| } | } | ||||
| ARegion *CTX_wm_region(const bContext *C) | ARegion *CTX_wm_region(const bContext *C) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 509 Lines • Show Last 20 Lines | |||||
Since the size of copyC->wm.area->type->name is known (it's BKE_ST_MAXNAME), I'd habitually use STREQLEN() instead of strcmp() == 0. Same for the strcmp()s below.