Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/screen_ops.c
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| ot->exec = space_type_set_or_cycle_exec; | ot->exec = space_type_set_or_cycle_exec; | ||||
| ot->poll = space_type_set_or_cycle_poll; | ot->poll = space_type_set_or_cycle_poll; | ||||
| ot->flag = 0; | ot->flag = 0; | ||||
| RNA_def_enum(ot->srna, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Type", ""); | RNA_def_enum(ot->srna, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Type", ""); | ||||
| } | } | ||||
| /** \} */ | |||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Area Space Cycle | |||||
| * \{ */ | |||||
| static const EnumPropertyItem area_space_cycle_direction[] = { | |||||
| {0, "BACK", 0, "Back", ""}, | |||||
| {1, "FORWARD", 0, "Forward", ""}, | |||||
| {0, NULL, 0, NULL, NULL}, | |||||
| }; | |||||
| static bool area_space_cycle_poll(bContext *C) | |||||
| { | |||||
| ScrArea *area = CTX_wm_area(C); | |||||
| return (area && !ELEM(area->spacetype, SPACE_TOPBAR, SPACE_STATUSBAR) && | |||||
| BLI_listbase_count_at_most(&area->spacedata, 2) > 1); | |||||
| } | |||||
| static int area_space_cycle_exec(bContext *C, wmOperator *op) | |||||
| { | |||||
| const eScreenCycle direction = RNA_enum_get(op->ptr, "direction"); | |||||
| ScrArea *area = CTX_wm_area(C); | |||||
| wmWindow *win = CTX_wm_window(C); | |||||
| SpaceLink *slold = area->spacedata.first; | |||||
| SpaceLink *slnew; | |||||
| /* XXX: No attempt to deal with header alignment. */ | |||||
| bool skip_region_exit = true; | |||||
| void *area_exit = area->type ? area->type->exit : NULL; | |||||
| if (skip_region_exit && area->type) { | |||||
| area->type->exit = NULL; | |||||
| } | |||||
| ED_area_exit(C, area); | |||||
| if (skip_region_exit && area->type) { | |||||
| area->type->exit = area_exit; | |||||
| } | |||||
| if (direction == SPACE_CONTEXT_CYCLE_PREV) { | |||||
| BLI_remlink(&area->spacedata, slold); | |||||
| BLI_addtail(&area->spacedata, slold); | |||||
| slnew = area->spacedata.first; | |||||
| } | |||||
| else { | |||||
| slnew = area->spacedata.last; | |||||
| BLI_remlink(&area->spacedata, slnew); | |||||
| BLI_addhead(&area->spacedata, slnew); | |||||
| } | |||||
| area->spacetype = slnew->spacetype; | |||||
| /* swap regions */ | |||||
| slold->regionbase = area->regionbase; | |||||
| area->regionbase = slnew->regionbase; | |||||
| BLI_listbase_clear(&slnew->regionbase); | |||||
| /* SPACE_FLAG_TYPE_WAS_ACTIVE is only used to go back to a previously active space that is | |||||
| * overlapped by temporary ones. It's now properly activated, so the flag should be cleared | |||||
| * at this point. */ | |||||
| slnew->link_flag &= ~SPACE_FLAG_TYPE_WAS_ACTIVE; | |||||
| ED_area_init(CTX_wm_manager(C), win, area); | |||||
| /* tell WM to refresh, cursor types etc */ | |||||
| WM_event_add_mousemove(win); | |||||
| /* send space change notifier */ | |||||
| WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, area); | |||||
| ED_area_tag_refresh(area); | |||||
| ED_area_tag_redraw(area); | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| static void SCREEN_OT_area_space_cycle(wmOperatorType *ot) | |||||
| { | |||||
| /* identifiers */ | |||||
| ot->name = "Cycle Area Editors"; | |||||
| ot->description = "Cycle through an area's editors"; | |||||
| ot->idname = "SCREEN_OT_area_space_cycle"; | |||||
| /* api callbacks */ | |||||
| ot->exec = area_space_cycle_exec; | |||||
| ot->poll = area_space_cycle_poll; | |||||
| ot->flag = 0; | |||||
| RNA_def_enum(ot->srna, | |||||
| "direction", | |||||
| area_space_cycle_direction, | |||||
| 0, | |||||
| "Direction", | |||||
| "Direction to cycle through"); | |||||
| } | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Space Context Cycle Operator | /** \name Space Context Cycle Operator | ||||
| * \{ */ | * \{ */ | ||||
| static const EnumPropertyItem space_context_cycle_direction[] = { | static const EnumPropertyItem space_context_cycle_direction[] = { | ||||
| {SPACE_CONTEXT_CYCLE_PREV, "PREV", 0, "Previous", ""}, | {SPACE_CONTEXT_CYCLE_PREV, "PREV", 0, "Previous", ""}, | ||||
| ▲ Show 20 Lines • Show All 180 Lines • ▼ Show 20 Lines | |||||
| WM_operatortype_append(SCREEN_OT_screenshot_area); | WM_operatortype_append(SCREEN_OT_screenshot_area); | ||||
| WM_operatortype_append(SCREEN_OT_userpref_show); | WM_operatortype_append(SCREEN_OT_userpref_show); | ||||
| WM_operatortype_append(SCREEN_OT_drivers_editor_show); | WM_operatortype_append(SCREEN_OT_drivers_editor_show); | ||||
| WM_operatortype_append(SCREEN_OT_info_log_show); | WM_operatortype_append(SCREEN_OT_info_log_show); | ||||
| WM_operatortype_append(SCREEN_OT_region_blend); | WM_operatortype_append(SCREEN_OT_region_blend); | ||||
| WM_operatortype_append(SCREEN_OT_space_type_set_or_cycle); | WM_operatortype_append(SCREEN_OT_space_type_set_or_cycle); | ||||
| WM_operatortype_append(SCREEN_OT_space_context_cycle); | WM_operatortype_append(SCREEN_OT_space_context_cycle); | ||||
| WM_operatortype_append(SCREEN_OT_workspace_cycle); | WM_operatortype_append(SCREEN_OT_workspace_cycle); | ||||
| WM_operatortype_append(SCREEN_OT_area_space_cycle); | |||||
| /* Frame changes. */ | /* Frame changes. */ | ||||
| WM_operatortype_append(SCREEN_OT_frame_offset); | WM_operatortype_append(SCREEN_OT_frame_offset); | ||||
| WM_operatortype_append(SCREEN_OT_frame_jump); | WM_operatortype_append(SCREEN_OT_frame_jump); | ||||
| WM_operatortype_append(SCREEN_OT_keyframe_jump); | WM_operatortype_append(SCREEN_OT_keyframe_jump); | ||||
| WM_operatortype_append(SCREEN_OT_marker_jump); | WM_operatortype_append(SCREEN_OT_marker_jump); | ||||
| WM_operatortype_append(SCREEN_OT_animation_step); | WM_operatortype_append(SCREEN_OT_animation_step); | ||||
| ▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines | |||||