Blender  V3.3
node_composite_keyingscreen.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. All rights reserved. */
3 
8 #include "DNA_movieclip_types.h"
9 #include "DNA_tracking_types.h"
10 
11 #include "BLI_math_base.h"
12 #include "BLI_math_color.h"
13 
14 #include "BKE_context.h"
15 #include "BKE_lib_id.h"
16 #include "BKE_tracking.h"
17 
18 #include "RNA_access.h"
19 #include "RNA_prototypes.h"
20 
21 #include "UI_interface.h"
22 #include "UI_resources.h"
23 
24 #include "node_composite_util.hh"
25 
26 /* **************** Keying Screen ******************** */
27 
29 
31 {
32  b.add_output<decl::Color>(N_("Screen"));
33 }
34 
36 {
37  bNode *node = (bNode *)ptr->data;
38 
39  NodeKeyingScreenData *data = MEM_cnew<NodeKeyingScreenData>(__func__);
40  node->storage = data;
41 
42  const Scene *scene = CTX_data_scene(C);
43  if (scene->clip) {
44  MovieClip *clip = scene->clip;
45 
46  node->id = &clip->id;
47  id_us_plus(&clip->id);
48 
49  const MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking);
50  BLI_strncpy(data->tracking_object, tracking_object->name, sizeof(data->tracking_object));
51  }
52 }
53 
55 {
56  bNode *node = (bNode *)ptr->data;
57 
58  uiTemplateID(layout,
59  C,
60  ptr,
61  "clip",
62  nullptr,
63  nullptr,
64  nullptr,
66  false,
67  nullptr);
68 
69  if (node->id) {
70  MovieClip *clip = (MovieClip *)node->id;
71  uiLayout *col;
72  PointerRNA tracking_ptr;
73 
74  RNA_pointer_create(&clip->id, &RNA_MovieTracking, &clip->tracking, &tracking_ptr);
75 
76  col = uiLayoutColumn(layout, true);
77  uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
78  }
79 }
80 
81 } // namespace blender::nodes::node_composite_keyingscreen_cc
82 
84 {
86 
87  static bNodeType ntype;
88 
94  &ntype, "NodeKeyingScreenData", node_free_standard_storage, node_copy_standard_storage);
95 
96  nodeRegisterType(&ntype);
97 }
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
void id_us_plus(struct ID *id)
Definition: lib_id.c:305
#define CMP_NODE_KEYINGSCREEN
Definition: BKE_node.h:1265
#define NODE_CLASS_MATTE
Definition: BKE_node.h:352
void node_type_storage(struct bNodeType *ntype, const char *storagename, void(*freefunc)(struct bNode *node), void(*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node))
Definition: node.cc:4426
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
struct MovieTrackingObject * BKE_tracking_object_get_active(struct MovieTracking *tracking)
Definition: tracking.c:2092
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
#define C
Definition: RandGen.cpp:25
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
void uiTemplateID(uiLayout *layout, const struct bContext *C, struct PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int filter, bool live_icon, const char *text)
void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon)
@ UI_TEMPLATE_ID_FILTER_ALL
OperationNode * node
Scene scene
uint col
static void cmp_node_keyingscreen_declare(NodeDeclarationBuilder &b)
static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, PointerRNA *ptr)
static void node_composit_init_keyingscreen(const bContext *C, PointerRNA *ptr)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_cmp_keyingscreen()
void cmp_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
Definition: node_util.c:55
void node_free_standard_storage(bNode *node)
Definition: node_util.c:43
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:136
struct MovieTracking tracking
void * data
Definition: RNA_types.h:38
struct MovieClip * clip
Defines a node type.
Definition: BKE_node.h:226
void(* initfunc_api)(const struct bContext *C, struct PointerRNA *ptr)
Definition: BKE_node.h:279
void(* draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)
Definition: BKE_node.h:244
NodeDeclareFunction declare
Definition: BKE_node.h:324
#define N_(msgid)
PointerRNA * ptr
Definition: wm_files.c:3480