Blender  V3.3
Functions | Variables
workspace.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_string_utils.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_asset.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
#include "BKE_idtype.h"
#include "BKE_lib_id.h"
#include "BKE_lib_query.h"
#include "BKE_main.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_workspace.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_workspace_types.h"
#include "DEG_depsgraph.h"
#include "MEM_guardedalloc.h"
#include "BLO_read_write.h"

Go to the source code of this file.

Functions

static void workspace_init_data (ID *id)
 
static void workspace_free_data (ID *id)
 
static void workspace_foreach_id (ID *id, LibraryForeachIDData *data)
 
static void workspace_blend_write (BlendWriter *writer, ID *id, const void *id_address)
 
static void workspace_blend_read_data (BlendDataReader *reader, ID *id)
 
static void workspace_blend_read_lib (BlendLibReader *reader, ID *id)
 
static void workspace_blend_read_expand (BlendExpander *expander, ID *id)
 
Internal Utils
static void workspace_layout_name_set (WorkSpace *workspace, WorkSpaceLayout *layout, const char *new_name)
 
static WorkSpaceLayoutworkspace_layout_find_exec (const WorkSpace *workspace, const bScreen *screen)
 
static void workspace_relation_add (ListBase *relation_list, void *parent, const int parentid, void *data)
 
static void workspace_relation_remove (ListBase *relation_list, WorkSpaceDataRelation *relation)
 
static void workspace_relation_ensure_updated (ListBase *relation_list, void *parent, const int parentid, void *data)
 
static voidworkspace_relation_get_data_matching_parent (const ListBase *relation_list, const void *parent)
 
static bool workspaces_is_screen_used (const Main *bmain, bScreen *screen)
 
Create, Delete, Init
WorkSpaceBKE_workspace_add (Main *bmain, const char *name)
 
void BKE_workspace_remove (Main *bmain, WorkSpace *workspace)
 
WorkSpaceInstanceHookBKE_workspace_instance_hook_create (const Main *bmain, const int winid)
 
void BKE_workspace_instance_hook_free (const Main *bmain, WorkSpaceInstanceHook *hook)
 
WorkSpaceLayoutBKE_workspace_layout_add (Main *bmain, WorkSpace *workspace, bScreen *screen, const char *name)
 
void BKE_workspace_layout_remove (Main *bmain, WorkSpace *workspace, WorkSpaceLayout *layout)
 
void BKE_workspace_relations_free (ListBase *relation_list)
 
General Utils
WorkSpaceLayoutBKE_workspace_layout_find (const WorkSpace *workspace, const bScreen *screen)
 
WorkSpaceLayoutBKE_workspace_layout_find_global (const Main *bmain, const bScreen *screen, WorkSpace **r_workspace)
 
WorkSpaceLayoutBKE_workspace_layout_iter_circular (const WorkSpace *workspace, WorkSpaceLayout *start, bool(*callback)(const WorkSpaceLayout *layout, void *arg), void *arg, const bool iter_backward)
 
void BKE_workspace_tool_remove (struct WorkSpace *workspace, struct bToolRef *tref)
 
bool BKE_workspace_owner_id_check (const WorkSpace *workspace, const char *owner_id)
 
void BKE_workspace_id_tag_all_visible (Main *bmain, int tag)
 
Getters/Setters
WorkSpaceBKE_workspace_active_get (WorkSpaceInstanceHook *hook)
 
void BKE_workspace_active_set (WorkSpaceInstanceHook *hook, WorkSpace *workspace)
 
WorkSpaceLayoutBKE_workspace_active_layout_get (const WorkSpaceInstanceHook *hook)
 
WorkSpaceLayoutBKE_workspace_active_layout_for_workspace_get (const WorkSpaceInstanceHook *hook, const WorkSpace *workspace)
 
void BKE_workspace_active_layout_set (WorkSpaceInstanceHook *hook, const int winid, WorkSpace *workspace, WorkSpaceLayout *layout)
 Activate a layout. More...
 
