IO: Use FileHandler in Node Editors
Use `FileHandlers` to handle file drag-n-drop in Node Editors. Drop-boxes still remain since they handle Images ID drag-n-drop. This also allows to open/drag-n-drop multiple files at once. Also this will allow add-ons to also support drag-n-drop for images and movies in node editors while still providing access to Blender's native support since File Handlers let users choose which to invoke if there's multiple configured. Pull Request: https://projects.blender.org/blender/blender/pulls/121051
This commit is contained in:
committed by
Hans Goudey
parent
749433f20b
commit
615100acda
@@ -6,6 +6,7 @@ from __future__ import annotations
|
||||
|
||||
import bpy
|
||||
from bpy.types import (
|
||||
FileHandler,
|
||||
Operator,
|
||||
PropertyGroup,
|
||||
)
|
||||
@@ -441,9 +442,27 @@ class NODE_OT_enum_definition_item_move(Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class NODE_FH_image_node(FileHandler):
|
||||
bl_idname = "NODE_FH_image_node"
|
||||
bl_label = "Image node"
|
||||
bl_import_operator = "node.add_file"
|
||||
bl_file_extensions = ";".join((*bpy.path.extensions_image, *bpy.path.extensions_movie))
|
||||
|
||||
@classmethod
|
||||
def poll_drop(cls, context):
|
||||
return (
|
||||
(context.area is not None) and
|
||||
(context.area.type == 'NODE_EDITOR') and
|
||||
(context.region is not None) and
|
||||
(context.region.type == 'WINDOW')
|
||||
)
|
||||
|
||||
|
||||
classes = (
|
||||
NodeSetting,
|
||||
|
||||
NODE_FH_image_node,
|
||||
|
||||
NODE_OT_add_node,
|
||||
NODE_OT_add_simulation_zone,
|
||||
NODE_OT_add_repeat_zone,
|
||||
|
||||
Reference in New Issue
Block a user