From 7ec7dac86067b62a88d5d5557010b9365757f5a9 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Wed, 27 Sep 2023 12:23:07 +0200 Subject: [PATCH 1/4] Fix background drawing in tool header after changing tools After changing tools (and possibly other context), the buttons section background drawing would be broken for one redraw, so the full region would be drawn with a background, rather than just behind the button boundaries. --- source/blender/editors/interface/interface_button_sections.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/editors/interface/interface_button_sections.cc b/source/blender/editors/interface/interface_button_sections.cc index edf855334a0..887d0e72eed 100644 --- a/source/blender/editors/interface/interface_button_sections.cc +++ b/source/blender/editors/interface/interface_button_sections.cc @@ -61,6 +61,10 @@ static Vector button_section_bounds_calc(const ARegion *region, const bool BLI_rcti_init_minmax(&cur_section_bounds); LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { + if (!block->active) { + continue; + } + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (but->type == UI_BTYPE_SEPR_SPACER) { /* Start a new section. */ From 4f617bc728dbe8db2e83f40eb28d648acf282645 Mon Sep 17 00:00:00 2001 From: Falk David Date: Wed, 27 Sep 2023 15:46:18 +0200 Subject: [PATCH 2/4] Fix: Expose GPv3 RNA only in experimental The `blender-v4.0-release` branch would not build because some parts of grease pencil v3 were still exposed when experimental features are disabled. This is hiding the relevant parts behind `#ifdef WITH_GREASE_PENCIL_V3` to make sure they are only built when the experimental features is enabled. Pull Request: https://projects.blender.org/blender/blender/pulls/112953 --- source/blender/editors/CMakeLists.txt | 4 ++++ source/blender/editors/animation/CMakeLists.txt | 3 +++ .../editors/animation/anim_channels_defines.cc | 12 ++++++++++++ source/blender/editors/include/UI_interface_c.hh | 2 ++ source/blender/editors/interface/CMakeLists.txt | 8 +++++++- source/blender/editors/space_buttons/CMakeLists.txt | 1 + .../blender/editors/space_buttons/buttons_context.cc | 4 ++++ .../blender/editors/space_outliner/outliner_draw.cc | 2 ++ source/blender/makesrna/intern/makesrna.cc | 2 ++ source/blender/makesrna/intern/rna_ID.cc | 2 ++ source/blender/makesrna/intern/rna_internal.h | 4 ++++ source/blender/makesrna/intern/rna_main.cc | 4 ++++ source/blender/makesrna/intern/rna_main_api.cc | 2 ++ source/blender/makesrna/intern/rna_object.cc | 2 ++ source/blender/makesrna/intern/rna_ui_api.cc | 2 ++ 15 files changed, 53 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index a0f11b6c7bf..ab6354768fb 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -7,6 +7,10 @@ if(WITH_BLENDER) add_definitions(-DWITH_INPUT_NDOF) endif() + if(WITH_EXPERIMENTAL_FEATURES) + add_definitions(-DWITH_GREASE_PENCIL_V3) + endif() + add_subdirectory(animation) add_subdirectory(armature) add_subdirectory(asset) diff --git a/source/blender/editors/animation/CMakeLists.txt b/source/blender/editors/animation/CMakeLists.txt index 55006c747a9..a47c3e19505 100644 --- a/source/blender/editors/animation/CMakeLists.txt +++ b/source/blender/editors/animation/CMakeLists.txt @@ -54,6 +54,9 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() +if(WITH_EXPERIMENTAL_FEATURES) + add_definitions(-DWITH_GREASE_PENCIL_V3) +endif() blender_add_lib(bf_editor_animation "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/animation/anim_channels_defines.cc b/source/blender/editors/animation/anim_channels_defines.cc index 88775bda077..1de1537ec6d 100644 --- a/source/blender/editors/animation/anim_channels_defines.cc +++ b/source/blender/editors/animation/anim_channels_defines.cc @@ -3507,6 +3507,7 @@ static bAnimChannelType ACF_GPL_LEGACY = { /* Grease Pencil Animation functions ------------------------------------------- */ +#ifdef WITH_GREASE_PENCIL_V3 namespace blender::ed::animation::greasepencil { /* Get pointer to the setting */ @@ -3740,6 +3741,7 @@ static bAnimChannelType ACF_GPLGROUP = { /*setting_flag*/ greasepencil::layer_setting_flag, /*setting_ptr*/ greasepencil::layer_group_setting_ptr, }; +#endif /* Mask Datablock ------------------------------------------- */ @@ -4306,9 +4308,15 @@ static void ANIM_init_channel_typeinfo_data() animchannelTypeInfo[type++] = &ACF_GPD_LEGACY; /* Grease Pencil Datablock (Legacy) */ animchannelTypeInfo[type++] = &ACF_GPL_LEGACY; /* Grease Pencil Layer (Legacy) */ +#ifdef WITH_GREASE_PENCIL_V3 animchannelTypeInfo[type++] = &ACF_GPD; /* Grease Pencil Datablock. */ animchannelTypeInfo[type++] = &ACF_GPLGROUP; /* Grease Pencil Layer Group. */ animchannelTypeInfo[type++] = &ACF_GPL; /* Grease Pencil Layer. */ +#else + animchannelTypeInfo[type++] = nullptr; + animchannelTypeInfo[type++] = nullptr; + animchannelTypeInfo[type++] = nullptr; +#endif animchannelTypeInfo[type++] = &ACF_MASKDATA; /* Mask Datablock */ animchannelTypeInfo[type++] = &ACF_MASKLAYER; /* Mask Layer */ @@ -5422,6 +5430,7 @@ static void draw_setting_widget(bAnimContext *ac, } } +#ifdef WITH_GREASE_PENCIL_V3 static void draw_grease_pencil_layer_widgets(bAnimListElem *ale, uiBlock *block, const rctf *rect, @@ -5484,6 +5493,7 @@ static void draw_grease_pencil_layer_widgets(bAnimListElem *ale, } MEM_freeN(opacity_rna_path); } +#endif void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, @@ -5905,9 +5915,11 @@ void ANIM_channel_draw_widgets(const bContext *C, MEM_freeN(gp_rna_path); } } +#ifdef WITH_GREASE_PENCIL_V3 else if (ale->type == ANIMTYPE_GREASE_PENCIL_LAYER) { draw_grease_pencil_layer_widgets(ale, block, rect, offset, channel_height, array_index); } +#endif /* Only if RNA-Path found. */ if (rna_path) { diff --git a/source/blender/editors/include/UI_interface_c.hh b/source/blender/editors/include/UI_interface_c.hh index 6eb05910e16..ef4ed7d1c7e 100644 --- a/source/blender/editors/include/UI_interface_c.hh +++ b/source/blender/editors/include/UI_interface_c.hh @@ -2662,7 +2662,9 @@ void uiTemplateLightLinkingCollection(uiLayout *layout, PointerRNA *ptr, const char *propname); +#ifdef WITH_GREASE_PENCIL_V3 void uiTemplateGreasePencilLayerTree(uiLayout *layout, bContext *C); +#endif void uiTemplateNodeTreeInterface(struct uiLayout *layout, struct PointerRNA *ptr); diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt index 116bb4071a2..4c0aa54b7de 100644 --- a/source/blender/editors/interface/CMakeLists.txt +++ b/source/blender/editors/interface/CMakeLists.txt @@ -69,7 +69,6 @@ set(SRC interface_style.cc interface_template_asset_view.cc interface_template_attribute_search.cc - interface_template_grease_pencil_layer_tree.cc interface_template_light_linking.cc interface_template_list.cc interface_template_node_tree_interface.cc @@ -123,6 +122,13 @@ if(WIN32 OR APPLE) endif() endif() +if(WITH_EXPERIMENTAL_FEATURES) + add_definitions(-DWITH_GREASE_PENCIL_V3) + list(APPEND SRC + interface_template_grease_pencil_layer_tree.cc + ) +endif() + blender_add_lib(bf_editor_interface "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt index a561a66c880..bc3b491a107 100644 --- a/source/blender/editors/space_buttons/CMakeLists.txt +++ b/source/blender/editors/space_buttons/CMakeLists.txt @@ -42,6 +42,7 @@ endif() if(WITH_EXPERIMENTAL_FEATURES) add_definitions(-DWITH_SIMULATION_DATABLOCK) add_definitions(-DWITH_POINT_CLOUD) + add_definitions(-DWITH_GREASE_PENCIL_V3) endif() blender_add_lib(bf_editor_space_buttons "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_buttons/buttons_context.cc b/source/blender/editors/space_buttons/buttons_context.cc index a3226858ce3..f8529ddc908 100644 --- a/source/blender/editors/space_buttons/buttons_context.cc +++ b/source/blender/editors/space_buttons/buttons_context.cc @@ -262,9 +262,11 @@ static bool buttons_context_path_data(ButsContextPath *path, int type) if (RNA_struct_is_a(ptr->type, &RNA_GreasePencil) && ELEM(type, -1, OB_GPENCIL_LEGACY)) { return true; } +#ifdef WITH_GREASE_PENCIL_V3 if (RNA_struct_is_a(ptr->type, &RNA_GreasePencilv3) && ELEM(type, -1, OB_GREASE_PENCIL)) { return true; } +#endif if (RNA_struct_is_a(ptr->type, &RNA_Curves) && ELEM(type, -1, OB_CURVES)) { return true; } @@ -1172,10 +1174,12 @@ int /*eContextResult*/ buttons_context(const bContext *C, set_pointer_type(path, result, &RNA_GreasePencil); return CTX_RESULT_OK; } +#ifdef WITH_GREASE_PENCIL_V3 if (CTX_data_equals(member, "grease_pencil")) { set_pointer_type(path, result, &RNA_GreasePencilv3); return CTX_RESULT_OK; } +#endif return CTX_RESULT_MEMBER_NOT_FOUND; } diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index 3ca30ce6816..809fd1d6f26 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -1501,6 +1501,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); } } +#ifdef WITH_GREASE_PENCIL_V3 else if (tselem->type == TSE_GREASE_PENCIL_NODE) { bke::greasepencil::TreeNode &node = tree_element_cast(te)->node(); @@ -1538,6 +1539,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, } } } +#endif else if (outliner_is_collection_tree_element(te)) { PointerRNA collection_ptr; PointerRNA layer_collection_ptr; diff --git a/source/blender/makesrna/intern/makesrna.cc b/source/blender/makesrna/intern/makesrna.cc index 250dcb2d3d1..983b267a08c 100644 --- a/source/blender/makesrna/intern/makesrna.cc +++ b/source/blender/makesrna/intern/makesrna.cc @@ -4732,7 +4732,9 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_dynamicpaint.cc", nullptr, RNA_def_dynamic_paint}, {"rna_fcurve.cc", "rna_fcurve_api.cc", RNA_def_fcurve}, {"rna_gpencil_legacy.cc", nullptr, RNA_def_gpencil}, +#ifdef WITH_GREASE_PENCIL_V3 {"rna_grease_pencil.cc", nullptr, RNA_def_grease_pencil}, +#endif {"rna_curves.cc", nullptr, RNA_def_curves}, {"rna_image.cc", "rna_image_api.cc", RNA_def_image}, {"rna_key.cc", nullptr, RNA_def_key}, diff --git a/source/blender/makesrna/intern/rna_ID.cc b/source/blender/makesrna/intern/rna_ID.cc index 894d00b2a44..b4ae65bc698 100644 --- a/source/blender/makesrna/intern/rna_ID.cc +++ b/source/blender/makesrna/intern/rna_ID.cc @@ -484,7 +484,9 @@ StructRNA *ID_code_to_RNA_type(short idcode) case ID_GD_LEGACY: return &RNA_GreasePencil; case ID_GP: +# ifdef WITH_GREASE_PENCIL_V3 return &RNA_GreasePencilv3; +# endif break; case ID_GR: return &RNA_Collection; diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 419509bd51f..cd6a1667f01 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -158,7 +158,9 @@ void RNA_def_depsgraph(struct BlenderRNA *brna); void RNA_def_dynamic_paint(struct BlenderRNA *brna); void RNA_def_fcurve(struct BlenderRNA *brna); void RNA_def_gpencil(struct BlenderRNA *brna); +#ifdef WITH_GREASE_PENCIL_V3 void RNA_def_grease_pencil(struct BlenderRNA *brna); +#endif void RNA_def_greasepencil_modifier(struct BlenderRNA *brna); void RNA_def_shader_fx(struct BlenderRNA *brna); void RNA_def_curves(struct BlenderRNA *brna); @@ -500,7 +502,9 @@ void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_palettes(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_gpencil_legacy(BlenderRNA *brna, PropertyRNA *cprop); +#ifdef WITH_GREASE_PENCIL_V3 void RNA_def_main_grease_pencil(BlenderRNA *brna, PropertyRNA *cprop); +#endif void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop); diff --git a/source/blender/makesrna/intern/rna_main.cc b/source/blender/makesrna/intern/rna_main.cc index a72d04583c4..7373b308f45 100644 --- a/source/blender/makesrna/intern/rna_main.cc +++ b/source/blender/makesrna/intern/rna_main.cc @@ -98,7 +98,9 @@ RNA_MAIN_LISTBASE_FUNCS_DEF(collections) RNA_MAIN_LISTBASE_FUNCS_DEF(curves) RNA_MAIN_LISTBASE_FUNCS_DEF(fonts) RNA_MAIN_LISTBASE_FUNCS_DEF(gpencils) +# ifdef WITH_GREASE_PENCIL_V3 RNA_MAIN_LISTBASE_FUNCS_DEF(grease_pencils) +# endif RNA_MAIN_LISTBASE_FUNCS_DEF(hair_curves) RNA_MAIN_LISTBASE_FUNCS_DEF(images) RNA_MAIN_LISTBASE_FUNCS_DEF(lattices) @@ -340,12 +342,14 @@ void RNA_def_main(BlenderRNA *brna) "Grease Pencil data-blocks", # endif RNA_def_main_gpencil_legacy}, +# ifdef WITH_GREASE_PENCIL_V3 {"grease_pencils_v3", "GreasePencilv3", "rna_Main_grease_pencils_begin", "Grease Pencil", "Grease Pencil data-blocks", RNA_def_main_grease_pencil}, +# endif {"movieclips", "MovieClip", "rna_Main_movieclips_begin", diff --git a/source/blender/makesrna/intern/rna_main_api.cc b/source/blender/makesrna/intern/rna_main_api.cc index cdc85c24e8a..2f24820b11d 100644 --- a/source/blender/makesrna/intern/rna_main_api.cc +++ b/source/blender/makesrna/intern/rna_main_api.cc @@ -2041,6 +2041,7 @@ void RNA_def_main_gpencil_legacy(BlenderRNA *brna, PropertyRNA *cprop) func, "do_ui_user", true, "", "Make sure interface does not reference this grease pencil"); } +#ifdef WITH_GREASE_PENCIL_V3 void RNA_def_main_grease_pencil(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; @@ -2050,6 +2051,7 @@ void RNA_def_main_grease_pencil(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_sdna(srna, "Main"); RNA_def_struct_ui_text(srna, "Main Grease Pencils", "Collection of grease pencils"); } +#endif void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop) { diff --git a/source/blender/makesrna/intern/rna_object.cc b/source/blender/makesrna/intern/rna_object.cc index f3218eb319a..3e3f15ba81a 100644 --- a/source/blender/makesrna/intern/rna_object.cc +++ b/source/blender/makesrna/intern/rna_object.cc @@ -607,8 +607,10 @@ static StructRNA *rna_Object_data_typef(PointerRNA *ptr) return &RNA_LightProbe; case OB_GPENCIL_LEGACY: return &RNA_GreasePencil; +# ifdef WITH_GREASE_PENCIL_V3 case OB_GREASE_PENCIL: return &RNA_GreasePencilv3; +# endif case OB_CURVES: return &RNA_Curves; case OB_POINTCLOUD: diff --git a/source/blender/makesrna/intern/rna_ui_api.cc b/source/blender/makesrna/intern/rna_ui_api.cc index 2391f4e399f..40da7e0eb78 100644 --- a/source/blender/makesrna/intern/rna_ui_api.cc +++ b/source/blender/makesrna/intern/rna_ui_api.cc @@ -2114,10 +2114,12 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); api_ui_item_rna_common(func); +# ifdef WITH_GREASE_PENCIL_V3 func = RNA_def_function( srna, "template_grease_pencil_layer_tree", "uiTemplateGreasePencilLayerTree"); RNA_def_function_ui_description(func, "View of the active grease pencil layer tree"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); +# endif func = RNA_def_function(srna, "template_node_tree_interface", "uiTemplateNodeTreeInterface"); RNA_def_function_ui_description(func, "Show a node tree interface"); From 9e495c5b06cb516cb252b1c1109712c1680ec921 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 27 Sep 2023 15:47:22 +0200 Subject: [PATCH 3/4] Geometry Nodes: Store tool group in a separate editor property This enables switching back and forth between the modifier and tool contexts of the geometry node editor without losing the assigned tool node group. See #101778 Pull Request: https://projects.blender.org/blender/blender/pulls/112926 --- .../startup/bl_operators/geometry_nodes.py | 2 +- scripts/startup/bl_ui/space_node.py | 2 +- .../blender/editors/space_node/space_node.cc | 2 + source/blender/makesdna/DNA_space_types.h | 7 ++++ source/blender/makesrna/intern/rna_space.cc | 40 +++++++++++-------- .../nodes/geometry/node_geometry_tree.cc | 2 +- 6 files changed, 36 insertions(+), 19 deletions(-) diff --git a/scripts/startup/bl_operators/geometry_nodes.py b/scripts/startup/bl_operators/geometry_nodes.py index 37dbb20b180..ec3e8c3e900 100644 --- a/scripts/startup/bl_operators/geometry_nodes.py +++ b/scripts/startup/bl_operators/geometry_nodes.py @@ -307,7 +307,7 @@ class NewGeometryNodeGroupTool(Operator): def execute(self, context): group = geometry_node_group_empty_tool_new(context) - context.space_data.node_tree = group + context.space_data.geometry_nodes_tool_tree = group return {'FINISHED'} diff --git a/scripts/startup/bl_ui/space_node.py b/scripts/startup/bl_ui/space_node.py index db3031b8333..f46de3927ad 100644 --- a/scripts/startup/bl_ui/space_node.py +++ b/scripts/startup/bl_ui/space_node.py @@ -162,7 +162,7 @@ class NODE_HT_header(Header): else: row.template_ID(snode, "node_tree", new="node.new_geometry_nodes_modifier") else: - layout.template_ID(snode, "node_tree", new="node.new_geometry_node_group_tool") + layout.template_ID(snode, "geometry_nodes_tool_tree", new="node.new_geometry_node_group_tool") if snode.node_tree: layout.popover(panel="NODE_PT_geometry_node_tool_object_types", text="Types") layout.popover(panel="NODE_PT_geometry_node_tool_mode", text="Modes") diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc index ee413e8a6a0..323eb5dc141 100644 --- a/source/blender/editors/space_node/space_node.cc +++ b/source/blender/editors/space_node/space_node.cc @@ -1253,6 +1253,8 @@ static void node_foreach_id(SpaceLink *space_link, LibraryForeachIDData *data) } } + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, snode->geometry_nodes_tool_tree, IDWALK_CB_USER_ONE); + /* Both `snode->id` and `snode->nodetree` have been remapped now, so their data can be * accessed. */ BLI_assert(snode->id == nullptr || snode->nodetree == nullptr || diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 7ca6dbb9cee..5c8c055ca50 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -1626,6 +1626,13 @@ typedef struct SpaceNode { */ char geometry_nodes_type; + /** + * Used as the editor's top-level node group for #SNODE_GEOMETRY_TOOL. This is stored in the + * node editor because it isn't part of the context otherwise, and it isn't meant to be set + * separately from the editor's regular node group. + */ + struct bNodeTree *geometry_nodes_tool_tree; + /** Grease-pencil data. */ struct bGPdata *gpd; diff --git a/source/blender/makesrna/intern/rna_space.cc b/source/blender/makesrna/intern/rna_space.cc index f795d233135..cb22f9bcbfc 100644 --- a/source/blender/makesrna/intern/rna_space.cc +++ b/source/blender/makesrna/intern/rna_space.cc @@ -2507,6 +2507,22 @@ static void rna_SpaceNodeEditor_node_tree_set(PointerRNA *ptr, ED_node_tree_start(snode, (bNodeTree *)value.data, nullptr, nullptr); } +static bool rna_SpaceNodeEditor_geometry_nodes_tool_tree_poll(PointerRNA * /*ptr*/, + const PointerRNA value) +{ + const bNodeTree &ntree = *static_cast(value.data); + if (ntree.type != NTREE_GEOMETRY) { + return false; + } + if (!ntree.geometry_node_asset_traits) { + return false; + } + if ((ntree.geometry_node_asset_traits->flag & GEO_NODE_ASSET_TOOL) == 0) { + return false; + } + return true; +} + static bool space_node_node_geometry_nodes_poll(const SpaceNode &snode, const bNodeTree &ntree) { switch (SpaceNodeGeometryNodesType(snode.geometry_nodes_type)) { @@ -2547,20 +2563,6 @@ static bool rna_SpaceNodeEditor_node_tree_poll(PointerRNA *ptr, const PointerRNA return true; } -static void rna_SpaceNodeEditor_geometry_nodes_type_update(Main * /*bmain*/, - Scene * /*scene*/, - PointerRNA *ptr) -{ - SpaceNode &snode = *static_cast(ptr->data); - if (snode.nodetree) { - if (snode.nodetree->type == NTREE_GEOMETRY) { - if (!space_node_node_geometry_nodes_poll(snode, *snode.nodetree)) { - snode.nodetree = nullptr; - } - } - } -} - static void rna_SpaceNodeEditor_node_tree_update(const bContext *C, PointerRNA * /*ptr*/) { ED_node_tree_update(C); @@ -7512,8 +7514,7 @@ static void rna_def_space_node(BlenderRNA *brna) RNA_def_property_enum_items(prop, geometry_nodes_type_items); RNA_def_property_ui_text(prop, "Geometry Nodes Type", ""); RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ID); - RNA_def_property_update( - prop, NC_SPACE | ND_SPACE_NODE, "rna_SpaceNodeEditor_geometry_nodes_type_update"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE, nullptr); prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -7561,6 +7562,13 @@ static void rna_def_space_node(BlenderRNA *brna) RNA_def_property_update( prop, NC_SPACE | ND_SPACE_NODE_VIEW, "rna_SpaceNodeEditor_show_backdrop_update"); + prop = RNA_def_property(srna, "geometry_nodes_tool_tree", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_funcs( + prop, nullptr, nullptr, nullptr, "rna_SpaceNodeEditor_geometry_nodes_tool_tree_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); + RNA_def_property_ui_text(prop, "Node Tool Tree", "Node group to edit as node tool"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE, "rna_SpaceNodeEditor_node_tree_update"); + prop = RNA_def_property(srna, "show_annotation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "flag", SNODE_SHOW_GPENCIL); RNA_def_property_ui_text(prop, "Show Annotation", "Show annotations for this view"); diff --git a/source/blender/nodes/geometry/node_geometry_tree.cc b/source/blender/nodes/geometry/node_geometry_tree.cc index 54689867747..1406bfdcb4c 100644 --- a/source/blender/nodes/geometry/node_geometry_tree.cc +++ b/source/blender/nodes/geometry/node_geometry_tree.cc @@ -35,7 +35,7 @@ static void geometry_node_tree_get_from_context( { const SpaceNode *snode = CTX_wm_space_node(C); if (snode->geometry_nodes_type == SNODE_GEOMETRY_TOOL) { - *r_ntree = snode->nodetree; + *r_ntree = snode->geometry_nodes_tool_tree; return; } From ff78d33bb4eed30e667fcd42f88368b253ac238c Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Wed, 27 Sep 2023 15:46:54 +0200 Subject: [PATCH 4/4] UI: Draw Image editor tool header transparent with button background Same as 55eaa755e3, but for the Image Editor, since this should be done consistently for all editors using tool headers with region background. --- source/blender/editors/space_image/space_image.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_image/space_image.cc b/source/blender/editors/space_image/space_image.cc index 5687d7b02b0..ba22f541e9f 100644 --- a/source/blender/editors/space_image/space_image.cc +++ b/source/blender/editors/space_image/space_image.cc @@ -941,6 +941,18 @@ static void image_tools_region_listener(const wmRegionListenerParams *params) } } +/************************* Tool header region **************************/ + +static void image_tools_header_region_draw(const bContext *C, ARegion *region) +{ + ScrArea *area = CTX_wm_area(C); + SpaceImage *sima = static_cast(area->spacedata.first); + + image_user_refresh_scene(C, sima); + + ED_region_header_with_button_sections(C, region, uiButtonSectionsAlign::Top); +} + /************************* header region **************************/ /* add handlers, stuff you only do once or on area/region changes */ @@ -1153,7 +1165,7 @@ void ED_spacetype_image() art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; art->listener = image_header_region_listener; art->init = image_header_region_init; - art->draw = image_header_region_draw; + art->draw = image_tools_header_region_draw; art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_header; BLI_addhead(&st->regiontypes, art);