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.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.node;
24 import godot.texture;
25 import godot.editorresourcepreviewgenerator;
26 import godot.resource;
27 /**
28 Helper to generate previews of resources or files.
29 
30 This object is used to generate previews for resources of files.
31 $(B Note:) This class shouldn't be instantiated directly. Instead, access the singleton using $(D EditorInterface.getResourcePreviewer).
32 */
33 @GodotBaseClass struct EditorResourcePreview
34 {
35 	package(godot) enum string _GODOT_internal_name = "EditorResourcePreview";
36 public:
37 @nogc nothrow:
38 	union { /** */ godot_object _godot_object; /** */ Node _GODOT_base; }
39 	alias _GODOT_base this;
40 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
41 	package(godot) __gshared bool _classBindingInitialized = false;
42 	package(godot) static struct GDNativeClassBinding
43 	{
44 		__gshared:
45 		@GodotName("_preview_ready") GodotMethod!(void, String, Texture, Texture, long, String, Variant) _previewReady;
46 		@GodotName("add_preview_generator") GodotMethod!(void, EditorResourcePreviewGenerator) addPreviewGenerator;
47 		@GodotName("check_for_invalidation") GodotMethod!(void, String) checkForInvalidation;
48 		@GodotName("queue_edited_resource_preview") GodotMethod!(void, Resource, GodotObject, String, Variant) queueEditedResourcePreview;
49 		@GodotName("queue_resource_preview") GodotMethod!(void, String, GodotObject, String, Variant) queueResourcePreview;
50 		@GodotName("remove_preview_generator") GodotMethod!(void, EditorResourcePreviewGenerator) removePreviewGenerator;
51 	}
52 	/// 
53 	pragma(inline, true) bool opEquals(in EditorResourcePreview other) const
54 	{ return _godot_object.ptr is other._godot_object.ptr; }
55 	/// 
56 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
57 	{ _godot_object.ptr = n; return null; }
58 	/// 
59 	pragma(inline, true) bool opEquals(typeof(null) n) const
60 	{ return _godot_object.ptr is n; }
61 	/// 
62 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
63 	mixin baseCasts;
64 	/// Construct a new instance of EditorResourcePreview.
65 	/// Note: use `memnew!EditorResourcePreview` instead.
66 	static EditorResourcePreview _new()
67 	{
68 		static godot_class_constructor constructor;
69 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("EditorResourcePreview");
70 		if(constructor is null) return typeof(this).init;
71 		return cast(EditorResourcePreview)(constructor());
72 	}
73 	@disable new(size_t s);
74 	/**
75 	
76 	*/
77 	void _previewReady(VariantArg5)(in String arg0, Texture arg1, Texture arg2, in long arg3, in String arg4, in VariantArg5 arg5)
78 	{
79 		Array _GODOT_args = Array.make();
80 		_GODOT_args.append(arg0);
81 		_GODOT_args.append(arg1);
82 		_GODOT_args.append(arg2);
83 		_GODOT_args.append(arg3);
84 		_GODOT_args.append(arg4);
85 		_GODOT_args.append(arg5);
86 		String _GODOT_method_name = String("_preview_ready");
87 		this.callv(_GODOT_method_name, _GODOT_args);
88 	}
89 	/**
90 	Create an own, custom preview generator.
91 	*/
92 	void addPreviewGenerator(EditorResourcePreviewGenerator generator)
93 	{
94 		checkClassBinding!(typeof(this))();
95 		ptrcall!(void)(GDNativeClassBinding.addPreviewGenerator, _godot_object, generator);
96 	}
97 	/**
98 	Check if the resource changed, if so, it will be invalidated and the corresponding signal emitted.
99 	*/
100 	void checkForInvalidation(in String path)
101 	{
102 		checkClassBinding!(typeof(this))();
103 		ptrcall!(void)(GDNativeClassBinding.checkForInvalidation, _godot_object, path);
104 	}
105 	/**
106 	Queue the `resource` being edited for preview. Once the preview is ready, the `receiver`'s `receiver_func` will be called. The `receiver_func` must take the following four arguments: $(D String) path, $(D Texture) preview, $(D Texture) thumbnail_preview, $(D Variant) userdata. `userdata` can be anything, and will be returned when `receiver_func` is called.
107 	$(B Note): If it was not possible to create the preview the `receiver_func` will still be called, but the preview will be null.
108 	*/
109 	void queueEditedResourcePreview(VariantArg3)(Resource resource, GodotObject receiver, in String receiver_func, in VariantArg3 userdata)
110 	{
111 		checkClassBinding!(typeof(this))();
112 		ptrcall!(void)(GDNativeClassBinding.queueEditedResourcePreview, _godot_object, resource, receiver, receiver_func, userdata);
113 	}
114 	/**
115 	Queue a resource file located at `path` for preview. Once the preview is ready, the `receiver`'s `receiver_func` will be called. The `receiver_func` must take the following four arguments: $(D String) path, $(D Texture) preview, $(D Texture) thumbnail_preview, $(D Variant) userdata. `userdata` can be anything, and will be returned when `receiver_func` is called.
116 	$(B Note): If it was not possible to create the preview the `receiver_func` will still be called, but the preview will be null.
117 	*/
118 	void queueResourcePreview(VariantArg3)(in String path, GodotObject receiver, in String receiver_func, in VariantArg3 userdata)
119 	{
120 		checkClassBinding!(typeof(this))();
121 		ptrcall!(void)(GDNativeClassBinding.queueResourcePreview, _godot_object, path, receiver, receiver_func, userdata);
122 	}
123 	/**
124 	Removes a custom preview generator.
125 	*/
126 	void removePreviewGenerator(EditorResourcePreviewGenerator generator)
127 	{
128 		checkClassBinding!(typeof(this))();
129 		ptrcall!(void)(GDNativeClassBinding.removePreviewGenerator, _godot_object, generator);
130 	}
131 }