bScreenBKE_workspace_active_screen_get (const WorkSpaceInstanceHook *hook)
 
void BKE_workspace_active_screen_set (WorkSpaceInstanceHook *hook, const int winid, WorkSpace *workspace, bScreen *screen)
 
const char * BKE_workspace_layout_name_get (const WorkSpaceLayout *layout)
 
void BKE_workspace_layout_name_set (WorkSpace *workspace, WorkSpaceLayout *layout, const char *new_name)
 
bScreenBKE_workspace_layout_screen_get (const WorkSpaceLayout *layout)
 

Variables

IDTypeInfo IDType_ID_WS
 

Function Documentation

◆ BKE_workspace_active_get()

WorkSpace* BKE_workspace_active_get ( WorkSpaceInstanceHook hook)

◆ BKE_workspace_active_layout_for_workspace_get()

WorkSpaceLayout* BKE_workspace_active_layout_for_workspace_get ( const WorkSpaceInstanceHook hook,
const WorkSpace workspace 
)

◆ BKE_workspace_active_layout_get()

WorkSpaceLayout* BKE_workspace_active_layout_get ( const WorkSpaceInstanceHook hook)

Definition at line 540 of file workspace.c.

References WorkSpaceInstanceHook::act_layout.

◆ BKE_workspace_active_layout_set()

void BKE_workspace_active_layout_set ( struct WorkSpaceInstanceHook hook,
int  winid,
struct WorkSpace workspace,
struct WorkSpaceLayout layout 
)

Activate a layout.

Sets layout as active for workspace when activated through or already active in hook. So when the active workspace of hook is workspace, layout becomes the active layout of hook too. See BKE_workspace_active_set().

workspace does not need to be active for this.

WorkSpaceInstanceHook.act_layout should only be modified directly to update the layout pointer.

Definition at line 557 of file workspace.c.

References WorkSpaceInstanceHook::act_layout, WorkSpace::hook_layout_relations, winid, and workspace_relation_ensure_updated().

Referenced by BKE_workspace_active_screen_set(), BKE_workspace_instance_hook_create(), do_version_workspaces_after_lib_link(), ED_workspace_change(), wm_add_default(), wm_window_copy(), and WM_window_set_active_layout().

◆ BKE_workspace_active_screen_get()

bScreen* BKE_workspace_active_screen_get ( const WorkSpaceInstanceHook hook)

Definition at line 566 of file workspace.c.

References WorkSpaceInstanceHook::act_layout, and WorkSpaceLayout::screen.

◆ BKE_workspace_active_screen_set()

void BKE_workspace_active_screen_set ( WorkSpaceInstanceHook hook,
const int  winid,
WorkSpace workspace,
bScreen screen 
)

◆ BKE_workspace_active_set()

void BKE_workspace_active_set ( WorkSpaceInstanceHook hook,
WorkSpace workspace 
)

◆ BKE_workspace_add()

WorkSpace* BKE_workspace_add ( Main bmain,
const char *  name 
)

◆ BKE_workspace_id_tag_all_visible()

void BKE_workspace_id_tag_all_visible ( Main bmain,
int  tag 
)

◆ BKE_workspace_instance_hook_create()

WorkSpaceInstanceHook* BKE_workspace_instance_hook_create ( const Main bmain,
const int  winid 
)

◆ BKE_workspace_instance_hook_free()

void BKE_workspace_instance_hook_free ( const Main bmain,
WorkSpaceInstanceHook hook 
)

◆ BKE_workspace_layout_add()

WorkSpaceLayout* BKE_workspace_layout_add ( struct Main bmain,
struct WorkSpace workspace,
struct bScreen screen,
const char *  name 
)

◆ BKE_workspace_layout_find()

WorkSpaceLayout* BKE_workspace_layout_find ( const WorkSpace workspace,
const bScreen screen 
)

