2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2010-08-10 15:14:19 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
* return info about ID types
|
|
|
|
*/
|
2011-02-27 20:40:57 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
2011-02-27 20:40:57 +00:00
|
|
|
*/
|
|
|
|
|
2010-08-10 15:14:19 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "DNA_ID.h"
|
|
|
|
|
2013-03-09 05:35:49 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2015-06-09 14:57:29 +02:00
|
|
|
|
2018-11-07 16:06:36 +01:00
|
|
|
#include "BKE_main.h"
|
2011-02-13 10:52:18 +00:00
|
|
|
#include "BKE_idcode.h"
|
|
|
|
|
2010-08-10 15:14:19 +00:00
|
|
|
typedef struct {
|
|
|
|
unsigned short code;
|
2010-12-03 17:05:21 +00:00
|
|
|
const char *name, *plural;
|
2015-06-09 14:57:29 +02:00
|
|
|
|
|
|
|
const char *i18n_context;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-08-10 15:14:19 +00:00
|
|
|
int flags;
|
2012-05-12 16:11:34 +00:00
|
|
|
#define IDTYPE_FLAGS_ISLINKABLE (1 << 0)
|
2010-08-10 15:14:19 +00:00
|
|
|
} IDType;
|
|
|
|
|
|
|
|
/* plural need to match rna_main.c's MainCollectionDef */
|
2015-08-16 17:32:01 +10:00
|
|
|
/* WARNING! Keep it in sync with i18n contexts in BLT_translation.h */
|
2012-05-12 16:11:34 +00:00
|
|
|
static IDType idtypes[] = {
|
2016-06-07 16:05:04 +10:00
|
|
|
/** ID's directly below must all be in #Main, and be kept in sync with #MAX_LIBARRAY (membership, not order) */
|
2018-11-10 09:24:23 +11:00
|
|
|
{ID_AC, "Action", "actions", BLT_I18NCONTEXT_ID_ACTION, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_AR, "Armature", "armatures", BLT_I18NCONTEXT_ID_ARMATURE, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_BR, "Brush", "brushes", BLT_I18NCONTEXT_ID_BRUSH, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_CA, "Camera", "cameras", BLT_I18NCONTEXT_ID_CAMERA, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_CF, "CacheFile", "cache_files", BLT_I18NCONTEXT_ID_CACHEFILE, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_GR, "Collection", "collections", BLT_I18NCONTEXT_ID_COLLECTION, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_CU, "Curve", "curves", BLT_I18NCONTEXT_ID_CURVE, IDTYPE_FLAGS_ISLINKABLE},
|
2019-03-08 09:55:40 +11:00
|
|
|
{ID_GD, "GPencil", "grease_pencils", BLT_I18NCONTEXT_ID_GPENCIL, IDTYPE_FLAGS_ISLINKABLE}, /* rename gpencil */
|
|
|
|
|
2018-11-10 09:24:23 +11:00
|
|
|
{ID_IM, "Image", "images", BLT_I18NCONTEXT_ID_IMAGE, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_IP, "Ipo", "ipos", "", IDTYPE_FLAGS_ISLINKABLE}, /* deprecated */
|
|
|
|
{ID_KE, "Key", "shape_keys", BLT_I18NCONTEXT_ID_SHAPEKEY, 0 },
|
2019-02-12 21:51:51 +01:00
|
|
|
{ID_LA, "Light", "lights", BLT_I18NCONTEXT_ID_LIGHT, IDTYPE_FLAGS_ISLINKABLE},
|
2018-11-10 09:24:23 +11:00
|
|
|
{ID_LI, "Library", "libraries", BLT_I18NCONTEXT_ID_LIBRARY, 0 },
|
|
|
|
{ID_LS, "FreestyleLineStyle", "linestyles", BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_LT, "Lattice", "lattices", BLT_I18NCONTEXT_ID_LATTICE, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_MA, "Material", "materials", BLT_I18NCONTEXT_ID_MATERIAL, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_MB, "Metaball", "metaballs", BLT_I18NCONTEXT_ID_METABALL, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_MC, "MovieClip", "movieclips", BLT_I18NCONTEXT_ID_MOVIECLIP, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_ME, "Mesh", "meshes", BLT_I18NCONTEXT_ID_MESH, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_MSK, "Mask", "masks", BLT_I18NCONTEXT_ID_MASK, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_NT, "NodeTree", "node_groups", BLT_I18NCONTEXT_ID_NODETREE, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_OB, "Object", "objects", BLT_I18NCONTEXT_ID_OBJECT, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_PA, "ParticleSettings", "particles", BLT_I18NCONTEXT_ID_PARTICLESETTINGS, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_PAL, "Palettes", "palettes", BLT_I18NCONTEXT_ID_PALETTE, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_PC, "PaintCurve", "paint_curves", BLT_I18NCONTEXT_ID_PAINTCURVE, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_LP, "LightProbe", "light_probes", BLT_I18NCONTEXT_ID_LIGHTPROBE, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_SCE, "Scene", "scenes", BLT_I18NCONTEXT_ID_SCENE, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_SCR, "Screen", "screens", BLT_I18NCONTEXT_ID_SCREEN, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_SEQ, "Sequence", "sequences", BLT_I18NCONTEXT_ID_SEQUENCE, 0 }, /* not actually ID data */
|
|
|
|
{ID_SPK, "Speaker", "speakers", BLT_I18NCONTEXT_ID_SPEAKER, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_SO, "Sound", "sounds", BLT_I18NCONTEXT_ID_SOUND, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_TE, "Texture", "textures", BLT_I18NCONTEXT_ID_TEXTURE, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_TXT, "Text", "texts", BLT_I18NCONTEXT_ID_TEXT, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_VF, "VFont", "fonts", BLT_I18NCONTEXT_ID_VFONT, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_WO, "World", "worlds", BLT_I18NCONTEXT_ID_WORLD, IDTYPE_FLAGS_ISLINKABLE},
|
|
|
|
{ID_WM, "WindowManager", "window_managers", BLT_I18NCONTEXT_ID_WINDOWMANAGER, 0 },
|
|
|
|
{ID_WS, "WorkSpace", "workspaces", BLT_I18NCONTEXT_ID_WORKSPACE, IDTYPE_FLAGS_ISLINKABLE},
|
2016-06-07 16:05:04 +10:00
|
|
|
|
|
|
|
/** Keep last, not an ID exactly, only include for completeness */
|
2019-02-27 19:25:21 +01:00
|
|
|
{ID_LINK_PLACEHOLDER, "Link Placeholder", "link_placeholders", BLT_I18NCONTEXT_ID_ID, 0}, /* plural is fake */
|
2010-08-10 15:14:19 +00:00
|
|
|
};
|
|
|
|
|
2019-02-27 19:25:21 +01:00
|
|
|
/* -1 for ID_LINK_PLACEHOLDER */
|
2016-06-07 16:05:04 +10:00
|
|
|
BLI_STATIC_ASSERT((ARRAY_SIZE(idtypes) - 1 == MAX_LIBARRAY), "Missing IDType");
|
|
|
|
|
2018-06-17 17:05:51 +02:00
|
|
|
static IDType *idtype_from_name(const char *str)
|
2010-08-10 15:14:19 +00:00
|
|
|
{
|
2014-05-18 23:50:44 +10:00
|
|
|
int i = ARRAY_SIZE(idtypes);
|
|
|
|
|
2013-03-10 06:18:03 +00:00
|
|
|
while (i--) {
|
|
|
|
if (STREQ(str, idtypes[i].name)) {
|
2010-08-10 15:14:19 +00:00
|
|
|
return &idtypes[i];
|
2013-03-10 06:18:03 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-10 15:14:19 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-10-15 16:02:36 +02:00
|
|
|
static IDType *idtype_from_code(short idcode)
|
2010-08-10 15:14:19 +00:00
|
|
|
{
|
2014-05-18 23:50:44 +10:00
|
|
|
int i = ARRAY_SIZE(idtypes);
|
|
|
|
|
2010-08-10 15:14:19 +00:00
|
|
|
while (i--)
|
2015-10-15 16:02:36 +02:00
|
|
|
if (idcode == idtypes[i].code)
|
2010-08-10 15:14:19 +00:00
|
|
|
return &idtypes[i];
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-08-10 15:14:19 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
/**
|
|
|
|
* Return if the ID code is a valid ID code.
|
|
|
|
*
|
2016-06-27 13:20:56 +10:00
|
|
|
* \param idcode: The code to check.
|
2013-03-24 12:13:13 +00:00
|
|
|
* \return Boolean, 0 when invalid.
|
|
|
|
*/
|
2015-10-15 16:02:36 +02:00
|
|
|
bool BKE_idcode_is_valid(short idcode)
|
2010-08-10 15:14:19 +00:00
|
|
|
{
|
2015-10-15 16:02:36 +02:00
|
|
|
return idtype_from_code(idcode) ? true : false;
|
2010-08-10 15:14:19 +00:00
|
|
|
}
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
/**
|
|
|
|
* Return non-zero when an ID type is linkable.
|
|
|
|
*
|
2016-06-27 13:20:56 +10:00
|
|
|
* \param idcode: The code to check.
|
2013-03-24 12:13:13 +00:00
|
|
|
* \return Boolean, 0 when non linkable.
|
|
|
|
*/
|
2015-10-15 16:02:36 +02:00
|
|
|
bool BKE_idcode_is_linkable(short idcode)
|
2011-09-28 05:53:40 +00:00
|
|
|
{
|
2015-10-15 16:02:36 +02:00
|
|
|
IDType *idt = idtype_from_code(idcode);
|
2014-01-31 03:09:01 +11:00
|
|
|
BLI_assert(idt);
|
2013-03-09 05:35:49 +00:00
|
|
|
return idt ? ((idt->flags & IDTYPE_FLAGS_ISLINKABLE) != 0) : false;
|
2010-08-10 15:14:19 +00:00
|
|
|
}
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
/**
|
|
|
|
* Convert an idcode into a name.
|
|
|
|
*
|
2016-06-27 13:20:56 +10:00
|
|
|
* \param idcode: The code to convert.
|
2013-03-24 12:13:13 +00:00
|
|
|
* \return A static string representing the name of
|
|
|
|
* the code.
|
|
|
|
*/
|
2015-10-15 16:02:36 +02:00
|
|
|
const char *BKE_idcode_to_name(short idcode)
|
2010-08-10 15:14:19 +00:00
|
|
|
{
|
2015-10-15 16:02:36 +02:00
|
|
|
IDType *idt = idtype_from_code(idcode);
|
2014-01-31 03:09:01 +11:00
|
|
|
BLI_assert(idt);
|
2012-05-12 16:11:34 +00:00
|
|
|
return idt ? idt->name : NULL;
|
2010-08-10 15:14:19 +00:00
|
|
|
}
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
/**
|
|
|
|
* Convert a name into an idcode (ie. ID_SCE)
|
|
|
|
*
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param name: The name to convert.
|
2013-03-24 12:13:13 +00:00
|
|
|
* \return The code for the name, or 0 if invalid.
|
|
|
|
*/
|
2015-10-15 16:02:36 +02:00
|
|
|
short BKE_idcode_from_name(const char *name)
|
2010-08-10 15:14:19 +00:00
|
|
|
{
|
2012-05-12 16:11:34 +00:00
|
|
|
IDType *idt = idtype_from_name(name);
|
2014-01-31 03:09:01 +11:00
|
|
|
BLI_assert(idt);
|
2012-05-12 16:11:34 +00:00
|
|
|
return idt ? idt->code : 0;
|
2010-08-10 15:14:19 +00:00
|
|
|
}
|
|
|
|
|
2015-08-10 17:26:37 +02:00
|
|
|
/**
|
|
|
|
* Convert an idcode into an idfilter (e.g. ID_OB -> FILTER_ID_OB).
|
|
|
|
*/
|
2015-10-15 16:02:36 +02:00
|
|
|
int BKE_idcode_to_idfilter(const short idcode)
|
2015-08-10 17:26:37 +02:00
|
|
|
{
|
|
|
|
#define CASE_IDFILTER(_id) case ID_##_id: return FILTER_ID_##_id
|
|
|
|
|
|
|
|
switch (idcode) {
|
|
|
|
CASE_IDFILTER(AC);
|
|
|
|
CASE_IDFILTER(AR);
|
|
|
|
CASE_IDFILTER(BR);
|
|
|
|
CASE_IDFILTER(CA);
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
CASE_IDFILTER(CF);
|
2015-08-10 17:26:37 +02:00
|
|
|
CASE_IDFILTER(CU);
|
|
|
|
CASE_IDFILTER(GD);
|
|
|
|
CASE_IDFILTER(GR);
|
|
|
|
CASE_IDFILTER(IM);
|
|
|
|
CASE_IDFILTER(LA);
|
|
|
|
CASE_IDFILTER(LS);
|
|
|
|
CASE_IDFILTER(LT);
|
|
|
|
CASE_IDFILTER(MA);
|
|
|
|
CASE_IDFILTER(MB);
|
|
|
|
CASE_IDFILTER(MC);
|
|
|
|
CASE_IDFILTER(ME);
|
|
|
|
CASE_IDFILTER(MSK);
|
|
|
|
CASE_IDFILTER(NT);
|
|
|
|
CASE_IDFILTER(OB);
|
2016-12-28 17:30:58 +01:00
|
|
|
CASE_IDFILTER(PA);
|
2015-08-10 17:26:37 +02:00
|
|
|
CASE_IDFILTER(PAL);
|
|
|
|
CASE_IDFILTER(PC);
|
2017-06-12 20:59:54 +10:00
|
|
|
CASE_IDFILTER(LP);
|
2015-08-10 17:26:37 +02:00
|
|
|
CASE_IDFILTER(SCE);
|
|
|
|
CASE_IDFILTER(SPK);
|
|
|
|
CASE_IDFILTER(SO);
|
|
|
|
CASE_IDFILTER(TE);
|
|
|
|
CASE_IDFILTER(TXT);
|
|
|
|
CASE_IDFILTER(VF);
|
|
|
|
CASE_IDFILTER(WO);
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
CASE_IDFILTER(WS);
|
2015-08-10 17:26:37 +02:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef CASE_IDFILTER
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert an idfilter into an idcode (e.g. FILTER_ID_OB -> ID_OB).
|
|
|
|
*/
|
2015-10-15 16:02:36 +02:00
|
|
|
short BKE_idcode_from_idfilter(const int idfilter)
|
2015-08-10 17:26:37 +02:00
|
|
|
{
|
|
|
|
#define CASE_IDFILTER(_id) case FILTER_ID_##_id: return ID_##_id
|
|
|
|
|
|
|
|
switch (idfilter) {
|
|
|
|
CASE_IDFILTER(AC);
|
|
|
|
CASE_IDFILTER(AR);
|
|
|
|
CASE_IDFILTER(BR);
|
|
|
|
CASE_IDFILTER(CA);
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
CASE_IDFILTER(CF);
|
2015-08-10 17:26:37 +02:00
|
|
|
CASE_IDFILTER(CU);
|
|
|
|
CASE_IDFILTER(GD);
|
|
|
|
CASE_IDFILTER(GR);
|
|
|
|
CASE_IDFILTER(IM);
|
|
|
|
CASE_IDFILTER(LA);
|
|
|
|
CASE_IDFILTER(LS);
|
|
|
|
CASE_IDFILTER(LT);
|
|
|
|
CASE_IDFILTER(MA);
|
|
|
|
CASE_IDFILTER(MB);
|
|
|
|
CASE_IDFILTER(MC);
|
|
|
|
CASE_IDFILTER(ME);
|
|
|
|
CASE_IDFILTER(MSK);
|
|
|
|
CASE_IDFILTER(NT);
|
|
|
|
CASE_IDFILTER(OB);
|
2016-12-28 17:30:58 +01:00
|
|
|
CASE_IDFILTER(PA);
|
2015-08-10 17:26:37 +02:00
|
|
|
CASE_IDFILTER(PAL);
|
|
|
|
CASE_IDFILTER(PC);
|
2017-06-12 20:59:54 +10:00
|
|
|
CASE_IDFILTER(LP);
|
2015-08-10 17:26:37 +02:00
|
|
|
CASE_IDFILTER(SCE);
|
|
|
|
CASE_IDFILTER(SPK);
|
|
|
|
CASE_IDFILTER(SO);
|
|
|
|
CASE_IDFILTER(TE);
|
|
|
|
CASE_IDFILTER(TXT);
|
|
|
|
CASE_IDFILTER(VF);
|
|
|
|
CASE_IDFILTER(WO);
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef CASE_IDFILTER
|
|
|
|
}
|
|
|
|
|
2016-08-08 17:51:15 +02:00
|
|
|
/**
|
|
|
|
* Convert an idcode into an index (e.g. ID_OB -> INDEX_ID_OB).
|
|
|
|
*/
|
|
|
|
int BKE_idcode_to_index(const short idcode)
|
|
|
|
{
|
|
|
|
#define CASE_IDINDEX(_id) case ID_##_id: return INDEX_ID_##_id
|
|
|
|
|
|
|
|
switch ((ID_Type)idcode) {
|
|
|
|
CASE_IDINDEX(AC);
|
|
|
|
CASE_IDINDEX(AR);
|
|
|
|
CASE_IDINDEX(BR);
|
|
|
|
CASE_IDINDEX(CA);
|
|
|
|
CASE_IDINDEX(CF);
|
|
|
|
CASE_IDINDEX(CU);
|
|
|
|
CASE_IDINDEX(GD);
|
|
|
|
CASE_IDINDEX(GR);
|
|
|
|
CASE_IDINDEX(IM);
|
|
|
|
CASE_IDINDEX(KE);
|
|
|
|
CASE_IDINDEX(IP);
|
|
|
|
CASE_IDINDEX(LA);
|
|
|
|
CASE_IDINDEX(LI);
|
|
|
|
CASE_IDINDEX(LS);
|
|
|
|
CASE_IDINDEX(LT);
|
|
|
|
CASE_IDINDEX(MA);
|
|
|
|
CASE_IDINDEX(MB);
|
|
|
|
CASE_IDINDEX(MC);
|
|
|
|
CASE_IDINDEX(ME);
|
|
|
|
CASE_IDINDEX(MSK);
|
|
|
|
CASE_IDINDEX(NT);
|
|
|
|
CASE_IDINDEX(OB);
|
2016-12-28 17:30:58 +01:00
|
|
|
CASE_IDINDEX(PA);
|
2016-08-08 17:51:15 +02:00
|
|
|
CASE_IDINDEX(PAL);
|
|
|
|
CASE_IDINDEX(PC);
|
2017-06-12 20:59:54 +10:00
|
|
|
CASE_IDINDEX(LP);
|
2016-08-08 17:51:15 +02:00
|
|
|
CASE_IDINDEX(SCE);
|
|
|
|
CASE_IDINDEX(SCR);
|
|
|
|
CASE_IDINDEX(SPK);
|
|
|
|
CASE_IDINDEX(SO);
|
|
|
|
CASE_IDINDEX(TE);
|
|
|
|
CASE_IDINDEX(TXT);
|
|
|
|
CASE_IDINDEX(VF);
|
|
|
|
CASE_IDINDEX(WM);
|
|
|
|
CASE_IDINDEX(WO);
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
CASE_IDINDEX(WS);
|
2016-08-08 17:51:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BLI_assert(0);
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#undef CASE_IDINDEX
|
|
|
|
}
|
|
|
|
|
2019-02-08 14:34:13 +01:00
|
|
|
/**
|
|
|
|
* Get an idcode from an index (e.g. INDEX_ID_OB -> ID_OB).
|
|
|
|
*/
|
|
|
|
short BKE_idcode_from_index(const int index)
|
|
|
|
{
|
|
|
|
#define CASE_IDCODE(_id) case INDEX_ID_##_id: return ID_##_id
|
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
CASE_IDCODE(AC);
|
|
|
|
CASE_IDCODE(AR);
|
|
|
|
CASE_IDCODE(BR);
|
|
|
|
CASE_IDCODE(CA);
|
|
|
|
CASE_IDCODE(CF);
|
|
|
|
CASE_IDCODE(CU);
|
|
|
|
CASE_IDCODE(GD);
|
|
|
|
CASE_IDCODE(GR);
|
|
|
|
CASE_IDCODE(IM);
|
|
|
|
CASE_IDCODE(KE);
|
|
|
|
CASE_IDCODE(IP);
|
|
|
|
CASE_IDCODE(LA);
|
|
|
|
CASE_IDCODE(LI);
|
|
|
|
CASE_IDCODE(LS);
|
|
|
|
CASE_IDCODE(LT);
|
|
|
|
CASE_IDCODE(MA);
|
|
|
|
CASE_IDCODE(MB);
|
|
|
|
CASE_IDCODE(MC);
|
|
|
|
CASE_IDCODE(ME);
|
|
|
|
CASE_IDCODE(MSK);
|
|
|
|
CASE_IDCODE(NT);
|
|
|
|
CASE_IDCODE(OB);
|
|
|
|
CASE_IDCODE(PA);
|
|
|
|
CASE_IDCODE(PAL);
|
|
|
|
CASE_IDCODE(PC);
|
|
|
|
CASE_IDCODE(LP);
|
|
|
|
CASE_IDCODE(SCE);
|
|
|
|
CASE_IDCODE(SCR);
|
|
|
|
CASE_IDCODE(SPK);
|
|
|
|
CASE_IDCODE(SO);
|
|
|
|
CASE_IDCODE(TE);
|
|
|
|
CASE_IDCODE(TXT);
|
|
|
|
CASE_IDCODE(VF);
|
|
|
|
CASE_IDCODE(WM);
|
|
|
|
CASE_IDCODE(WO);
|
|
|
|
CASE_IDCODE(WS);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_assert(0);
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#undef CASE_IDCODE
|
|
|
|
}
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
/**
|
|
|
|
* Convert an idcode into a name (plural).
|
|
|
|
*
|
2016-06-27 13:20:56 +10:00
|
|
|
* \param idcode: The code to convert.
|
2013-03-24 12:13:13 +00:00
|
|
|
* \return A static string representing the name of
|
|
|
|
* the code.
|
|
|
|
*/
|
2015-10-15 16:02:36 +02:00
|
|
|
const char *BKE_idcode_to_name_plural(short idcode)
|
2010-08-10 15:14:19 +00:00
|
|
|
{
|
2015-10-15 16:02:36 +02:00
|
|
|
IDType *idt = idtype_from_code(idcode);
|
2014-01-31 03:09:01 +11:00
|
|
|
BLI_assert(idt);
|
2012-05-12 16:11:34 +00:00
|
|
|
return idt ? idt->plural : NULL;
|
2010-08-10 15:14:19 +00:00
|
|
|
}
|
2011-03-12 14:38:00 +00:00
|
|
|
|
2015-06-09 14:57:29 +02:00
|
|
|
/**
|
|
|
|
* Convert an idcode into its translations' context.
|
|
|
|
*
|
2016-06-27 13:20:56 +10:00
|
|
|
* \param idcode: The code to convert.
|
2015-06-09 14:57:29 +02:00
|
|
|
* \return A static string representing the i18n context of the code.
|
|
|
|
*/
|
2015-10-15 16:02:36 +02:00
|
|
|
const char *BKE_idcode_to_translation_context(short idcode)
|
2015-06-09 14:57:29 +02:00
|
|
|
{
|
2015-10-15 16:02:36 +02:00
|
|
|
IDType *idt = idtype_from_code(idcode);
|
2015-06-09 14:57:29 +02:00
|
|
|
BLI_assert(idt);
|
2015-08-16 17:32:01 +10:00
|
|
|
return idt ? idt->i18n_context : BLT_I18NCONTEXT_DEFAULT;
|
2015-06-09 14:57:29 +02:00
|
|
|
}
|
|
|
|
|
2013-03-24 12:13:13 +00:00
|
|
|
/**
|
|
|
|
* Return an ID code and steps the index forward 1.
|
|
|
|
*
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param index: start as 0.
|
2013-03-24 12:13:13 +00:00
|
|
|
* \return the code, 0 when all codes have been returned.
|
|
|
|
*/
|
2015-10-15 16:02:36 +02:00
|
|
|
short BKE_idcode_iter_step(int *index)
|
2011-03-12 14:38:00 +00:00
|
|
|
{
|
2014-05-18 23:50:44 +10:00
|
|
|
return (*index < ARRAY_SIZE(idtypes)) ? idtypes[(*index)++].code : 0;
|
2011-03-12 14:38:00 +00:00
|
|
|
}
|