Blender V4.3
workspace.cc File Reference
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_string_utils.hh"
#include "BLI_utildefines.h"
#include "BLT_translation.hh"
#include "BKE_asset.hh"
#include "BKE_global.hh"
#include "BKE_idprop.hh"
#include "BKE_idtype.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_query.hh"
#include "BKE_main.hh"
#include "BKE_viewer_path.hh"
#include "BKE_workspace.hh"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_workspace_types.h"
#include "MEM_guardedalloc.h"
#include "BLO_read_write.hh"

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_after_liblink (BlendLibReader *reader, 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 void * workspace_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 (WorkSpace *workspace, bToolRef *tref)
 
void BKE_workspace_tool_id_replace_table (WorkSpace *workspace, const int space_type, const int mode, const char *idname_prefix_skip, const char *replace_table[][2], int replace_table_num)
 
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.
 
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)
 
Status
void BKE_workspace_status_clear (WorkSpace *workspace)
 

Variables

IDTypeInfo IDType_ID_WS
 

Function Documentation

◆ BKE_workspace_active_get()

◆ BKE_workspace_active_layout_for_workspace_get()

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

Get the layout to be activated should workspace become or be the active workspace in hook.

Definition at line 591 of file workspace.cc.

References WorkSpaceInstanceHook::act_layout, WorkSpaceInstanceHook::active, WorkSpace::hook_layout_relations, and workspace_relation_get_data_matching_parent().

Referenced by BLO_update_defaults_startup_blend(), and workspace_change_get_new_layout().

◆ BKE_workspace_active_layout_get()

WorkSpaceLayout * BKE_workspace_active_layout_get ( const WorkSpaceInstanceHook * hook)

Get the layout that is active for hook (which is the visible layout for the active workspace in hook).

Definition at line 586 of file workspace.cc.

References WorkSpaceInstanceHook::act_layout.

Referenced by ED_workspace_duplicate(), ED_workspace_layout_cycle(), screen_new_exec(), wm_window_close(), WM_window_get_active_layout(), and workspace_layout_delete_doit().

◆ BKE_workspace_active_layout_set()

void BKE_workspace_active_layout_set ( WorkSpaceInstanceHook * hook,
int winid,
WorkSpace * workspace,
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 604 of file workspace.cc.

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()

◆ BKE_workspace_active_screen_set()

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

◆ BKE_workspace_active_set()

◆ BKE_workspace_add()

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

◆ BKE_workspace_id_tag_all_visible()

◆ 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 ( Main * bmain,
WorkSpace * workspace,
bScreen * screen,
const char * name )

◆ BKE_workspace_layout_find()

◆ BKE_workspace_layout_find_global()

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

Definition at line 444 of file workspace.cc.

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

◆ BKE_workspace_layout_iter_circular()

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

Circular workspace layout iterator.

Parameters
callbackCustom function which gets executed for each layout. Can return false to stop iterating.
argCustom data passed to each callback call.
Returns
the layout at which callback returned false.

Definition at line 469 of file workspace.cc.

References callback, WorkSpace::layouts, LISTBASE_CIRCULAR_BACKWARD_BEGIN, LISTBASE_CIRCULAR_BACKWARD_END, LISTBASE_CIRCULAR_FORWARD_BEGIN, and LISTBASE_CIRCULAR_FORWARD_END.

Referenced by ED_workspace_layout_cycle(), and ED_workspace_screen_change_ensure_unused_layout().

◆ BKE_workspace_layout_name_get()

const char * BKE_workspace_layout_name_get ( const WorkSpaceLayout * layout)

Definition at line 627 of file workspace.cc.

References WorkSpaceLayout::name.

Referenced by ED_workspace_layout_duplicate().

◆ BKE_workspace_layout_name_set()

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

Definition at line 631 of file workspace.cc.

References workspace_layout_name_set().

◆ BKE_workspace_layout_remove()

◆ BKE_workspace_layout_screen_get()

◆ 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 408 of file workspace.cc.

References ListBase::first, and workspace_relation_remove().

Referenced by workspace_free_data().

◆ BKE_workspace_remove()

void BKE_workspace_remove ( Main * bmain,
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 324 of file workspace.cc.

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

◆ BKE_workspace_status_clear()

void BKE_workspace_status_clear ( WorkSpace * workspace)

Empty the Workspace status items to clear the status bar.

Definition at line 649 of file workspace.cc.

References WorkSpace::runtime.

Referenced by mesh_bisect_modal(), transformEvent(), viewRedrawPost(), workspace_free_data(), and WorkspaceStatus::WorkspaceStatus().

◆ BKE_workspace_tool_id_replace_table()

void BKE_workspace_tool_id_replace_table ( WorkSpace * workspace,
const int space_type,
const int mode,
const char * idname_prefix_skip,
const char * replace_table[][2],
int replace_table_num )

◆ BKE_workspace_tool_remove()

void BKE_workspace_tool_remove ( WorkSpace * workspace,
bToolRef * tref )

◆ workspace_blend_read_after_liblink()

static void workspace_blend_read_after_liblink ( BlendLibReader * reader,
ID * id )
static

◆ workspace_blend_read_data()

◆ workspace_blend_write()

◆ workspace_foreach_id()

◆ workspace_free_data()

◆ 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.cc.

References BLI_findptr(), WorkSpace::layouts, and offsetof.

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 249 of file workspace.cc.

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 294 of file workspace.cc.

References workspace_layout_find_exec().

Referenced by BKE_workspace_layout_add().

Variable Documentation

◆ IDType_ID_WS

IDTypeInfo IDType_ID_WS
Initial value:
= {
sizeof(WorkSpace),
"WorkSpace",
N_("workspaces"),
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
}
@ IDTYPE_FLAGS_NO_ANIMDATA
Definition BKE_idtype.hh:41
@ IDTYPE_FLAGS_ONLY_APPEND
Definition BKE_idtype.hh:36
@ IDTYPE_FLAGS_NO_COPY
Definition BKE_idtype.hh:30
@ IDTYPE_FLAGS_NO_MEMFILE_UNDO
Definition BKE_idtype.hh:50
@ IDTYPE_FLAGS_NEVER_UNUSED
Definition BKE_idtype.hh:64
#define BLT_I18NCONTEXT_ID_WORKSPACE
#define FILTER_ID_WS
Definition DNA_ID.h:1193
@ INDEX_ID_WS
Definition DNA_ID.h:1321
#define FILTER_ID_SCE
Definition DNA_ID.h:1184
@ ID_WS
struct WorkSpace WorkSpace
#define N_(msgid)
static void workspace_free_data(ID *id)
Definition workspace.cc:50
static void workspace_blend_read_after_liblink(BlendLibReader *reader, ID *id)
Definition workspace.cc:139
static void workspace_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition workspace.cc:82
static void workspace_foreach_id(ID *id, LibraryForeachIDData *data)
Definition workspace.cc:69
static void workspace_init_data(ID *id)
Definition workspace.cc:41
static void workspace_blend_read_data(BlendDataReader *reader, ID *id)
Definition workspace.cc:101

Definition at line 177 of file workspace.cc.