◆ BKE_workspace_layout_find_global()

WorkSpaceLayout* BKE_workspace_layout_find_global ( const Main bmain,
const bScreen screen,
WorkSpace **  r_workspace 
)

Definition at line 426 of file workspace.c.

References ListBase::first, NULL, workspace_layout_find_exec(), and Main::workspaces.

◆ BKE_workspace_layout_iter_circular()

WorkSpaceLayout* BKE_workspace_layout_iter_circular ( const WorkSpace workspace,
WorkSpaceLayout start,
bool(*)(const WorkSpaceLayout *layout, void *arg)  callback,
void arg,
const bool  iter_backward 
)

◆ BKE_workspace_layout_name_get()

const char* BKE_workspace_layout_name_get ( const WorkSpaceLayout layout)

Definition at line 580 of file workspace.c.

References WorkSpaceLayout::name.

◆ BKE_workspace_layout_name_set()

void BKE_workspace_layout_name_set ( WorkSpace workspace,
WorkSpaceLayout layout,
const char *  new_name 
)

Definition at line 584 of file workspace.c.

References workspace_layout_name_set().

◆ BKE_workspace_layout_remove()

void BKE_workspace_layout_remove ( Main bmain,
WorkSpace workspace,
WorkSpaceLayout layout 
)

◆ BKE_workspace_layout_screen_get()

bScreen* BKE_workspace_layout_screen_get ( const WorkSpaceLayout layout)

Definition at line 591 of file workspace.c.

References WorkSpaceLayout::screen.

Referenced by workspace_blend_read_expand().

◆ BKE_workspace_owner_id_check()

bool BKE_workspace_owner_id_check ( const WorkSpace workspace,
const char *  owner_id 
)

◆ BKE_workspace_relations_free()

void BKE_workspace_relations_free ( ListBase relation_list)

Definition at line 394 of file workspace.c.

References ListBase::first, and workspace_relation_remove().

Referenced by workspace_free_data().

◆ BKE_workspace_remove()

void BKE_workspace_remove ( struct Main bmain,
struct WorkSpace workspace 
)

Remove workspace by freeing itself and its data. This is a higher-level wrapper that calls workspace_free_data (through BKE_id_free) to free the workspace data, and frees other data-blocks owned by workspace and its layouts (currently that is screens only).

Always use this to remove (and free) workspaces. Don't free non-ID workspace members here.

Definition at line 321 of file workspace.c.

References BKE_id_free(), BKE_workspace_layout_remove(), ListBase::first, and WorkSpace::layouts.

◆ BKE_workspace_tool_remove()

void BKE_workspace_tool_remove ( struct WorkSpace workspace,
struct bToolRef tref 
)

◆ workspace_blend_read_data()

static void workspace_blend_read_data ( BlendDataReader reader,
ID id 
)
static

◆ workspace_blend_read_expand()

static void workspace_blend_read_expand ( BlendExpander expander,
ID id 
)
static

◆ workspace_blend_read_lib()

static void workspace_blend_read_lib ( BlendLibReader reader,
ID id 
)
static

◆ workspace_blend_write()

static void workspace_blend_write ( BlendWriter writer,
ID id,
const void id_address 
)
static

◆ workspace_foreach_id()

static void workspace_foreach_id ( ID id,
LibraryForeachIDData data 
)
static

◆ workspace_free_data()

static void workspace_free_data ( ID id)
static

◆ workspace_init_data()

static void workspace_init_data ( ID id)
static

◆ workspace_layout_find_exec()

static WorkSpaceLayout* workspace_layout_find_exec ( const WorkSpace workspace,
const bScreen screen 
)
static

This should only be used directly when it is to be expected that there isn't a layout within workspace that wraps screen. Usually - especially outside of BKE_workspace - BKE_workspace_layout_find should be used!

Definition at line 230 of file workspace.c.

References BLI_findptr(), and WorkSpace::layouts.

