1 /** 2 Custom generator of previews. 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.editorresourcepreviewgenerator; 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.classdb; 23 import godot.reference; 24 import godot.texture; 25 import godot.resource; 26 /** 27 Custom generator of previews. 28 29 Custom code to generate previews. Please check "file_dialog/thumbnail_size" in EditorSettings to find out the right size to do previews at. 30 */ 31 @GodotBaseClass struct EditorResourcePreviewGenerator 32 { 33 enum string _GODOT_internal_name = "EditorResourcePreviewGenerator"; 34 public: 35 @nogc nothrow: 36 union { godot_object _godot_object; Reference _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("handles") GodotMethod!(bool, String) handles; 44 @GodotName("generate") GodotMethod!(Texture, Resource, Vector2) generate; 45 @GodotName("generate_from_path") GodotMethod!(Texture, String, Vector2) generateFromPath; 46 } 47 bool opEquals(in EditorResourcePreviewGenerator other) const { return _godot_object.ptr is other._godot_object.ptr; } 48 EditorResourcePreviewGenerator opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 49 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 50 mixin baseCasts; 51 static EditorResourcePreviewGenerator _new() 52 { 53 static godot_class_constructor constructor; 54 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("EditorResourcePreviewGenerator"); 55 if(constructor is null) return typeof(this).init; 56 return cast(EditorResourcePreviewGenerator)(constructor()); 57 } 58 @disable new(size_t s); 59 /** 60 Return if your generator supports this resource type. 61 */ 62 bool handles(StringArg0)(in StringArg0 type) 63 { 64 Array _GODOT_args = Array.empty_array; 65 _GODOT_args.append(type); 66 String _GODOT_method_name = String("handles"); 67 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool); 68 } 69 /** 70 Generate a preview from a given resource with the specified size. This must always be implemented. 71 Returning an empty texture is an OK way to fail and let another generator take care. 72 Care must be taken because this function is always called from a thread (not the main thread). 73 */ 74 Ref!Texture generate(Resource from, in Vector2 size) 75 { 76 Array _GODOT_args = Array.empty_array; 77 _GODOT_args.append(from); 78 _GODOT_args.append(size); 79 String _GODOT_method_name = String("generate"); 80 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Texture); 81 } 82 /** 83 Generate a preview directly from a path with the specified size. Implementing this is optional, as default code will load and call $(D generate). 84 Returning an empty texture is an OK way to fail and let another generator take care. 85 Care must be taken because this function is always called from a thread (not the main thread). 86 */ 87 Ref!Texture generateFromPath(StringArg0)(in StringArg0 path, in Vector2 size) 88 { 89 Array _GODOT_args = Array.empty_array; 90 _GODOT_args.append(path); 91 _GODOT_args.append(size); 92 String _GODOT_method_name = String("generate_from_path"); 93 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Texture); 94 } 95 }