diff --git a/source/blender/nodes/geometry/include/NOD_geo_bake.hh b/source/blender/nodes/geometry/include/NOD_geo_bake.hh index 84b1aafd2de..731ac8bfd63 100644 --- a/source/blender/nodes/geometry/include/NOD_geo_bake.hh +++ b/source/blender/nodes/geometry/include/NOD_geo_bake.hh @@ -99,5 +99,6 @@ struct BakeDrawContext { std::string get_baked_string(const BakeDrawContext &ctx); std::optional get_bake_state_string(const BakeDrawContext &ctx); void draw_common_bake_settings(BakeDrawContext &ctx, uiLayout *layout); +void draw_bake_button(const BakeDrawContext &ctx, uiLayout *layout); } // namespace blender::nodes diff --git a/source/blender/nodes/geometry/nodes/node_geo_bake.cc b/source/blender/nodes/geometry/nodes/node_geo_bake.cc index ac2c4b1c9a9..f8dc72ee3b8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_bake.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_bake.cc @@ -529,42 +529,6 @@ class LazyFunctionForBakeNode final : public LazyFunction { } }; -static void draw_bake_button(uiLayout *layout, const BakeDrawContext &ctx) -{ - uiLayout *col = uiLayoutColumn(layout, true); - uiLayout *row = uiLayoutRow(col, true); - { - PointerRNA ptr; - uiItemFullO(row, - "OBJECT_OT_geometry_node_bake_single", - IFACE_("Bake"), - ICON_NONE, - nullptr, - WM_OP_INVOKE_DEFAULT, - UI_ITEM_NONE, - &ptr); - WM_operator_properties_id_lookup_set_from_id(&ptr, &ctx.object->id); - RNA_string_set(&ptr, "modifier_name", ctx.nmd->modifier.name); - RNA_int_set(&ptr, "bake_id", ctx.bake->id); - } - { - uiLayout *subrow = uiLayoutRow(row, true); - uiLayoutSetActive(subrow, ctx.is_baked); - PointerRNA ptr; - uiItemFullO(subrow, - "OBJECT_OT_geometry_node_bake_delete_single", - "", - ICON_TRASH, - nullptr, - WM_OP_INVOKE_DEFAULT, - UI_ITEM_NONE, - &ptr); - WM_operator_properties_id_lookup_set_from_id(&ptr, &ctx.object->id); - RNA_string_set(&ptr, "modifier_name", ctx.nmd->modifier.name); - RNA_int_set(&ptr, "bake_id", ctx.bake->id); - } -} - static void node_extra_info(NodeExtraInfoParams ¶ms) { BakeDrawContext ctx; @@ -593,7 +557,7 @@ static void node_layout(uiLayout *layout, bContext *C, PointerRNA *ptr) uiLayoutSetEnabled(row, !ctx.is_baked); uiItemR(row, &ctx.bake_rna, "bake_mode", UI_ITEM_R_EXPAND, IFACE_("Mode"), ICON_NONE); } - draw_bake_button(col, ctx); + draw_bake_button(ctx, col); } static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -616,7 +580,7 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) uiItemR(row, &ctx.bake_rna, "bake_mode", UI_ITEM_R_EXPAND, IFACE_("Mode"), ICON_NONE); } - draw_bake_button(col, ctx); + draw_bake_button(ctx, col); if (const std::optional bake_state_str = get_bake_state_string(ctx)) { uiItemL(col, bake_state_str->c_str(), ICON_NONE); } @@ -765,6 +729,42 @@ std::optional get_bake_state_string(const BakeDrawContext &ctx) return std::nullopt; } +void draw_bake_button(const BakeDrawContext &ctx, uiLayout *layout) +{ + uiLayout *col = uiLayoutColumn(layout, true); + uiLayout *row = uiLayoutRow(col, true); + { + PointerRNA ptr; + uiItemFullO(row, + "OBJECT_OT_geometry_node_bake_single", + IFACE_("Bake"), + ICON_NONE, + nullptr, + WM_OP_INVOKE_DEFAULT, + UI_ITEM_NONE, + &ptr); + WM_operator_properties_id_lookup_set_from_id(&ptr, &ctx.object->id); + RNA_string_set(&ptr, "modifier_name", ctx.nmd->modifier.name); + RNA_int_set(&ptr, "bake_id", ctx.bake->id); + } + { + uiLayout *subrow = uiLayoutRow(row, true); + uiLayoutSetActive(subrow, ctx.is_baked); + PointerRNA ptr; + uiItemFullO(subrow, + "OBJECT_OT_geometry_node_bake_delete_single", + "", + ICON_TRASH, + nullptr, + WM_OP_INVOKE_DEFAULT, + UI_ITEM_NONE, + &ptr); + WM_operator_properties_id_lookup_set_from_id(&ptr, &ctx.object->id); + RNA_string_set(&ptr, "modifier_name", ctx.nmd->modifier.name); + RNA_int_set(&ptr, "bake_id", ctx.bake->id); + } +} + void draw_common_bake_settings(BakeDrawContext &ctx, uiLayout *layout) { uiLayout *settings_col = uiLayoutColumn(layout, false); diff --git a/source/blender/nodes/geometry/nodes/node_geo_simulation.cc b/source/blender/nodes/geometry/nodes/node_geo_simulation.cc index 2640ec937e3..a25651edf6b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_simulation.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_simulation.cc @@ -323,37 +323,7 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *current_no { uiLayout *col = uiLayoutColumn(layout, false); - uiLayout *row = uiLayoutRow(col, true); - { - char bake_label[1024] = N_("Bake"); - - PointerRNA ptr; - uiItemFullO(row, - "OBJECT_OT_geometry_node_bake_single", - bake_label, - ICON_NONE, - nullptr, - WM_OP_INVOKE_DEFAULT, - UI_ITEM_NONE, - &ptr); - WM_operator_properties_id_lookup_set_from_id(&ptr, &ctx.object->id); - RNA_string_set(&ptr, "modifier_name", ctx.nmd->modifier.name); - RNA_int_set(&ptr, "bake_id", ctx.bake->id); - } - { - PointerRNA ptr; - uiItemFullO(row, - "OBJECT_OT_geometry_node_bake_delete_single", - "", - ICON_TRASH, - nullptr, - WM_OP_INVOKE_DEFAULT, - UI_ITEM_NONE, - &ptr); - WM_operator_properties_id_lookup_set_from_id(&ptr, &ctx.object->id); - RNA_string_set(&ptr, "modifier_name", ctx.nmd->modifier.name); - RNA_int_set(&ptr, "bake_id", ctx.bake->id); - } + draw_bake_button(ctx, col); if (const std::optional bake_state_str = get_bake_state_string(ctx)) { uiItemL(col, bake_state_str->c_str(), ICON_NONE); }