Blender V5.3
interface_template_strip_modifiers.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include "DNA_scene_types.h"
12#include "DNA_sequence_types.h"
13
14#include "BKE_context.hh"
15#include "BKE_screen.hh"
16
17#include "BLI_listbase.hh"
18
19#include "SEQ_modifier.hh"
20#include "SEQ_select.hh"
21
22#include "RNA_access.hh"
23#include "RNA_prototypes.hh"
24
25#include "UI_interface.hh"
27
28namespace blender::ui {
29
30static void strip_modifier_panel_id(void *smd_link, char *r_name)
31{
32 StripModifierData *smd = reinterpret_cast<StripModifierData *>(smd_link);
34}
35
37{
38 ARegion *region = CTX_wm_region(C);
39
40 Scene *sequencer_scene = CTX_data_sequencer_scene(C);
41 if (!sequencer_scene) {
42 return;
43 }
44 Strip *active_strip = seq::select_active_get(sequencer_scene);
45 BLI_assert(active_strip != nullptr);
46 ListBaseT<StripModifierData> *modifiers = &active_strip->modifiers;
47
48 const bool panels_match = panel_list_matches_data(region, modifiers, strip_modifier_panel_id);
49
50 if (!panels_match) {
51 panels_free_instanced(C, region);
52 for (StripModifierData &smd : *modifiers) {
54 if (mti->panel_register == nullptr) {
55 continue;
56 }
57
58 char panel_idname[MAX_NAME];
59 strip_modifier_panel_id(&smd, panel_idname);
60
61 /* Create custom data RNA pointer. */
62 PointerRNA *md_ptr = MEM_new<PointerRNA>(__func__);
63 *md_ptr = RNA_pointer_create_discrete(&sequencer_scene->id, RNA_StripModifier, &smd);
64
65 panel_add_instanced(C, region, &region->panels, panel_idname, md_ptr);
66 }
67 }
68 else {
69 /* Assuming there's only one group of instanced panels, update the custom data pointers. */
70 Panel *panel = region->panels.first();
71 for (StripModifierData &smd : *modifiers) {
73 if (mti->panel_register == nullptr) {
74 continue;
75 }
76
77 /* Move to the next instanced panel corresponding to the next modifier. */
78 while ((panel->type == nullptr) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) {
79 panel = panel->next;
80 /* There shouldn't be fewer panels than modifiers with UIs. */
81 BLI_assert(panel != nullptr);
82 }
83
84 PointerRNA *md_ptr = MEM_new<PointerRNA>(__func__);
85 *md_ptr = RNA_pointer_create_discrete(&sequencer_scene->id, RNA_StripModifier, &smd);
86 panel_custom_data_set(panel, md_ptr);
87
88 panel = panel->next;
89 }
90 }
91}
92
93} // namespace blender::ui
#define MAX_NAME
Definition DNA_defs.h:63
#define C
Definition RandGen.cpp:29
void modifier_type_panel_id(eStripModifierType type, char *r_idname)
Strip * select_active_get(const Scene *scene)
const StripModifierTypeInfo * modifier_type_info_get(eStripModifierType type)
bool panel_list_matches_data(ARegion *region, ListBase *data, ListPanelIDFromDataFunc panel_idname_func)
void template_strip_modifiers(Layout *layout, bContext *C)
static void strip_modifier_panel_id(void *smd_link, char *r_name)
void panels_free_instanced(const bContext *C, ARegion *region)
void panel_custom_data_set(Panel *panel, PointerRNA *custom_data)
Panel * panel_add_instanced(const bContext *C, ARegion *region, ListBaseT< Panel > *panels, const char *panel_idname, PointerRNA *custom_data)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
Scene * CTX_data_sequencer_scene(const bContext *C)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
@ PANEL_TYPE_INSTANCED
ARegion * CTX_wm_region(const bContext *C)
ListBaseT< Panel > panels
struct PanelType * type
struct Panel * next
void(*) panel_register(ARegionType *region_type)