This PR switches out the internal scene context function used from the sequencer. This is done in preparation for #140271. Using a separate context function allows us to keep the existing `context.scene` to refer to the active scene and use a separate context member to refer to the sequencer scene in the workspace (which is added in #140271). Previous attempts simply overrode the `context.scene` to refer to a different scene than the active one in the window. This has two issues: 1) Any operator that wants to use the active scene in the window can't do it in the context of the sequencer. This is a problem for example for poll functions of operators that don't have anything to do with the sequencer. 2) For better or for worse, Blender expects the `context.scene` to always exist. For the sequencer, we'd like to possibly have no sequence selected. Using a different context member for the sequencer has some advantages: 1) Although we have to change quite a few places, it's limited to the sequencer. We don't have to change other parts of Blender to make things work. 2) It allows us to prepare for the future when we might want to separate the VSE from the scene. This is a step in that direction. Having a different context function makes it easy to find the places that would need to be refactored. Pull Request: https://projects.blender.org/blender/blender/pulls/141271
54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
/* SPDX-FileCopyrightText: 2022 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup sequencer
|
|
*/
|
|
|
|
#include "DNA_screen_types.h"
|
|
#include "DNA_windowmanager_types.h"
|
|
|
|
#include "BKE_context.hh"
|
|
|
|
#include "ED_screen.hh"
|
|
|
|
#include "UI_view2d.hh"
|
|
|
|
#include "WM_api.hh"
|
|
|
|
/* Own include. */
|
|
#include "sequencer_intern.hh"
|
|
|
|
namespace blender::ed::vse {
|
|
|
|
static wmOperatorStatus sequencer_rename_channel_invoke(bContext *C,
|
|
wmOperator * /*op*/,
|
|
const wmEvent *event)
|
|
{
|
|
SeqChannelDrawContext context;
|
|
SpaceSeq *sseq = CTX_wm_space_seq(C);
|
|
channel_draw_context_init(C, CTX_wm_region(C), &context);
|
|
float mouse_y = UI_view2d_region_to_view_y(context.timeline_region_v2d, event->mval[1]);
|
|
|
|
sseq->runtime->rename_channel_index = mouse_y;
|
|
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, CTX_data_sequencer_scene(C));
|
|
return OPERATOR_FINISHED;
|
|
}
|
|
|
|
void SEQUENCER_OT_rename_channel(wmOperatorType *ot)
|
|
{
|
|
/* Identifiers. */
|
|
ot->name = "Rename Channel";
|
|
ot->idname = "SEQUENCER_OT_rename_channel";
|
|
|
|
/* API callbacks. */
|
|
ot->invoke = sequencer_rename_channel_invoke;
|
|
ot->poll = sequencer_edit_with_channel_region_poll;
|
|
|
|
/* Flags. */
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
|
|
}
|
|
|
|
} // namespace blender::ed::vse
|