2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2008 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2008-12-23 02:07:13 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup edscr
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2023-07-22 11:27:25 +10:00
|
|
|
#include <cstdio>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <cstring>
|
2008-12-23 02:07:13 +00:00
|
|
|
|
2018-04-16 16:27:55 +02:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2020-03-30 19:33:13 +02:00
|
|
|
#include "DNA_anim_types.h"
|
2009-10-29 19:59:38 +00:00
|
|
|
#include "DNA_armature_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_object_types.h"
|
2008-12-23 02:07:13 +00:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_screen_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_sequence_types.h"
|
2011-11-08 16:59:06 +00:00
|
|
|
#include "DNA_space_types.h"
|
|
|
|
|
#include "DNA_windowmanager_types.h"
|
2021-07-08 22:33:02 +02:00
|
|
|
#include "DNA_workspace_types.h"
|
2008-12-23 02:07:13 +00:00
|
|
|
|
2020-10-02 11:56:06 +02:00
|
|
|
#include "BLI_ghash.h"
|
2020-04-03 17:38:58 +02:00
|
|
|
#include "BLI_listbase.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2009-10-29 19:59:38 +00:00
|
|
|
#include "BKE_action.h"
|
2023-11-16 11:41:55 +01:00
|
|
|
#include "BKE_armature.hh"
|
2024-02-09 19:12:23 +01:00
|
|
|
#include "BKE_blender.hh"
|
2023-11-16 11:41:55 +01:00
|
|
|
#include "BKE_context.hh"
|
2023-03-13 10:42:51 +01:00
|
|
|
#include "BKE_gpencil_legacy.h"
|
2024-01-23 15:18:09 -05:00
|
|
|
#include "BKE_layer.hh"
|
2023-10-09 23:41:53 +02:00
|
|
|
#include "BKE_object.hh"
|
2021-10-19 16:24:23 +02:00
|
|
|
#include "BKE_tracking.h"
|
2018-02-06 17:28:00 +11:00
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_access.hh"
|
2022-03-14 16:54:46 +01:00
|
|
|
#include "RNA_prototypes.h"
|
2009-03-19 19:03:38 +00:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_anim_api.hh"
|
|
|
|
|
#include "ED_armature.hh"
|
|
|
|
|
#include "ED_clip.hh"
|
|
|
|
|
#include "ED_gpencil_legacy.hh"
|
2009-07-19 17:44:44 +00:00
|
|
|
|
2023-11-02 01:05:06 +01:00
|
|
|
#include "SEQ_channels.hh"
|
|
|
|
|
#include "SEQ_select.hh"
|
|
|
|
|
#include "SEQ_sequencer.hh"
|
|
|
|
|
#include "SEQ_transform.hh"
|
2020-11-01 21:03:31 +01:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "UI_interface.hh"
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "WM_api.hh"
|
2011-11-08 16:59:06 +00:00
|
|
|
|
2023-12-05 15:05:28 +01:00
|
|
|
#include "ANIM_bone_collections.hh"
|
Anim: replace Bone Groups & Armature Layers with Bone Collections
Armature layers (the 32 little dots) and bone groups are replaced with
Bone Collections:
- Bone collections are stored on the armature, and have a name that is
unique within that armature.
- An armature can have an arbitrary number of bone collections (instead
of the fixed 32 layers).
- Bones can be assigned to zero or more bone collections.
- Bone collections have a visibility setting, just like objects in scene
collections.
- When a bone is in at least one collection, and all its collections in
are hidden, the bone is hidden. In other cases (in any visible
collection, or in no collection at all), the bone visibility is
determined by its own 'hidden' flag.
- For now, bone collections cannot be nested; they are a flat list just
like bone groups were. Nestability of bone collections is intended to
be implemented in a later 4.x release.
- Since bone collections are defined on the armature, they can be used
from both pose mode and edit mode.
Versioning converts bone groups and armature layers to new bone
collections. Layers that do not contain any bones are skipped. The old
data structures remain in DNA and are unaltered, for limited forward
compatibility. That way at least a save with Blender 4.0 will not
immediately erase the bone group and armature layers and their bone
assignments.
Shortcuts:
- M/Shift+M in pose/edit mode: move to collection (M) and add to
collection (shift+M). This works similar to the M/Shift+M menus for
objects & scene collections.
- Ctrl+G in pose mode shows a port of the old 'bone groups' menu. This
is likely to be removed in the near future, as the functionality
overlaps with the M/Shift+M menus.
This is the first commit of a series; the bone collections feature will
be improved before the Blender 4.0 release. See #108941 for more info.
Pull request: https://projects.blender.org/blender/blender/pulls/109976
2023-08-22 12:15:54 +02:00
|
|
|
|
2024-03-26 20:34:48 -04:00
|
|
|
#include "screen_intern.hh"
|
2011-02-14 17:55:27 +00:00
|
|
|
|
2024-01-24 18:18:14 +01:00
|
|
|
using blender::Vector;
|
|
|
|
|
|
2019-04-18 17:17:32 +02:00
|
|
|
const char *screen_context_dir[] = {
|
|
|
|
|
"scene",
|
|
|
|
|
"view_layer",
|
|
|
|
|
"visible_objects",
|
|
|
|
|
"selectable_objects",
|
|
|
|
|
"selected_objects",
|
|
|
|
|
"editable_objects",
|
|
|
|
|
"selected_editable_objects",
|
|
|
|
|
"objects_in_mode",
|
|
|
|
|
"objects_in_mode_unique_data",
|
|
|
|
|
"visible_bones",
|
|
|
|
|
"editable_bones",
|
|
|
|
|
"selected_bones",
|
|
|
|
|
"selected_editable_bones",
|
|
|
|
|
"visible_pose_bones",
|
|
|
|
|
"selected_pose_bones",
|
|
|
|
|
"selected_pose_bones_from_active_object",
|
|
|
|
|
"active_bone",
|
|
|
|
|
"active_pose_bone",
|
|
|
|
|
"active_object",
|
|
|
|
|
"object",
|
|
|
|
|
"edit_object",
|
|
|
|
|
"sculpt_object",
|
|
|
|
|
"vertex_paint_object",
|
|
|
|
|
"weight_paint_object",
|
|
|
|
|
"image_paint_object",
|
|
|
|
|
"particle_edit_object",
|
|
|
|
|
"pose_object",
|
2021-08-30 20:56:37 +10:00
|
|
|
"active_sequence_strip",
|
2019-04-18 17:17:32 +02:00
|
|
|
"sequences",
|
|
|
|
|
"selected_sequences",
|
|
|
|
|
"selected_editable_sequences", /* sequencer */
|
2021-08-31 11:46:46 +10:00
|
|
|
"active_nla_track",
|
|
|
|
|
"active_nla_strip",
|
|
|
|
|
"selected_nla_strips", /* nla editor */
|
2021-10-19 16:24:23 +02:00
|
|
|
"selected_movieclip_tracks",
|
2019-04-18 17:17:32 +02:00
|
|
|
"gpencil_data",
|
|
|
|
|
"gpencil_data_owner", /* grease pencil data */
|
2020-01-07 11:29:42 +01:00
|
|
|
"annotation_data",
|
|
|
|
|
"annotation_data_owner",
|
2019-04-18 17:17:32 +02:00
|
|
|
"visible_gpencil_layers",
|
|
|
|
|
"editable_gpencil_layers",
|
|
|
|
|
"editable_gpencil_strokes",
|
|
|
|
|
"active_gpencil_layer",
|
|
|
|
|
"active_gpencil_frame",
|
2020-01-07 11:29:42 +01:00
|
|
|
"active_annotation_layer",
|
2019-04-18 17:17:32 +02:00
|
|
|
"active_operator",
|
2022-07-10 12:28:44 +03:00
|
|
|
"active_action",
|
2021-07-16 12:36:57 +03:00
|
|
|
"selected_visible_actions",
|
|
|
|
|
"selected_editable_actions",
|
2019-06-16 13:32:50 +03:00
|
|
|
"visible_fcurves",
|
|
|
|
|
"editable_fcurves",
|
|
|
|
|
"selected_visible_fcurves",
|
2019-04-18 17:17:32 +02:00
|
|
|
"selected_editable_fcurves",
|
2019-06-16 13:32:50 +03:00
|
|
|
"active_editable_fcurve",
|
2020-10-15 14:53:26 -04:00
|
|
|
"selected_editable_keyframes",
|
UI: Support UI list tooltips, defined via Python scripts
Makes it possible to create tooltips for UI list rows, which can be
filled in .py scripts, similar to how they can extend other menus. This
is used by the (to be committed) Pose Library add-on to display pose
operations (selecting bones of a pose, blending a pose, etc).
It's important that the Python scripts check if the UI list is the
correct one by checking the list ID.
For this to work, a new `bpy.context.ui_list` can be checked. For
example, the Pose Library add-on does the following check:
```
def is_pose_asset_view() -> bool:
# Important: Must check context first, or the menu is added for every kind of list.
list = getattr(context, "ui_list", None)
if not list or list.bl_idname != "UI_UL_asset_view" or list.list_id != "pose_assets":
return False
if not context.asset_handle:
return False
return True
```
2021-07-13 15:01:00 +02:00
|
|
|
"ui_list",
|
2023-04-29 20:31:27 -07:00
|
|
|
"property",
|
2023-09-19 16:27:07 +02:00
|
|
|
"asset_library_reference",
|
2023-07-12 13:43:00 +02:00
|
|
|
nullptr,
|
2019-04-18 17:17:32 +02:00
|
|
|
};
|
2011-02-15 14:38:43 +00:00
|
|
|
|
2020-10-02 11:56:06 +02:00
|
|
|
/* Each function `screen_ctx_XXX()` will be called when the screen context "XXX" is requested.
|
|
|
|
|
* ensure_ed_screen_context_functions() is responsible for creating the hash map from context
|
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
|
|
|
* member name to function. */
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_scene(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
|
|
|
|
CTX_data_id_pointer_set(result, &scene->id);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_visible_objects(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2023-07-12 13:43:00 +02:00
|
|
|
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
|
2022-09-14 21:33:51 +02:00
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
2022-09-14 21:33:51 +02:00
|
|
|
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) {
|
2020-10-02 11:56:06 +02:00
|
|
|
if (BASE_VISIBLE(v3d, base)) {
|
|
|
|
|
CTX_data_id_list_add(result, &base->object->id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_selectable_objects(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2023-07-12 13:43:00 +02:00
|
|
|
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
|
2022-09-14 21:33:51 +02:00
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
2022-09-14 21:33:51 +02:00
|
|
|
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) {
|
2020-10-02 11:56:06 +02:00
|
|
|
if (BASE_SELECTABLE(v3d, base)) {
|
|
|
|
|
CTX_data_id_list_add(result, &base->object->id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_selected_objects(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2023-07-12 13:43:00 +02:00
|
|
|
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
|
2022-09-14 21:33:51 +02:00
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
2022-09-14 21:33:51 +02:00
|
|
|
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) {
|
2020-10-02 11:56:06 +02:00
|
|
|
if (BASE_SELECTED(v3d, base)) {
|
|
|
|
|
CTX_data_id_list_add(result, &base->object->id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_selected_editable_objects(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2023-07-12 13:43:00 +02:00
|
|
|
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
|
2022-09-14 21:33:51 +02:00
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
2022-09-14 21:33:51 +02:00
|
|
|
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) {
|
2020-10-02 11:56:06 +02:00
|
|
|
if (BASE_SELECTED_EDITABLE(v3d, base)) {
|
|
|
|
|
CTX_data_id_list_add(result, &base->object->id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_editable_objects(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2023-07-12 13:43:00 +02:00
|
|
|
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
|
2022-09-14 21:33:51 +02:00
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
/* Visible + Editable, but not necessarily selected */
|
2022-09-14 21:33:51 +02:00
|
|
|
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) {
|
2020-10-02 11:56:06 +02:00
|
|
|
if (BASE_EDITABLE(v3d, base)) {
|
|
|
|
|
CTX_data_id_list_add(result, &base->object->id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_objects_in_mode(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2023-07-12 13:43:00 +02:00
|
|
|
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
|
2022-09-14 21:30:20 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
if (obact && (obact->mode != OB_MODE_OBJECT)) {
|
2022-09-14 21:30:20 +02:00
|
|
|
FOREACH_OBJECT_IN_MODE_BEGIN (scene, view_layer, v3d, obact->type, obact->mode, ob_iter) {
|
2020-10-02 11:56:06 +02:00
|
|
|
CTX_data_id_list_add(result, &ob_iter->id);
|
|
|
|
|
}
|
|
|
|
|
FOREACH_OBJECT_IN_MODE_END;
|
|
|
|
|
}
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_objects_in_mode_unique_data(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2023-07-12 13:43:00 +02:00
|
|
|
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
|
2022-09-14 21:30:20 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
if (obact && (obact->mode != OB_MODE_OBJECT)) {
|
2022-09-14 21:30:20 +02:00
|
|
|
FOREACH_OBJECT_IN_MODE_BEGIN (scene, view_layer, v3d, obact->type, obact->mode, ob_iter) {
|
2020-10-02 11:56:06 +02:00
|
|
|
ob_iter->id.tag |= LIB_TAG_DOIT;
|
|
|
|
|
}
|
|
|
|
|
FOREACH_OBJECT_IN_MODE_END;
|
2022-09-14 21:30:20 +02:00
|
|
|
FOREACH_OBJECT_IN_MODE_BEGIN (scene, view_layer, v3d, obact->type, obact->mode, ob_iter) {
|
2020-10-02 11:56:06 +02:00
|
|
|
if (ob_iter->id.tag & LIB_TAG_DOIT) {
|
|
|
|
|
ob_iter->id.tag &= ~LIB_TAG_DOIT;
|
|
|
|
|
CTX_data_id_list_add(result, &ob_iter->id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
FOREACH_OBJECT_IN_MODE_END;
|
|
|
|
|
}
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_visible_or_editable_bones_(const bContext *C,
|
|
|
|
|
bContextDataResult *result,
|
|
|
|
|
const bool editable_bones)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2022-09-14 21:30:20 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
2022-09-01 10:00:53 +02:00
|
|
|
Object *obedit = BKE_view_layer_edit_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
bArmature *arm = static_cast<bArmature *>(
|
|
|
|
|
(obedit && obedit->type == OB_ARMATURE) ? obedit->data : nullptr);
|
|
|
|
|
EditBone *flipbone = nullptr;
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
if (arm && arm->edbo) {
|
2024-01-24 18:18:14 +01:00
|
|
|
Vector<Object *> objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
|
|
|
|
|
scene, view_layer, CTX_wm_view3d(C));
|
|
|
|
|
for (Object *ob : objects) {
|
2023-07-12 13:43:00 +02:00
|
|
|
arm = static_cast<bArmature *>(ob->data);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
/* Attention: X-Axis Mirroring is also handled here... */
|
|
|
|
|
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
|
|
|
|
|
/* first and foremost, bone must be visible and selected */
|
|
|
|
|
if (EBONE_VISIBLE(arm, ebone)) {
|
|
|
|
|
/* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
|
|
|
|
|
* so that most users of this data don't need to explicitly check for it themselves.
|
|
|
|
|
*
|
|
|
|
|
* We need to make sure that these mirrored copies are not selected, otherwise some
|
|
|
|
|
* bones will be operated on twice.
|
|
|
|
|
*/
|
|
|
|
|
if (arm->flag & ARM_MIRROR_EDIT) {
|
|
|
|
|
flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* if we're filtering for editable too, use the check for that instead,
|
|
|
|
|
* as it has selection check too */
|
|
|
|
|
if (editable_bones) {
|
|
|
|
|
/* only selected + editable */
|
|
|
|
|
if (EBONE_EDITABLE(ebone)) {
|
|
|
|
|
CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
|
|
|
|
|
|
|
|
|
|
if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) {
|
|
|
|
|
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* only include bones if visible */
|
|
|
|
|
CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
|
|
|
|
|
|
|
|
|
|
if ((flipbone) && EBONE_VISIBLE(arm, flipbone) == 0) {
|
|
|
|
|
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_visible_bones(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
return screen_ctx_visible_or_editable_bones_(C, result, false);
|
|
|
|
|
}
|
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 screen_ctx_editable_bones(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
return screen_ctx_visible_or_editable_bones_(C, result, true);
|
|
|
|
|
}
|
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 screen_ctx_selected_bones_(const bContext *C,
|
|
|
|
|
bContextDataResult *result,
|
|
|
|
|
const bool selected_editable_bones)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2022-09-14 21:30:20 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
2022-09-01 10:00:53 +02:00
|
|
|
Object *obedit = BKE_view_layer_edit_object_get(view_layer);
|
2023-07-12 13:43:00 +02:00
|
|
|
bArmature *arm = static_cast<bArmature *>(
|
|
|
|
|
(obedit && obedit->type == OB_ARMATURE) ? obedit->data : nullptr);
|
|
|
|
|
EditBone *flipbone = nullptr;
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
if (arm && arm->edbo) {
|
2024-01-24 18:18:14 +01:00
|
|
|
Vector<Object *> objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
|
|
|
|
|
scene, view_layer, CTX_wm_view3d(C));
|
|
|
|
|
for (Object *ob : objects) {
|
2023-07-12 13:43:00 +02:00
|
|
|
arm = static_cast<bArmature *>(ob->data);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
/* Attention: X-Axis Mirroring is also handled here... */
|
|
|
|
|
LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
|
|
|
|
|
/* first and foremost, bone must be visible and selected */
|
|
|
|
|
if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) {
|
|
|
|
|
/* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
|
|
|
|
|
* so that most users of this data don't need to explicitly check for it themselves.
|
|
|
|
|
*
|
|
|
|
|
* We need to make sure that these mirrored copies are not selected, otherwise some
|
|
|
|
|
* bones will be operated on twice.
|
|
|
|
|
*/
|
|
|
|
|
if (arm->flag & ARM_MIRROR_EDIT) {
|
|
|
|
|
flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* if we're filtering for editable too, use the check for that instead,
|
|
|
|
|
* as it has selection check too */
|
|
|
|
|
if (selected_editable_bones) {
|
|
|
|
|
/* only selected + editable */
|
|
|
|
|
if (EBONE_EDITABLE(ebone)) {
|
|
|
|
|
CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
|
|
|
|
|
|
|
|
|
|
if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) {
|
|
|
|
|
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* only include bones if selected */
|
|
|
|
|
CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
|
|
|
|
|
|
|
|
|
|
if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) {
|
|
|
|
|
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_selected_bones(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
return screen_ctx_selected_bones_(C, result, false);
|
|
|
|
|
}
|
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 screen_ctx_selected_editable_bones(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
return screen_ctx_selected_bones_(C, result, true);
|
|
|
|
|
}
|
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 screen_ctx_visible_pose_bones(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2023-07-12 13:43:00 +02:00
|
|
|
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
|
2022-09-14 21:30:20 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
Object *obpose = BKE_object_pose_armature_get(obact);
|
|
|
|
|
if (obpose && obpose->pose && obpose->data) {
|
|
|
|
|
if (obpose != obact) {
|
|
|
|
|
FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN (obpose, pchan) {
|
|
|
|
|
CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan);
|
|
|
|
|
}
|
|
|
|
|
FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
|
|
|
|
|
}
|
|
|
|
|
else if (obact->mode & OB_MODE_POSE) {
|
2022-09-14 21:30:20 +02:00
|
|
|
FOREACH_OBJECT_IN_MODE_BEGIN (scene, view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter) {
|
2020-10-02 11:56:06 +02:00
|
|
|
FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN (ob_iter, pchan) {
|
|
|
|
|
CTX_data_list_add(result, &ob_iter->id, &RNA_PoseBone, pchan);
|
|
|
|
|
}
|
|
|
|
|
FOREACH_PCHAN_VISIBLE_IN_OBJECT_END;
|
|
|
|
|
}
|
|
|
|
|
FOREACH_OBJECT_IN_MODE_END;
|
|
|
|
|
}
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_selected_pose_bones(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2023-07-12 13:43:00 +02:00
|
|
|
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
|
2022-09-14 21:30:20 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
Object *obpose = BKE_object_pose_armature_get(obact);
|
|
|
|
|
if (obpose && obpose->pose && obpose->data) {
|
|
|
|
|
if (obpose != obact) {
|
|
|
|
|
FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (obpose, pchan) {
|
|
|
|
|
CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan);
|
|
|
|
|
}
|
|
|
|
|
FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
|
|
|
|
|
}
|
|
|
|
|
else if (obact->mode & OB_MODE_POSE) {
|
2022-09-14 21:30:20 +02:00
|
|
|
FOREACH_OBJECT_IN_MODE_BEGIN (scene, view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter) {
|
2020-10-02 11:56:06 +02:00
|
|
|
FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob_iter, pchan) {
|
|
|
|
|
CTX_data_list_add(result, &ob_iter->id, &RNA_PoseBone, pchan);
|
|
|
|
|
}
|
|
|
|
|
FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
|
|
|
|
|
}
|
|
|
|
|
FOREACH_OBJECT_IN_MODE_END;
|
|
|
|
|
}
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_selected_pose_bones_from_active_object(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
Object *obpose = BKE_object_pose_armature_get(obact);
|
|
|
|
|
if (obpose && obpose->pose && obpose->data) {
|
|
|
|
|
if (obpose != obact) {
|
|
|
|
|
FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (obpose, pchan) {
|
|
|
|
|
CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan);
|
|
|
|
|
}
|
|
|
|
|
FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
|
|
|
|
|
}
|
|
|
|
|
else if (obact->mode & OB_MODE_POSE) {
|
|
|
|
|
FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (obact, pchan) {
|
|
|
|
|
CTX_data_list_add(result, &obact->id, &RNA_PoseBone, pchan);
|
|
|
|
|
}
|
|
|
|
|
FOREACH_PCHAN_SELECTED_IN_OBJECT_END;
|
|
|
|
|
}
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_active_bone(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
if (obact && obact->type == OB_ARMATURE) {
|
2023-07-12 13:43:00 +02:00
|
|
|
bArmature *arm = static_cast<bArmature *>(obact->data);
|
2020-10-02 11:56:06 +02:00
|
|
|
if (arm->edbo) {
|
|
|
|
|
if (arm->act_edbone) {
|
|
|
|
|
CTX_data_pointer_set(result, &arm->id, &RNA_EditBone, arm->act_edbone);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (arm->act_bone) {
|
|
|
|
|
CTX_data_pointer_set(result, &arm->id, &RNA_Bone, arm->act_bone);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_active_pose_bone(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
Object *obpose = BKE_object_pose_armature_get(obact);
|
|
|
|
|
|
2023-08-29 10:59:06 +02:00
|
|
|
bPoseChannel *pchan = BKE_pose_channel_active_if_bonecoll_visible(obpose);
|
2020-10-02 11:56:06 +02:00
|
|
|
if (pchan) {
|
|
|
|
|
CTX_data_pointer_set(result, &obpose->id, &RNA_PoseBone, pchan);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_active_object(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
if (obact) {
|
|
|
|
|
CTX_data_id_pointer_set(result, &obact->id);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02:00
|
|
|
}
|
2023-04-29 20:31:27 -07:00
|
|
|
|
|
|
|
|
static eContextResult screen_ctx_property(const bContext *C, bContextDataResult *result)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
int index;
|
|
|
|
|
|
|
|
|
|
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
|
2023-06-06 16:22:56 +02:00
|
|
|
if (ptr.data && prop) {
|
|
|
|
|
/* UI_context_active_but_prop_get returns an index of 0 if the property is not
|
|
|
|
|
* an array, but other functions expect -1 for non-arrays. */
|
|
|
|
|
if (!RNA_property_array_check(prop)) {
|
|
|
|
|
index = -1;
|
|
|
|
|
}
|
2023-04-29 20:31:27 -07:00
|
|
|
|
2023-06-06 16:22:56 +02:00
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_PROPERTY);
|
|
|
|
|
CTX_data_pointer_set_ptr(result, &ptr);
|
|
|
|
|
CTX_data_prop_set(result, prop, index);
|
|
|
|
|
}
|
2023-04-29 20:31:27 -07:00
|
|
|
|
|
|
|
|
return CTX_RESULT_OK;
|
|
|
|
|
}
|
|
|
|
|
|
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 screen_ctx_object(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
if (obact) {
|
|
|
|
|
CTX_data_id_pointer_set(result, &obact->id);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_edit_object(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
2022-09-01 10:00:53 +02:00
|
|
|
Object *obedit = BKE_view_layer_edit_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
/* convenience for now, 1 object per scene in editmode */
|
|
|
|
|
if (obedit) {
|
|
|
|
|
CTX_data_id_pointer_set(result, &obedit->id);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_sculpt_object(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
if (obact && (obact->mode & OB_MODE_SCULPT)) {
|
|
|
|
|
CTX_data_id_pointer_set(result, &obact->id);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_vertex_paint_object(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
if (obact && (obact->mode & OB_MODE_VERTEX_PAINT)) {
|
|
|
|
|
CTX_data_id_pointer_set(result, &obact->id);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_weight_paint_object(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
if (obact && (obact->mode & OB_MODE_ALL_WEIGHT_PAINT)) {
|
|
|
|
|
CTX_data_id_pointer_set(result, &obact->id);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_image_paint_object(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
if (obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) {
|
|
|
|
|
CTX_data_id_pointer_set(result, &obact->id);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_particle_edit_object(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
if (obact && (obact->mode & OB_MODE_PARTICLE_EDIT)) {
|
|
|
|
|
CTX_data_id_pointer_set(result, &obact->id);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_pose_object(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
Object *obpose = BKE_object_pose_armature_get(obact);
|
|
|
|
|
if (obpose) {
|
|
|
|
|
CTX_data_id_pointer_set(result, &obpose->id);
|
|
|
|
|
}
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02:00
|
|
|
}
|
2021-08-30 20:56:37 +10:00
|
|
|
static eContextResult screen_ctx_active_sequence_strip(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
|
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
|
|
|
|
Sequence *seq = SEQ_select_active_get(scene);
|
|
|
|
|
if (seq) {
|
|
|
|
|
CTX_data_pointer_set(result, &scene->id, &RNA_Sequence, seq);
|
|
|
|
|
return CTX_RESULT_OK;
|
|
|
|
|
}
|
|
|
|
|
return CTX_RESULT_NO_DATA;
|
|
|
|
|
}
|
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 screen_ctx_sequences(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
2021-09-02 11:29:32 +10:00
|
|
|
Editing *ed = SEQ_editing_get(scene);
|
2020-10-02 11:56:06 +02:00
|
|
|
if (ed) {
|
|
|
|
|
LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) {
|
|
|
|
|
CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq);
|
|
|
|
|
}
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_selected_sequences(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
2021-09-02 11:29:32 +10:00
|
|
|
Editing *ed = SEQ_editing_get(scene);
|
2020-10-02 11:56:06 +02:00
|
|
|
if (ed) {
|
|
|
|
|
LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) {
|
|
|
|
|
if (seq->flag & SELECT) {
|
|
|
|
|
CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_selected_editable_sequences(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
2021-09-02 11:29:32 +10:00
|
|
|
Editing *ed = SEQ_editing_get(scene);
|
2023-07-12 13:43:00 +02:00
|
|
|
if (ed == nullptr) {
|
2022-04-04 16:27:37 +02:00
|
|
|
return CTX_RESULT_NO_DATA;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-04 12:52:48 +02:00
|
|
|
ListBase *channels = SEQ_channels_displayed_get(ed);
|
2022-04-04 16:27:37 +02:00
|
|
|
LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) {
|
|
|
|
|
if (seq->flag & SELECT && !SEQ_transform_is_locked(channels, seq)) {
|
|
|
|
|
CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq);
|
2020-10-02 11:56:06 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-04-04 16:27:37 +02:00
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
|
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02:00
|
|
|
}
|
2022-04-04 16:27:37 +02:00
|
|
|
|
2021-08-31 11:46:46 +10:00
|
|
|
static eContextResult screen_ctx_active_nla_track(const bContext *C, bContextDataResult *result)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr;
|
|
|
|
|
if (ANIM_nla_context_track_ptr(C, &ptr)) {
|
2021-08-31 12:45:45 +10:00
|
|
|
CTX_data_pointer_set_ptr(result, &ptr);
|
2021-08-31 11:46:46 +10:00
|
|
|
return CTX_RESULT_OK;
|
|
|
|
|
}
|
|
|
|
|
return CTX_RESULT_NO_DATA;
|
|
|
|
|
}
|
|
|
|
|
static eContextResult screen_ctx_active_nla_strip(const bContext *C, bContextDataResult *result)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr;
|
|
|
|
|
if (ANIM_nla_context_strip_ptr(C, &ptr)) {
|
2021-08-31 12:45:45 +10:00
|
|
|
CTX_data_pointer_set_ptr(result, &ptr);
|
2021-08-31 11:46:46 +10:00
|
|
|
return CTX_RESULT_OK;
|
|
|
|
|
}
|
|
|
|
|
return CTX_RESULT_NO_DATA;
|
|
|
|
|
}
|
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 screen_ctx_selected_nla_strips(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
bAnimContext ac;
|
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) != 0) {
|
2023-07-12 13:43:00 +02:00
|
|
|
ListBase anim_data = {nullptr, nullptr};
|
2020-10-02 11:56:06 +02:00
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
ANIM_animdata_filter(
|
|
|
|
|
&ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac.data, eAnimCont_Types(ac.datatype));
|
2020-10-02 11:56:06 +02:00
|
|
|
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
|
|
|
|
|
if (ale->datatype != ALE_NLASTRIP) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
NlaTrack *nlt = (NlaTrack *)ale->data;
|
|
|
|
|
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
|
|
|
|
|
if (strip->flag & NLASTRIP_FLAG_SELECT) {
|
2020-12-14 16:55:19 -05:00
|
|
|
CTX_data_list_add(result, ale->id, &RNA_NlaStrip, strip);
|
2020-10-02 11:56:06 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ANIM_animdata_freelist(&anim_data);
|
|
|
|
|
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02:00
|
|
|
}
|
2021-10-19 16:24:23 +02:00
|
|
|
static eContextResult screen_ctx_selected_movieclip_tracks(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
|
|
|
|
{
|
|
|
|
|
SpaceClip *space_clip = CTX_wm_space_clip(C);
|
2023-07-12 13:43:00 +02:00
|
|
|
if (space_clip == nullptr) {
|
2021-10-19 16:24:23 +02:00
|
|
|
return CTX_RESULT_NO_DATA;
|
|
|
|
|
}
|
|
|
|
|
MovieClip *clip = ED_space_clip_get_clip(space_clip);
|
2023-07-12 13:43:00 +02:00
|
|
|
if (clip == nullptr) {
|
2021-10-19 16:24:23 +02:00
|
|
|
return CTX_RESULT_NO_DATA;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-07 11:32:21 +02:00
|
|
|
const MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking);
|
|
|
|
|
LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
|
2021-10-19 16:24:23 +02:00
|
|
|
if (!TRACK_SELECTED(track)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
CTX_data_list_add(result, &clip->id, &RNA_MovieTrackingTrack, track);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
|
|
|
|
return CTX_RESULT_OK;
|
|
|
|
|
}
|
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 screen_ctx_gpencil_data(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2023-07-12 13:43:00 +02:00
|
|
|
/* FIXME: for some reason, CTX_data_active_object(C) returns nullptr when called from these
|
2020-10-02 11:56:06 +02:00
|
|
|
* situations (as outlined above - see Campbell's #ifdefs).
|
|
|
|
|
* That causes the get_active function to fail when called from context.
|
|
|
|
|
* For that reason, we end up using an alternative where we pass everything in!
|
|
|
|
|
*/
|
|
|
|
|
bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
|
|
|
|
|
|
|
|
|
|
if (gpd) {
|
|
|
|
|
CTX_data_id_pointer_set(result, &gpd->id);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_gpencil_data_owner(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-16 21:56:58 -05:00
|
|
|
|
2020-10-02 11:56:06 +02:00
|
|
|
/* Pointer to which data/datablock owns the reference to the Grease Pencil data being used
|
|
|
|
|
* (as gpencil_data). */
|
|
|
|
|
PointerRNA ptr;
|
2020-10-16 21:56:58 -05:00
|
|
|
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers_direct(area, obact, &ptr);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
if (gpd_ptr) {
|
2021-08-31 12:45:45 +10:00
|
|
|
CTX_data_pointer_set_ptr(result, &ptr);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_annotation_data(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
|
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
|
|
|
|
bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)screen, area, scene);
|
|
|
|
|
|
|
|
|
|
if (gpd) {
|
|
|
|
|
CTX_data_id_pointer_set(result, &gpd->id);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_annotation_data_owner(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
|
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
2020-10-16 21:56:58 -05:00
|
|
|
|
2020-10-02 11:56:06 +02:00
|
|
|
/* Pointer to which data/datablock owns the reference to the Grease Pencil data being used. */
|
|
|
|
|
PointerRNA ptr;
|
2020-10-16 21:56:58 -05:00
|
|
|
bGPdata **gpd_ptr = ED_annotation_data_get_pointers_direct((ID *)screen, area, scene, &ptr);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
if (gpd_ptr) {
|
2021-08-31 12:45:45 +10:00
|
|
|
CTX_data_pointer_set_ptr(result, &ptr);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_active_gpencil_layer(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
|
|
|
|
|
|
|
|
|
|
if (gpd) {
|
|
|
|
|
bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
|
|
|
|
|
|
|
|
|
|
if (gpl) {
|
|
|
|
|
CTX_data_pointer_set(result, &gpd->id, &RNA_GPencilLayer, gpl);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_active_annotation_layer(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
|
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
|
|
|
|
bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)screen, area, scene);
|
|
|
|
|
|
|
|
|
|
if (gpd) {
|
|
|
|
|
bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
|
|
|
|
|
|
|
|
|
|
if (gpl) {
|
|
|
|
|
CTX_data_pointer_set(result, &gpd->id, &RNA_GPencilLayer, gpl);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_active_gpencil_frame(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
|
|
|
|
|
|
|
|
|
|
if (gpd) {
|
|
|
|
|
bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd);
|
|
|
|
|
|
|
|
|
|
if (gpl) {
|
|
|
|
|
CTX_data_pointer_set(result, &gpd->id, &RNA_GPencilLayer, gpl->actframe);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_visible_gpencil_layers(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
|
|
|
|
|
|
|
|
|
|
if (gpd) {
|
|
|
|
|
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
|
|
|
|
|
if ((gpl->flag & GP_LAYER_HIDE) == 0) {
|
|
|
|
|
CTX_data_list_add(result, &gpd->id, &RNA_GPencilLayer, gpl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_editable_gpencil_layers(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
|
|
|
|
|
|
|
|
|
|
if (gpd) {
|
|
|
|
|
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
|
|
|
|
|
if (BKE_gpencil_layer_is_editable(gpl)) {
|
|
|
|
|
CTX_data_list_add(result, &gpd->id, &RNA_GPencilLayer, gpl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_editable_gpencil_strokes(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2020-10-02 11:56:06 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
|
|
|
|
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
bGPdata *gpd = ED_gpencil_data_get_active_direct(area, obact);
|
2023-07-18 14:18:07 +10:00
|
|
|
const bool is_multiedit = bool(GPENCIL_MULTIEDIT_SESSIONS_ON(gpd));
|
2020-10-02 11:56:06 +02:00
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
if (gpd == nullptr) {
|
2020-10-16 21:56:58 -05:00
|
|
|
return CTX_RESULT_NO_DATA;
|
|
|
|
|
}
|
2020-10-02 11:56:06 +02:00
|
|
|
|
2020-10-16 21:56:58 -05:00
|
|
|
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
|
|
|
|
|
if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe)) {
|
|
|
|
|
bGPDframe *gpf;
|
|
|
|
|
bGPDframe *init_gpf = gpl->actframe;
|
|
|
|
|
if (is_multiedit) {
|
2023-07-12 13:43:00 +02:00
|
|
|
init_gpf = static_cast<bGPDframe *>(gpl->frames.first);
|
2020-10-16 21:56:58 -05:00
|
|
|
}
|
2020-10-02 11:56:06 +02:00
|
|
|
|
2020-10-16 21:56:58 -05:00
|
|
|
for (gpf = init_gpf; gpf; gpf = gpf->next) {
|
|
|
|
|
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
|
|
|
|
|
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
|
|
|
|
|
if (ED_gpencil_stroke_can_use_direct(area, gps)) {
|
|
|
|
|
/* check if the color is editable */
|
2021-01-16 16:44:49 +01:00
|
|
|
if (ED_gpencil_stroke_material_editable(obact, gpl, gps) == false) {
|
2020-10-16 21:56:58 -05:00
|
|
|
continue;
|
2020-10-02 11:56:06 +02:00
|
|
|
}
|
2020-10-16 21:56:58 -05:00
|
|
|
|
|
|
|
|
CTX_data_list_add(result, &gpd->id, &RNA_GPencilStroke, gps);
|
2020-10-02 11:56:06 +02:00
|
|
|
}
|
|
|
|
|
}
|
2020-10-16 21:56:58 -05:00
|
|
|
}
|
2021-06-26 21:35:18 +10:00
|
|
|
/* If not multi-edit out of loop. */
|
2020-10-16 21:56:58 -05:00
|
|
|
if (!is_multiedit) {
|
|
|
|
|
break;
|
2020-10-02 11:56:06 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-16 21:56:58 -05:00
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
|
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_active_operator(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
2023-07-12 13:43:00 +02:00
|
|
|
wmOperator *op = nullptr;
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
SpaceFile *sfile = CTX_wm_space_file(C);
|
|
|
|
|
if (sfile) {
|
|
|
|
|
op = sfile->op;
|
|
|
|
|
}
|
|
|
|
|
else if ((op = UI_context_active_operator_get(C))) {
|
|
|
|
|
/* do nothing */
|
|
|
|
|
}
|
|
|
|
|
else {
|
2021-07-03 23:08:40 +10:00
|
|
|
/* NOTE: this checks poll, could be a problem, but this also
|
2020-10-02 11:56:06 +02:00
|
|
|
* happens for the toolbar */
|
|
|
|
|
op = WM_operator_last_redo(C);
|
|
|
|
|
}
|
2021-07-03 23:08:40 +10:00
|
|
|
/* TODO: get the operator from popup's. */
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
if (op && op->ptr) {
|
2023-07-12 13:43:00 +02:00
|
|
|
CTX_data_pointer_set(result, nullptr, &RNA_Operator, op);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02:00
|
|
|
}
|
2021-07-16 12:36:57 +03:00
|
|
|
static eContextResult screen_ctx_sel_actions_impl(const bContext *C,
|
|
|
|
|
bContextDataResult *result,
|
2022-07-10 12:28:44 +03:00
|
|
|
bool active_only,
|
2021-07-16 12:36:57 +03:00
|
|
|
bool editable)
|
|
|
|
|
{
|
|
|
|
|
bAnimContext ac;
|
2024-03-22 16:49:12 +01:00
|
|
|
if (!ANIM_animdata_get_context(C, &ac) || !ELEM(ac.spacetype, SPACE_ACTION, SPACE_GRAPH)) {
|
|
|
|
|
return CTX_RESULT_NO_DATA;
|
|
|
|
|
}
|
2022-07-10 12:28:44 +03:00
|
|
|
|
2024-03-22 16:49:12 +01:00
|
|
|
/* In the Action and Shape Key editor always use the action field at the top. */
|
|
|
|
|
if (ac.spacetype == SPACE_ACTION) {
|
|
|
|
|
SpaceAction *saction = (SpaceAction *)ac.sl;
|
2021-07-16 12:36:57 +03:00
|
|
|
|
2024-03-22 16:49:12 +01:00
|
|
|
if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY)) {
|
|
|
|
|
if (active_only) {
|
|
|
|
|
CTX_data_id_pointer_set(result, (ID *)saction->action);
|
2021-07-16 12:36:57 +03:00
|
|
|
}
|
2024-03-22 16:49:12 +01:00
|
|
|
else {
|
|
|
|
|
if (saction->action && !(editable && ID_IS_LINKED(saction->action))) {
|
|
|
|
|
CTX_data_id_list_add(result, &saction->action->id);
|
|
|
|
|
}
|
2021-07-16 12:36:57 +03:00
|
|
|
|
2024-03-22 16:49:12 +01:00
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
|
|
|
|
}
|
2021-07-16 12:36:57 +03:00
|
|
|
|
2024-03-22 16:49:12 +01:00
|
|
|
return CTX_RESULT_OK;
|
2021-07-16 12:36:57 +03:00
|
|
|
}
|
2024-03-22 16:49:12 +01:00
|
|
|
}
|
2021-07-16 12:36:57 +03:00
|
|
|
|
2024-03-22 16:49:12 +01:00
|
|
|
/* Search for selected animation data items. */
|
|
|
|
|
ListBase anim_data = {nullptr, nullptr};
|
2021-07-16 12:36:57 +03:00
|
|
|
|
2024-03-22 16:49:12 +01:00
|
|
|
int filter = ANIMFILTER_DATA_VISIBLE;
|
|
|
|
|
bool check_selected = false;
|
2021-07-16 12:36:57 +03:00
|
|
|
|
2024-03-22 16:49:12 +01:00
|
|
|
switch (ac.spacetype) {
|
|
|
|
|
case SPACE_GRAPH:
|
|
|
|
|
filter |= ANIMFILTER_FCURVESONLY | ANIMFILTER_CURVE_VISIBLE |
|
|
|
|
|
(active_only ? ANIMFILTER_ACTIVE : ANIMFILTER_SEL);
|
|
|
|
|
break;
|
2021-07-16 12:36:57 +03:00
|
|
|
|
2024-03-22 16:49:12 +01:00
|
|
|
case SPACE_ACTION:
|
|
|
|
|
filter |= ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS;
|
|
|
|
|
check_selected = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-07-16 12:36:57 +03:00
|
|
|
|
2024-03-22 16:49:12 +01:00
|
|
|
ANIM_animdata_filter(
|
|
|
|
|
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
|
2021-07-16 12:36:57 +03:00
|
|
|
|
2024-03-22 16:49:12 +01:00
|
|
|
GSet *seen_set = active_only ? nullptr : BLI_gset_ptr_new("seen actions");
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
|
|
|
|
|
/* In dopesheet check selection status of individual items, skipping
|
|
|
|
|
* if not selected or has no selection flag. This is needed so that
|
|
|
|
|
* selecting action or group rows without any channels works. */
|
|
|
|
|
if (check_selected && ANIM_channel_setting_get(&ac, ale, ACHANNEL_SETTING_SELECT) <= 0) {
|
|
|
|
|
continue;
|
2021-07-16 12:36:57 +03:00
|
|
|
}
|
|
|
|
|
|
2024-03-22 16:49:12 +01:00
|
|
|
bAction *action = ANIM_channel_action_get(ale);
|
|
|
|
|
if (!action) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2021-07-16 12:36:57 +03:00
|
|
|
|
2024-03-22 16:49:12 +01:00
|
|
|
if (active_only) {
|
|
|
|
|
CTX_data_id_pointer_set(result, (ID *)action);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (editable && ID_IS_LINKED(action)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2022-07-10 12:28:44 +03:00
|
|
|
|
2024-03-22 16:49:12 +01:00
|
|
|
/* Add the action to the output list if not already added. */
|
|
|
|
|
if (BLI_gset_add(seen_set, action)) {
|
|
|
|
|
CTX_data_id_list_add(result, &action->id);
|
2022-07-10 12:28:44 +03:00
|
|
|
}
|
2024-03-22 16:49:12 +01:00
|
|
|
}
|
2022-07-10 12:28:44 +03:00
|
|
|
|
2024-03-22 16:49:12 +01:00
|
|
|
ANIM_animdata_freelist(&anim_data);
|
|
|
|
|
|
|
|
|
|
if (!active_only) {
|
|
|
|
|
BLI_gset_free(seen_set, nullptr);
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
2021-07-16 12:36:57 +03:00
|
|
|
}
|
2024-03-22 16:49:12 +01:00
|
|
|
|
|
|
|
|
return CTX_RESULT_OK;
|
2021-07-16 12:36:57 +03:00
|
|
|
}
|
2022-07-10 12:28:44 +03:00
|
|
|
static eContextResult screen_ctx_active_action(const bContext *C, bContextDataResult *result)
|
|
|
|
|
{
|
|
|
|
|
return screen_ctx_sel_actions_impl(C, result, true, false);
|
|
|
|
|
}
|
2021-07-16 12:36:57 +03:00
|
|
|
static eContextResult screen_ctx_selected_visible_actions(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
|
|
|
|
{
|
2022-07-10 12:28:44 +03:00
|
|
|
return screen_ctx_sel_actions_impl(C, result, false, false);
|
2021-07-16 12:36:57 +03:00
|
|
|
}
|
|
|
|
|
static eContextResult screen_ctx_selected_editable_actions(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
|
|
|
|
{
|
2022-07-10 12:28:44 +03:00
|
|
|
return screen_ctx_sel_actions_impl(C, result, false, true);
|
2021-07-16 12:36:57 +03: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
|
|
|
static eContextResult screen_ctx_sel_edit_fcurves_(const bContext *C,
|
|
|
|
|
bContextDataResult *result,
|
|
|
|
|
const int extra_filter)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
bAnimContext ac;
|
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_ACTION, SPACE_GRAPH)) {
|
2023-07-12 13:43:00 +02:00
|
|
|
ListBase anim_data = {nullptr, nullptr};
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS) |
|
Animation: Add GP layers in regular Dopesheet
Grease Pencil animation channels are now also shown in the Dopesheet
mode of the Dopesheet editor and in the Timeline.
Grease pencil related events are now listened not only by container
`SACTCONT_GPENCIL` (Grease Pencil Dopesheet), but also
`SACTCONT_DOPESHEET` (main Dopesheet), and `SACTCONT_TIMELINE`
(timeline).
A new Animation Filter flag was added: `ANIMFILTER_FCURVESONLY`. For now
this only filters out Grease Pencil Layer channels.
**Implemented:**
- Preview range set: now only considers selected Grease Pencil keyframes
when `onlySel` parameter is true. Not only this allows the operator to
work with grease pencil keyframes in main dopesheet, but it also fixes
the operator in the Grease Pencil dopesheet.
- Translation: allocation (and freeing) of specific memory for
translation of Grease Pencil keyframes.
- Copy/Paste: call to both Fcurve and GPencil operators, to allow for
mixed selection. Errors are only reported when both the FCurve and
GPencil functions fail to paste anything.
- Keyframe Type change and Insert Keyframe: removed some code here to
unify Grease Pencil dopesheet and main dopesheet code.
- Jump, Snap, Mirror, Select all/box/lasso/circle, Select left/right,
Clickselect: account for Grease Pencil channels within the channels
loop, no need for `ANIMFILTER_FCURVESONLY` there.
**Not Implemented:**
- Graph-related operators. The filter `ANIMFILTER_FCURVESONLY` is
naively added to all graph-related operators, meaning more-or-less all
operators that used `ANIMFILTER_CURVE_VISIBLE`.
- Select linked: is for F-curves channel only
- Select more/less: not yet implemented for grease pencil layers.
- Clean Keys, Sample, Extrapolation, Interpolation, Easing, and Handle
type change: work on Fcurve-channels only, so the
`ANIMFILTER_FCURVESONLY` filter is activated
Graying out these operators (when no fcurve keyframe is selected) can be
done with custom poll functions BUT may affect performance. This is NOT
done in this patch.
**Dopesheet Summary Selection:**
The main summary of the dopesheet now also takes into account Grease
Pencil keyframes, using some nasty copy/pasting of code, as explained
[on devtalk](https://devtalk.blender.org/t/gpencil-layers-integration-in-main-dopesheet-selection-issue/24527).
It works, but may be improved, providing some deeper changes.
Reviewed By: mendio, pepeland, sybren
Maniphest Tasks: T97477
Differential Revision: https://developer.blender.org/D15003
2022-06-30 15:16:05 +02:00
|
|
|
(ac.spacetype == SPACE_GRAPH ?
|
|
|
|
|
(ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY) :
|
|
|
|
|
ANIMFILTER_LIST_VISIBLE) |
|
2020-10-02 11:56:06 +02:00
|
|
|
extra_filter;
|
|
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
ANIM_animdata_filter(
|
|
|
|
|
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
|
|
|
|
|
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
|
|
|
|
|
CTX_data_list_add(result, ale->fcurve_owner_id, &RNA_FCurve, ale->data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ANIM_animdata_freelist(&anim_data);
|
|
|
|
|
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02: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
|
|
|
static eContextResult screen_ctx_editable_fcurves(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
return screen_ctx_sel_edit_fcurves_(C, result, ANIMFILTER_FOREDIT);
|
|
|
|
|
}
|
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 screen_ctx_visible_fcurves(const bContext *C, bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
return screen_ctx_sel_edit_fcurves_(C, result, 0);
|
|
|
|
|
}
|
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 screen_ctx_selected_editable_fcurves(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
return screen_ctx_sel_edit_fcurves_(C, result, ANIMFILTER_SEL | ANIMFILTER_FOREDIT);
|
|
|
|
|
}
|
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 screen_ctx_selected_visible_fcurves(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2008-12-23 02:07:13 +00:00
|
|
|
{
|
2020-10-02 11:56:06 +02:00
|
|
|
return screen_ctx_sel_edit_fcurves_(C, result, ANIMFILTER_SEL);
|
|
|
|
|
}
|
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 screen_ctx_active_editable_fcurve(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
2020-10-02 11:56:06 +02:00
|
|
|
{
|
|
|
|
|
bAnimContext ac;
|
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_GRAPH)) {
|
2023-07-12 13:43:00 +02:00
|
|
|
ListBase anim_data = {nullptr, nullptr};
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT |
|
Animation: Add GP layers in regular Dopesheet
Grease Pencil animation channels are now also shown in the Dopesheet
mode of the Dopesheet editor and in the Timeline.
Grease pencil related events are now listened not only by container
`SACTCONT_GPENCIL` (Grease Pencil Dopesheet), but also
`SACTCONT_DOPESHEET` (main Dopesheet), and `SACTCONT_TIMELINE`
(timeline).
A new Animation Filter flag was added: `ANIMFILTER_FCURVESONLY`. For now
this only filters out Grease Pencil Layer channels.
**Implemented:**
- Preview range set: now only considers selected Grease Pencil keyframes
when `onlySel` parameter is true. Not only this allows the operator to
work with grease pencil keyframes in main dopesheet, but it also fixes
the operator in the Grease Pencil dopesheet.
- Translation: allocation (and freeing) of specific memory for
translation of Grease Pencil keyframes.
- Copy/Paste: call to both Fcurve and GPencil operators, to allow for
mixed selection. Errors are only reported when both the FCurve and
GPencil functions fail to paste anything.
- Keyframe Type change and Insert Keyframe: removed some code here to
unify Grease Pencil dopesheet and main dopesheet code.
- Jump, Snap, Mirror, Select all/box/lasso/circle, Select left/right,
Clickselect: account for Grease Pencil channels within the channels
loop, no need for `ANIMFILTER_FCURVESONLY` there.
**Not Implemented:**
- Graph-related operators. The filter `ANIMFILTER_FCURVESONLY` is
naively added to all graph-related operators, meaning more-or-less all
operators that used `ANIMFILTER_CURVE_VISIBLE`.
- Select linked: is for F-curves channel only
- Select more/less: not yet implemented for grease pencil layers.
- Clean Keys, Sample, Extrapolation, Interpolation, Easing, and Handle
type change: work on Fcurve-channels only, so the
`ANIMFILTER_FCURVESONLY` filter is activated
Graying out these operators (when no fcurve keyframe is selected) can be
done with custom poll functions BUT may affect performance. This is NOT
done in this patch.
**Dopesheet Summary Selection:**
The main summary of the dopesheet now also takes into account Grease
Pencil keyframes, using some nasty copy/pasting of code, as explained
[on devtalk](https://devtalk.blender.org/t/gpencil-layers-integration-in-main-dopesheet-selection-issue/24527).
It works, but may be improved, providing some deeper changes.
Reviewed By: mendio, pepeland, sybren
Maniphest Tasks: T97477
Differential Revision: https://developer.blender.org/D15003
2022-06-30 15:16:05 +02:00
|
|
|
ANIMFILTER_FCURVESONLY | ANIMFILTER_CURVE_VISIBLE);
|
2020-10-02 11:56:06 +02:00
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
ANIM_animdata_filter(
|
|
|
|
|
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
|
2020-10-02 11:56:06 +02:00
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
|
|
|
|
|
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
|
|
|
|
|
CTX_data_pointer_set(result, ale->fcurve_owner_id, &RNA_FCurve, ale->data);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-02 11:56:06 +02:00
|
|
|
ANIM_animdata_freelist(&anim_data);
|
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
|
|
|
return CTX_RESULT_OK;
|
2020-10-02 11:56:06 +02: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
|
|
|
return CTX_RESULT_NO_DATA;
|
2020-10-02 11:56:06 +02:00
|
|
|
}
|
2020-10-15 14:53:26 -04:00
|
|
|
static eContextResult screen_ctx_selected_editable_keyframes(const bContext *C,
|
|
|
|
|
bContextDataResult *result)
|
|
|
|
|
{
|
|
|
|
|
bAnimContext ac;
|
|
|
|
|
if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_ACTION, SPACE_GRAPH)) {
|
2023-07-12 13:43:00 +02:00
|
|
|
ListBase anim_data = {nullptr, nullptr};
|
2020-10-15 14:53:26 -04:00
|
|
|
|
|
|
|
|
/* Use keyframes from editable selected FCurves. */
|
|
|
|
|
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS | ANIMFILTER_FOREDIT |
|
|
|
|
|
ANIMFILTER_SEL) |
|
Animation: Add GP layers in regular Dopesheet
Grease Pencil animation channels are now also shown in the Dopesheet
mode of the Dopesheet editor and in the Timeline.
Grease pencil related events are now listened not only by container
`SACTCONT_GPENCIL` (Grease Pencil Dopesheet), but also
`SACTCONT_DOPESHEET` (main Dopesheet), and `SACTCONT_TIMELINE`
(timeline).
A new Animation Filter flag was added: `ANIMFILTER_FCURVESONLY`. For now
this only filters out Grease Pencil Layer channels.
**Implemented:**
- Preview range set: now only considers selected Grease Pencil keyframes
when `onlySel` parameter is true. Not only this allows the operator to
work with grease pencil keyframes in main dopesheet, but it also fixes
the operator in the Grease Pencil dopesheet.
- Translation: allocation (and freeing) of specific memory for
translation of Grease Pencil keyframes.
- Copy/Paste: call to both Fcurve and GPencil operators, to allow for
mixed selection. Errors are only reported when both the FCurve and
GPencil functions fail to paste anything.
- Keyframe Type change and Insert Keyframe: removed some code here to
unify Grease Pencil dopesheet and main dopesheet code.
- Jump, Snap, Mirror, Select all/box/lasso/circle, Select left/right,
Clickselect: account for Grease Pencil channels within the channels
loop, no need for `ANIMFILTER_FCURVESONLY` there.
**Not Implemented:**
- Graph-related operators. The filter `ANIMFILTER_FCURVESONLY` is
naively added to all graph-related operators, meaning more-or-less all
operators that used `ANIMFILTER_CURVE_VISIBLE`.
- Select linked: is for F-curves channel only
- Select more/less: not yet implemented for grease pencil layers.
- Clean Keys, Sample, Extrapolation, Interpolation, Easing, and Handle
type change: work on Fcurve-channels only, so the
`ANIMFILTER_FCURVESONLY` filter is activated
Graying out these operators (when no fcurve keyframe is selected) can be
done with custom poll functions BUT may affect performance. This is NOT
done in this patch.
**Dopesheet Summary Selection:**
The main summary of the dopesheet now also takes into account Grease
Pencil keyframes, using some nasty copy/pasting of code, as explained
[on devtalk](https://devtalk.blender.org/t/gpencil-layers-integration-in-main-dopesheet-selection-issue/24527).
It works, but may be improved, providing some deeper changes.
Reviewed By: mendio, pepeland, sybren
Maniphest Tasks: T97477
Differential Revision: https://developer.blender.org/D15003
2022-06-30 15:16:05 +02:00
|
|
|
(ac.spacetype == SPACE_GRAPH ?
|
|
|
|
|
(ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FCURVESONLY) :
|
|
|
|
|
ANIMFILTER_LIST_VISIBLE);
|
2020-10-15 14:53:26 -04:00
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
ANIM_animdata_filter(
|
|
|
|
|
&ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
|
2020-10-15 14:53:26 -04:00
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
FCurve *fcurve;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
|
|
|
|
|
if (!ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fcurve = (FCurve *)ale->data;
|
2023-07-12 13:43:00 +02:00
|
|
|
if (fcurve->bezt == nullptr) {
|
2020-12-03 15:02:56 +01:00
|
|
|
/* Skip baked FCurves. */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-15 14:53:26 -04:00
|
|
|
for (i = 0, bezt = fcurve->bezt; i < fcurve->totvert; i++, bezt++) {
|
|
|
|
|
if ((bezt->f2 & SELECT) == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CTX_data_list_add(result, ale->fcurve_owner_id, &RNA_Keyframe, bezt);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ANIM_animdata_freelist(&anim_data);
|
|
|
|
|
|
|
|
|
|
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
|
|
|
|
|
return CTX_RESULT_OK;
|
|
|
|
|
}
|
|
|
|
|
return CTX_RESULT_NO_DATA;
|
|
|
|
|
}
|
2020-10-02 11:56:06 +02:00
|
|
|
|
2021-07-08 22:33:02 +02:00
|
|
|
static eContextResult screen_ctx_asset_library(const bContext *C, bContextDataResult *result)
|
|
|
|
|
{
|
|
|
|
|
WorkSpace *workspace = CTX_wm_workspace(C);
|
|
|
|
|
CTX_data_pointer_set(
|
2021-08-06 15:18:18 +02:00
|
|
|
result, &workspace->id, &RNA_AssetLibraryReference, &workspace->asset_library_ref);
|
2021-07-08 22:33:02 +02:00
|
|
|
return CTX_RESULT_OK;
|
|
|
|
|
}
|
|
|
|
|
|
UI: Support UI list tooltips, defined via Python scripts
Makes it possible to create tooltips for UI list rows, which can be
filled in .py scripts, similar to how they can extend other menus. This
is used by the (to be committed) Pose Library add-on to display pose
operations (selecting bones of a pose, blending a pose, etc).
It's important that the Python scripts check if the UI list is the
correct one by checking the list ID.
For this to work, a new `bpy.context.ui_list` can be checked. For
example, the Pose Library add-on does the following check:
```
def is_pose_asset_view() -> bool:
# Important: Must check context first, or the menu is added for every kind of list.
list = getattr(context, "ui_list", None)
if not list or list.bl_idname != "UI_UL_asset_view" or list.list_id != "pose_assets":
return False
if not context.asset_handle:
return False
return True
```
2021-07-13 15:01:00 +02:00
|
|
|
static eContextResult screen_ctx_ui_list(const bContext *C, bContextDataResult *result)
|
|
|
|
|
{
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
ARegion *region = CTX_wm_region(C);
|
2021-09-24 21:10:02 +10:00
|
|
|
if (region) {
|
|
|
|
|
uiList *list = UI_list_find_mouse_over(region, win->eventstate);
|
|
|
|
|
if (list) {
|
2023-07-12 13:43:00 +02:00
|
|
|
CTX_data_pointer_set(result, nullptr, &RNA_UIList, list);
|
2021-09-24 21:10:02 +10:00
|
|
|
return CTX_RESULT_OK;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return CTX_RESULT_NO_DATA;
|
UI: Support UI list tooltips, defined via Python scripts
Makes it possible to create tooltips for UI list rows, which can be
filled in .py scripts, similar to how they can extend other menus. This
is used by the (to be committed) Pose Library add-on to display pose
operations (selecting bones of a pose, blending a pose, etc).
It's important that the Python scripts check if the UI list is the
correct one by checking the list ID.
For this to work, a new `bpy.context.ui_list` can be checked. For
example, the Pose Library add-on does the following check:
```
def is_pose_asset_view() -> bool:
# Important: Must check context first, or the menu is added for every kind of list.
list = getattr(context, "ui_list", None)
if not list or list.bl_idname != "UI_UL_asset_view" or list.list_id != "pose_assets":
return False
if not context.asset_handle:
return False
return True
```
2021-07-13 15:01:00 +02:00
|
|
|
}
|
|
|
|
|
|
2020-10-02 12:57:11 +02:00
|
|
|
/* Registry of context callback functions. */
|
|
|
|
|
|
2023-07-24 11:04:19 +10:00
|
|
|
using context_callback = eContextResult (*)(const bContext *C, bContextDataResult *result);
|
2023-07-12 13:43:00 +02:00
|
|
|
static GHash *ed_screen_context_functions = nullptr;
|
2020-10-02 12:57:11 +02:00
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
static void free_context_function_ghash(void * /*user_data*/)
|
2020-10-02 12:57:11 +02:00
|
|
|
{
|
2023-07-12 13:43:00 +02:00
|
|
|
BLI_ghash_free(ed_screen_context_functions, nullptr, nullptr);
|
2020-10-02 12:57:11 +02:00
|
|
|
}
|
|
|
|
|
static inline void register_context_function(const char *member, context_callback function)
|
|
|
|
|
{
|
2023-07-12 13:43:00 +02:00
|
|
|
BLI_ghash_insert(
|
|
|
|
|
ed_screen_context_functions, (void *)member, reinterpret_cast<void *>(function));
|
2020-10-02 12:57:11 +02:00
|
|
|
}
|
|
|
|
|
|
2023-07-13 09:54:02 +10:00
|
|
|
static void ensure_ed_screen_context_functions()
|
2020-10-02 12:57:11 +02:00
|
|
|
{
|
2023-07-12 13:43:00 +02:00
|
|
|
if (ed_screen_context_functions != nullptr) {
|
2020-10-02 12:57:11 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Murmur hash is faster for smaller strings (according to BLI_hash_mm2). */
|
|
|
|
|
ed_screen_context_functions = BLI_ghash_new(
|
|
|
|
|
BLI_ghashutil_strhash_p_murmur, BLI_ghashutil_strcmp, __func__);
|
|
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
BKE_blender_atexit_register(free_context_function_ghash, nullptr);
|
2020-10-02 12:57:11 +02:00
|
|
|
|
|
|
|
|
register_context_function("scene", screen_ctx_scene);
|
|
|
|
|
register_context_function("visible_objects", screen_ctx_visible_objects);
|
|
|
|
|
register_context_function("selectable_objects", screen_ctx_selectable_objects);
|
|
|
|
|
register_context_function("selected_objects", screen_ctx_selected_objects);
|
|
|
|
|
register_context_function("selected_editable_objects", screen_ctx_selected_editable_objects);
|
|
|
|
|
register_context_function("editable_objects", screen_ctx_editable_objects);
|
|
|
|
|
register_context_function("objects_in_mode", screen_ctx_objects_in_mode);
|
|
|
|
|
register_context_function("objects_in_mode_unique_data", screen_ctx_objects_in_mode_unique_data);
|
|
|
|
|
register_context_function("visible_bones", screen_ctx_visible_bones);
|
|
|
|
|
register_context_function("editable_bones", screen_ctx_editable_bones);
|
|
|
|
|
register_context_function("selected_bones", screen_ctx_selected_bones);
|
|
|
|
|
register_context_function("selected_editable_bones", screen_ctx_selected_editable_bones);
|
|
|
|
|
register_context_function("visible_pose_bones", screen_ctx_visible_pose_bones);
|
|
|
|
|
register_context_function("selected_pose_bones", screen_ctx_selected_pose_bones);
|
|
|
|
|
register_context_function("selected_pose_bones_from_active_object",
|
|
|
|
|
screen_ctx_selected_pose_bones_from_active_object);
|
|
|
|
|
register_context_function("active_bone", screen_ctx_active_bone);
|
|
|
|
|
register_context_function("active_pose_bone", screen_ctx_active_pose_bone);
|
|
|
|
|
register_context_function("active_object", screen_ctx_active_object);
|
|
|
|
|
register_context_function("object", screen_ctx_object);
|
|
|
|
|
register_context_function("edit_object", screen_ctx_edit_object);
|
|
|
|
|
register_context_function("sculpt_object", screen_ctx_sculpt_object);
|
|
|
|
|
register_context_function("vertex_paint_object", screen_ctx_vertex_paint_object);
|
|
|
|
|
register_context_function("weight_paint_object", screen_ctx_weight_paint_object);
|
|
|
|
|
register_context_function("image_paint_object", screen_ctx_image_paint_object);
|
|
|
|
|
register_context_function("particle_edit_object", screen_ctx_particle_edit_object);
|
|
|
|
|
register_context_function("pose_object", screen_ctx_pose_object);
|
2021-08-30 20:56:37 +10:00
|
|
|
register_context_function("active_sequence_strip", screen_ctx_active_sequence_strip);
|
2020-10-02 12:57:11 +02:00
|
|
|
register_context_function("sequences", screen_ctx_sequences);
|
|
|
|
|
register_context_function("selected_sequences", screen_ctx_selected_sequences);
|
|
|
|
|
register_context_function("selected_editable_sequences", screen_ctx_selected_editable_sequences);
|
2021-08-31 11:46:46 +10:00
|
|
|
register_context_function("active_nla_track", screen_ctx_active_nla_track);
|
|
|
|
|
register_context_function("active_nla_strip", screen_ctx_active_nla_strip);
|
2020-10-02 12:57:11 +02:00
|
|
|
register_context_function("selected_nla_strips", screen_ctx_selected_nla_strips);
|
2021-10-19 16:24:23 +02:00
|
|
|
register_context_function("selected_movieclip_tracks", screen_ctx_selected_movieclip_tracks);
|
2020-10-02 12:57:11 +02:00
|
|
|
register_context_function("gpencil_data", screen_ctx_gpencil_data);
|
|
|
|
|
register_context_function("gpencil_data_owner", screen_ctx_gpencil_data_owner);
|
|
|
|
|
register_context_function("annotation_data", screen_ctx_annotation_data);
|
|
|
|
|
register_context_function("annotation_data_owner", screen_ctx_annotation_data_owner);
|
|
|
|
|
register_context_function("active_gpencil_layer", screen_ctx_active_gpencil_layer);
|
|
|
|
|
register_context_function("active_annotation_layer", screen_ctx_active_annotation_layer);
|
|
|
|
|
register_context_function("active_gpencil_frame", screen_ctx_active_gpencil_frame);
|
|
|
|
|
register_context_function("visible_gpencil_layers", screen_ctx_visible_gpencil_layers);
|
|
|
|
|
register_context_function("editable_gpencil_layers", screen_ctx_editable_gpencil_layers);
|
|
|
|
|
register_context_function("editable_gpencil_strokes", screen_ctx_editable_gpencil_strokes);
|
|
|
|
|
register_context_function("active_operator", screen_ctx_active_operator);
|
2022-07-10 12:28:44 +03:00
|
|
|
register_context_function("active_action", screen_ctx_active_action);
|
2021-07-16 12:36:57 +03:00
|
|
|
register_context_function("selected_visible_actions", screen_ctx_selected_visible_actions);
|
|
|
|
|
register_context_function("selected_editable_actions", screen_ctx_selected_editable_actions);
|
2020-10-02 12:57:11 +02:00
|
|
|
register_context_function("editable_fcurves", screen_ctx_editable_fcurves);
|
|
|
|
|
register_context_function("visible_fcurves", screen_ctx_visible_fcurves);
|
|
|
|
|
register_context_function("selected_editable_fcurves", screen_ctx_selected_editable_fcurves);
|
|
|
|
|
register_context_function("selected_visible_fcurves", screen_ctx_selected_visible_fcurves);
|
|
|
|
|
register_context_function("active_editable_fcurve", screen_ctx_active_editable_fcurve);
|
2020-10-15 14:53:26 -04:00
|
|
|
register_context_function("selected_editable_keyframes", screen_ctx_selected_editable_keyframes);
|
2023-09-19 16:27:07 +02:00
|
|
|
register_context_function("asset_library_reference", screen_ctx_asset_library);
|
UI: Support UI list tooltips, defined via Python scripts
Makes it possible to create tooltips for UI list rows, which can be
filled in .py scripts, similar to how they can extend other menus. This
is used by the (to be committed) Pose Library add-on to display pose
operations (selecting bones of a pose, blending a pose, etc).
It's important that the Python scripts check if the UI list is the
correct one by checking the list ID.
For this to work, a new `bpy.context.ui_list` can be checked. For
example, the Pose Library add-on does the following check:
```
def is_pose_asset_view() -> bool:
# Important: Must check context first, or the menu is added for every kind of list.
list = getattr(context, "ui_list", None)
if not list or list.bl_idname != "UI_UL_asset_view" or list.list_id != "pose_assets":
return False
if not context.asset_handle:
return False
return True
```
2021-07-13 15:01:00 +02:00
|
|
|
register_context_function("ui_list", screen_ctx_ui_list);
|
2023-04-29 20:31:27 -07:00
|
|
|
register_context_function("property", screen_ctx_property);
|
2020-10-02 12:57:11 +02:00
|
|
|
}
|
|
|
|
|
|
2020-10-02 11:56:06 +02:00
|
|
|
int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result)
|
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (CTX_data_dir(member)) {
|
2011-02-15 14:38:43 +00:00
|
|
|
CTX_data_dir_set(result, screen_context_dir);
|
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
|
|
|
return CTX_RESULT_OK;
|
2009-06-20 14:55:28 +00:00
|
|
|
}
|
2020-10-02 11:56:06 +02:00
|
|
|
|
2020-10-02 12:57:11 +02:00
|
|
|
ensure_ed_screen_context_functions();
|
2023-07-12 13:43:00 +02:00
|
|
|
context_callback callback = reinterpret_cast<context_callback>(
|
|
|
|
|
BLI_ghash_lookup(ed_screen_context_functions, member));
|
|
|
|
|
if (callback == nullptr) {
|
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
|
|
|
return CTX_RESULT_MEMBER_NOT_FOUND;
|
2019-06-16 13:32:50 +03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-02 12:57:11 +02:00
|
|
|
return callback(C, result);
|
2008-12-23 02:07:13 +00:00
|
|
|
}
|