Blender  V3.3
node_composite_viewer.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2006 Blender Foundation. All rights reserved. */
3 
8 #include "BKE_global.h"
9 #include "BKE_image.h"
10 
11 #include "RNA_access.h"
12 
13 #include "UI_interface.h"
14 #include "UI_resources.h"
15 
16 #include "node_composite_util.hh"
17 
18 /* **************** VIEWER ******************** */
19 
21 
23 {
24  b.add_input<decl::Color>(N_("Image")).default_value({0.0f, 0.0f, 0.0f, 1.0f});
25  b.add_input<decl::Float>(N_("Alpha")).default_value(1.0f).min(0.0f).max(1.0f);
26  b.add_input<decl::Float>(N_("Z")).default_value(1.0f).min(0.0f).max(1.0f);
27 }
28 
30 {
31  ImageUser *iuser = MEM_cnew<ImageUser>(__func__);
32  node->storage = iuser;
33  iuser->sfra = 1;
34  node->custom3 = 0.5f;
35  node->custom4 = 0.5f;
36 
37  node->id = (ID *)BKE_image_ensure_viewer(G.main, IMA_TYPE_COMPOSITE, "Viewer Node");
38 }
39 
41 {
42  uiItemR(layout, ptr, "use_alpha", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
43 }
44 
46 {
47  uiLayout *col;
48 
49  uiItemR(layout, ptr, "use_alpha", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
50  uiItemR(layout, ptr, "tile_order", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
51  if (RNA_enum_get(ptr, "tile_order") == 0) {
52  col = uiLayoutColumn(layout, true);
53  uiItemR(col, ptr, "center_x", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
54  uiItemR(col, ptr, "center_y", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
55  }
56 }
57 
58 } // namespace blender::nodes::node_composite_viewer_cc
59 
61 {
62  namespace file_ns = blender::nodes::node_composite_viewer_cc;
63 
64  static bNodeType ntype;
65 
70  ntype.flag |= NODE_PREVIEW;
73 
74  ntype.no_muting = true;
75 
76  nodeRegisterType(&ntype);
77 }
struct Image * BKE_image_ensure_viewer(struct Main *bmain, int type, const char *name)
#define NODE_CLASS_OUTPUT
Definition: BKE_node.h:346
#define CMP_NODE_VIEWER
Definition: BKE_node.h:1196
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
Definition: node.cc:4390
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
#define UNUSED(x)
@ IMA_TYPE_COMPOSITE
#define NODE_PREVIEW
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
OperationNode * node
bNodeTree * ntree
uint col
#define G(x, y, z)
static void node_composit_init_viewer(bNodeTree *UNUSED(ntree), bNode *node)
static void node_composit_buts_viewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static void cmp_node_viewer_declare(NodeDeclarationBuilder &b)
static void node_composit_buts_viewer_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void cmp_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
void register_node_type_cmp_viewer()
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
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
Definition: DNA_ID.h:368
Defines a node type.
Definition: BKE_node.h:226
short flag
Definition: BKE_node.h:236
void(* draw_buttons_ex)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)
Definition: BKE_node.h:246
void(* draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)
Definition: BKE_node.h:244
NodeDeclareFunction declare
Definition: BKE_node.h:324
bool no_muting
Definition: BKE_node.h:338
#define N_(msgid)
PointerRNA * ptr
Definition: wm_files.c:3480