Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/workspace_edit.c
| Show First 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | if (screen_new) { | ||||
| BLI_assert(CTX_wm_workspace(C) == workspace_new); | BLI_assert(CTX_wm_workspace(C) == workspace_new); | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| static void workspace_duplicate_update_screen_data(WorkSpace *workspace_new, WorkSpaceLayout *layout) | |||||
| { | |||||
| /* Update active transform orientation pointer of 3D Views. A bit ulgy, this should actually | |||||
| * be done in view3d_duplicate, but we can't get the correct workspace from there */ | |||||
| bScreen *screen = BKE_workspace_layout_screen_get(layout); | |||||
| for (ScrArea *area = screen->areabase.first; area; area = area->next) { | |||||
| for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { | |||||
| if (sl->spacetype == SPACE_VIEW3D) { | |||||
| View3D *v3d = (View3D *)sl; | |||||
| ListBase *transform_orientations = BKE_workspace_transform_orientations_get(workspace_new); | |||||
| v3d->custom_orientation = BLI_findstring( | |||||
| transform_orientations, v3d->custom_orientation->name, | |||||
| offsetof(TransformOrientation, name)); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * Duplicate a workspace including its layouts. Does not activate the workspace, but | * Duplicate a workspace including its layouts. Does not activate the workspace, but | ||||
| * it stores the screen-layout to be activated (BKE_workspace_temp_layout_store) | * it stores the screen-layout to be activated (BKE_workspace_temp_layout_store) | ||||
| */ | */ | ||||
| WorkSpace *ED_workspace_duplicate( | WorkSpace *ED_workspace_duplicate( | ||||
| WorkSpace *workspace_old, Main *bmain, wmWindow *win) | WorkSpace *workspace_old, Main *bmain, wmWindow *win) | ||||
| { | { | ||||
| WorkSpaceLayout *layout_active_old = BKE_workspace_active_layout_get(win->workspace_hook); | WorkSpaceLayout *layout_active_old = BKE_workspace_active_layout_get(win->workspace_hook); | ||||
| ListBase *layouts_old = BKE_workspace_layouts_get(workspace_old); | ListBase *layouts_old = BKE_workspace_layouts_get(workspace_old); | ||||
| WorkSpace *workspace_new = ED_workspace_add( | WorkSpace *workspace_new = ED_workspace_add( | ||||
| bmain, BKE_workspace_name_get(workspace_old), | bmain, BKE_workspace_name_get(workspace_old), | ||||
| BKE_workspace_render_layer_get(workspace_old)); | BKE_workspace_render_layer_get(workspace_old)); | ||||
| ListBase *transform_orientations_old = BKE_workspace_transform_orientations_get(workspace_old); | |||||
| ListBase *transform_orientations_new = BKE_workspace_transform_orientations_get(workspace_new); | |||||
| #ifdef USE_WORKSPACE_MODE | #ifdef USE_WORKSPACE_MODE | ||||
| BKE_workspace_object_mode_set(workspace_new, BKE_workspace_object_mode_get(workspace_old)); | BKE_workspace_object_mode_set(workspace_new, BKE_workspace_object_mode_get(workspace_old)); | ||||
| #endif | #endif | ||||
| BLI_duplicatelist(transform_orientations_new, transform_orientations_old); | |||||
| BKE_WORKSPACE_LAYOUT_ITER_BEGIN (layout_old, layouts_old->first) { | BKE_WORKSPACE_LAYOUT_ITER_BEGIN (layout_old, layouts_old->first) { | ||||
| WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(workspace_new, layout_old, win); | WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(workspace_new, layout_old, win); | ||||
| if (layout_active_old == layout_old) { | if (layout_active_old == layout_old) { | ||||
| BKE_workspace_temp_layout_store_set(win->workspace_hook, layout_new); | BKE_workspace_temp_layout_store_set(win->workspace_hook, layout_new); | ||||
| } | } | ||||
| workspace_duplicate_update_screen_data(workspace_new, layout_new); | |||||
| } BKE_WORKSPACE_LAYOUT_ITER_END; | } BKE_WORKSPACE_LAYOUT_ITER_END; | ||||
| return workspace_new; | return workspace_new; | ||||
| } | } | ||||
| /** | /** | ||||
| * \return if succeeded. | * \return if succeeded. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 189 Lines • Show Last 20 Lines | |||||