1 /**
2 Helper to generate previews of resources or files.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.editorresourcepreview;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.meta;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.object;
22 import godot.node;
23 import godot.texture;
24 import godot.resource;
25 import godot.editorresourcepreviewgenerator;
26 /**
27 Helper to generate previews of resources or files.
28 
29 This object is used to generate previews for resources of files.
30 */
31 @GodotBaseClass struct EditorResourcePreview
32 {
33 	enum string _GODOT_internal_name = "EditorResourcePreview";
34 public:
35 @nogc nothrow:
36 	union { godot_object _godot_object; Node _GODOT_base; }
37 	alias _GODOT_base this;
38 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
39 	package(godot) __gshared bool _classBindingInitialized = false;
40 	package(godot) static struct _classBinding
41 	{
42 		__gshared:
43 		@GodotName("_preview_ready") GodotMethod!(void, String, Texture, Texture, long, String, Variant) _previewReady;
44 		@GodotName("queue_resource_preview") GodotMethod!(void, String, GodotObject, String, Variant) queueResourcePreview;
45 		@GodotName("queue_edited_resource_preview") GodotMethod!(void, Resource, GodotObject, String, Variant) queueEditedResourcePreview;
46 		@GodotName("add_preview_generator") GodotMethod!(void, EditorResourcePreviewGenerator) addPreviewGenerator;
47 		@GodotName("remove_preview_generator") GodotMethod!(void, EditorResourcePreviewGenerator) removePreviewGenerator;
48 		@GodotName("check_for_invalidation") GodotMethod!(void, String) checkForInvalidation;
49 	}
50 	bool opEquals(in EditorResourcePreview other) const { return _godot_object.ptr is other._godot_object.ptr; }
51 	EditorResourcePreview opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
52 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
53 	mixin baseCasts;
54 	static EditorResourcePreview _new()
55 	{
56 		static godot_class_constructor constructor;
57 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("EditorResourcePreview");
58 		if(constructor is null) return typeof(this).init;
59 		return cast(EditorResourcePreview)(constructor());
60 	}
61 	@disable new(size_t s);
62 	/**
63 	
64 	*/
65 	void _previewReady(StringArg0, StringArg4, VariantArg5)(in StringArg0 arg0, Texture arg1, Texture arg2, in long arg3, in StringArg4 arg4, in VariantArg5 arg5)
66 	{
67 		Array _GODOT_args = Array.empty_array;
68 		_GODOT_args.append(arg0);
69 		_GODOT_args.append(arg1);
70 		_GODOT_args.append(arg2);
71 		_GODOT_args.append(arg3);
72 		_GODOT_args.append(arg4);
73 		_GODOT_args.append(arg5);
74 		String _GODOT_method_name = String("_preview_ready");
75 		this.callv(_GODOT_method_name, _GODOT_args);
76 	}
77 	/**
78 	Queue a resource file for preview (using a path). Once the preview is ready, your receiver.receiver_func will be called either containing the preview texture or an empty texture (if no preview was possible). Callback must have the format: (path,texture,userdata). Userdata can be anything.
79 	*/
80 	void queueResourcePreview(StringArg0, StringArg2, VariantArg3)(in StringArg0 path, GodotObject receiver, in StringArg2 receiver_func, in VariantArg3 userdata)
81 	{
82 		checkClassBinding!(typeof(this))();
83 		ptrcall!(void)(_classBinding.queueResourcePreview, _godot_object, path, receiver, receiver_func, userdata);
84 	}
85 	/**
86 	Queue a resource being edited for preview (using an instance). Once the preview is ready, your receiver.receiver_func will be called either containing the preview texture or an empty texture (if no preview was possible). Callback must have the format: (path,texture,userdata). Userdata can be anything.
87 	*/
88 	void queueEditedResourcePreview(StringArg2, VariantArg3)(Resource resource, GodotObject receiver, in StringArg2 receiver_func, in VariantArg3 userdata)
89 	{
90 		checkClassBinding!(typeof(this))();
91 		ptrcall!(void)(_classBinding.queueEditedResourcePreview, _godot_object, resource, receiver, receiver_func, userdata);
92 	}
93 	/**
94 	Create an own, custom preview generator.
95 	*/
96 	void addPreviewGenerator(EditorResourcePreviewGenerator generator)
97 	{
98 		checkClassBinding!(typeof(this))();
99 		ptrcall!(void)(_classBinding.addPreviewGenerator, _godot_object, generator);
100 	}
101 	/**
102 	Remove a custom preview generator.
103 	*/
104 	void removePreviewGenerator(EditorResourcePreviewGenerator generator)
105 	{
106 		checkClassBinding!(typeof(this))();
107 		ptrcall!(void)(_classBinding.removePreviewGenerator, _godot_object, generator);
108 	}
109 	/**
110 	Check if the resource changed, if so it will be invalidated and the corresponding signal emitted.
111 	*/
112 	void checkForInvalidation(StringArg0)(in StringArg0 path)
113 	{
114 		checkClassBinding!(typeof(this))();
115 		ptrcall!(void)(_classBinding.checkForInvalidation, _godot_object, path);
116 	}
117 }