From c01496fe3d973670b0644bb3629f968aefb887bd Mon Sep 17 00:00:00 2001 From: Gangneron Date: Thu, 4 Jan 2024 19:55:43 +0100 Subject: [PATCH 01/16] Add render menu to Video Sequencer --- scripts/startup/bl_ui/space_sequencer.py | 48 +++++++++++++----------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/scripts/startup/bl_ui/space_sequencer.py b/scripts/startup/bl_ui/space_sequencer.py index 8559c33ee3a..279a2d4be78 100644 --- a/scripts/startup/bl_ui/space_sequencer.py +++ b/scripts/startup/bl_ui/space_sequencer.py @@ -490,32 +490,11 @@ class SEQUENCER_MT_view(Menu): if context.preferences.view.show_developer_ui: layout.menu("SEQUENCER_MT_view_cache", text="Show Cache") - layout.separator() - - layout.operator("render.opengl", text="Sequence Render Image", icon='RENDER_STILL').sequencer = True - props = layout.operator("render.opengl", text="Sequence Render Animation", icon='RENDER_ANIMATION') - props.animation = True - props.sequencer = True - layout.separator() layout.operator("sequencer.export_subtitles", text="Export Subtitles", icon='EXPORT') layout.separator() - # Note that the context is needed for the shortcut to display properly. - layout.operator_context = 'INVOKE_REGION_PREVIEW' if is_preview else 'INVOKE_REGION_WIN' - props = layout.operator( - "wm.context_toggle_enum", - text="Toggle Sequencer/Preview", - icon='SEQ_SEQUENCER' if is_preview else 'SEQ_PREVIEW', - ) - props.data_path = "space_data.view_type" - props.value_1 = 'SEQUENCER' - props.value_2 = 'PREVIEW' - layout.operator_context = 'INVOKE_DEFAULT' - - layout.separator() - layout.menu("INFO_MT_area") @@ -1113,6 +1092,32 @@ class SEQUENCER_MT_retiming(Menu): layout.operator("sequencer.retiming_key_add") layout.operator("sequencer.retiming_freeze_frame_add") +class SEQUENCER_MT_render(Menu): + bl_label = "Render" + bl_translation_context = i18n_contexts.operator_default + + def draw(self, context): + + layout = self.layout + layout.operator("render.opengl", text="Sequence Render Image", icon='RENDER_STILL').sequencer = True + props = layout.operator("render.opengl", text="Sequence Render Animation", icon='RENDER_ANIMATION') + props.animation = True + props.sequencer = True + + layout.separator() + + # Note that the context is needed for the shortcut to display properly. + layout.operator_context = 'INVOKE_REGION_PREVIEW' if is_preview else 'INVOKE_REGION_WIN' + props = layout.operator( + "wm.context_toggle_enum", + text="Toggle Sequencer/Preview", + icon='SEQ_SEQUENCER' if is_preview else 'SEQ_PREVIEW', + ) + props.data_path = "space_data.view_type" + props.value_1 = 'SEQUENCER' + props.value_2 = 'PREVIEW' + layout.operator_context = 'INVOKE_DEFAULT' + class SEQUENCER_MT_context_menu(Menu): bl_label = "Sequencer" @@ -2824,6 +2829,7 @@ classes = ( SEQUENCER_MT_preview_context_menu, SEQUENCER_MT_pivot_pie, SEQUENCER_MT_retiming, + SEQUENCER_MT_render, SEQUENCER_MT_view_pie, SEQUENCER_MT_preview_view_pie, -- 2.30.2 From 8fb20174a95f4e8feb5e4c7f49b2f00ddb6ac7ce Mon Sep 17 00:00:00 2001 From: Gangneron Date: Sat, 18 May 2024 19:17:33 +0200 Subject: [PATCH 02/16] =?UTF-8?q?T=C3=A9l=C3=A9verser=20les=20fichiers=20v?= =?UTF-8?q?ers=20"source/blender/editors/space=5Fsequencer"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editors/space_sequencer/CMakeLists.txt | 12 ++ .../space_sequencer/sequencer_manager.cc | 130 ++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 source/blender/editors/space_sequencer/sequencer_manager.cc diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt index f6656599d85..30bc5ff7567 100644 --- a/source/blender/editors/space_sequencer/CMakeLists.txt +++ b/source/blender/editors/space_sequencer/CMakeLists.txt @@ -29,6 +29,7 @@ set(SRC sequencer_clipboard.cc sequencer_drag_drop.cc sequencer_edit.cc + sequencer_manager.cc sequencer_modifier.cc sequencer_ops.cc sequencer_preview.cc @@ -46,6 +47,7 @@ set(SRC sequencer_intern.hh sequencer_quads_batch.hh + sequencer_scopes.hh ) set(LIB @@ -73,6 +75,16 @@ if(WITH_AUDASPACE) add_definitions(-DWITH_AUDASPACE) endif() +if(WITH_TBB) + add_definitions(-DWITH_TBB) + list(APPEND INC_SYS + ${TBB_INCLUDE_DIRS} + ) + list(APPEND LIB + ${TBB_LIBRARIES} + ) +endif() + blender_add_lib(bf_editor_space_sequencer "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/editors/space_sequencer/sequencer_manager.cc b/source/blender/editors/space_sequencer/sequencer_manager.cc new file mode 100644 index 00000000000..7f701236ac8 --- /dev/null +++ b/source/blender/editors/space_sequencer/sequencer_manager.cc @@ -0,0 +1,130 @@ +/* SPDX-FileCopyrightText: 2024 Blender Authors +* +* SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BLI_path_util.h" +#include "BKE_context.h" +#include "BKE_report.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "ED_screen.h" +#include "UI_interface.h" +#include "UI_resources.h" +#include "WM_api.h" +#include "WM_types.h" + +/* Operator for selecting text files */ +static int open_text_file_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + BKE_reportf(op->reports, RPT_INFO, "Selected text file: %s", filepath); + return OPERATOR_FINISHED; +} + +static void open_text_file(wmOperatorType *ot) +{ + ot->name = "Open Text File"; + ot->idname = "FILE_OT_open_text_file"; + ot->description = "Select a text file"; + + ot->exec = open_text_file_exec; + ot->poll = ED_operator_areaactive; + + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_TEXT, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +} + +/* Operator for selecting video files */ +static int open_video_file_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + BKE_reportf(op->reports, RPT_INFO, "Selected video file: %s", filepath); + return OPERATOR_FINISHED; +} + +static void open_video_file(wmOperatorType *ot) +{ + ot->name = "Open Video File"; + ot->idname = "FILE_OT_open_video_file"; + ot->description = "Select a video file"; + + ot->exec = open_video_file_exec; + ot->poll = ED_operator_areaactive; + + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +} + +/* Operator for selecting sound files */ +static int open_sound_file_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + BKE_reportf(op->reports, RPT_INFO, "Selected sound file: %s", filepath); + return OPERATOR_FINISHED; +} + +static void open_sound_file(wmOperatorType *ot) +{ + ot->name = "Open Sound File"; + ot->idname = "FILE_OT_open_sound_file"; + ot->description = "Select a sound file"; + + ot->exec = open_sound_file_exec; + ot->poll = ED_operator_areaactive; + + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_SOUND, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +} + +/* Operator for selecting image files */ +static int open_image_file_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + BKE_reportf(op->reports, RPT_INFO, "Selected image file: %s", filepath); + return OPERATOR_FINISHED; +} + +static void open_image_file(wmOperatorType *ot) +{ + ot->name = "Open Image File"; + ot->idname = "FILE_OT_open_image_file"; + ot->description = "Select an image file"; + + ot->exec = open_image_file_exec; + ot->poll = ED_operator_areaactive; + + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +} + +static void file_selector_panel_draw(const bContext *C, Panel *panel) +{ + uiLayout *layout = panel->layout; + uiLayoutSetPropSep(layout, true); + + uiItemO(layout, "Select Text File", ICON_FILE_BLEND, "FILE_OT_open_text_file"); + uiItemO(layout, "Select Video File", ICON_FILE_MOVIE, "FILE_OT_open_video_file"); + uiItemO(layout, "Select Sound File", ICON_SOUND, "FILE_OT_open_sound_file"); + uiItemO(layout, "Select Image File", ICON_IMAGE_DATA, "FILE_OT_open_image_file"); +} + +void file_selector_panel_register(ARegionType *art) +{ + PanelType *pt; + + pt = MEM_callocN(sizeof(PanelType), "spacetype file selector panel"); + strcpy(pt->idname, "SEQUENCER_PT_file_selector"); + strcpy(pt->label, "File Selector"); + strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); + pt->draw = file_selector_panel_draw; + pt->poll = ED_operator_areaactive; + + BLI_addtail(&art->paneltypes, pt); +} + +/* Register the panel in the appropriate space */ +void register_file_selector_panel(void) +{ + SpaceType *st = BKE_spacetype_from_id(SPACE_SEQ); + ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_UI); + file_selector_panel_register(art); +} -- 2.30.2 From cd9d218c84d41ae95328ae63cb685ebb650d3d24 Mon Sep 17 00:00:00 2001 From: Gangneron Date: Sat, 18 May 2024 19:28:01 +0200 Subject: [PATCH 03/16] fix --- scripts/startup/bl_ui/space_sequencer.py | 48 ++++++++++-------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/scripts/startup/bl_ui/space_sequencer.py b/scripts/startup/bl_ui/space_sequencer.py index 279a2d4be78..cc105418db4 100644 --- a/scripts/startup/bl_ui/space_sequencer.py +++ b/scripts/startup/bl_ui/space_sequencer.py @@ -490,9 +490,29 @@ class SEQUENCER_MT_view(Menu): if context.preferences.view.show_developer_ui: layout.menu("SEQUENCER_MT_view_cache", text="Show Cache") + layout.separator() + + layout.operator("render.opengl", text="Sequence Render Image", icon='RENDER_STILL').sequencer = True + props = layout.operator("render.opengl", text="Sequence Render Animation", icon='RENDER_ANIMATION') + props.animation = True + props.sequencer = True + layout.separator() layout.operator("sequencer.export_subtitles", text="Export Subtitles", icon='EXPORT') + layout.separator() + # Note that the context is needed for the shortcut to display properly. + layout.operator_context = 'INVOKE_REGION_PREVIEW' if is_preview else 'INVOKE_REGION_WIN' + props = layout.operator( + "wm.context_toggle_enum", + text="Toggle Sequencer/Preview", + icon='SEQ_SEQUENCER' if is_preview else 'SEQ_PREVIEW', + ) + props.data_path = "space_data.view_type" + props.value_1 = 'SEQUENCER' + props.value_2 = 'PREVIEW' + layout.operator_context = 'INVOKE_DEFAULT' + layout.separator() layout.menu("INFO_MT_area") @@ -1092,33 +1112,6 @@ class SEQUENCER_MT_retiming(Menu): layout.operator("sequencer.retiming_key_add") layout.operator("sequencer.retiming_freeze_frame_add") -class SEQUENCER_MT_render(Menu): - bl_label = "Render" - bl_translation_context = i18n_contexts.operator_default - - def draw(self, context): - - layout = self.layout - layout.operator("render.opengl", text="Sequence Render Image", icon='RENDER_STILL').sequencer = True - props = layout.operator("render.opengl", text="Sequence Render Animation", icon='RENDER_ANIMATION') - props.animation = True - props.sequencer = True - - layout.separator() - - # Note that the context is needed for the shortcut to display properly. - layout.operator_context = 'INVOKE_REGION_PREVIEW' if is_preview else 'INVOKE_REGION_WIN' - props = layout.operator( - "wm.context_toggle_enum", - text="Toggle Sequencer/Preview", - icon='SEQ_SEQUENCER' if is_preview else 'SEQ_PREVIEW', - ) - props.data_path = "space_data.view_type" - props.value_1 = 'SEQUENCER' - props.value_2 = 'PREVIEW' - layout.operator_context = 'INVOKE_DEFAULT' - - class SEQUENCER_MT_context_menu(Menu): bl_label = "Sequencer" @@ -2829,7 +2822,6 @@ classes = ( SEQUENCER_MT_preview_context_menu, SEQUENCER_MT_pivot_pie, SEQUENCER_MT_retiming, - SEQUENCER_MT_render, SEQUENCER_MT_view_pie, SEQUENCER_MT_preview_view_pie, -- 2.30.2 From bf2cd0f0005a8cb33e1a21ed83eae73b1ed222af Mon Sep 17 00:00:00 2001 From: Gangneron Date: Sat, 18 May 2024 19:30:21 +0200 Subject: [PATCH 04/16] fix --- scripts/startup/bl_ui/space_sequencer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/startup/bl_ui/space_sequencer.py b/scripts/startup/bl_ui/space_sequencer.py index cc105418db4..bd27705b00d 100644 --- a/scripts/startup/bl_ui/space_sequencer.py +++ b/scripts/startup/bl_ui/space_sequencer.py @@ -501,6 +501,7 @@ class SEQUENCER_MT_view(Menu): layout.operator("sequencer.export_subtitles", text="Export Subtitles", icon='EXPORT') layout.separator() + # Note that the context is needed for the shortcut to display properly. layout.operator_context = 'INVOKE_REGION_PREVIEW' if is_preview else 'INVOKE_REGION_WIN' props = layout.operator( @@ -1112,6 +1113,7 @@ class SEQUENCER_MT_retiming(Menu): layout.operator("sequencer.retiming_key_add") layout.operator("sequencer.retiming_freeze_frame_add") + class SEQUENCER_MT_context_menu(Menu): bl_label = "Sequencer" -- 2.30.2 From 613537c48c631e8ae5e4b0dabce64b51b74a1481 Mon Sep 17 00:00:00 2001 From: Gangneron Date: Sat, 18 May 2024 19:31:25 +0200 Subject: [PATCH 05/16] fix --- scripts/startup/bl_ui/space_sequencer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/startup/bl_ui/space_sequencer.py b/scripts/startup/bl_ui/space_sequencer.py index bd27705b00d..8559c33ee3a 100644 --- a/scripts/startup/bl_ui/space_sequencer.py +++ b/scripts/startup/bl_ui/space_sequencer.py @@ -502,7 +502,7 @@ class SEQUENCER_MT_view(Menu): layout.separator() - # Note that the context is needed for the shortcut to display properly. + # Note that the context is needed for the shortcut to display properly. layout.operator_context = 'INVOKE_REGION_PREVIEW' if is_preview else 'INVOKE_REGION_WIN' props = layout.operator( "wm.context_toggle_enum", -- 2.30.2 From 409733924158776a1ced955f057ca0cc707378eb Mon Sep 17 00:00:00 2001 From: Gangneron Date: Sun, 19 May 2024 17:00:52 +0200 Subject: [PATCH 06/16] progress Add id system and the operator in register --- .../space_sequencer/sequencer_intern.hh | 69 +++-- .../space_sequencer/sequencer_manager.cc | 272 +++++++++--------- 2 files changed, 181 insertions(+), 160 deletions(-) diff --git a/source/blender/editors/space_sequencer/sequencer_intern.hh b/source/blender/editors/space_sequencer/sequencer_intern.hh index cbbb220adcd..3e3c561d274 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.hh +++ b/source/blender/editors/space_sequencer/sequencer_intern.hh @@ -8,11 +8,15 @@ #pragma once +#include "BLI_utility_mixins.hh" #include "BLI_vector.hh" #include "BLI_vector_set.hh" #include "DNA_sequence_types.h" +#include "ED_sequencer.hh" #include "RNA_access.hh" +#include "sequencer_scopes.hh" + /* Internal exports only. */ class SeqQuadsBatch; @@ -38,7 +42,24 @@ struct Editing; struct ListBase; #define DEFAULT_IMG_STRIP_LENGTH 25 /* XXX arbitrary but ok for now. */ -#define OVERLAP_ALPHA 180 + +namespace blender::ed::seq { + +struct SpaceSeq_Runtime : public NonCopyable { + /** Required for Thumbnail job start condition. */ + rctf last_thumbnail_area = {0, 0, 0, 0}; + /** Stores lists of most recently displayed thumbnails. */ + GHash *last_displayed_thumbnails = nullptr; + int rename_channel_index = 0; + float timeline_clamp_custom_range = 0; + + blender::ed::seq::SeqScopes scopes; + + SpaceSeq_Runtime() = default; + ~SpaceSeq_Runtime(); +}; + +} // namespace blender::ed::seq struct SeqChannelDrawContext { const bContext *C; @@ -63,10 +84,6 @@ struct SeqChannelDrawContext { void draw_timeline_seq(const bContext *C, ARegion *region); void draw_timeline_seq_display(const bContext *C, ARegion *region); -void color3ubv_from_seq(const Scene *curscene, - const Sequence *seq, - bool show_strip_color_tag, - uchar r_col[3]); /* `sequencer_preview_draw.cc` */ @@ -125,7 +142,7 @@ void channel_draw_context_init(const bContext *C, /* `sequencer_edit.cc` */ -void seq_rectf(const Scene *scene, Sequence *seq, rctf *rectf); +void seq_rectf(const Scene *scene, const Sequence *seq, rctf *rectf); Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int sel); void recurs_sel_seq(Sequence *seq_meta); int seq_effect_find_selected(Scene *scene, @@ -157,20 +174,10 @@ bool sequencer_view_strips_poll(bContext *C); */ blender::VectorSet all_strips_from_context(bContext *C); -/** - * Returns collection with selected strips presented to user. If operation is done in preview, - * collection is limited to selected presented strips, that can produce image output at current - * frame. - * - * \param C: context - * \return collection of strips (`Sequence`) - */ -blender::VectorSet selected_strips_from_context(bContext *C); - /* Externals. */ -extern EnumPropertyItem sequencer_prop_effect_types[]; -extern EnumPropertyItem prop_side_types[]; +extern const EnumPropertyItem sequencer_prop_effect_types[]; +extern const EnumPropertyItem prop_side_types[]; /* Operators. */ @@ -236,7 +243,10 @@ void SEQUENCER_OT_select_side(wmOperatorType *ot); void SEQUENCER_OT_select_box(wmOperatorType *ot); void SEQUENCER_OT_select_inverse(wmOperatorType *ot); void SEQUENCER_OT_select_grouped(wmOperatorType *ot); -Sequence *find_nearest_seq(const Scene *scene, const View2D *v2d, const int mval[2], int *r_hand); +Sequence *find_nearest_seq(const Scene *scene, + const View2D *v2d, + const int mval[2], + eSeqHandle *r_hand); /* `sequencer_add.cc` */ @@ -258,14 +268,6 @@ void sequencer_dropboxes(); void sequencer_operatortypes(); void sequencer_keymap(wmKeyConfig *keyconf); -/* sequencer_scope.c */ - -ImBuf *make_waveform_view_from_ibuf(ImBuf *ibuf); -ImBuf *make_sep_waveform_view_from_ibuf(ImBuf *ibuf); -ImBuf *make_vectorscope_view_from_ibuf(ImBuf *ibuf); -ImBuf *make_zebra_view_from_ibuf(ImBuf *ibuf, float perc); -ImBuf *make_histogram_view_from_ibuf(ImBuf *ibuf); - /* `sequencer_buttons.cc` */ void sequencer_buttons_register(ARegionType *art); @@ -322,13 +324,20 @@ int sequencer_retiming_box_select_exec(bContext *C, wmOperator *op); /* `sequencer_retiming_draw.cc` */ void sequencer_draw_retiming(const bContext *C, SeqQuadsBatch *quads); -blender::Vector sequencer_visible_strips_get(const bContext *C); -SeqRetimingKey *try_to_realize_virtual_key(const bContext *C, Sequence *seq, const int mval[2]); +SeqRetimingKey *try_to_realize_virtual_keys(const bContext *C, Sequence *seq, const int mval[2]); SeqRetimingKey *retiming_mousover_key_get(const bContext *C, const int mval[2], Sequence **r_seq); int left_fake_key_frame_get(const bContext *C, const Sequence *seq); int right_fake_key_frame_get(const bContext *C, const Sequence *seq); -bool retiming_keys_are_visible(const bContext *C); +bool retiming_keys_are_visible(const SpaceSeq *sseq); + +/* `sequencer_timeline_draw.cc` */ +blender::Vector sequencer_visible_strips_get(const bContext *C); +blender::Vector sequencer_visible_strips_get(const Scene *scene, const View2D *v2d); /* `sequencer_clipboard.cc` */ int sequencer_clipboard_copy_exec(bContext *C, wmOperator *op); int sequencer_clipboard_paste_exec(bContext *C, wmOperator *op); + +/* sequencer_manager.cc*/ + +void register_file_selector_panel(void); \ No newline at end of file diff --git a/source/blender/editors/space_sequencer/sequencer_manager.cc b/source/blender/editors/space_sequencer/sequencer_manager.cc index 7f701236ac8..aceed422eb9 100644 --- a/source/blender/editors/space_sequencer/sequencer_manager.cc +++ b/source/blender/editors/space_sequencer/sequencer_manager.cc @@ -1,130 +1,142 @@ -/* SPDX-FileCopyrightText: 2024 Blender Authors -* -* SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BLI_path_util.h" -#include "BKE_context.h" -#include "BKE_report.h" -#include "DNA_screen_types.h" -#include "DNA_space_types.h" -#include "ED_screen.h" -#include "UI_interface.h" -#include "UI_resources.h" -#include "WM_api.h" -#include "WM_types.h" - -/* Operator for selecting text files */ -static int open_text_file_exec(bContext *C, wmOperator *op) -{ - char filepath[FILE_MAX]; - RNA_string_get(op->ptr, "filepath", filepath); - BKE_reportf(op->reports, RPT_INFO, "Selected text file: %s", filepath); - return OPERATOR_FINISHED; -} - -static void open_text_file(wmOperatorType *ot) -{ - ot->name = "Open Text File"; - ot->idname = "FILE_OT_open_text_file"; - ot->description = "Select a text file"; - - ot->exec = open_text_file_exec; - ot->poll = ED_operator_areaactive; - - WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_TEXT, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); -} - -/* Operator for selecting video files */ -static int open_video_file_exec(bContext *C, wmOperator *op) -{ - char filepath[FILE_MAX]; - RNA_string_get(op->ptr, "filepath", filepath); - BKE_reportf(op->reports, RPT_INFO, "Selected video file: %s", filepath); - return OPERATOR_FINISHED; -} - -static void open_video_file(wmOperatorType *ot) -{ - ot->name = "Open Video File"; - ot->idname = "FILE_OT_open_video_file"; - ot->description = "Select a video file"; - - ot->exec = open_video_file_exec; - ot->poll = ED_operator_areaactive; - - WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); -} - -/* Operator for selecting sound files */ -static int open_sound_file_exec(bContext *C, wmOperator *op) -{ - char filepath[FILE_MAX]; - RNA_string_get(op->ptr, "filepath", filepath); - BKE_reportf(op->reports, RPT_INFO, "Selected sound file: %s", filepath); - return OPERATOR_FINISHED; -} - -static void open_sound_file(wmOperatorType *ot) -{ - ot->name = "Open Sound File"; - ot->idname = "FILE_OT_open_sound_file"; - ot->description = "Select a sound file"; - - ot->exec = open_sound_file_exec; - ot->poll = ED_operator_areaactive; - - WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_SOUND, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); -} - -/* Operator for selecting image files */ -static int open_image_file_exec(bContext *C, wmOperator *op) -{ - char filepath[FILE_MAX]; - RNA_string_get(op->ptr, "filepath", filepath); - BKE_reportf(op->reports, RPT_INFO, "Selected image file: %s", filepath); - return OPERATOR_FINISHED; -} - -static void open_image_file(wmOperatorType *ot) -{ - ot->name = "Open Image File"; - ot->idname = "FILE_OT_open_image_file"; - ot->description = "Select an image file"; - - ot->exec = open_image_file_exec; - ot->poll = ED_operator_areaactive; - - WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); -} - -static void file_selector_panel_draw(const bContext *C, Panel *panel) -{ - uiLayout *layout = panel->layout; - uiLayoutSetPropSep(layout, true); - - uiItemO(layout, "Select Text File", ICON_FILE_BLEND, "FILE_OT_open_text_file"); - uiItemO(layout, "Select Video File", ICON_FILE_MOVIE, "FILE_OT_open_video_file"); - uiItemO(layout, "Select Sound File", ICON_SOUND, "FILE_OT_open_sound_file"); - uiItemO(layout, "Select Image File", ICON_IMAGE_DATA, "FILE_OT_open_image_file"); -} - -void file_selector_panel_register(ARegionType *art) -{ - PanelType *pt; - - pt = MEM_callocN(sizeof(PanelType), "spacetype file selector panel"); - strcpy(pt->idname, "SEQUENCER_PT_file_selector"); - strcpy(pt->label, "File Selector"); - strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); - pt->draw = file_selector_panel_draw; - pt->poll = ED_operator_areaactive; - - BLI_addtail(&art->paneltypes, pt); -} - -/* Register the panel in the appropriate space */ -void register_file_selector_panel(void) -{ - SpaceType *st = BKE_spacetype_from_id(SPACE_SEQ); - ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_UI); - file_selector_panel_register(art); -} +#include "BLI_path_util.h" +#include "BKE_context.h" +#include "BKE_report.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "ED_screen.h" +#include "UI_interface.h" +#include "UI_resources.h" +#include "WM_api.h" +#include "WM_types.h" + +/* Operator for selecting text files */ +static int open_text_file_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + BKE_reportf(op->reports, RPT_INFO, "Selected text file: %s", filepath); + return OPERATOR_FINISHED; +} + +static void open_text_file(wmOperatorType *ot) +{ + ot->name = "Open Text File"; + ot->idname = "FILE_OT_open_text_file"; + ot->description = "Select a text file"; + id == 1; + + ot->exec = open_text_file_exec; + ot->poll = ED_operator_areaactive; + + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_TEXT, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +} + +/* Operator for selecting video files */ +static int open_video_file_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + BKE_reportf(op->reports, RPT_INFO, "Selected video file: %s", filepath); + return OPERATOR_FINISHED; +} + +static void open_video_file(wmOperatorType *ot) +{ + ot->name = "Open Video File"; + ot->idname = "FILE_OT_open_video_file"; + ot->description = "Select a video file"; + id == 2; + + ot->exec = open_video_file_exec; + ot->poll = ED_operator_areaactive; + + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +} + +/* Operator for selecting sound files */ +static int open_sound_file_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + BKE_reportf(op->reports, RPT_INFO, "Selected sound file: %s", filepath); + return OPERATOR_FINISHED; +} + +static void open_sound_file(wmOperatorType *ot) +{ + ot->name = "Open Sound File"; + ot->idname = "FILE_OT_open_sound_file"; + ot->description = "Select a sound file"; + id == 3; + + ot->exec = open_sound_file_exec; + ot->poll = ED_operator_areaactive; + + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_SOUND, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +} + +/* Operator for selecting image files */ +static int open_image_file_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + BKE_reportf(op->reports, RPT_INFO, "Selected image file: %s", filepath); + return OPERATOR_FINISHED; +} + +static void open_image_file(wmOperatorType *ot) +{ + ot->name = "Open Image File"; + ot->idname = "FILE_OT_open_image_file"; + ot->description = "Select an image file"; + id == 4; + + ot->exec = open_image_file_exec; + ot->poll = ED_operator_areaactive; + + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +} + +static void file_selector_panel_draw(const bContext *C, Panel *panel) +{ + uiLayout *layout = panel->layout; + uiLayoutSetPropSep(layout, true); + + uiItemO(layout, "Select Text File", ICON_FILE_BLEND, "FILE_OT_open_text_file"); + uiItemO(layout, "Select Video File", ICON_FILE_MOVIE, "FILE_OT_open_video_file"); + uiItemO(layout, "Select Sound File", ICON_SOUND, "FILE_OT_open_sound_file"); + uiItemO(layout, "Select Image File", ICON_IMAGE_DATA, "FILE_OT_open_image_file"); +} + +void file_selector_panel_register(ARegionType *art) +{ + PanelType *pt; + + pt = MEM_callocN(sizeof(PanelType), "spacetype file selector panel"); + strcpy(pt->idname, "SEQUENCER_PT_file_selector"); + strcpy(pt->label, "File Selector"); + strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); + pt->draw = file_selector_panel_draw; + pt->poll = ED_operator_areaactive; + + BLI_addtail(&art->paneltypes, pt); +} + +/* Register the panel in the appropriate space */ +void register_file_selector_panel(void) +{ + SpaceType *st = BKE_spacetype_from_id(SPACE_SEQ); + ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_UI); + file_selector_panel_register(art); + void file_selector_panel_register(ARegionType *art) + static void open_text_file(wmOperatorType *ot) + static void open_sound_file(wmOperatorType *ot) + static void open_video_file(wmOperatorType *ot) + static void open_image_file(wmOperatorType *ot) + static void file_selector_panel_draw(const bContext *C, Panel *panel) + static int open_texte_file_exec(bContext *C, wmOperator *op) + static int open_sound_file_exec(bContext *C, wmOperator *op) + static int open_video_file_exec(bContext *C, wmOperator *op) + static int open_image_file_exec(bContext *C, wmOperator *op) + +} -- 2.30.2 From 1ed98b4f19824ab5dd7eba44c37b5a95dfcc23c2 Mon Sep 17 00:00:00 2001 From: Gangneron Date: Sun, 19 May 2024 17:03:21 +0200 Subject: [PATCH 07/16] progress Fix format --- .../space_sequencer/sequencer_manager.cc | 284 +++++++++--------- 1 file changed, 142 insertions(+), 142 deletions(-) diff --git a/source/blender/editors/space_sequencer/sequencer_manager.cc b/source/blender/editors/space_sequencer/sequencer_manager.cc index aceed422eb9..8a64b6ccc64 100644 --- a/source/blender/editors/space_sequencer/sequencer_manager.cc +++ b/source/blender/editors/space_sequencer/sequencer_manager.cc @@ -1,142 +1,142 @@ -#include "BLI_path_util.h" -#include "BKE_context.h" -#include "BKE_report.h" -#include "DNA_screen_types.h" -#include "DNA_space_types.h" -#include "ED_screen.h" -#include "UI_interface.h" -#include "UI_resources.h" -#include "WM_api.h" -#include "WM_types.h" - -/* Operator for selecting text files */ -static int open_text_file_exec(bContext *C, wmOperator *op) -{ - char filepath[FILE_MAX]; - RNA_string_get(op->ptr, "filepath", filepath); - BKE_reportf(op->reports, RPT_INFO, "Selected text file: %s", filepath); - return OPERATOR_FINISHED; -} - -static void open_text_file(wmOperatorType *ot) -{ - ot->name = "Open Text File"; - ot->idname = "FILE_OT_open_text_file"; - ot->description = "Select a text file"; - id == 1; - - ot->exec = open_text_file_exec; - ot->poll = ED_operator_areaactive; - - WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_TEXT, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); -} - -/* Operator for selecting video files */ -static int open_video_file_exec(bContext *C, wmOperator *op) -{ - char filepath[FILE_MAX]; - RNA_string_get(op->ptr, "filepath", filepath); - BKE_reportf(op->reports, RPT_INFO, "Selected video file: %s", filepath); - return OPERATOR_FINISHED; -} - -static void open_video_file(wmOperatorType *ot) -{ - ot->name = "Open Video File"; - ot->idname = "FILE_OT_open_video_file"; - ot->description = "Select a video file"; - id == 2; - - ot->exec = open_video_file_exec; - ot->poll = ED_operator_areaactive; - - WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); -} - -/* Operator for selecting sound files */ -static int open_sound_file_exec(bContext *C, wmOperator *op) -{ - char filepath[FILE_MAX]; - RNA_string_get(op->ptr, "filepath", filepath); - BKE_reportf(op->reports, RPT_INFO, "Selected sound file: %s", filepath); - return OPERATOR_FINISHED; -} - -static void open_sound_file(wmOperatorType *ot) -{ - ot->name = "Open Sound File"; - ot->idname = "FILE_OT_open_sound_file"; - ot->description = "Select a sound file"; - id == 3; - - ot->exec = open_sound_file_exec; - ot->poll = ED_operator_areaactive; - - WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_SOUND, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); -} - -/* Operator for selecting image files */ -static int open_image_file_exec(bContext *C, wmOperator *op) -{ - char filepath[FILE_MAX]; - RNA_string_get(op->ptr, "filepath", filepath); - BKE_reportf(op->reports, RPT_INFO, "Selected image file: %s", filepath); - return OPERATOR_FINISHED; -} - -static void open_image_file(wmOperatorType *ot) -{ - ot->name = "Open Image File"; - ot->idname = "FILE_OT_open_image_file"; - ot->description = "Select an image file"; - id == 4; - - ot->exec = open_image_file_exec; - ot->poll = ED_operator_areaactive; - - WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); -} - -static void file_selector_panel_draw(const bContext *C, Panel *panel) -{ - uiLayout *layout = panel->layout; - uiLayoutSetPropSep(layout, true); - - uiItemO(layout, "Select Text File", ICON_FILE_BLEND, "FILE_OT_open_text_file"); - uiItemO(layout, "Select Video File", ICON_FILE_MOVIE, "FILE_OT_open_video_file"); - uiItemO(layout, "Select Sound File", ICON_SOUND, "FILE_OT_open_sound_file"); - uiItemO(layout, "Select Image File", ICON_IMAGE_DATA, "FILE_OT_open_image_file"); -} - -void file_selector_panel_register(ARegionType *art) -{ - PanelType *pt; - - pt = MEM_callocN(sizeof(PanelType), "spacetype file selector panel"); - strcpy(pt->idname, "SEQUENCER_PT_file_selector"); - strcpy(pt->label, "File Selector"); - strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); - pt->draw = file_selector_panel_draw; - pt->poll = ED_operator_areaactive; - - BLI_addtail(&art->paneltypes, pt); -} - -/* Register the panel in the appropriate space */ -void register_file_selector_panel(void) -{ - SpaceType *st = BKE_spacetype_from_id(SPACE_SEQ); - ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_UI); - file_selector_panel_register(art); - void file_selector_panel_register(ARegionType *art) - static void open_text_file(wmOperatorType *ot) - static void open_sound_file(wmOperatorType *ot) - static void open_video_file(wmOperatorType *ot) - static void open_image_file(wmOperatorType *ot) - static void file_selector_panel_draw(const bContext *C, Panel *panel) - static int open_texte_file_exec(bContext *C, wmOperator *op) - static int open_sound_file_exec(bContext *C, wmOperator *op) - static int open_video_file_exec(bContext *C, wmOperator *op) - static int open_image_file_exec(bContext *C, wmOperator *op) - -} +#include "BLI_path_util.h" +#include "BKE_context.h" +#include "BKE_report.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" +#include "ED_screen.h" +#include "UI_interface.h" +#include "UI_resources.h" +#include "WM_api.h" +#include "WM_types.h" + +/* Operator for selecting text files */ +static int open_text_file_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + BKE_reportf(op->reports, RPT_INFO, "Selected text file: %s", filepath); + return OPERATOR_FINISHED; +} + +static void open_text_file(wmOperatorType *ot) +{ + ot->name = "Open Text File"; + ot->idname = "FILE_OT_open_text_file"; + ot->description = "Select a text file"; + id == 1; + + ot->exec = open_text_file_exec; + ot->poll = ED_operator_areaactive; + + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_TEXT, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +} + +/* Operator for selecting video files */ +static int open_video_file_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + BKE_reportf(op->reports, RPT_INFO, "Selected video file: %s", filepath); + return OPERATOR_FINISHED; +} + +static void open_video_file(wmOperatorType *ot) +{ + ot->name = "Open Video File"; + ot->idname = "FILE_OT_open_video_file"; + ot->description = "Select a video file"; + id == 2; + + ot->exec = open_video_file_exec; + ot->poll = ED_operator_areaactive; + + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +} + +/* Operator for selecting sound files */ +static int open_sound_file_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + BKE_reportf(op->reports, RPT_INFO, "Selected sound file: %s", filepath); + return OPERATOR_FINISHED; +} + +static void open_sound_file(wmOperatorType *ot) +{ + ot->name = "Open Sound File"; + ot->idname = "FILE_OT_open_sound_file"; + ot->description = "Select a sound file"; + id == 3; + + ot->exec = open_sound_file_exec; + ot->poll = ED_operator_areaactive; + + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_SOUND, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +} + +/* Operator for selecting image files */ +static int open_image_file_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + BKE_reportf(op->reports, RPT_INFO, "Selected image file: %s", filepath); + return OPERATOR_FINISHED; +} + +static void open_image_file(wmOperatorType *ot) +{ + ot->name = "Open Image File"; + ot->idname = "FILE_OT_open_image_file"; + ot->description = "Select an image file"; + id == 4; + + ot->exec = open_image_file_exec; + ot->poll = ED_operator_areaactive; + + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +} + +static void file_selector_panel_draw(const bContext *C, Panel *panel) +{ + uiLayout *layout = panel->layout; + uiLayoutSetPropSep(layout, true); + + uiItemO(layout, "Select Text File", ICON_FILE_BLEND, "FILE_OT_open_text_file"); + uiItemO(layout, "Select Video File", ICON_FILE_MOVIE, "FILE_OT_open_video_file"); + uiItemO(layout, "Select Sound File", ICON_SOUND, "FILE_OT_open_sound_file"); + uiItemO(layout, "Select Image File", ICON_IMAGE_DATA, "FILE_OT_open_image_file"); +} + +void file_selector_panel_register(ARegionType *art) +{ + PanelType *pt; + + pt = MEM_callocN(sizeof(PanelType), "spacetype file selector panel"); + strcpy(pt->idname, "SEQUENCER_PT_file_selector"); + strcpy(pt->label, "File Selector"); + strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); + pt->draw = file_selector_panel_draw; + pt->poll = ED_operator_areaactive; + + BLI_addtail(&art->paneltypes, pt); +} + +/* Register the panel in the appropriate space */ +void register_file_selector_panel(void) +{ + SpaceType *st = BKE_spacetype_from_id(SPACE_SEQ); + ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_UI); + file_selector_panel_register(art); + void file_selector_panel_register(ARegionType *art) + static void open_text_file(wmOperatorType *ot) + static void open_sound_file(wmOperatorType *ot) + static void open_video_file(wmOperatorType *ot) + static void open_image_file(wmOperatorType *ot) + static void file_selector_panel_draw(const bContext *C, Panel *panel) + static int open_texte_file_exec(bContext *C, wmOperator *op) + static int open_sound_file_exec(bContext *C, wmOperator *op) + static int open_video_file_exec(bContext *C, wmOperator *op) + static int open_image_file_exec(bContext *C, wmOperator *op) + +} -- 2.30.2 From 42dc2ffa0410f5d74dcc25c61a88a26236dcab02 Mon Sep 17 00:00:00 2001 From: Gangneron Date: Sun, 19 May 2024 17:05:02 +0200 Subject: [PATCH 08/16] fix problem --- .../space_sequencer/sequencer_manager.cc | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/space_sequencer/sequencer_manager.cc b/source/blender/editors/space_sequencer/sequencer_manager.cc index 8a64b6ccc64..a131260dc2e 100644 --- a/source/blender/editors/space_sequencer/sequencer_manager.cc +++ b/source/blender/editors/space_sequencer/sequencer_manager.cc @@ -128,15 +128,15 @@ void register_file_selector_panel(void) SpaceType *st = BKE_spacetype_from_id(SPACE_SEQ); ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_UI); file_selector_panel_register(art); - void file_selector_panel_register(ARegionType *art) - static void open_text_file(wmOperatorType *ot) - static void open_sound_file(wmOperatorType *ot) - static void open_video_file(wmOperatorType *ot) - static void open_image_file(wmOperatorType *ot) - static void file_selector_panel_draw(const bContext *C, Panel *panel) - static int open_texte_file_exec(bContext *C, wmOperator *op) - static int open_sound_file_exec(bContext *C, wmOperator *op) - static int open_video_file_exec(bContext *C, wmOperator *op) - static int open_image_file_exec(bContext *C, wmOperator *op) + void file_selector_panel_register(ARegionType *art); + static void open_text_file(wmOperatorType *ot); + static void open_sound_file(wmOperatorType *ot); + static void open_video_file(wmOperatorType *ot); + static void open_image_file(wmOperatorType *ot); + static void file_selector_panel_draw(const bContext *C, Panel *panel); + static int open_texte_file_exec(bContext *C, wmOperator *op); + static int open_sound_file_exec(bContext *C, wmOperator *op); + static int open_video_file_exec(bContext *C, wmOperator *op); + static int open_image_file_exec(bContext *C, wmOperator *op); } -- 2.30.2 From 85ee85bc92917e8ca4d2e4e64b534ad6a1a27c52 Mon Sep 17 00:00:00 2001 From: Gangneron Date: Thu, 13 Jun 2024 14:56:16 +0200 Subject: [PATCH 09/16] WIP: Add search files --- .../blender/editors/space_sequencer/sequencer_manager.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/blender/editors/space_sequencer/sequencer_manager.cc b/source/blender/editors/space_sequencer/sequencer_manager.cc index a131260dc2e..ac18d43759a 100644 --- a/source/blender/editors/space_sequencer/sequencer_manager.cc +++ b/source/blender/editors/space_sequencer/sequencer_manager.cc @@ -9,6 +9,15 @@ #include "WM_api.h" #include "WM_types.h" +/* Search for files */ +static void search_files(const char *query, uiLayout *layout) +{ + for (int i = 0; i < cached_file_count; i++) { + if (BLI_strcasestr(cached_files[i].file_path, query)) { + uiItemL(layout, cached_files[i].file_path, ICON_FILE); + } + } +} /* Operator for selecting text files */ static int open_text_file_exec(bContext *C, wmOperator *op) { -- 2.30.2 From b533dc2ab86d3edc5eb3dc2476a0d64946a98f15 Mon Sep 17 00:00:00 2001 From: Gangneron Date: Thu, 13 Jun 2024 14:57:50 +0200 Subject: [PATCH 10/16] WIP: Progress --- source/blender/editors/space_sequencer/sequencer_manager.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/editors/space_sequencer/sequencer_manager.cc b/source/blender/editors/space_sequencer/sequencer_manager.cc index ac18d43759a..4db7d8813dc 100644 --- a/source/blender/editors/space_sequencer/sequencer_manager.cc +++ b/source/blender/editors/space_sequencer/sequencer_manager.cc @@ -111,10 +111,16 @@ static void file_selector_panel_draw(const bContext *C, Panel *panel) uiLayout *layout = panel->layout; uiLayoutSetPropSep(layout, true); + /* Draw the search bar */ + uiLayout *row = uiLayoutRow(layout, false); + uiItemL(row, "Search:", ICON_VIEWZOOM); + uiItemR(row, NULL, 0, 0, "search", ICON_NONE); + uiItemO(layout, "Select Text File", ICON_FILE_BLEND, "FILE_OT_open_text_file"); uiItemO(layout, "Select Video File", ICON_FILE_MOVIE, "FILE_OT_open_video_file"); uiItemO(layout, "Select Sound File", ICON_SOUND, "FILE_OT_open_sound_file"); uiItemO(layout, "Select Image File", ICON_IMAGE_DATA, "FILE_OT_open_image_file"); + } void file_selector_panel_register(ARegionType *art) -- 2.30.2 From 376876beaf5894e3093d2106916a2b94ff82bc3a Mon Sep 17 00:00:00 2001 From: Gangneron Date: Thu, 13 Jun 2024 15:00:24 +0200 Subject: [PATCH 11/16] WIP: Add file in cache and attribute ID --- .../space_sequencer/sequencer_manager.cc | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/source/blender/editors/space_sequencer/sequencer_manager.cc b/source/blender/editors/space_sequencer/sequencer_manager.cc index 4db7d8813dc..e0003ca62be 100644 --- a/source/blender/editors/space_sequencer/sequencer_manager.cc +++ b/source/blender/editors/space_sequencer/sequencer_manager.cc @@ -3,11 +3,72 @@ #include "BKE_report.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "DNA_ID.h" #include "ED_screen.h" #include "UI_interface.h" #include "UI_resources.h" #include "WM_api.h" #include "WM_types.h" +#include "SEQ_add.h" +#include "DNA_sequence_types.h" +#include "BLI_string.h" + +/* Define a simple cache for imported files */ +#define MAX_CACHED_FILES 100 +static ID cached_files[MAX_CACHED_FILES]; +static int cached_file_count = 0; +static int current_file_id = 0; + +/* Add a file to the cache */ +static void add_to_cache(const char *filepath) +{ + if (cached_file_count < MAX_CACHED_FILES) { + ID *file = &cached_files[cached_file_count]; + file->file_id = current_file_id++; + BLI_strncpy(file->file_path, filepath, sizeof(file->file_path)); + cached_file_count++; + } +} + +/* Draw the cached files in the panel */ +static void draw_cached_files(uiLayout *layout) +{ + for (int i = 0; i < cached_file_count; i++) { + uiItemL(layout, cached_files[i].file_path, ICON_FILE); + } +} + +/* Search for files */ +static void search_files(const char *query, uiLayout *layout) +{ + for (int i = 0; i < cached_file_count; i++) { + if (BLI_strcasestr(cached_files[i].file_path, query)) { + uiItemL(layout, cached_files[i].file_path, ICON_FILE); + } + } +} + +/* Operator for selecting text files */ +static int open_text_file_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + add_to_cache(filepath); + BKE_reportf(op->reports, RPT_INFO, "Selected text file: %s", filepath); + return OPERATOR_FINISHED; +} + +static void open_text_file(wmOperatorType *ot) +{ + ot->name = "Open Text File"; + ot->idname = "FILE_OT_open_text_file"; + ot->description = "Select a text file"; + + ot->exec = open_text_file_exec; + ot->poll = ED_operator_areaactive; + + WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_TEXT, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +} /* Search for files */ static void search_files(const char *query, uiLayout *layout) @@ -121,6 +182,9 @@ static void file_selector_panel_draw(const bContext *C, Panel *panel) uiItemO(layout, "Select Sound File", ICON_SOUND, "FILE_OT_open_sound_file"); uiItemO(layout, "Select Image File", ICON_IMAGE_DATA, "FILE_OT_open_image_file"); + /* Draw the cached files */ + draw_cached_files(layout); + } void file_selector_panel_register(ARegionType *art) -- 2.30.2 From 48b1a5a6964d958adf041bd6effd38ee079900b6 Mon Sep 17 00:00:00 2001 From: Gangneron Date: Thu, 13 Jun 2024 15:03:05 +0200 Subject: [PATCH 12/16] WIP --- .../space_sequencer/sequencer_manager.cc | 91 ++----------------- 1 file changed, 7 insertions(+), 84 deletions(-) diff --git a/source/blender/editors/space_sequencer/sequencer_manager.cc b/source/blender/editors/space_sequencer/sequencer_manager.cc index e0003ca62be..7649cd5fecb 100644 --- a/source/blender/editors/space_sequencer/sequencer_manager.cc +++ b/source/blender/editors/space_sequencer/sequencer_manager.cc @@ -3,82 +3,12 @@ #include "BKE_report.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" -#include "DNA_ID.h" #include "ED_screen.h" #include "UI_interface.h" #include "UI_resources.h" #include "WM_api.h" #include "WM_types.h" -#include "SEQ_add.h" -#include "DNA_sequence_types.h" -#include "BLI_string.h" -/* Define a simple cache for imported files */ -#define MAX_CACHED_FILES 100 -static ID cached_files[MAX_CACHED_FILES]; -static int cached_file_count = 0; -static int current_file_id = 0; - -/* Add a file to the cache */ -static void add_to_cache(const char *filepath) -{ - if (cached_file_count < MAX_CACHED_FILES) { - ID *file = &cached_files[cached_file_count]; - file->file_id = current_file_id++; - BLI_strncpy(file->file_path, filepath, sizeof(file->file_path)); - cached_file_count++; - } -} - -/* Draw the cached files in the panel */ -static void draw_cached_files(uiLayout *layout) -{ - for (int i = 0; i < cached_file_count; i++) { - uiItemL(layout, cached_files[i].file_path, ICON_FILE); - } -} - -/* Search for files */ -static void search_files(const char *query, uiLayout *layout) -{ - for (int i = 0; i < cached_file_count; i++) { - if (BLI_strcasestr(cached_files[i].file_path, query)) { - uiItemL(layout, cached_files[i].file_path, ICON_FILE); - } - } -} - -/* Operator for selecting text files */ -static int open_text_file_exec(bContext *C, wmOperator *op) -{ - char filepath[FILE_MAX]; - RNA_string_get(op->ptr, "filepath", filepath); - add_to_cache(filepath); - BKE_reportf(op->reports, RPT_INFO, "Selected text file: %s", filepath); - return OPERATOR_FINISHED; -} - -static void open_text_file(wmOperatorType *ot) -{ - ot->name = "Open Text File"; - ot->idname = "FILE_OT_open_text_file"; - ot->description = "Select a text file"; - - ot->exec = open_text_file_exec; - ot->poll = ED_operator_areaactive; - - WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | FILE_TYPE_TEXT, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); -} - -/* Search for files */ -static void search_files(const char *query, uiLayout *layout) -{ - for (int i = 0; i < cached_file_count; i++) { - if (BLI_strcasestr(cached_files[i].file_path, query)) { - uiItemL(layout, cached_files[i].file_path, ICON_FILE); - } - } -} /* Operator for selecting text files */ static int open_text_file_exec(bContext *C, wmOperator *op) { @@ -93,7 +23,6 @@ static void open_text_file(wmOperatorType *ot) ot->name = "Open Text File"; ot->idname = "FILE_OT_open_text_file"; ot->description = "Select a text file"; - id == 1; ot->exec = open_text_file_exec; ot->poll = ED_operator_areaactive; @@ -115,7 +44,6 @@ static void open_video_file(wmOperatorType *ot) ot->name = "Open Video File"; ot->idname = "FILE_OT_open_video_file"; ot->description = "Select a video file"; - id == 2; ot->exec = open_video_file_exec; ot->poll = ED_operator_areaactive; @@ -137,7 +65,6 @@ static void open_sound_file(wmOperatorType *ot) ot->name = "Open Sound File"; ot->idname = "FILE_OT_open_sound_file"; ot->description = "Select a sound file"; - id == 3; ot->exec = open_sound_file_exec; ot->poll = ED_operator_areaactive; @@ -159,7 +86,6 @@ static void open_image_file(wmOperatorType *ot) ot->name = "Open Image File"; ot->idname = "FILE_OT_open_image_file"; ot->description = "Select an image file"; - id == 4; ot->exec = open_image_file_exec; ot->poll = ED_operator_areaactive; @@ -172,19 +98,10 @@ static void file_selector_panel_draw(const bContext *C, Panel *panel) uiLayout *layout = panel->layout; uiLayoutSetPropSep(layout, true); - /* Draw the search bar */ - uiLayout *row = uiLayoutRow(layout, false); - uiItemL(row, "Search:", ICON_VIEWZOOM); - uiItemR(row, NULL, 0, 0, "search", ICON_NONE); - uiItemO(layout, "Select Text File", ICON_FILE_BLEND, "FILE_OT_open_text_file"); uiItemO(layout, "Select Video File", ICON_FILE_MOVIE, "FILE_OT_open_video_file"); uiItemO(layout, "Select Sound File", ICON_SOUND, "FILE_OT_open_sound_file"); uiItemO(layout, "Select Image File", ICON_IMAGE_DATA, "FILE_OT_open_image_file"); - - /* Draw the cached files */ - draw_cached_files(layout); - } void file_selector_panel_register(ARegionType *art) @@ -192,7 +109,7 @@ void file_selector_panel_register(ARegionType *art) PanelType *pt; pt = MEM_callocN(sizeof(PanelType), "spacetype file selector panel"); - strcpy(pt->idname, "SEQUENCER_PT_file_selector"); + strcpy(pt->idname, "FILE_PT_selector"); strcpy(pt->label, "File Selector"); strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); pt->draw = file_selector_panel_draw; @@ -202,6 +119,12 @@ void file_selector_panel_register(ARegionType *art) } /* Register the panel in the appropriate space */ +void register_file_selector_panel(void) +{ + ARegionType *art = BKE_regiontype_from_id(RGN_TYPE_UI); + file_selector_panel_register(art); +} + void register_file_selector_panel(void) { SpaceType *st = BKE_spacetype_from_id(SPACE_SEQ); -- 2.30.2 From 7683186f54709a21253a33d9761b839340e57b3f Mon Sep 17 00:00:00 2001 From: Gangneron Date: Thu, 13 Jun 2024 15:04:06 +0200 Subject: [PATCH 13/16] WIP --- .../space_sequencer/sequencer_manager.cc | 111 +++++++++++++++++- 1 file changed, 107 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_sequencer/sequencer_manager.cc b/source/blender/editors/space_sequencer/sequencer_manager.cc index 7649cd5fecb..c5c62d34099 100644 --- a/source/blender/editors/space_sequencer/sequencer_manager.cc +++ b/source/blender/editors/space_sequencer/sequencer_manager.cc @@ -3,17 +3,57 @@ #include "BKE_report.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "DNA_ID.h" #include "ED_screen.h" #include "UI_interface.h" #include "UI_resources.h" #include "WM_api.h" #include "WM_types.h" +#include "SEQ_add.h" +#include "DNA_sequence_types.h" +#include "BLI_string.h" + +/* Define a simple cache for imported files */ +#define MAX_CACHED_FILES 100 +static ID cached_files[MAX_CACHED_FILES]; +static int cached_file_count = 0; +static int current_file_id = 0; + +/* Add a file to the cache */ +static void add_to_cache(const char *filepath) +{ + if (cached_file_count < MAX_CACHED_FILES) { + ID *file = &cached_files[cached_file_count]; + file->file_id = current_file_id++; + BLI_strncpy(file->file_path, filepath, sizeof(file->file_path)); + cached_file_count++; + } +} + +/* Draw the cached files in the panel */ +static void draw_cached_files(uiLayout *layout) +{ + for (int i = 0; i < cached_file_count; i++) { + uiItemL(layout, cached_files[i].file_path, ICON_FILE); + } +} + +/* Search for files */ +static void search_files(const char *query, uiLayout *layout) +{ + for (int i = 0; i < cached_file_count; i++) { + if (BLI_strcasestr(cached_files[i].file_path, query)) { + uiItemL(layout, cached_files[i].file_path, ICON_FILE); + } + } +} /* Operator for selecting text files */ static int open_text_file_exec(bContext *C, wmOperator *op) { char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); + add_to_cache(filepath); BKE_reportf(op->reports, RPT_INFO, "Selected text file: %s", filepath); return OPERATOR_FINISHED; } @@ -35,6 +75,7 @@ static int open_video_file_exec(bContext *C, wmOperator *op) { char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); + add_to_cache(filepath); BKE_reportf(op->reports, RPT_INFO, "Selected video file: %s", filepath); return OPERATOR_FINISHED; } @@ -56,6 +97,7 @@ static int open_sound_file_exec(bContext *C, wmOperator *op) { char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); + add_to_cache(filepath); BKE_reportf(op->reports, RPT_INFO, "Selected sound file: %s", filepath); return OPERATOR_FINISHED; } @@ -77,6 +119,7 @@ static int open_image_file_exec(bContext *C, wmOperator *op) { char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); + add_to_cache(filepath); BKE_reportf(op->reports, RPT_INFO, "Selected image file: %s", filepath); return OPERATOR_FINISHED; } @@ -97,11 +140,20 @@ static void file_selector_panel_draw(const bContext *C, Panel *panel) { uiLayout *layout = panel->layout; uiLayoutSetPropSep(layout, true); - + + /* Draw the search bar */ + uiLayout *row = uiLayoutRow(layout, false); + uiItemL(row, "Search:", ICON_VIEWZOOM); + uiItemR(row, NULL, 0, 0, "search", ICON_NONE); + + /* Draw the buttons for selecting files */ uiItemO(layout, "Select Text File", ICON_FILE_BLEND, "FILE_OT_open_text_file"); uiItemO(layout, "Select Video File", ICON_FILE_MOVIE, "FILE_OT_open_video_file"); uiItemO(layout, "Select Sound File", ICON_SOUND, "FILE_OT_open_sound_file"); uiItemO(layout, "Select Image File", ICON_IMAGE_DATA, "FILE_OT_open_image_file"); + + /* Draw the cached files */ + draw_cached_files(layout); } void file_selector_panel_register(ARegionType *art) @@ -109,7 +161,7 @@ void file_selector_panel_register(ARegionType *art) PanelType *pt; pt = MEM_callocN(sizeof(PanelType), "spacetype file selector panel"); - strcpy(pt->idname, "FILE_PT_selector"); + strcpy(pt->idname, "SEQUENCER_PT_file_selector"); strcpy(pt->label, "File Selector"); strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); pt->draw = file_selector_panel_draw; @@ -118,11 +170,62 @@ void file_selector_panel_register(ARegionType *art) BLI_addtail(&art->paneltypes, pt); } -/* Register the panel in the appropriate space */ +/* Drag-and-drop handlers */ +static void sequencer_drop_init(wmDrag *drag, wmDropBox *drop) +{ + RNA_string_set(drop->ptr, "filepath", drag->path); +} + +static bool sequencer_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +{ + if (drag->type == WM_DRAG_PATH) { + const char *extension = BLI_path_extension(drag->path); + return (extension && (BLI_path_extension_check_array(extension, ".avi;.mov;.mp4;.wav;.mp3;.ogg;.png;.jpg;.jpeg;.bmp;.tiff;.tif"))); + } + return false; +} + +static int sequencer_drop_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + + /* Add the dropped file to the sequencer */ + SEQ_add_movie_strip(C, filepath, NULL, 0, 0, 0, 0, 0); + BKE_reportf(op->reports, RPT_INFO, "Dropped file added to sequencer: %s", filepath); + + return OPERATOR_FINISHED; +} + +static void sequencer_drop(wmOperatorType *ot) +{ + ot->name = "Drop File to Sequencer"; + ot->idname = "SEQUENCER_OT_drop"; + ot->description = "Drop a file into the sequencer"; + + ot->exec = sequencer_drop_exec; + ot->poll = ED_operator_areaactive; + + RNA_def_string(ot->srna, "filepath", NULL, FILE_MAX, "File Path", "Path of the file to drop"); +} + +/* Register the dropbox */ +void register_sequencer_dropbox(void) +{ + ListBase *lb = WM_dropboxmap_find("Sequencer", SPACE_SEQ, RGN_TYPE_WINDOW); + + WM_dropbox_add(lb, "SEQUENCER_OT_drop", sequencer_drop_poll, sequencer_drop_init); +} + +/* Register the panel and dropbox in the appropriate space */ void register_file_selector_panel(void) { - ARegionType *art = BKE_regiontype_from_id(RGN_TYPE_UI); + SpaceType *st = BKE_spacetype_from_id(SPACE_SEQ); + ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_UI); file_selector_panel_register(art); + + /* Register the dropbox for the sequencer */ + register_sequencer_dropbox(); } void register_file_selector_panel(void) -- 2.30.2 From da051bec5e24b30dfa5650d4721d2ec925651cea Mon Sep 17 00:00:00 2001 From: Gangneron Date: Thu, 13 Jun 2024 15:07:42 +0200 Subject: [PATCH 14/16] Add fonction register --- source/blender/editors/space_sequencer/space_sequencer.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_sequencer/space_sequencer.cc b/source/blender/editors/space_sequencer/space_sequencer.cc index cccd6df2753..1c99780c40d 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.cc +++ b/source/blender/editors/space_sequencer/space_sequencer.cc @@ -339,7 +339,8 @@ static void sequencer_listener(const wmSpaceTypeListenerParams *params) break; } } - +/*fonction of sequencer_manager.cc*/ + extern void register_file_selector_panel(void); /* DO NOT make this static, this hides the symbol and breaks API generation script. */ extern "C" const char *sequencer_context_dir[]; /* Quiet warning. */ const char *sequencer_context_dir[] = {"edit_mask", nullptr}; -- 2.30.2 From 2123a4e110e42420f13ddf5c4fa05eab22af782f Mon Sep 17 00:00:00 2001 From: Gangneron Date: Thu, 13 Jun 2024 15:11:06 +0200 Subject: [PATCH 15/16] Add reference --- source/blender/editors/include/ED_sequencer.hh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/editors/include/ED_sequencer.hh b/source/blender/editors/include/ED_sequencer.hh index 12372e9d9f0..685d14d67c2 100644 --- a/source/blender/editors/include/ED_sequencer.hh +++ b/source/blender/editors/include/ED_sequencer.hh @@ -46,3 +46,8 @@ Sequence *ED_sequencer_special_preview_get(); void ED_sequencer_special_preview_set(bContext *C, const int mval[2]); void ED_sequencer_special_preview_clear(); bool sequencer_retiming_mode_is_active(const bContext *C); + +void ED_sequencer_file_manager(void){ + register_file_selector_panel(); + register_sequencer_dropbox(); +} \ No newline at end of file -- 2.30.2 From 0554724f892798ee3e5e6b87d69a67d4d1336bbd Mon Sep 17 00:00:00 2001 From: Gangneron Date: Thu, 13 Jun 2024 15:16:03 +0200 Subject: [PATCH 16/16] Add ID in DNA_ID.h --- source/blender/makesdna/DNA_ID.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 23ee67b2a84..f2a4acdc246 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -173,6 +173,25 @@ typedef struct IDProperty { IDPropertyUIData *ui_data; } IDProperty; +typedef struct ID { + void *next, *prev; + struct ID *newid; + struct Library *lib; + char name[66]; /* MAX_ID_NAME */ + short flag; + short tag; + int us, icon_id; + int recalc; + int recalc_up_to_undo_push; + short idcode; + char _pad[6]; + + /* NEW: Custom fields for file selector */ + int file_id; + char file_path[1024]; /* Maximum file path length */ +} ID; + + #define MAX_IDPROP_NAME 64 #define DEFAULT_ALLOC_FOR_NULL_STRINGS 64 -- 2.30.2