1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 */ 16 17 /** \file 18 * \ingroup DNA 19 * 20 * Use API in BKE_workspace.h to edit these. 21 */ 22 23 #pragma once 24 25 #include "DNA_scene_types.h" 26 27 # 28 # 29 typedef struct bToolRef_Runtime { 30 int cursor; 31 32 /** One of these 3 must be defined. */ 33 char keymap[64]; 34 char gizmo_group[64]; 35 char data_block[64]; 36 37 /** Keymap for #bToolRef.idname_fallback, if set. */ 38 char keymap_fallback[64]; 39 40 /** Use to infer primary operator to use when setting accelerator keys. */ 41 char op[64]; 42 43 /** Index when a tool is a member of a group. */ 44 int index; 45 } bToolRef_Runtime; 46 47 /* Stored per mode. */ 48 typedef struct bToolRef { 49 struct bToolRef *next, *prev; 50 char idname[64]; 51 52 /** Optionally use these when not interacting directly with the primary tools gizmo. */ 53 char idname_fallback[64]; 54 55 /** Use to avoid initializing the same tool multiple times. */ 56 short tag; 57 58 /** #bToolKey (spacetype, mode), used in 'WM_api.h' */ 59 short space_type; 60 /** 61 * Value depends on the 'space_type', object mode for 3D view, image editor has own mode too. 62 * RNA needs to handle using item function. 63 */ 64 int mode; 65 66 /** 67 * Use for tool options, each group's name must match a tool name: 68 * 69 * {"Tool Name": {"SOME_OT_operator": {...}, ..}, ..} 70 * 71 * This is done since different tools may call the same operators with their own options. 72 */ 73 IDProperty *properties; 74 75 /** Variables needed to operate the tool. */ 76 bToolRef_Runtime *runtime; 77 } bToolRef; 78 79 /** 80 * \brief Wrapper for bScreen. 81 * 82 * #bScreens are IDs and thus stored in a main list-base. 83 * We also want to store a list-base of them within the workspace 84 * (so each workspace can have its own set of screen-layouts) 85 * which would mess with the next/prev pointers. 86 * So we use this struct to wrap a bScreen pointer with another pair of next/prev pointers. 87 */ 88 typedef struct WorkSpaceLayout { 89 struct WorkSpaceLayout *next, *prev; 90 91 struct bScreen *screen; 92 /* The name of this layout, we override the RNA name of the screen with this 93 * (but not ID name itself) */ 94 /** MAX_NAME. */ 95 char name[64]; 96 } WorkSpaceLayout; 97 98 /** Optional tags, which features to use, aligned with #bAddon names by convention. */ 99 typedef struct wmOwnerID { 100 struct wmOwnerID *next, *prev; 101 /** MAX_NAME. */ 102 char name[64]; 103 } wmOwnerID; 104 105 typedef struct WorkSpace { 106 ID id; 107 108 /** WorkSpaceLayout. */ 109 ListBase layouts; 110 /* Store for each hook (so for each window) which layout has 111 * been activated the last time this workspace was visible. */ 112 /** WorkSpaceDataRelation. */ 113 ListBase hook_layout_relations; 114 115 /* Feature tagging (use for addons) */ 116 /** #wmOwnerID. */ 117 ListBase owner_ids; 118 119 /** List of #bToolRef */ 120 ListBase tools; 121 122 char _pad[4]; 123 124 int object_mode; 125 126 /** Enum eWorkSpaceFlags. */ 127 int flags; 128 129 /** Number for workspace tab reordering in the UI. */ 130 int order; 131 132 /** Info text from modal operators (runtime). */ 133 char *status_text; 134 } WorkSpace; 135 136 /** 137 * Generic (and simple/primitive) struct for storing a history of assignments/relations 138 * of workspace data to non-workspace data in a listbase inside the workspace. 139 * 140 * Using this we can restore the old state of a workspace if the user switches back to it. 141 * 142 * Usage 143 * ===== 144 * When activating a workspace, it should activate the screen-layout that was active in that 145 * workspace before *in this window*. 146 * More concretely: 147 * * There are two windows, win1 and win2. 148 * * Both show workspace ws1, but both also had workspace ws2 activated at some point before. 149 * * Last time ws2 was active in win1, screen-layout sl1 was activated. 150 * * Last time ws2 was active in win2, screen-layout sl2 was activated. 151 * * When changing from ws1 to ws2 in win1, screen-layout sl1 should be activated again. 152 * * When changing from ws1 to ws2 in win2, screen-layout sl2 should be activated again. 153 * So that means we have to store the active screen-layout in a per workspace, per window 154 * relation. This struct is used to store an active screen-layout for each window within the 155 * workspace. 156 * To find the screen-layout to activate for this window-workspace combination, simply lookup 157 * the WorkSpaceDataRelation with the workspace-hook of the window set as parent. 158 */ 159 typedef struct WorkSpaceDataRelation { 160 struct WorkSpaceDataRelation *next, *prev; 161 162 /** The data used to identify the relation 163 * (e.g. to find screen-layout (= value) from/for a hook). 164 * Note: Now runtime only. */ 165 void *parent; 166 /** The value for this parent-data/workspace relation. */ 167 void *value; 168 169 /** Reference to the actual parent window, wmWindow->winid. Used in read/write code. */ 170 int parentid; 171 char _pad_0[4]; 172 } WorkSpaceDataRelation; 173 174 /** 175 * Little wrapper to store data that is going to be per window, but coming from the workspace. 176 * It allows us to keep workspace and window data completely separate. 177 */ 178 typedef struct WorkSpaceInstanceHook { 179 WorkSpace *active; 180 struct WorkSpaceLayout *act_layout; 181 182 /** Needed because we can't change workspaces/layouts in running handler loop, 183 * it would break context. */ 184 WorkSpace *temp_workspace_store; 185 struct WorkSpaceLayout *temp_layout_store; 186 } WorkSpaceInstanceHook; 187 188 typedef enum eWorkSpaceFlags { 189 WORKSPACE_USE_FILTER_BY_ORIGIN = (1 << 1), 190 } eWorkSpaceFlags; 191