2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2008-12-18 02:56:48 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup bke
|
2011-02-27 20:40:57 +00:00
|
|
|
*/
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
#include <cstddef>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <cstring>
|
2010-08-22 14:15:28 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2018-08-29 15:32:50 +02:00
|
|
|
#include "DNA_collection_types.h"
|
2023-03-13 10:42:51 +01:00
|
|
|
#include "DNA_gpencil_legacy_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_linestyle_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_space_types.h"
|
2009-01-17 18:35:33 +00:00
|
|
|
#include "DNA_view3d_types.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "DNA_windowmanager_types.h"
|
2017-06-13 12:02:08 +02:00
|
|
|
#include "DNA_workspace_types.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
|
2023-09-22 03:18:17 +02:00
|
|
|
#include "DEG_depsgraph.hh"
|
2017-04-04 13:07:41 +02:00
|
|
|
|
2008-12-23 02:07:13 +00:00
|
|
|
#include "BLI_listbase.h"
|
2009-05-28 23:13:42 +00:00
|
|
|
#include "BLI_string.h"
|
2012-11-16 15:15:40 +00:00
|
|
|
#include "BLI_threads.h"
|
2012-05-19 13:28:19 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-23 02:07:13 +00:00
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2013-02-19 15:45:56 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
#include "BKE_layer.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_main.h"
|
2017-07-13 15:43:36 +02:00
|
|
|
#include "BKE_scene.h"
|
2023-09-25 17:48:21 -04:00
|
|
|
#include "BKE_screen.hh"
|
2016-10-22 15:00:32 +02:00
|
|
|
#include "BKE_sound.h"
|
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
|
|
|
#include "BKE_workspace.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
|
2017-10-16 17:15:03 -02:00
|
|
|
#include "RE_engine.h"
|
|
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_access.hh"
|
2022-03-14 16:54:46 +01:00
|
|
|
#include "RNA_prototypes.h"
|
2013-03-07 02:44:55 +00:00
|
|
|
|
2019-02-01 12:44:19 +11:00
|
|
|
#include "CLG_log.h"
|
|
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2013-03-07 02:44:55 +00:00
|
|
|
# include "BPY_extern.h"
|
2010-01-23 20:43:55 +00:00
|
|
|
#endif
|
2009-11-10 16:18:54 +00:00
|
|
|
|
2019-02-01 12:44:19 +11:00
|
|
|
static CLG_LogRef LOG = {"bke.context"};
|
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
/* struct */
|
|
|
|
|
|
|
|
|
|
struct bContext {
|
|
|
|
|
int thread;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
/* windowmanager context */
|
|
|
|
|
struct {
|
2022-12-18 14:40:30 -06:00
|
|
|
wmWindowManager *manager;
|
|
|
|
|
wmWindow *window;
|
|
|
|
|
WorkSpace *workspace;
|
|
|
|
|
bScreen *screen;
|
|
|
|
|
ScrArea *area;
|
|
|
|
|
ARegion *region;
|
|
|
|
|
ARegion *menu;
|
|
|
|
|
wmGizmoGroup *gizmo_group;
|
2023-08-31 11:59:58 -04:00
|
|
|
const bContextStore *store;
|
2021-04-20 11:42:00 +10:00
|
|
|
|
|
|
|
|
/* Operator poll. */
|
|
|
|
|
/**
|
|
|
|
|
* Store the reason the poll function fails (static string, not allocated).
|
|
|
|
|
* For more advanced formatting use `operator_poll_msg_dyn_params`.
|
|
|
|
|
*/
|
|
|
|
|
const char *operator_poll_msg;
|
2021-04-20 11:57:28 +10:00
|
|
|
/**
|
|
|
|
|
* Store values to dynamically to create the string (called when a tool-tip is shown).
|
|
|
|
|
*/
|
2023-06-03 08:36:28 +10:00
|
|
|
bContextPollMsgDyn_Params operator_poll_msg_dyn_params;
|
2008-12-18 02:56:48 +00:00
|
|
|
} wm;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
/* data context */
|
|
|
|
|
struct {
|
2022-12-18 14:40:30 -06:00
|
|
|
Main *main;
|
|
|
|
|
Scene *scene;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-23 02:07:13 +00:00
|
|
|
int recursion;
|
2019-08-16 04:54:10 +10:00
|
|
|
/** True if python is initialized. */
|
|
|
|
|
bool py_init;
|
2009-10-29 09:25:11 +00:00
|
|
|
void *py_context;
|
2020-09-17 18:23:12 +10:00
|
|
|
/**
|
|
|
|
|
* If we need to remove members, do so in a copy
|
|
|
|
|
* (keep this to check if the copy needs freeing).
|
|
|
|
|
*/
|
|
|
|
|
void *py_context_orig;
|
2008-12-18 02:56:48 +00:00
|
|
|
} data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* context */
|
|
|
|
|
|
2023-07-02 19:37:22 +10:00
|
|
|
bContext *CTX_create()
|
2008-12-18 02:56:48 +00:00
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
bContext *C = MEM_cnew<bContext>(__func__);
|
2008-12-18 02:56:48 +00:00
|
|
|
|
|
|
|
|
return C;
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-25 20:49:15 +00:00
|
|
|
bContext *CTX_copy(const bContext *C)
|
2008-12-18 02:56:48 +00:00
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
bContext *newC = MEM_new<bContext>(__func__);
|
|
|
|
|
*newC = *C;
|
2008-12-18 02:56:48 +00:00
|
|
|
|
2021-04-20 11:57:28 +10:00
|
|
|
memset(&newC->wm.operator_poll_msg_dyn_params, 0, sizeof(newC->wm.operator_poll_msg_dyn_params));
|
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
return newC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CTX_free(bContext *C)
|
|
|
|
|
{
|
2021-04-20 11:57:28 +10:00
|
|
|
/* This may contain a dynamically allocated message, free. */
|
|
|
|
|
CTX_wm_operator_poll_msg_clear(C);
|
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
MEM_freeN(C);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-28 23:13:42 +00:00
|
|
|
/* store */
|
|
|
|
|
|
2023-08-31 10:46:53 -04:00
|
|
|
bContextStore *CTX_store_add(blender::Vector<std::unique_ptr<bContextStore>> &contexts,
|
2022-12-18 19:13:15 -06:00
|
|
|
const blender::StringRefNull name,
|
|
|
|
|
const PointerRNA *ptr)
|
2009-05-28 23:13:42 +00:00
|
|
|
{
|
|
|
|
|
/* ensure we have a context to put the entry in, if it was already used
|
|
|
|
|
* we have to copy the context to ensure */
|
2023-08-31 10:46:53 -04:00
|
|
|
if (contexts.is_empty()) {
|
|
|
|
|
contexts.append(std::make_unique<bContextStore>());
|
|
|
|
|
}
|
|
|
|
|
else if (contexts.last()->used) {
|
|
|
|
|
auto new_ctx = std::make_unique<bContextStore>(bContextStore{contexts.last()->entries, false});
|
|
|
|
|
contexts.append(std::move(new_ctx));
|
2009-05-28 23:13:42 +00:00
|
|
|
}
|
|
|
|
|
|
2023-08-31 10:46:53 -04:00
|
|
|
bContextStore *ctx = contexts.last().get();
|
2022-12-18 19:13:15 -06:00
|
|
|
ctx->entries.append(bContextStoreEntry{name, *ptr});
|
2009-05-28 23:13:42 +00:00
|
|
|
return ctx;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 10:46:53 -04:00
|
|
|
bContextStore *CTX_store_add_all(blender::Vector<std::unique_ptr<bContextStore>> &contexts,
|
2023-08-31 11:59:58 -04:00
|
|
|
const bContextStore *context)
|
2012-04-03 15:18:59 +00:00
|
|
|
{
|
2023-08-31 10:46:53 -04:00
|
|
|
/* ensure we have a context to put the entry in, if it was already used
|
2012-04-03 15:18:59 +00:00
|
|
|
* we have to copy the context to ensure */
|
2023-08-31 10:46:53 -04:00
|
|
|
if (contexts.is_empty()) {
|
|
|
|
|
contexts.append(std::make_unique<bContextStore>());
|
|
|
|
|
}
|
|
|
|
|
else if (contexts.last()->used) {
|
|
|
|
|
auto new_ctx = std::make_unique<bContextStore>(bContextStore{contexts.last()->entries, false});
|
|
|
|
|
contexts.append(std::move(new_ctx));
|
2012-04-03 15:18:59 +00:00
|
|
|
}
|
|
|
|
|
|
2023-08-31 10:46:53 -04:00
|
|
|
bContextStore *ctx = contexts.last().get();
|
2022-12-18 19:13:15 -06:00
|
|
|
for (const bContextStoreEntry &src_entry : context->entries) {
|
|
|
|
|
ctx->entries.append(src_entry);
|
2012-04-03 15:18:59 +00:00
|
|
|
}
|
|
|
|
|
return ctx;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 11:59:58 -04:00
|
|
|
const bContextStore *CTX_store_get(const bContext *C)
|
2020-12-11 22:20:31 +01:00
|
|
|
{
|
|
|
|
|
return C->wm.store;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 11:59:58 -04:00
|
|
|
void CTX_store_set(bContext *C, const bContextStore *store)
|
2009-05-28 23:13:42 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
C->wm.store = store;
|
2009-05-28 23:13:42 +00:00
|
|
|
}
|
|
|
|
|
|
2022-04-26 22:23:52 +02:00
|
|
|
const PointerRNA *CTX_store_ptr_lookup(const bContextStore *store,
|
2022-12-18 19:13:15 -06:00
|
|
|
const blender::StringRefNull name,
|
2022-04-26 22:23:52 +02:00
|
|
|
const StructRNA *type)
|
|
|
|
|
{
|
2022-12-18 19:13:15 -06:00
|
|
|
for (auto entry = store->entries.rbegin(); entry != store->entries.rend(); ++entry) {
|
|
|
|
|
if (entry->name == name) {
|
2022-12-23 12:04:56 +01:00
|
|
|
if (!type || (type && RNA_struct_is_a(entry->ptr.type, type))) {
|
2022-12-18 19:13:15 -06:00
|
|
|
return &entry->ptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-26 22:23:52 +02:00
|
|
|
}
|
2022-12-18 19:13:15 -06:00
|
|
|
return nullptr;
|
2022-04-26 22:23:52 +02:00
|
|
|
}
|
|
|
|
|
|
2018-09-24 17:27:41 +02:00
|
|
|
/* is python initialized? */
|
2012-05-02 12:14:27 +00:00
|
|
|
|
2019-08-16 04:54:10 +10:00
|
|
|
bool CTX_py_init_get(bContext *C)
|
2009-07-18 19:40:26 +00:00
|
|
|
{
|
|
|
|
|
return C->data.py_init;
|
|
|
|
|
}
|
2019-08-16 04:54:10 +10:00
|
|
|
void CTX_py_init_set(bContext *C, bool value)
|
2009-07-18 19:40:26 +00:00
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
C->data.py_init = value;
|
2009-07-18 19:40:26 +00:00
|
|
|
}
|
|
|
|
|
|
2010-12-07 04:12:15 +00:00
|
|
|
void *CTX_py_dict_get(const bContext *C)
|
2009-10-29 09:25:11 +00:00
|
|
|
{
|
|
|
|
|
return C->data.py_context;
|
|
|
|
|
}
|
2020-09-17 18:23:12 +10:00
|
|
|
void *CTX_py_dict_get_orig(const bContext *C)
|
2009-10-29 09:25:11 +00:00
|
|
|
{
|
2020-09-17 18:23:12 +10:00
|
|
|
return C->data.py_context_orig;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
void CTX_py_state_push(bContext *C, bContext_PyState *pystate, void *value)
|
2020-09-17 18:23:12 +10:00
|
|
|
{
|
|
|
|
|
pystate->py_context = C->data.py_context;
|
|
|
|
|
pystate->py_context_orig = C->data.py_context_orig;
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
C->data.py_context = value;
|
2020-09-17 18:23:12 +10:00
|
|
|
C->data.py_context_orig = value;
|
|
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
void CTX_py_state_pop(bContext *C, bContext_PyState *pystate)
|
2020-09-17 18:23:12 +10:00
|
|
|
{
|
|
|
|
|
C->data.py_context = pystate->py_context;
|
|
|
|
|
C->data.py_context_orig = pystate->py_context_orig;
|
2009-10-29 09:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
/* data context utility functions */
|
|
|
|
|
|
2008-12-23 02:07:13 +00:00
|
|
|
struct bContextDataResult {
|
2009-03-19 19:03:38 +00:00
|
|
|
PointerRNA ptr;
|
2008-12-23 02:07:13 +00:00
|
|
|
ListBase list;
|
2023-04-29 20:31:27 -07:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
int index;
|
2009-06-20 14:55:28 +00:00
|
|
|
const char **dir;
|
2010-04-24 19:26:05 +00:00
|
|
|
short type; /* 0: normal, 1: seq */
|
2008-12-23 02:07:13 +00:00
|
|
|
};
|
2008-12-18 02:56:48 +00:00
|
|
|
|
2014-04-22 23:05:58 +10:00
|
|
|
static void *ctx_wm_python_context_get(const bContext *C,
|
|
|
|
|
const char *member,
|
|
|
|
|
const StructRNA *member_type,
|
|
|
|
|
void *fall_through)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
|
|
|
|
#ifdef WITH_PYTHON
|
2012-10-25 03:10:35 +00:00
|
|
|
if (UNLIKELY(C && CTX_py_dict_get(C))) {
|
|
|
|
|
bContextDataResult result;
|
2012-05-02 12:14:27 +00:00
|
|
|
memset(&result, 0, sizeof(bContextDataResult));
|
2012-05-06 17:22:54 +00:00
|
|
|
BPY_context_member_get((bContext *)C, member, &result);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-04-22 23:05:58 +10:00
|
|
|
if (result.ptr.data) {
|
|
|
|
|
if (RNA_struct_is_a(result.ptr.type, member_type)) {
|
|
|
|
|
return result.ptr.data;
|
|
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
|
|
|
|
CLOG_WARN(&LOG,
|
|
|
|
|
"PyContext '%s' is a '%s', expected a '%s'",
|
|
|
|
|
member,
|
|
|
|
|
RNA_struct_identifier(result.ptr.type),
|
|
|
|
|
RNA_struct_identifier(member_type));
|
2014-04-22 23:05:58 +10:00
|
|
|
}
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
2012-07-29 17:49:14 +00:00
|
|
|
#else
|
2014-11-24 12:01:51 +01:00
|
|
|
UNUSED_VARS(C, member, member_type);
|
2012-05-02 12:14:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
2012-11-16 15:15:40 +00:00
|
|
|
/* don't allow UI context access from non-main threads */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_thread_is_main()) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-11-16 15:15:40 +00:00
|
|
|
|
2012-05-02 12:14:27 +00:00
|
|
|
return fall_through;
|
|
|
|
|
}
|
|
|
|
|
|
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
2020-10-02 18:56:25 +02:00
|
|
|
static eContextResult ctx_data_get(bContext *C, const char *member, bContextDataResult *result)
|
2008-12-23 02:07:13 +00:00
|
|
|
{
|
2020-04-03 14:23:21 +02:00
|
|
|
bScreen *screen;
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area;
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region;
|
2014-04-01 11:34:00 +11:00
|
|
|
int done = 0, recursion = C->data.recursion;
|
2012-05-06 17:22:54 +00:00
|
|
|
int ret = 0;
|
2008-12-18 02:56:48 +00:00
|
|
|
|
2008-12-23 02:07:13 +00:00
|
|
|
memset(result, 0, sizeof(bContextDataResult));
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2012-03-24 06:18:31 +00:00
|
|
|
if (CTX_py_dict_get(C)) {
|
2013-06-10 12:17:36 +00:00
|
|
|
if (BPY_context_member_get(C, member, result)) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return CTX_RESULT_OK;
|
2013-06-10 12:17:36 +00:00
|
|
|
}
|
2009-10-29 09:25:11 +00:00
|
|
|
}
|
2010-01-23 20:43:55 +00:00
|
|
|
#endif
|
2012-11-16 15:15:40 +00:00
|
|
|
|
|
|
|
|
/* don't allow UI context access from non-main threads */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!BLI_thread_is_main()) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return CTX_RESULT_MEMBER_NOT_FOUND;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-23 02:07:13 +00:00
|
|
|
/* we check recursion to ensure that we do not get infinite
|
2014-06-09 11:01:51 +10:00
|
|
|
* loops requesting data from ourselves in a context callback */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-10 15:09:53 +00:00
|
|
|
/* Ok, this looks evil...
|
2012-05-27 19:40:36 +00:00
|
|
|
* if (ret) done = -(-ret | -done);
|
2009-11-10 15:09:53 +00:00
|
|
|
*
|
|
|
|
|
* Values in order of importance
|
|
|
|
|
* (0, -1, 1) - Where 1 is highest priority
|
2021-01-20 15:15:38 +11:00
|
|
|
*/
|
2012-05-06 17:22:54 +00:00
|
|
|
if (done != 1 && recursion < 1 && C->wm.store) {
|
|
|
|
|
C->data.recursion = 1;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
const PointerRNA *ptr = CTX_store_ptr_lookup(C->wm.store, member, nullptr);
|
2020-10-17 16:30:56 -05:00
|
|
|
|
2022-04-26 22:23:52 +02:00
|
|
|
if (ptr) {
|
|
|
|
|
result->ptr = *ptr;
|
2014-04-01 11:34:00 +11:00
|
|
|
done = 1;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-05-28 23:13:42 +00:00
|
|
|
}
|
2020-03-06 16:56:42 +01:00
|
|
|
if (done != 1 && recursion < 2 && (region = CTX_wm_region(C))) {
|
2012-05-06 17:22:54 +00:00
|
|
|
C->data.recursion = 2;
|
2020-03-06 16:56:42 +01:00
|
|
|
if (region->type && region->type->context) {
|
|
|
|
|
ret = region->type->context(C, member, result);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ret) {
|
2012-05-06 17:22:54 +00:00
|
|
|
done = -(-ret | -done);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-11-10 15:09:53 +00:00
|
|
|
}
|
2020-04-03 13:25:03 +02:00
|
|
|
if (done != 1 && recursion < 3 && (area = CTX_wm_area(C))) {
|
2012-05-06 17:22:54 +00:00
|
|
|
C->data.recursion = 3;
|
2020-04-03 13:25:03 +02:00
|
|
|
if (area->type && area->type->context) {
|
|
|
|
|
ret = area->type->context(C, member, result);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ret) {
|
2012-05-06 17:22:54 +00:00
|
|
|
done = -(-ret | -done);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-11-10 15:09:53 +00:00
|
|
|
}
|
2008-12-23 02:07:13 +00:00
|
|
|
}
|
2020-10-17 16:30:56 -05:00
|
|
|
|
2020-04-03 14:23:21 +02:00
|
|
|
if (done != 1 && recursion < 4 && (screen = CTX_wm_screen(C))) {
|
2022-12-18 14:40:30 -06:00
|
|
|
bContextDataCallback cb = reinterpret_cast<bContextDataCallback>(screen->context);
|
2012-05-06 17:22:54 +00:00
|
|
|
C->data.recursion = 4;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (cb) {
|
2009-11-10 15:09:53 +00:00
|
|
|
ret = cb(C, member, result);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ret) {
|
2012-05-06 17:22:54 +00:00
|
|
|
done = -(-ret | -done);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-11-10 15:09:53 +00:00
|
|
|
}
|
2008-12-23 02:07:13 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
C->data.recursion = recursion;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
return eContextResult(done);
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
2009-03-19 19:03:38 +00:00
|
|
|
static void *ctx_data_pointer_get(const bContext *C, const char *member)
|
2008-12-18 02:56:48 +00:00
|
|
|
{
|
|
|
|
|
bContextDataResult result;
|
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
2020-10-02 18:56:25 +02:00
|
|
|
if (C && ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
|
2012-12-28 10:08:17 +00:00
|
|
|
BLI_assert(result.type == CTX_DATA_TYPE_POINTER);
|
2009-03-19 19:03:38 +00:00
|
|
|
return result.ptr.data;
|
2012-12-28 10:08:17 +00:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
static bool ctx_data_pointer_verify(const bContext *C, const char *member, void **pointer)
|
2008-12-18 02:56:48 +00:00
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
/* if context is nullptr, pointer must be nullptr too and that is a valid return */
|
|
|
|
|
if (C == nullptr) {
|
|
|
|
|
*pointer = nullptr;
|
2022-11-01 15:18:53 +01:00
|
|
|
return true;
|
2010-01-27 20:12:54 +00:00
|
|
|
}
|
2020-10-17 16:30:56 -05:00
|
|
|
|
|
|
|
|
bContextDataResult result;
|
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
2020-10-02 18:56:25 +02:00
|
|
|
if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
|
2012-12-28 10:08:17 +00:00
|
|
|
BLI_assert(result.type == CTX_DATA_TYPE_POINTER);
|
2012-05-06 17:22:54 +00:00
|
|
|
*pointer = result.ptr.data;
|
2022-11-01 15:18:53 +01:00
|
|
|
return true;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
*pointer = nullptr;
|
2022-11-01 15:18:53 +01:00
|
|
|
return false;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
static bool ctx_data_collection_get(const bContext *C, const char *member, ListBase *list)
|
2008-12-18 02:56:48 +00:00
|
|
|
{
|
|
|
|
|
bContextDataResult result;
|
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
2020-10-02 18:56:25 +02:00
|
|
|
if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
|
2012-12-28 10:08:17 +00:00
|
|
|
BLI_assert(result.type == CTX_DATA_TYPE_COLLECTION);
|
2012-05-06 17:22:54 +00:00
|
|
|
*list = result.list;
|
2022-11-01 15:18:53 +01:00
|
|
|
return true;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(list);
|
2009-06-28 11:37:45 +00:00
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
return false;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
2019-05-21 10:49:05 -03:00
|
|
|
static int ctx_data_base_collection_get(const bContext *C, const char *member, ListBase *list)
|
|
|
|
|
{
|
|
|
|
|
ListBase ctx_object_list;
|
2019-05-24 09:49:40 -03:00
|
|
|
if ((ctx_data_collection_get(C, member, &ctx_object_list) == false) ||
|
|
|
|
|
BLI_listbase_is_empty(&ctx_object_list))
|
|
|
|
|
{
|
|
|
|
|
BLI_listbase_clear(list);
|
2019-05-21 10:49:05 -03:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bContextDataResult result;
|
|
|
|
|
memset(&result, 0, sizeof(bContextDataResult));
|
|
|
|
|
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
2019-05-21 10:49:05 -03:00
|
|
|
|
2020-10-17 16:30:56 -05:00
|
|
|
bool ok = false;
|
|
|
|
|
|
2019-05-21 10:49:05 -03:00
|
|
|
CollectionPointerLink *ctx_object;
|
2022-12-18 14:40:30 -06:00
|
|
|
for (ctx_object = static_cast<CollectionPointerLink *>(ctx_object_list.first); ctx_object;
|
|
|
|
|
ctx_object = ctx_object->next)
|
|
|
|
|
{
|
|
|
|
|
Object *ob = static_cast<Object *>(ctx_object->ptr.data);
|
2019-05-21 10:49:05 -03:00
|
|
|
Base *base = BKE_view_layer_base_find(view_layer, ob);
|
2022-12-18 14:40:30 -06:00
|
|
|
if (base != nullptr) {
|
2019-05-21 10:49:05 -03:00
|
|
|
CTX_data_list_add(&result, &scene->id, &RNA_ObjectBase, base);
|
|
|
|
|
ok = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CTX_data_type_set(&result, CTX_DATA_TYPE_COLLECTION);
|
|
|
|
|
BLI_freelistN(&ctx_object_list);
|
|
|
|
|
|
|
|
|
|
*list = result.list;
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-20 14:55:28 +00:00
|
|
|
PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
|
2008-12-23 02:07:13 +00:00
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
bContextDataResult result;
|
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
2020-10-02 18:56:25 +02:00
|
|
|
if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
|
2012-12-28 10:08:17 +00:00
|
|
|
BLI_assert(result.type == CTX_DATA_TYPE_POINTER);
|
2009-03-19 19:03:38 +00:00
|
|
|
return result.ptr;
|
2012-12-28 09:48:35 +00:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
|
|
|
|
return PointerRNA_NULL;
|
2009-06-24 14:03:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr = CTX_data_pointer_get(C, member);
|
2009-03-19 19:03:38 +00:00
|
|
|
|
2012-07-24 10:28:29 +00:00
|
|
|
if (ptr.data) {
|
|
|
|
|
if (RNA_struct_is_a(ptr.type, type)) {
|
|
|
|
|
return ptr;
|
|
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
|
|
|
|
CLOG_WARN(&LOG,
|
|
|
|
|
"member '%s' is '%s', not '%s'",
|
|
|
|
|
member,
|
|
|
|
|
RNA_struct_identifier(ptr.type),
|
|
|
|
|
RNA_struct_identifier(type));
|
2012-07-24 10:28:29 +00:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2009-06-24 14:03:55 +00:00
|
|
|
return PointerRNA_NULL;
|
2008-12-23 02:07:13 +00:00
|
|
|
}
|
|
|
|
|
|
2019-11-16 20:50:59 +03:00
|
|
|
PointerRNA CTX_data_pointer_get_type_silent(const bContext *C, const char *member, StructRNA *type)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr = CTX_data_pointer_get(C, member);
|
|
|
|
|
|
|
|
|
|
if (ptr.data && RNA_struct_is_a(ptr.type, type)) {
|
|
|
|
|
return ptr;
|
|
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
|
|
|
|
return PointerRNA_NULL;
|
2019-11-16 20:50:59 +03:00
|
|
|
}
|
|
|
|
|
|
2009-06-20 14:55:28 +00:00
|
|
|
ListBase CTX_data_collection_get(const bContext *C, const char *member)
|
2008-12-23 02:07:13 +00:00
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
bContextDataResult result;
|
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
2020-10-02 18:56:25 +02:00
|
|
|
if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
|
2012-12-28 10:08:17 +00:00
|
|
|
BLI_assert(result.type == CTX_DATA_TYPE_COLLECTION);
|
2009-03-19 19:03:38 +00:00
|
|
|
return result.list;
|
|
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
ListBase list = {nullptr, nullptr};
|
2020-08-07 12:30:43 +02:00
|
|
|
return list;
|
2009-03-19 19:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
Anim: move bone colors from bone groups to individual bones
Move control over the color of bones from bone groups to the bones
themselves. Instead of using bone groups (which are defined on the pose,
and thus owned by the object), the color is stored on:
- the bone (`struct Bone`, or RNA `armature.bones['bone_name'].color`)
- a possible override on the pose bone (`struct bPoseChannel`, or RNA
`ob.pose.bones['bone_name'].color`).
When the pose bone is set to its default color, the color is determined
by the armature bone. In armature edit mode, the armature bone colors
are always used, as then the pose data is unavailable.
Versioning code converts bone group colors to bone colors. If the
Armature has a single user, the group color is stored on the bones
directly. If it has multiple users, the group colors will be stored on
the pose bones instead.
The bone group color is not removed from DNA for forward compatibility,
that is, to avoid immediate dataloss when saving a 3.6 file with 4.0.
This is part of the replacement of bone groups & armature layers with
bone collections. See the design task at #108941.
Pull request: https://projects.blender.org/blender/blender/pulls/109976
2023-08-22 11:11:52 +02:00
|
|
|
void CTX_data_collection_remap_property(ListBase /*CollectionPointerLink*/ collection_pointers,
|
|
|
|
|
const char *propname)
|
|
|
|
|
{
|
|
|
|
|
LISTBASE_FOREACH (CollectionPointerLink *, link, &collection_pointers) {
|
|
|
|
|
PointerRNA original_ptr = link->ptr;
|
|
|
|
|
PointerRNA remapped_ptr = RNA_pointer_get(&original_ptr, propname);
|
|
|
|
|
link->ptr = remapped_ptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-27 15:10:56 +10:00
|
|
|
int /*eContextResult*/ CTX_data_get(const bContext *C,
|
|
|
|
|
const char *member,
|
|
|
|
|
PointerRNA *r_ptr,
|
|
|
|
|
ListBase *r_lb,
|
|
|
|
|
PropertyRNA **r_prop,
|
|
|
|
|
int *r_index,
|
|
|
|
|
short *r_type)
|
2009-03-19 19:03:38 +00:00
|
|
|
{
|
|
|
|
|
bContextDataResult result;
|
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
2020-10-02 18:56:25 +02:00
|
|
|
eContextResult ret = ctx_data_get((bContext *)C, member, &result);
|
2009-03-19 19:03:38 +00:00
|
|
|
|
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
2020-10-02 18:56:25 +02:00
|
|
|
if (ret == CTX_RESULT_OK) {
|
2012-05-06 17:22:54 +00:00
|
|
|
*r_ptr = result.ptr;
|
|
|
|
|
*r_lb = result.list;
|
2023-04-29 20:31:27 -07:00
|
|
|
*r_prop = result.prop;
|
|
|
|
|
*r_index = result.index;
|
2012-05-06 17:22:54 +00:00
|
|
|
*r_type = result.type;
|
2009-03-19 19:03:38 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
memset(r_ptr, 0, sizeof(*r_ptr));
|
|
|
|
|
memset(r_lb, 0, sizeof(*r_lb));
|
2012-05-06 17:22:54 +00:00
|
|
|
*r_type = 0;
|
2009-03-19 19:03:38 +00:00
|
|
|
}
|
2009-11-10 15:09:53 +00:00
|
|
|
|
|
|
|
|
return ret;
|
2009-03-19 19:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
static void data_dir_add(ListBase *lb, const char *member, const bool use_all)
|
2009-06-20 14:55:28 +00:00
|
|
|
{
|
|
|
|
|
LinkData *link;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((use_all == false) && STREQ(member, "scene")) { /* exception */
|
2009-06-20 14:55:28 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-06-20 14:55:28 +00:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (BLI_findstring(lb, member, offsetof(LinkData, data))) {
|
2010-08-22 14:15:28 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
link = MEM_cnew<LinkData>(__func__);
|
2012-05-06 17:22:54 +00:00
|
|
|
link->data = (void *)member;
|
2009-06-20 14:55:28 +00:00
|
|
|
BLI_addtail(lb, link);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
ListBase CTX_data_dir_get_ex(const bContext *C,
|
|
|
|
|
const bool use_store,
|
|
|
|
|
const bool use_rna,
|
|
|
|
|
const bool use_all)
|
2009-06-20 14:55:28 +00:00
|
|
|
{
|
|
|
|
|
bContextDataResult result;
|
|
|
|
|
ListBase lb;
|
2020-04-03 14:23:21 +02:00
|
|
|
bScreen *screen;
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area;
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region;
|
2009-06-20 14:55:28 +00:00
|
|
|
int a;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-06-20 14:55:28 +00:00
|
|
|
memset(&lb, 0, sizeof(lb));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-19 02:08:58 +00:00
|
|
|
if (use_rna) {
|
|
|
|
|
char name[256], *nameptr;
|
|
|
|
|
int namelen;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-19 02:08:58 +00:00
|
|
|
PropertyRNA *iterprop;
|
2023-09-06 00:48:50 +02:00
|
|
|
PointerRNA ctx_ptr = RNA_pointer_create(nullptr, &RNA_Context, (void *)C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-19 02:08:58 +00:00
|
|
|
iterprop = RNA_struct_iterator_property(ctx_ptr.type);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-19 02:08:58 +00:00
|
|
|
RNA_PROP_BEGIN (&ctx_ptr, itemptr, iterprop) {
|
|
|
|
|
nameptr = RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
|
|
|
|
|
data_dir_add(&lb, name, use_all);
|
|
|
|
|
if (nameptr) {
|
|
|
|
|
if (name != nameptr) {
|
|
|
|
|
MEM_freeN(nameptr);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-12-19 02:08:58 +00:00
|
|
|
RNA_PROP_END;
|
|
|
|
|
}
|
|
|
|
|
if (use_store && C->wm.store) {
|
2022-12-18 19:13:15 -06:00
|
|
|
for (const bContextStoreEntry &entry : C->wm.store->entries) {
|
|
|
|
|
data_dir_add(&lb, entry.name.c_str(), use_all);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-06-20 14:55:28 +00:00
|
|
|
}
|
2020-03-06 16:56:42 +01:00
|
|
|
if ((region = CTX_wm_region(C)) && region->type && region->type->context) {
|
2009-06-20 14:55:28 +00:00
|
|
|
memset(&result, 0, sizeof(result));
|
2020-03-06 16:56:42 +01:00
|
|
|
region->type->context(C, "", &result);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (result.dir) {
|
|
|
|
|
for (a = 0; result.dir[a]; a++) {
|
2012-12-19 02:08:58 +00:00
|
|
|
data_dir_add(&lb, result.dir[a], use_all);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
}
|
2009-06-20 14:55:28 +00:00
|
|
|
}
|
2020-04-03 13:25:03 +02:00
|
|
|
if ((area = CTX_wm_area(C)) && area->type && area->type->context) {
|
2009-06-20 14:55:28 +00:00
|
|
|
memset(&result, 0, sizeof(result));
|
2020-04-03 13:25:03 +02:00
|
|
|
area->type->context(C, "", &result);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (result.dir) {
|
|
|
|
|
for (a = 0; result.dir[a]; a++) {
|
2012-12-19 02:08:58 +00:00
|
|
|
data_dir_add(&lb, result.dir[a], use_all);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
}
|
2009-06-20 14:55:28 +00:00
|
|
|
}
|
2020-04-03 14:23:21 +02:00
|
|
|
if ((screen = CTX_wm_screen(C)) && screen->context) {
|
2022-12-18 14:40:30 -06:00
|
|
|
bContextDataCallback cb = reinterpret_cast<bContextDataCallback>(screen->context);
|
2009-06-20 14:55:28 +00:00
|
|
|
memset(&result, 0, sizeof(result));
|
|
|
|
|
cb(C, "", &result);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (result.dir) {
|
|
|
|
|
for (a = 0; result.dir[a]; a++) {
|
2012-12-19 02:08:58 +00:00
|
|
|
data_dir_add(&lb, result.dir[a], use_all);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
}
|
2009-06-20 14:55:28 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-06-20 14:55:28 +00:00
|
|
|
return lb;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-19 02:08:58 +00:00
|
|
|
ListBase CTX_data_dir_get(const bContext *C)
|
|
|
|
|
{
|
2014-04-01 11:34:00 +11:00
|
|
|
return CTX_data_dir_get_ex(C, true, false, false);
|
2012-12-19 02:08:58 +00:00
|
|
|
}
|
|
|
|
|
|
2013-07-27 10:32:27 +00:00
|
|
|
bool CTX_data_equals(const char *member, const char *str)
|
2009-03-19 19:03:38 +00:00
|
|
|
{
|
2022-10-07 22:52:53 +11:00
|
|
|
return STREQ(member, str);
|
2009-03-19 19:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
2013-07-27 10:32:27 +00:00
|
|
|
bool CTX_data_dir(const char *member)
|
2009-06-20 14:55:28 +00:00
|
|
|
{
|
2011-05-01 06:34:40 +00:00
|
|
|
return member[0] == '\0';
|
2009-06-20 14:55:28 +00:00
|
|
|
}
|
|
|
|
|
|
2009-03-19 19:03:38 +00:00
|
|
|
void CTX_data_id_pointer_set(bContextDataResult *result, ID *id)
|
|
|
|
|
{
|
2023-09-06 00:48:50 +02:00
|
|
|
result->ptr = RNA_id_pointer_create(id);
|
2009-03-19 19:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CTX_data_pointer_set(bContextDataResult *result, ID *id, StructRNA *type, void *data)
|
|
|
|
|
{
|
2023-09-06 00:48:50 +02:00
|
|
|
result->ptr = RNA_pointer_create(id, type, data);
|
2009-03-19 19:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-31 12:45:45 +10:00
|
|
|
void CTX_data_pointer_set_ptr(bContextDataResult *result, const PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
result->ptr = *ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-19 19:03:38 +00:00
|
|
|
void CTX_data_id_list_add(bContextDataResult *result, ID *id)
|
|
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
CollectionPointerLink *link = MEM_cnew<CollectionPointerLink>(__func__);
|
2023-09-06 00:48:50 +02:00
|
|
|
link->ptr = RNA_id_pointer_create(id);
|
2009-03-19 19:03:38 +00:00
|
|
|
|
|
|
|
|
BLI_addtail(&result->list, link);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CTX_data_list_add(bContextDataResult *result, ID *id, StructRNA *type, void *data)
|
|
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
CollectionPointerLink *link = MEM_cnew<CollectionPointerLink>(__func__);
|
2023-09-06 00:48:50 +02:00
|
|
|
link->ptr = RNA_pointer_create(id, type, data);
|
2008-12-23 02:07:13 +00:00
|
|
|
|
|
|
|
|
BLI_addtail(&result->list, link);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-31 12:45:45 +10:00
|
|
|
void CTX_data_list_add_ptr(bContextDataResult *result, const PointerRNA *ptr)
|
|
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
CollectionPointerLink *link = MEM_cnew<CollectionPointerLink>(__func__);
|
2021-08-31 12:45:45 +10:00
|
|
|
link->ptr = *ptr;
|
|
|
|
|
|
|
|
|
|
BLI_addtail(&result->list, link);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
int ctx_data_list_count(const bContext *C, bool (*func)(const bContext *, ListBase *))
|
2009-01-17 00:51:42 +00:00
|
|
|
{
|
|
|
|
|
ListBase list;
|
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (func(C, &list)) {
|
2014-11-16 13:57:58 +01:00
|
|
|
int tot = BLI_listbase_count(&list);
|
2009-02-07 13:39:54 +00:00
|
|
|
BLI_freelistN(&list);
|
|
|
|
|
return tot;
|
|
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
|
|
|
|
return 0;
|
2009-01-17 00:51:42 +00:00
|
|
|
}
|
|
|
|
|
|
2023-04-29 20:31:27 -07:00
|
|
|
void CTX_data_prop_set(bContextDataResult *result, PropertyRNA *prop, int index)
|
|
|
|
|
{
|
|
|
|
|
result->prop = prop;
|
|
|
|
|
result->index = index;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-20 14:55:28 +00:00
|
|
|
void CTX_data_dir_set(bContextDataResult *result, const char **dir)
|
|
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
result->dir = dir;
|
2009-06-20 14:55:28 +00:00
|
|
|
}
|
|
|
|
|
|
2010-04-24 19:26:05 +00:00
|
|
|
void CTX_data_type_set(bContextDataResult *result, short type)
|
|
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
result->type = type;
|
2010-04-24 19:26:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
short CTX_data_type_get(bContextDataResult *result)
|
|
|
|
|
{
|
|
|
|
|
return result->type;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-02 12:14:27 +00:00
|
|
|
/* window manager context */
|
|
|
|
|
|
|
|
|
|
wmWindowManager *CTX_wm_manager(const bContext *C)
|
|
|
|
|
{
|
|
|
|
|
return C->wm.manager;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-17 15:18:54 -04:00
|
|
|
bool CTX_wm_interface_locked(const bContext *C)
|
|
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return bool(C->wm.manager->is_interface_locked);
|
2020-07-17 15:18:54 -04:00
|
|
|
}
|
|
|
|
|
|
2012-05-02 12:14:27 +00:00
|
|
|
wmWindow *CTX_wm_window(const bContext *C)
|
|
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<wmWindow *>(
|
|
|
|
|
ctx_wm_python_context_get(C, "window", &RNA_Window, C->wm.window));
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
WorkSpace *CTX_wm_workspace(const bContext *C)
|
|
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<WorkSpace *>(
|
|
|
|
|
ctx_wm_python_context_get(C, "workspace", &RNA_WorkSpace, C->wm.workspace));
|
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
|
|
|
}
|
|
|
|
|
|
2012-05-02 12:14:27 +00:00
|
|
|
bScreen *CTX_wm_screen(const bContext *C)
|
|
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<bScreen *>(ctx_wm_python_context_get(C, "screen", &RNA_Screen, C->wm.screen));
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScrArea *CTX_wm_area(const bContext *C)
|
|
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<ScrArea *>(ctx_wm_python_context_get(C, "area", &RNA_Area, C->wm.area));
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SpaceLink *CTX_wm_space_data(const bContext *C)
|
|
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2022-12-18 14:40:30 -06:00
|
|
|
return (area) ? static_cast<SpaceLink *>(area->spacedata.first) : nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ARegion *CTX_wm_region(const bContext *C)
|
|
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<ARegion *>(ctx_wm_python_context_get(C, "region", &RNA_Region, C->wm.region));
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void *CTX_wm_region_data(const bContext *C)
|
|
|
|
|
{
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2022-12-18 14:40:30 -06:00
|
|
|
return (region) ? region->regiondata : nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
ARegion *CTX_wm_menu(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
|
|
|
|
return C->wm.menu;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
wmGizmoGroup *CTX_wm_gizmo_group(const bContext *C)
|
2017-07-24 05:19:13 +10:00
|
|
|
{
|
2018-07-14 23:49:00 +02:00
|
|
|
return C->wm.gizmo_group;
|
2017-07-24 05:19:13 +10:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
wmMsgBus *CTX_wm_message_bus(const bContext *C)
|
2017-11-13 19:43:34 +11:00
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return C->wm.manager ? C->wm.manager->message_bus : nullptr;
|
2017-11-13 19:43:34 +11:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
ReportList *CTX_wm_reports(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (C->wm.manager) {
|
2012-05-02 12:14:27 +00:00
|
|
|
return &(C->wm.manager->reports);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-05-02 12:14:27 +00:00
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
View3D *CTX_wm_view3d(const bContext *C)
|
|
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_VIEW3D) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<View3D *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RegionView3D *CTX_wm_region_view3d(const bContext *C)
|
|
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2012-05-02 14:22:22 +00:00
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
if (area && area->spacetype == SPACE_VIEW3D) {
|
2020-03-06 16:56:42 +01:00
|
|
|
if (region && region->regiontype == RGN_TYPE_WINDOW) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<RegionView3D *>(region->regiondata);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceText *CTX_wm_space_text(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_TEXT) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceText *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceConsole *CTX_wm_space_console(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_CONSOLE) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceConsole *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceImage *CTX_wm_space_image(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_IMAGE) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceImage *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceProperties *CTX_wm_space_properties(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_PROPERTIES) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceProperties *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceFile *CTX_wm_space_file(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_FILE) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceFile *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceSeq *CTX_wm_space_seq(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_SEQ) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceSeq *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceOutliner *CTX_wm_space_outliner(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_OUTLINER) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceOutliner *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceNla *CTX_wm_space_nla(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_NLA) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceNla *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceNode *CTX_wm_space_node(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_NODE) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceNode *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceGraph *CTX_wm_space_graph(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_GRAPH) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceGraph *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceAction *CTX_wm_space_action(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_ACTION) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceAction *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceInfo *CTX_wm_space_info(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_INFO) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceInfo *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceUserPref *CTX_wm_space_userpref(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_USERPREF) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceUserPref *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceClip *CTX_wm_space_clip(const bContext *C)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_CLIP) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceClip *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceTopBar *CTX_wm_space_topbar(const bContext *C)
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_TOPBAR) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceTopBar *>(area->spacedata.first);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
SpaceSpreadsheet *CTX_wm_space_spreadsheet(const bContext *C)
|
2021-03-08 16:23:21 +01:00
|
|
|
{
|
|
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area && area->spacetype == SPACE_SPREADSHEET) {
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<SpaceSpreadsheet *>(area->spacedata.first);
|
2021-03-08 16:23:21 +01:00
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2021-03-08 16:23:21 +01:00
|
|
|
}
|
|
|
|
|
|
2012-05-02 12:14:27 +00:00
|
|
|
void CTX_wm_manager_set(bContext *C, wmWindowManager *wm)
|
|
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
C->wm.manager = wm;
|
2022-12-18 14:40:30 -06:00
|
|
|
C->wm.window = nullptr;
|
|
|
|
|
C->wm.screen = nullptr;
|
|
|
|
|
C->wm.area = nullptr;
|
|
|
|
|
C->wm.region = nullptr;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2020-09-17 18:23:12 +10:00
|
|
|
#ifdef WITH_PYTHON
|
|
|
|
|
# define PYCTX_REGION_MEMBERS "region", "region_data"
|
|
|
|
|
# define PYCTX_AREA_MEMBERS "area", "space_data", PYCTX_REGION_MEMBERS
|
|
|
|
|
# define PYCTX_SCREEN_MEMBERS "screen", PYCTX_AREA_MEMBERS
|
|
|
|
|
# define PYCTX_WINDOW_MEMBERS "window", "scene", "workspace", PYCTX_SCREEN_MEMBERS
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-05-02 12:14:27 +00:00
|
|
|
void CTX_wm_window_set(bContext *C, wmWindow *win)
|
|
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
C->wm.window = win;
|
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
|
|
|
if (win) {
|
|
|
|
|
C->data.scene = win->scene;
|
|
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
C->wm.workspace = (win) ? BKE_workspace_active_get(win->workspace_hook) : nullptr;
|
|
|
|
|
C->wm.screen = (win) ? BKE_workspace_active_screen_get(win->workspace_hook) : nullptr;
|
|
|
|
|
C->wm.area = nullptr;
|
|
|
|
|
C->wm.region = nullptr;
|
2020-09-17 18:23:12 +10:00
|
|
|
|
|
|
|
|
#ifdef WITH_PYTHON
|
2022-12-18 14:40:30 -06:00
|
|
|
if (C->data.py_context != nullptr) {
|
|
|
|
|
const char *members[] = {PYCTX_WINDOW_MEMBERS};
|
|
|
|
|
BPY_context_dict_clear_members_array(
|
|
|
|
|
&C->data.py_context, C->data.py_context_orig, members, ARRAY_SIZE(members));
|
2020-09-17 18:23:12 +10:00
|
|
|
}
|
|
|
|
|
#endif
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CTX_wm_screen_set(bContext *C, bScreen *screen)
|
|
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
C->wm.screen = screen;
|
2022-12-18 14:40:30 -06:00
|
|
|
C->wm.area = nullptr;
|
|
|
|
|
C->wm.region = nullptr;
|
2020-09-17 18:23:12 +10:00
|
|
|
|
|
|
|
|
#ifdef WITH_PYTHON
|
2022-12-18 14:40:30 -06:00
|
|
|
if (C->data.py_context != nullptr) {
|
|
|
|
|
const char *members[] = {PYCTX_SCREEN_MEMBERS};
|
|
|
|
|
BPY_context_dict_clear_members_array(
|
|
|
|
|
&C->data.py_context, C->data.py_context_orig, members, ARRAY_SIZE(members));
|
2020-09-17 18:23:12 +10:00
|
|
|
}
|
|
|
|
|
#endif
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CTX_wm_area_set(bContext *C, ScrArea *area)
|
|
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
C->wm.area = area;
|
2022-12-18 14:40:30 -06:00
|
|
|
C->wm.region = nullptr;
|
2020-09-17 18:23:12 +10:00
|
|
|
|
|
|
|
|
#ifdef WITH_PYTHON
|
2022-12-18 14:40:30 -06:00
|
|
|
if (C->data.py_context != nullptr) {
|
|
|
|
|
const char *members[] = {PYCTX_AREA_MEMBERS};
|
|
|
|
|
BPY_context_dict_clear_members_array(
|
|
|
|
|
&C->data.py_context, C->data.py_context_orig, members, ARRAY_SIZE(members));
|
2020-09-17 18:23:12 +10:00
|
|
|
}
|
|
|
|
|
#endif
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CTX_wm_region_set(bContext *C, ARegion *region)
|
|
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
C->wm.region = region;
|
2020-09-17 18:23:12 +10:00
|
|
|
|
|
|
|
|
#ifdef WITH_PYTHON
|
2022-12-18 14:40:30 -06:00
|
|
|
if (C->data.py_context != nullptr) {
|
|
|
|
|
const char *members[] = {PYCTX_REGION_MEMBERS};
|
|
|
|
|
BPY_context_dict_clear_members_array(
|
|
|
|
|
&C->data.py_context, C->data.py_context_orig, members, ARRAY_SIZE(members));
|
2020-09-17 18:23:12 +10:00
|
|
|
}
|
|
|
|
|
#endif
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CTX_wm_menu_set(bContext *C, ARegion *menu)
|
|
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
C->wm.menu = menu;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
void CTX_wm_gizmo_group_set(bContext *C, wmGizmoGroup *gzgroup)
|
2017-07-24 05:19:13 +10:00
|
|
|
{
|
2018-07-15 14:24:10 +02:00
|
|
|
C->wm.gizmo_group = gzgroup;
|
2017-07-24 05:19:13 +10:00
|
|
|
}
|
|
|
|
|
|
2021-04-20 11:42:00 +10:00
|
|
|
void CTX_wm_operator_poll_msg_clear(bContext *C)
|
|
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
bContextPollMsgDyn_Params *params = &C->wm.operator_poll_msg_dyn_params;
|
|
|
|
|
if (params->free_fn != nullptr) {
|
2021-04-20 11:57:28 +10:00
|
|
|
params->free_fn(C, params->user_data);
|
|
|
|
|
}
|
2022-12-18 14:40:30 -06:00
|
|
|
params->get_fn = nullptr;
|
|
|
|
|
params->free_fn = nullptr;
|
|
|
|
|
params->user_data = nullptr;
|
2021-04-20 11:57:28 +10:00
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
C->wm.operator_poll_msg = nullptr;
|
2021-04-20 11:42:00 +10:00
|
|
|
}
|
2012-05-02 12:14:27 +00:00
|
|
|
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
|
|
|
|
|
{
|
2021-04-20 11:57:28 +10:00
|
|
|
CTX_wm_operator_poll_msg_clear(C);
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
C->wm.operator_poll_msg = msg;
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
void CTX_wm_operator_poll_msg_set_dynamic(bContext *C, const bContextPollMsgDyn_Params *params)
|
2012-05-02 12:14:27 +00:00
|
|
|
{
|
2021-04-20 11:57:28 +10:00
|
|
|
CTX_wm_operator_poll_msg_clear(C);
|
|
|
|
|
|
|
|
|
|
C->wm.operator_poll_msg_dyn_params = *params;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *CTX_wm_operator_poll_msg_get(bContext *C, bool *r_free)
|
|
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
bContextPollMsgDyn_Params *params = &C->wm.operator_poll_msg_dyn_params;
|
|
|
|
|
if (params->get_fn != nullptr) {
|
2021-04-20 11:57:28 +10:00
|
|
|
char *msg = params->get_fn(C, params->user_data);
|
2022-12-18 14:40:30 -06:00
|
|
|
if (msg != nullptr) {
|
2021-04-20 11:57:28 +10:00
|
|
|
*r_free = true;
|
|
|
|
|
}
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*r_free = false;
|
2013-02-19 15:45:56 +00:00
|
|
|
return IFACE_(C->wm.operator_poll_msg);
|
2012-05-02 12:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
/* data context */
|
|
|
|
|
|
|
|
|
|
Main *CTX_data_main(const bContext *C)
|
|
|
|
|
{
|
|
|
|
|
Main *bmain;
|
2022-12-18 14:40:30 -06:00
|
|
|
if (ctx_data_pointer_verify(C, "blend_data", (void **)&bmain)) {
|
2008-12-18 02:56:48 +00:00
|
|
|
return bmain;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
|
|
|
|
return C->data.main;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CTX_data_main_set(bContext *C, Main *bmain)
|
|
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
C->data.main = bmain;
|
2016-10-22 15:00:32 +02:00
|
|
|
BKE_sound_init_main(bmain);
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Scene *CTX_data_scene(const bContext *C)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene;
|
2022-12-18 14:40:30 -06:00
|
|
|
if (ctx_data_pointer_verify(C, "scene", (void **)&scene)) {
|
2008-12-18 02:56:48 +00:00
|
|
|
return scene;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
|
|
|
|
return C->data.scene;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
ViewLayer *CTX_data_view_layer(const bContext *C)
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
{
|
2017-11-23 13:51:49 -02:00
|
|
|
ViewLayer *view_layer;
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
if (ctx_data_pointer_verify(C, "view_layer", (void **)&view_layer)) {
|
2017-11-23 13:51:49 -02:00
|
|
|
return view_layer;
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
}
|
2018-07-04 13:00:46 +02:00
|
|
|
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
if (win) {
|
|
|
|
|
view_layer = BKE_view_layer_find(scene, win->view_layer_name);
|
|
|
|
|
if (view_layer) {
|
|
|
|
|
return view_layer;
|
|
|
|
|
}
|
2017-10-16 17:15:03 -02:00
|
|
|
}
|
2018-07-04 13:00:46 +02:00
|
|
|
|
|
|
|
|
return BKE_view_layer_default_view(scene);
|
2017-10-16 17:15:03 -02:00
|
|
|
}
|
|
|
|
|
|
2017-11-28 15:08:43 +01:00
|
|
|
RenderEngineType *CTX_data_engine_type(const bContext *C)
|
2017-10-16 17:15:03 -02:00
|
|
|
{
|
2018-04-17 13:35:05 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
return RE_engines_find(scene->r.engine);
|
2017-10-16 17:15:03 -02:00
|
|
|
}
|
|
|
|
|
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
LayerCollection *CTX_data_layer_collection(const bContext *C)
|
|
|
|
|
{
|
2017-11-23 13:51:49 -02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2017-12-28 12:24:10 -02:00
|
|
|
LayerCollection *layer_collection;
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
if (ctx_data_pointer_verify(C, "layer_collection", (void **)&layer_collection)) {
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
if (BKE_view_layer_has_collection(view_layer, layer_collection->collection)) {
|
2017-12-28 12:24:10 -02:00
|
|
|
return layer_collection;
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* fallback */
|
2017-11-23 13:51:49 -02:00
|
|
|
return BKE_layer_collection_get_active(view_layer);
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
}
|
|
|
|
|
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
Collection *CTX_data_collection(const bContext *C)
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
{
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
Collection *collection;
|
2022-12-18 14:40:30 -06:00
|
|
|
if (ctx_data_pointer_verify(C, "collection", (void **)&collection)) {
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
return collection;
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-12-28 12:24:10 -02:00
|
|
|
LayerCollection *layer_collection = CTX_data_layer_collection(C);
|
|
|
|
|
if (layer_collection) {
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
return layer_collection->collection;
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
/* fallback */
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2019-09-02 14:31:19 +02:00
|
|
|
return scene->master_collection;
|
Render Layers and Collections (merge from render-layers)
Design Documents
----------------
* https://wiki.blender.org/index.php/Dev:2.8/Source/Layers
* https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised
User Commit Log
---------------
* New Layer and Collection system to replace render layers and viewport layers.
* A layer is a set of collections of objects (and their drawing options) required for specific tasks.
* A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers.
* All Scenes have a master collection that all other collections are children of.
* New collection "context" tab (in Properties Editor)
* New temporary viewport "collections" panel to control per-collection
visibility
Missing User Features
---------------------
* Collection "Filter"
Option to add objects based on their names
* Collection Manager operators
The existing buttons are placeholders
* Collection Manager drawing
The editor main region is empty
* Collection Override
* Per-Collection engine settings
This will come as a separate commit, as part of the clay-engine branch
Dev Commit Log
--------------
* New DNA file (DNA_layer_types.h) with the new structs
We are replacing Base by a new extended Base while keeping it backward
compatible with some legacy settings (i.e., lay, flag_legacy).
Renamed all Base to BaseLegacy to make it clear the areas of code that
still need to be converted
Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp
* Unittesting for main syncronization requirements
- read, write, add/copy/remove objects, copy scene, collection
link/unlinking, context)
* New Editor: Collection Manager
Based on patch by Julian Eisel
This is extracted from the layer-manager branch. With the following changes:
- Renamed references of layer manager to collections manager
- I doesn't include the editors/space_collections/ draw and util files
- The drawing code itself will be implemented separately by Julian
* Base / Object:
A little note about them. Original Blender code would try to keep them
in sync through the code, juggling flags back and forth. This will now
be handled by Depsgraph, keeping Object and Bases more separated
throughout the non-rendering code.
Scene.base is being cleared in doversion, and the old viewport drawing
code was poorly converted to use the new bases while the new viewport
code doesn't get merged and replace the old one.
Python API Changes
------------------
```
- scene.layers
+ # no longer exists
- scene.objects
+ scene.scene_layers.active.objects
- scene.objects.active
+ scene.render_layers.active.objects.active
- bpy.context.scene.objects.link()
+ bpy.context.scene_collection.objects.link()
- bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+ bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
- bpy.context.object.select
+ bpy.context.object.select = True
+ bpy.context.object.select = False
+ bpy.context.object.select_get()
+ bpy.context.object.select_set(action='SELECT')
+ bpy.context.object.select_set(action='DESELECT')
-AddObjectHelper.layers
+ # no longer exists
```
2017-02-07 10:18:38 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-19 13:42:54 +11:00
|
|
|
enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit,
|
|
|
|
|
const Object *ob,
|
|
|
|
|
const eObjectMode object_mode)
|
2009-08-15 19:40:09 +00:00
|
|
|
{
|
2017-05-03 00:45:10 +10:00
|
|
|
// Object *obedit = CTX_data_edit_object(C);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (obedit) {
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (obedit->type) {
|
2009-08-15 19:40:09 +00:00
|
|
|
case OB_MESH:
|
2009-08-16 03:40:00 +00:00
|
|
|
return CTX_MODE_EDIT_MESH;
|
2022-02-18 09:50:29 -06:00
|
|
|
case OB_CURVES_LEGACY:
|
2009-08-16 03:40:00 +00:00
|
|
|
return CTX_MODE_EDIT_CURVE;
|
2009-08-15 19:40:09 +00:00
|
|
|
case OB_SURF:
|
2009-08-16 03:40:00 +00:00
|
|
|
return CTX_MODE_EDIT_SURFACE;
|
2009-08-15 19:40:09 +00:00
|
|
|
case OB_FONT:
|
2009-08-16 03:40:00 +00:00
|
|
|
return CTX_MODE_EDIT_TEXT;
|
2009-08-15 19:40:09 +00:00
|
|
|
case OB_ARMATURE:
|
2009-08-16 03:40:00 +00:00
|
|
|
return CTX_MODE_EDIT_ARMATURE;
|
2009-08-15 19:40:09 +00:00
|
|
|
case OB_MBALL:
|
2009-08-16 03:40:00 +00:00
|
|
|
return CTX_MODE_EDIT_METABALL;
|
2009-08-15 19:40:09 +00:00
|
|
|
case OB_LATTICE:
|
2009-08-16 03:40:00 +00:00
|
|
|
return CTX_MODE_EDIT_LATTICE;
|
2022-02-18 11:16:02 +01:00
|
|
|
case OB_CURVES:
|
|
|
|
|
return CTX_MODE_EDIT_CURVES;
|
2023-05-30 11:14:16 +02:00
|
|
|
case OB_GREASE_PENCIL:
|
2023-06-21 16:47:18 +02:00
|
|
|
return CTX_MODE_EDIT_GREASE_PENCIL;
|
2023-06-28 12:52:45 -04:00
|
|
|
case OB_POINTCLOUD:
|
|
|
|
|
return CTX_MODE_EDIT_POINT_CLOUD;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-08-15 19:40:09 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2017-05-03 00:45:10 +10:00
|
|
|
// Object *ob = CTX_data_active_object(C);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ob) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (object_mode & OB_MODE_POSE) {
|
2018-02-06 16:16:50 +11:00
|
|
|
return CTX_MODE_POSE;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
if (object_mode & OB_MODE_SCULPT) {
|
2018-02-06 16:16:50 +11:00
|
|
|
return CTX_MODE_SCULPT;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
if (object_mode & OB_MODE_WEIGHT_PAINT) {
|
2018-02-06 16:16:50 +11:00
|
|
|
return CTX_MODE_PAINT_WEIGHT;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
if (object_mode & OB_MODE_VERTEX_PAINT) {
|
2018-02-06 16:16:50 +11:00
|
|
|
return CTX_MODE_PAINT_VERTEX;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
if (object_mode & OB_MODE_TEXTURE_PAINT) {
|
2018-02-06 16:16:50 +11:00
|
|
|
return CTX_MODE_PAINT_TEXTURE;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
if (object_mode & OB_MODE_PARTICLE_EDIT) {
|
2018-02-06 16:16:50 +11:00
|
|
|
return CTX_MODE_PARTICLE;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2023-07-03 15:15:54 +02:00
|
|
|
if (object_mode & OB_MODE_PAINT_GPENCIL_LEGACY) {
|
|
|
|
|
return CTX_MODE_PAINT_GPENCIL_LEGACY;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2023-07-03 15:15:54 +02:00
|
|
|
if (object_mode & OB_MODE_EDIT_GPENCIL_LEGACY) {
|
2023-06-21 16:47:18 +02:00
|
|
|
return CTX_MODE_EDIT_GPENCIL_LEGACY;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2023-07-03 15:15:54 +02:00
|
|
|
if (object_mode & OB_MODE_SCULPT_GPENCIL_LEGACY) {
|
|
|
|
|
return CTX_MODE_SCULPT_GPENCIL_LEGACY;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2023-07-03 15:15:54 +02:00
|
|
|
if (object_mode & OB_MODE_WEIGHT_GPENCIL_LEGACY) {
|
|
|
|
|
return CTX_MODE_WEIGHT_GPENCIL_LEGACY;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2023-07-03 15:15:54 +02:00
|
|
|
if (object_mode & OB_MODE_VERTEX_GPENCIL_LEGACY) {
|
|
|
|
|
return CTX_MODE_VERTEX_GPENCIL_LEGACY;
|
2020-03-09 16:27:24 +01:00
|
|
|
}
|
2022-02-15 12:32:15 +01:00
|
|
|
if (object_mode & OB_MODE_SCULPT_CURVES) {
|
|
|
|
|
return CTX_MODE_SCULPT_CURVES;
|
|
|
|
|
}
|
2023-07-03 16:34:30 +02:00
|
|
|
if (object_mode & OB_MODE_PAINT_GREASE_PENCIL) {
|
|
|
|
|
return CTX_MODE_PAINT_GREASE_PENCIL;
|
|
|
|
|
}
|
2009-08-15 19:40:09 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2009-08-16 03:40:00 +00:00
|
|
|
return CTX_MODE_OBJECT;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-19 13:42:54 +11:00
|
|
|
enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
|
2017-05-03 00:45:10 +10:00
|
|
|
{
|
|
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2022-12-18 14:40:30 -06:00
|
|
|
Object *obact = obedit ? nullptr : CTX_data_active_object(C);
|
|
|
|
|
return CTX_data_mode_enum_ex(obedit, obact, obact ? eObjectMode(obact->mode) : OB_MODE_OBJECT);
|
2017-05-03 00:45:10 +10:00
|
|
|
}
|
2009-08-16 03:40:00 +00:00
|
|
|
|
2021-06-24 15:56:58 +10:00
|
|
|
/**
|
|
|
|
|
* Would prefer if we can use the enum version below over this one - Campbell.
|
|
|
|
|
*
|
|
|
|
|
* \note Must be aligned with above enum.
|
|
|
|
|
*/
|
2010-12-03 17:05:21 +00:00
|
|
|
static const char *data_mode_strings[] = {
|
2023-07-03 16:34:30 +02:00
|
|
|
"mesh_edit",
|
|
|
|
|
"curve_edit",
|
|
|
|
|
"surface_edit",
|
|
|
|
|
"text_edit",
|
|
|
|
|
"armature_edit",
|
|
|
|
|
"mball_edit",
|
|
|
|
|
"lattice_edit",
|
|
|
|
|
"curves_edit",
|
|
|
|
|
"grease_pencil_edit",
|
|
|
|
|
"point_cloud_edit",
|
|
|
|
|
"posemode",
|
|
|
|
|
"sculpt_mode",
|
|
|
|
|
"weightpaint",
|
|
|
|
|
"vertexpaint",
|
|
|
|
|
"imagepaint",
|
|
|
|
|
"particlemode",
|
|
|
|
|
"objectmode",
|
|
|
|
|
"greasepencil_paint",
|
|
|
|
|
"greasepencil_edit",
|
|
|
|
|
"greasepencil_sculpt",
|
|
|
|
|
"greasepencil_weight",
|
|
|
|
|
"greasepencil_vertex",
|
|
|
|
|
"curves_sculpt",
|
|
|
|
|
"grease_pencil_paint",
|
|
|
|
|
nullptr,
|
2009-08-16 03:40:00 +00:00
|
|
|
};
|
2018-01-03 13:10:42 +00:00
|
|
|
BLI_STATIC_ASSERT(ARRAY_SIZE(data_mode_strings) == CTX_MODE_NUM + 1,
|
|
|
|
|
"Must have a string for each context mode")
|
2010-12-03 17:05:21 +00:00
|
|
|
const char *CTX_data_mode_string(const bContext *C)
|
2009-08-16 03:40:00 +00:00
|
|
|
{
|
|
|
|
|
return data_mode_strings[CTX_data_mode_enum(C)];
|
2009-08-15 19:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
void CTX_data_scene_set(bContext *C, Scene *scene)
|
|
|
|
|
{
|
2012-05-06 17:22:54 +00:00
|
|
|
C->data.scene = scene;
|
2020-09-17 18:23:12 +10:00
|
|
|
|
|
|
|
|
#ifdef WITH_PYTHON
|
2022-12-18 14:40:30 -06:00
|
|
|
if (C->data.py_context != nullptr) {
|
|
|
|
|
const char *members[] = {"scene"};
|
|
|
|
|
BPY_context_dict_clear_members_array(&C->data.py_context, C->data.py_context_orig, members, 1);
|
2020-09-17 18:23:12 +10:00
|
|
|
}
|
|
|
|
|
#endif
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ToolSettings *CTX_data_tool_settings(const bContext *C)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (scene) {
|
2008-12-18 02:56:48 +00:00
|
|
|
return scene->toolsettings;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2020-08-07 12:30:43 +02:00
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
return nullptr;
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_selected_ids(const bContext *C, ListBase *list)
|
2020-12-11 21:54:10 +01:00
|
|
|
{
|
|
|
|
|
return ctx_data_collection_get(C, "selected_ids", list);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_selected_nodes(const bContext *C, ListBase *list)
|
2009-01-02 23:58:03 +00:00
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "selected_nodes", list);
|
2009-01-02 23:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_selected_editable_objects(const bContext *C, ListBase *list)
|
2009-01-17 18:35:33 +00:00
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "selected_editable_objects", list);
|
2009-01-17 18:35:33 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_selected_editable_bases(const bContext *C, ListBase *list)
|
2009-01-17 18:35:33 +00:00
|
|
|
{
|
2019-05-21 10:49:05 -03:00
|
|
|
return ctx_data_base_collection_get(C, "selected_editable_objects", list);
|
2009-01-17 18:35:33 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_editable_objects(const bContext *C, ListBase *list)
|
2016-02-06 12:59:03 +13:00
|
|
|
{
|
|
|
|
|
return ctx_data_collection_get(C, "editable_objects", list);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_editable_bases(const bContext *C, ListBase *list)
|
2016-02-06 12:59:03 +13:00
|
|
|
{
|
2019-05-21 10:49:05 -03:00
|
|
|
return ctx_data_base_collection_get(C, "editable_objects", list);
|
2016-02-06 12:59:03 +13:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_selected_objects(const bContext *C, ListBase *list)
|
2008-12-23 02:07:13 +00:00
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "selected_objects", list);
|
2008-12-23 02:07:13 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_selected_bases(const bContext *C, ListBase *list)
|
2008-12-23 02:07:13 +00:00
|
|
|
{
|
2019-05-21 10:49:05 -03:00
|
|
|
return ctx_data_base_collection_get(C, "selected_objects", list);
|
2008-12-23 02:07:13 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_visible_objects(const bContext *C, ListBase *list)
|
2008-12-28 18:10:24 +00:00
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "visible_objects", list);
|
2008-12-28 18:10:24 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_visible_bases(const bContext *C, ListBase *list)
|
2008-12-28 18:10:24 +00:00
|
|
|
{
|
2019-05-21 10:49:05 -03:00
|
|
|
return ctx_data_base_collection_get(C, "visible_objects", list);
|
2008-12-28 18:10:24 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_selectable_objects(const bContext *C, ListBase *list)
|
2009-07-11 11:31:49 +00:00
|
|
|
{
|
|
|
|
|
return ctx_data_collection_get(C, "selectable_objects", list);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_selectable_bases(const bContext *C, ListBase *list)
|
2009-07-11 11:31:49 +00:00
|
|
|
{
|
2019-05-21 10:49:05 -03:00
|
|
|
return ctx_data_base_collection_get(C, "selectable_objects", list);
|
2009-07-11 11:31:49 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
Object *CTX_data_active_object(const bContext *C)
|
2008-12-23 02:07:13 +00:00
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<Object *>(ctx_data_pointer_get(C, "active_object"));
|
2008-12-23 02:07:13 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
Base *CTX_data_active_base(const bContext *C)
|
2008-12-18 02:56:48 +00:00
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
Object *ob = CTX_data_active_object(C);
|
2019-05-21 10:49:05 -03:00
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
if (ob == nullptr) {
|
|
|
|
|
return nullptr;
|
2019-05-21 10:49:05 -03:00
|
|
|
}
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = CTX_data_scene(C);
|
2019-05-21 10:49:05 -03:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
2019-05-21 10:49:05 -03:00
|
|
|
return BKE_view_layer_base_find(view_layer, ob);
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
Object *CTX_data_edit_object(const bContext *C)
|
2008-12-18 02:56:48 +00:00
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<Object *>(ctx_data_pointer_get(C, "edit_object"));
|
2008-12-18 02:56:48 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
Image *CTX_data_edit_image(const bContext *C)
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<Image *>(ctx_data_pointer_get(C, "edit_image"));
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
Text *CTX_data_edit_text(const bContext *C)
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<Text *>(ctx_data_pointer_get(C, "edit_text"));
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
MovieClip *CTX_data_edit_movieclip(const bContext *C)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<MovieClip *>(ctx_data_pointer_get(C, "edit_movieclip"));
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
Mask *CTX_data_edit_mask(const bContext *C)
|
2012-06-04 16:42:58 +00:00
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<Mask *>(ctx_data_pointer_get(C, "edit_mask"));
|
2012-06-04 16:42:58 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
EditBone *CTX_data_active_bone(const bContext *C)
|
2009-02-05 03:28:07 +00:00
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<EditBone *>(ctx_data_pointer_get(C, "active_bone"));
|
2009-02-05 03:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
CacheFile *CTX_data_edit_cachefile(const bContext *C)
|
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
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<CacheFile *>(ctx_data_pointer_get(C, "edit_cachefile"));
|
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
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_selected_bones(const bContext *C, ListBase *list)
|
2009-02-05 03:28:07 +00:00
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "selected_bones", list);
|
2009-02-05 03:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_selected_editable_bones(const bContext *C, ListBase *list)
|
2009-02-05 03:28:07 +00:00
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "selected_editable_bones", list);
|
2009-02-05 03:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_visible_bones(const bContext *C, ListBase *list)
|
2009-02-14 07:27:12 +00:00
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "visible_bones", list);
|
2009-02-14 07:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_editable_bones(const bContext *C, ListBase *list)
|
2009-02-14 07:27:12 +00:00
|
|
|
{
|
2009-03-19 19:03:38 +00:00
|
|
|
return ctx_data_collection_get(C, "editable_bones", list);
|
2009-02-14 07:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-18 14:40:30 -06:00
|
|
|
bPoseChannel *CTX_data_active_pose_bone(const bContext *C)
|
2009-02-05 03:28:07 +00:00
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<bPoseChannel *>(ctx_data_pointer_get(C, "active_pose_bone"));
|
2009-02-05 03:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_selected_pose_bones(const bContext *C, ListBase *list)
|
2009-02-05 03:28:07 +00:00
|
|
|
{
|
2009-11-25 15:00:29 +00:00
|
|
|
return ctx_data_collection_get(C, "selected_pose_bones", list);
|
2009-02-05 03:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_selected_pose_bones_from_active_object(const bContext *C, ListBase *list)
|
2018-10-19 08:29:15 -03:00
|
|
|
{
|
|
|
|
|
return ctx_data_collection_get(C, "selected_pose_bones_from_active_object", list);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_visible_pose_bones(const bContext *C, ListBase *list)
|
2009-02-14 07:27:12 +00:00
|
|
|
{
|
2009-11-25 15:00:29 +00:00
|
|
|
return ctx_data_collection_get(C, "visible_pose_bones", list);
|
2009-02-14 07:27:12 +00:00
|
|
|
}
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
|
|
|
|
|
bGPdata *CTX_data_gpencil_data(const bContext *C)
|
|
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<bGPdata *>(ctx_data_pointer_get(C, "gpencil_data"));
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bGPDlayer *CTX_data_active_gpencil_layer(const bContext *C)
|
|
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<bGPDlayer *>(ctx_data_pointer_get(C, "active_gpencil_layer"));
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bGPDframe *CTX_data_active_gpencil_frame(const bContext *C)
|
|
|
|
|
{
|
2022-12-18 14:40:30 -06:00
|
|
|
return static_cast<bGPDframe *>(ctx_data_pointer_get(C, "active_gpencil_frame"));
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_visible_gpencil_layers(const bContext *C, ListBase *list)
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
{
|
|
|
|
|
return ctx_data_collection_get(C, "visible_gpencil_layers", list);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_editable_gpencil_layers(const bContext *C, ListBase *list)
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
{
|
|
|
|
|
return ctx_data_collection_get(C, "editable_gpencil_layers", list);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 15:18:53 +01:00
|
|
|
bool CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list)
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
{
|
|
|
|
|
return ctx_data_collection_get(C, "editable_gpencil_strokes", list);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-06 15:18:18 +02:00
|
|
|
const AssetLibraryReference *CTX_wm_asset_library_ref(const bContext *C)
|
2021-07-08 22:33:02 +02:00
|
|
|
{
|
2023-09-19 16:27:07 +02:00
|
|
|
return static_cast<AssetLibraryReference *>(ctx_data_pointer_get(C, "asset_library_reference"));
|
2021-07-08 22:33:02 +02:00
|
|
|
}
|
|
|
|
|
|
2023-09-19 15:41:15 +02:00
|
|
|
static AssetHandle ctx_wm_asset_handle(const bContext *C, bool *r_is_valid)
|
2021-07-08 23:20:26 +02:00
|
|
|
{
|
|
|
|
|
AssetHandle *asset_handle_p =
|
|
|
|
|
(AssetHandle *)CTX_data_pointer_get_type(C, "asset_handle", &RNA_AssetHandle).data;
|
|
|
|
|
if (asset_handle_p) {
|
|
|
|
|
*r_is_valid = true;
|
|
|
|
|
return *asset_handle_p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If the asset handle was not found in context directly, try if there's an active file with
|
|
|
|
|
* asset data there instead. Not nice to have this here, would be better to have this in
|
2023-08-05 02:57:52 +02:00
|
|
|
* `ED_asset.hh`, but we can't include that in BKE. Even better would be not needing this at all
|
2021-07-08 23:20:26 +02:00
|
|
|
* and being able to have editors return this in the usual `context` callback. But that would
|
|
|
|
|
* require returning a non-owning pointer, which we don't have in the Asset Browser (yet). */
|
|
|
|
|
FileDirEntry *file =
|
|
|
|
|
(FileDirEntry *)CTX_data_pointer_get_type(C, "active_file", &RNA_FileSelectEntry).data;
|
Asset System: New core type to represent assets (`AssetRepresenation`)
Introduces a new `AssetRepresentation` type, as a runtime only container
to hold asset information. It is supposed to become _the_ main way to
represent and refer to assets in the asset system, see T87235. It can
store things like the asset name, asset traits, preview and other asset
metadata.
Technical documentation:
https://wiki.blender.org/wiki/Source/Architecture/Asset_System/Back_End#Asset_Representation.
By introducing a proper asset representation type, we do an important
step away from the previous, non-optimal representation of assets as
files in the file browser backend, and towards the asset system as
backend. It should replace the temporary & hacky `AssetHandle` design in
the near future. Note that the loading of asset data still happens
through the file browser backend, check the linked to Wiki page for more
information on that.
As a side-effect, asset metadata isn't stored in file browser file
entries when browsing with link/append anymore. Don't think this was
ever used, but scripts may have accessed this. Can be brought back if
there's a need for it.
2022-11-09 18:34:31 +01:00
|
|
|
if (file && file->asset) {
|
2021-07-08 23:20:26 +02:00
|
|
|
*r_is_valid = true;
|
2022-12-19 12:50:09 +01:00
|
|
|
return AssetHandle{file};
|
2021-07-08 23:20:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*r_is_valid = false;
|
2022-12-18 14:40:30 -06:00
|
|
|
return AssetHandle{nullptr};
|
2021-07-08 23:20:26 +02:00
|
|
|
}
|
|
|
|
|
|
2023-07-04 14:46:19 +02:00
|
|
|
blender::asset_system::AssetRepresentation *CTX_wm_asset(const bContext *C)
|
2023-03-16 15:40:31 +01:00
|
|
|
{
|
2023-09-19 12:50:27 +02:00
|
|
|
if (auto *asset = static_cast<blender::asset_system::AssetRepresentation *>(
|
|
|
|
|
ctx_data_pointer_get(C, "asset")))
|
|
|
|
|
{
|
|
|
|
|
return asset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Expose the asset representation from the asset-handle.
|
|
|
|
|
* TODO(Julian): #AssetHandle should be properly replaced by #AssetRepresentation. */
|
|
|
|
|
bool is_valid;
|
2023-09-19 15:41:15 +02:00
|
|
|
if (AssetHandle handle = ctx_wm_asset_handle(C, &is_valid); is_valid) {
|
2023-09-19 12:50:27 +02:00
|
|
|
return handle.file_data->asset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
2023-03-16 15:40:31 +01:00
|
|
|
}
|
|
|
|
|
|
2019-07-25 16:36:22 +02:00
|
|
|
Depsgraph *CTX_data_depsgraph_pointer(const bContext *C)
|
2017-04-04 13:07:41 +02:00
|
|
|
{
|
2019-09-09 14:49:05 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2017-04-04 13:07:41 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2017-11-22 10:52:39 -02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2020-08-21 11:56:03 +02:00
|
|
|
Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer);
|
2019-05-17 18:59:29 +02:00
|
|
|
/* Dependency graph might have been just allocated, and hence it will not be marked.
|
|
|
|
|
* This confuses redo system due to the lack of flushing changes back to the original data.
|
|
|
|
|
* In the future we would need to check whether the CTX_wm_window(C) is in editing mode (as an
|
|
|
|
|
* opposite of playback-preview-only) and set active flag based on that. */
|
|
|
|
|
DEG_make_active(depsgraph);
|
|
|
|
|
return depsgraph;
|
2017-04-04 13:07:41 +02:00
|
|
|
}
|
2018-05-01 10:14:20 +02:00
|
|
|
|
2019-07-25 16:36:22 +02:00
|
|
|
Depsgraph *CTX_data_expect_evaluated_depsgraph(const bContext *C)
|
Dependency graph API changes
Main goal here is to make it obvious and predictable about
what is going on.
Summary of changes.
- Access to dependency graph is now only possible to a fully evaluated
graph. This is now done via context.evaluated_depsgraph_get().
The call will ensure both relations and datablocks are updated.
This way we don't allow access to some known bad state of the graph,
and also making explicit that getting update dependency graph is not
cheap.
- Access to evaluated ID is now possible via id.evaluated_get().
It was already possible to get evaluated ID via dependency graph,
but that was a bit confusing why access to original is done via ID
and to evaluated via depsgraph.
If datablock is not covered by dependency graph it will be returned
as-is.
- Similarly, request for original from an ID which is not evaluated
will return ID as-is.
- Removed scene.update().
This is very expensive to update all the view layers.
- Added depsgraph.update().
Now when temporary changes to objects are to be done, this is to
happen on original object and then dependency graph is to be
updated.
- Changed object.to_mesh() to behave the following way:
* When is used for original object modifiers are ignored.
For meshes this acts similar to mesh-copy, not very useful but
allows to keep code paths similar (i.e. for exporter which has
Apply Modifiers option it's only matter choosing between original
and evaluated object, the to_mesh() part can stay the same).
For curves this gives a mesh which is constructed from displist
without taking own modifiers and modifiers of bevel/taper objects
into account.
For metaballs this gives empty mesh.
Polygonization of metaball is not possible from a single object.
* When is used for evaluated object modifiers are always applied.
In fact, no evaluation is happening, the mesh is either copied
as-is, or constructed from current state of curve cache.
Arguments to apply modifiers and calculate original coordinates (ORCO,
aka undeformed coordinates) are removed. The ORCO is to be calculated
as part of dependency graph evaluation.
File used to regression-test (a packed Python script into .blend):
{F7033464}
Patch to make addons tests to pass:
{F7033466}
NOTE: I've included changes to FBX exporter, and those are addressing
report T63689.
NOTE: All the enabled-by-default addons are to be ported still, but
first want to have agreement on this part of changes.
NOTE: Also need to work on documentation for Python API, but, again,
better be done after having agreement on this work.
Reviewers: brecht, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D4834
2019-05-09 11:26:49 +02:00
|
|
|
{
|
2019-07-25 16:36:22 +02:00
|
|
|
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
|
|
|
|
|
/* TODO(sergey): Assert that the dependency graph is fully evaluated.
|
2023-01-03 10:19:27 +11:00
|
|
|
* Note that first the depsgraph and scene post-evaluation hooks needs to run extra round of
|
|
|
|
|
* updates first to make check here really reliable. */
|
2019-07-25 16:36:22 +02:00
|
|
|
return depsgraph;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Depsgraph *CTX_data_ensure_evaluated_depsgraph(const bContext *C)
|
|
|
|
|
{
|
|
|
|
|
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
|
Dependency graph API changes
Main goal here is to make it obvious and predictable about
what is going on.
Summary of changes.
- Access to dependency graph is now only possible to a fully evaluated
graph. This is now done via context.evaluated_depsgraph_get().
The call will ensure both relations and datablocks are updated.
This way we don't allow access to some known bad state of the graph,
and also making explicit that getting update dependency graph is not
cheap.
- Access to evaluated ID is now possible via id.evaluated_get().
It was already possible to get evaluated ID via dependency graph,
but that was a bit confusing why access to original is done via ID
and to evaluated via depsgraph.
If datablock is not covered by dependency graph it will be returned
as-is.
- Similarly, request for original from an ID which is not evaluated
will return ID as-is.
- Removed scene.update().
This is very expensive to update all the view layers.
- Added depsgraph.update().
Now when temporary changes to objects are to be done, this is to
happen on original object and then dependency graph is to be
updated.
- Changed object.to_mesh() to behave the following way:
* When is used for original object modifiers are ignored.
For meshes this acts similar to mesh-copy, not very useful but
allows to keep code paths similar (i.e. for exporter which has
Apply Modifiers option it's only matter choosing between original
and evaluated object, the to_mesh() part can stay the same).
For curves this gives a mesh which is constructed from displist
without taking own modifiers and modifiers of bevel/taper objects
into account.
For metaballs this gives empty mesh.
Polygonization of metaball is not possible from a single object.
* When is used for evaluated object modifiers are always applied.
In fact, no evaluation is happening, the mesh is either copied
as-is, or constructed from current state of curve cache.
Arguments to apply modifiers and calculate original coordinates (ORCO,
aka undeformed coordinates) are removed. The ORCO is to be calculated
as part of dependency graph evaluation.
File used to regression-test (a packed Python script into .blend):
{F7033464}
Patch to make addons tests to pass:
{F7033466}
NOTE: I've included changes to FBX exporter, and those are addressing
report T63689.
NOTE: All the enabled-by-default addons are to be ported still, but
first want to have agreement on this part of changes.
NOTE: Also need to work on documentation for Python API, but, again,
better be done after having agreement on this work.
Reviewers: brecht, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D4834
2019-05-09 11:26:49 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2019-05-28 15:52:26 +02:00
|
|
|
BKE_scene_graph_evaluated_ensure(depsgraph, bmain);
|
Dependency graph API changes
Main goal here is to make it obvious and predictable about
what is going on.
Summary of changes.
- Access to dependency graph is now only possible to a fully evaluated
graph. This is now done via context.evaluated_depsgraph_get().
The call will ensure both relations and datablocks are updated.
This way we don't allow access to some known bad state of the graph,
and also making explicit that getting update dependency graph is not
cheap.
- Access to evaluated ID is now possible via id.evaluated_get().
It was already possible to get evaluated ID via dependency graph,
but that was a bit confusing why access to original is done via ID
and to evaluated via depsgraph.
If datablock is not covered by dependency graph it will be returned
as-is.
- Similarly, request for original from an ID which is not evaluated
will return ID as-is.
- Removed scene.update().
This is very expensive to update all the view layers.
- Added depsgraph.update().
Now when temporary changes to objects are to be done, this is to
happen on original object and then dependency graph is to be
updated.
- Changed object.to_mesh() to behave the following way:
* When is used for original object modifiers are ignored.
For meshes this acts similar to mesh-copy, not very useful but
allows to keep code paths similar (i.e. for exporter which has
Apply Modifiers option it's only matter choosing between original
and evaluated object, the to_mesh() part can stay the same).
For curves this gives a mesh which is constructed from displist
without taking own modifiers and modifiers of bevel/taper objects
into account.
For metaballs this gives empty mesh.
Polygonization of metaball is not possible from a single object.
* When is used for evaluated object modifiers are always applied.
In fact, no evaluation is happening, the mesh is either copied
as-is, or constructed from current state of curve cache.
Arguments to apply modifiers and calculate original coordinates (ORCO,
aka undeformed coordinates) are removed. The ORCO is to be calculated
as part of dependency graph evaluation.
File used to regression-test (a packed Python script into .blend):
{F7033464}
Patch to make addons tests to pass:
{F7033466}
NOTE: I've included changes to FBX exporter, and those are addressing
report T63689.
NOTE: All the enabled-by-default addons are to be ported still, but
first want to have agreement on this part of changes.
NOTE: Also need to work on documentation for Python API, but, again,
better be done after having agreement on this work.
Reviewers: brecht, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D4834
2019-05-09 11:26:49 +02:00
|
|
|
return depsgraph;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 10:14:20 +02:00
|
|
|
Depsgraph *CTX_data_depsgraph_on_load(const bContext *C)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2020-08-21 11:56:03 +02:00
|
|
|
return BKE_scene_get_depsgraph(scene, view_layer);
|
2018-05-01 10:14:20 +02:00
|
|
|
}
|