Referenced by BKE_workspace_layout_find(), BKE_workspace_layout_find_global(), and workspaces_is_screen_used().

◆ workspace_layout_name_set()

static void workspace_layout_name_set ( WorkSpace workspace,
WorkSpaceLayout layout,
const char *  new_name 
)
static

◆ workspace_relation_add()

static void workspace_relation_add ( ListBase relation_list,
void parent,
const int  parentid,
void data 
)
static

◆ workspace_relation_ensure_updated()

static void workspace_relation_ensure_updated ( ListBase relation_list,
void parent,
const int  parentid,
void data 
)
static

◆ workspace_relation_get_data_matching_parent()

static void* workspace_relation_get_data_matching_parent ( const ListBase relation_list,
const void parent 
)
static

◆ workspace_relation_remove()

static void workspace_relation_remove ( ListBase relation_list,
WorkSpaceDataRelation relation 
)
static

Definition at line 248 of file workspace.c.

References BLI_remlink(), and MEM_freeN.

Referenced by BKE_workspace_instance_hook_free(), and BKE_workspace_relations_free().

◆ workspaces_is_screen_used()

static bool workspaces_is_screen_used ( const Main bmain,
bScreen screen 
)
static

Checks if screen is already used within any workspace. A screen should never be assigned to multiple WorkSpaceLayouts, but that should be ensured outside of the BKE_workspace module and without such checks. Hence, this should only be used as assert check before assigning a screen to a workspace.

Definition at line 293 of file workspace.c.

References WorkSpace::id, ID::next, and workspace_layout_find_exec().

Referenced by BKE_workspace_layout_add().

Variable Documentation

◆ IDType_ID_WS

IDTypeInfo IDType_ID_WS
Initial value:
= {
.id_code = ID_WS,
.id_filter = FILTER_ID_WS,
.main_listbase_index = INDEX_ID_WS,
.struct_size = sizeof(WorkSpace),
.name = "WorkSpace",
.name_plural = "workspaces",
.translation_context = BLT_I18NCONTEXT_ID_WORKSPACE,
.asset_type_info = NULL,
.copy_data = NULL,
.free_data = workspace_free_data,
.make_local = NULL,
.foreach_id = workspace_foreach_id,
.foreach_cache = NULL,
.foreach_path = NULL,
.owner_get = NULL,
.blend_write = workspace_blend_write,
.blend_read_data = workspace_blend_read_data,
.blend_read_lib = workspace_blend_read_lib,
.blend_read_expand = workspace_blend_read_expand,
.blend_read_undo_preserve = NULL,
.lib_override_apply_post = NULL,
}
@ IDTYPE_FLAGS_NO_ANIMDATA
Definition: BKE_idtype.h:41
@ IDTYPE_FLAGS_ONLY_APPEND
Definition: BKE_idtype.h:36
@ IDTYPE_FLAGS_NO_COPY
Definition: BKE_idtype.h:30
#define BLT_I18NCONTEXT_ID_WORKSPACE
@ INDEX_ID_WS
Definition: DNA_ID.h:1053
#define FILTER_ID_WS
Definition: DNA_ID.h:928
@ ID_WS
Definition: DNA_ID_enums.h:79
struct WorkSpace WorkSpace
static void init_data(ModifierData *md)
static void workspace_blend_read_expand(BlendExpander *expander, ID *id)
Definition: workspace.c:169
static void workspace_free_data(ID *id)
Definition: workspace.c:50
static void workspace_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition: workspace.c:77
static void workspace_foreach_id(ID *id, LibraryForeachIDData *data)
Definition: workspace.c:66
static void workspace_init_data(ID *id)
Definition: workspace.c:43
static void workspace_blend_read_data(BlendDataReader *reader, ID *id)
Definition: workspace.c:94
static void workspace_blend_read_lib(BlendLibReader *reader, ID *id)
Definition: workspace.c:120

Definition at line 178 of file workspace.c.