Files
test/source/blender/blenkernel/BKE_layer.h
Julian Eisel 7f564d74f9 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:59:37 +02:00

255 lines
13 KiB
C

/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* Contributor(s): Blender Foundation, Dalai Felinto
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BKE_LAYER_H__
#define __BKE_LAYER_H__
/** \file blender/blenkernel/BKE_layer.h
* \ingroup bke
*/
#include "BKE_collection.h"
#ifdef __cplusplus
extern "C" {
#endif
#define TODO_LAYER_SYNC /* syncing of SceneCollection and LayerCollection trees*/
#define TODO_LAYER_SYNC_FILTER /* syncing of filter_objects across all trees */
#define TODO_LAYER_OVERRIDE /* CollectionOverride */
#define TODO_LAYER_CONTEXT /* get/set current (context) SceneLayer */
#define TODO_LAYER_BASE /* BaseLegacy to Base related TODO */
#define TODO_LAYER_OPERATORS /* collection mamanger and property panel operators */
#define TODO_LAYER_DEPSGRAPH /* placeholder for real Depsgraph fix */
#define TODO_LAYER /* generic todo */
#define ROOT_PROP "root"
struct EvaluationContext;
struct LayerCollection;
struct ID;
struct IDProperty;
struct ListBase;
struct Main;
struct Object;
struct Base;
struct RenderEngine;
struct Scene;
struct SceneCollection;
struct SceneLayer;
void BKE_layer_exit(void);
struct SceneLayer *BKE_scene_layer_render_active(const struct Scene *scene);
struct SceneLayer *BKE_scene_layer_context_active_ex(const struct Main *bmain, const struct Scene *scene);
struct SceneLayer *BKE_scene_layer_context_active(const struct Scene *scene);
struct SceneLayer *BKE_scene_layer_add(struct Scene *scene, const char *name);
bool BKE_scene_layer_remove(struct Main *bmain, struct Scene *scene, struct SceneLayer *sl);
void BKE_scene_layer_free(struct SceneLayer *sl);
void BKE_scene_layer_engine_set(struct SceneLayer *sl, const char *engine);
void BKE_scene_layer_selected_objects_tag(struct SceneLayer *sl, const int tag);
struct SceneLayer *BKE_scene_layer_find_from_collection(const struct Scene *scene, struct LayerCollection *lc);
struct Base *BKE_scene_layer_base_find(struct SceneLayer *sl, struct Object *ob);
void BKE_scene_layer_base_deselect_all(struct SceneLayer *sl);
void BKE_scene_layer_base_select(struct SceneLayer *sl, struct Base *selbase);
void BKE_layer_collection_free(struct SceneLayer *sl, struct LayerCollection *lc);
struct LayerCollection *BKE_layer_collection_get_active(struct SceneLayer *sl);
struct LayerCollection *BKE_layer_collection_get_active_ensure(struct Scene *scene, struct SceneLayer *sl);
int BKE_layer_collection_count(struct SceneLayer *sl);
int BKE_layer_collection_findindex(struct SceneLayer *sl, const struct LayerCollection *lc);
bool BKE_layer_collection_move_above(const struct Scene *scene, struct LayerCollection *lc_dst, struct LayerCollection *lc_src);
bool BKE_layer_collection_move_below(const struct Scene *scene, struct LayerCollection *lc_dst, struct LayerCollection *lc_src);
bool BKE_layer_collection_move_into(const struct Scene *scene, struct LayerCollection *lc_dst, struct LayerCollection *lc_src);
void BKE_layer_collection_resync(const struct Scene *scene, const struct SceneCollection *sc);
struct LayerCollection *BKE_collection_link(struct SceneLayer *sl, struct SceneCollection *sc);
void BKE_collection_unlink(struct SceneLayer *sl, struct LayerCollection *lc);
bool BKE_scene_layer_has_collection(struct SceneLayer *sl, const struct SceneCollection *sc);
bool BKE_scene_has_object(struct Scene *scene, struct Object *ob);
/* syncing */
void BKE_layer_sync_new_scene_collection(struct Scene *scene, const struct SceneCollection *sc_parent, struct SceneCollection *sc);
void BKE_layer_sync_object_link(const struct Scene *scene, struct SceneCollection *sc, struct Object *ob);
void BKE_layer_sync_object_unlink(const struct Scene *scene, struct SceneCollection *sc, struct Object *ob);
/* override */
void BKE_collection_override_datablock_add(struct LayerCollection *lc, const char *data_path, struct ID *id);
/* engine settings */
typedef void (*EngineSettingsCB)(struct RenderEngine *engine, struct IDProperty *props);
struct IDProperty *BKE_layer_collection_engine_evaluated_get(struct Object *ob, const int type, const char *engine_name);
struct IDProperty *BKE_layer_collection_engine_collection_get(struct LayerCollection *lc, const int type, const char *engine_name);
struct IDProperty *BKE_layer_collection_engine_scene_get(struct Scene *scene, const int type, const char *engine_name);
void BKE_layer_collection_engine_settings_callback_register(struct Main *bmain, const char *engine_name, EngineSettingsCB func);
void BKE_layer_collection_engine_settings_callback_free(void);
void BKE_layer_collection_engine_settings_create(struct IDProperty *root);
void BKE_layer_collection_engine_settings_validate_scene(struct Scene *scene);
void BKE_layer_collection_engine_settings_validate_collection(struct LayerCollection *lc);
struct IDProperty *BKE_scene_layer_engine_evaluated_get(struct SceneLayer *sl, const int type, const char *engine_name);
struct IDProperty *BKE_scene_layer_engine_layer_get(struct SceneLayer *sl, const int type, const char *engine_name);
struct IDProperty *BKE_scene_layer_engine_scene_get(struct Scene *scene, const int type, const char *engine_name);
void BKE_scene_layer_engine_settings_callback_register(struct Main *bmain, const char *engine_name, EngineSettingsCB func);
void BKE_scene_layer_engine_settings_callback_free(void);
void BKE_scene_layer_engine_settings_validate_scene(struct Scene *scene);
void BKE_scene_layer_engine_settings_validate_layer(struct SceneLayer *sl);
void BKE_scene_layer_engine_settings_create(struct IDProperty *root);
void BKE_collection_engine_property_add_float(struct IDProperty *props, const char *name, float value);
void BKE_collection_engine_property_add_float_array(
struct IDProperty *props, const char *name, const float *values, const int array_length);
void BKE_collection_engine_property_add_int(struct IDProperty *props, const char *name, int value);
void BKE_collection_engine_property_add_bool(struct IDProperty *props, const char *name, bool value);
int BKE_collection_engine_property_value_get_int(struct IDProperty *props, const char *name);
float BKE_collection_engine_property_value_get_float(struct IDProperty *props, const char *name);
const float *BKE_collection_engine_property_value_get_float_array(struct IDProperty *props, const char *name);
bool BKE_collection_engine_property_value_get_bool(struct IDProperty *props, const char *name);
void BKE_collection_engine_property_value_set_int(struct IDProperty *props, const char *name, int value);
void BKE_collection_engine_property_value_set_float(struct IDProperty *props, const char *name, float value);
void BKE_collection_engine_property_value_set_float_array(struct IDProperty *props, const char *name, const float *values);
void BKE_collection_engine_property_value_set_bool(struct IDProperty *props, const char *name, bool value);
/* evaluation */
void BKE_layer_eval_layer_collection_pre(struct EvaluationContext *eval_ctx,
struct Scene *scene,
struct SceneLayer *scene_layer);
void BKE_layer_eval_layer_collection(struct EvaluationContext *eval_ctx,
struct LayerCollection *layer_collection,
struct LayerCollection *parent_layer_collection);
void BKE_layer_eval_layer_collection_post(struct EvaluationContext *eval_ctx,
struct SceneLayer *scene_layer);
/* iterators */
void BKE_selected_objects_iterator_begin(BLI_Iterator *iter, void *data_in);
void BKE_selected_objects_iterator_next(BLI_Iterator *iter);
void BKE_selected_objects_iterator_end(BLI_Iterator *iter);
void BKE_visible_objects_iterator_begin(BLI_Iterator *iter, void *data_in);
void BKE_visible_objects_iterator_next(BLI_Iterator *iter);
void BKE_visible_objects_iterator_end(BLI_Iterator *iter);
void BKE_selected_bases_iterator_begin(BLI_Iterator *iter, void *data_in);
void BKE_selected_bases_iterator_next(BLI_Iterator *iter);
void BKE_selected_bases_iterator_end(BLI_Iterator *iter);
void BKE_visible_bases_iterator_begin(BLI_Iterator *iter, void *data_in);
void BKE_visible_bases_iterator_next(BLI_Iterator *iter);
void BKE_visible_bases_iterator_end(BLI_Iterator *iter);
#define FOREACH_SELECTED_OBJECT(sl, _instance) \
ITER_BEGIN(BKE_selected_objects_iterator_begin, \
BKE_selected_objects_iterator_next, \
BKE_selected_objects_iterator_end, \
sl, Object *, _instance)
#define FOREACH_SELECTED_OBJECT_END \
ITER_END
#define FOREACH_VISIBLE_OBJECT(sl, _instance) \
ITER_BEGIN(BKE_visible_objects_iterator_begin, \
BKE_visible_objects_iterator_next, \
BKE_visible_objects_iterator_end, \
sl, Object *, _instance)
#define FOREACH_VISIBLE_OBJECT_END \
ITER_END
#define FOREACH_SELECTED_BASE(sl, _instance) \
ITER_BEGIN(BKE_selected_bases_iterator_begin, \
BKE_selected_bases_iterator_next, \
BKE_selected_bases_iterator_end, \
sl, Base *, _instance)
#define FOREACH_SELECTED_BASE_END \
ITER_END
#define FOREACH_VISIBLE_BASE(sl, _instance) \
ITER_BEGIN(BKE_visible_bases_iterator_begin, \
BKE_visible_bases_iterator_next, \
BKE_visible_bases_iterator_end, \
sl, Base *, _instance)
#define FOREACH_VISIBLE_BASE_END \
ITER_END
#define FOREACH_OBJECT(sl, _instance) \
{ \
Object *_instance; \
Base *base; \
for (base = (sl)->object_bases.first; base; base = base->next) { \
_instance = base->object;
#define FOREACH_OBJECT_END \
} \
}
#define FOREACH_OBJECT_FLAG(scene, sl, flag, _instance) \
{ \
IteratorBeginCb func_begin; \
IteratorCb func_next, func_end; \
void *data_in; \
\
if (flag == SELECT) { \
func_begin = &BKE_selected_objects_iterator_begin; \
func_next = &BKE_selected_objects_iterator_next; \
func_end = &BKE_selected_objects_iterator_end; \
data_in = (sl); \
} \
else { \
func_begin = BKE_scene_objects_iterator_begin; \
func_next = BKE_scene_objects_iterator_next; \
func_end = BKE_scene_objects_iterator_end; \
data_in = (scene); \
} \
ITER_BEGIN(func_begin, func_next, func_end, data_in, Object *, _instance)
#define FOREACH_OBJECT_FLAG_END \
ITER_END \
}
#ifdef __cplusplus
}
#endif
#endif /* __BKE_LAYER_H__ */