1 /* 2 Copyright © 2020, Inochi2D Project 3 Distributed under the 2-Clause BSD License, see LICENSE file. 4 5 Authors: Luna Nielsen 6 */ 7 module creator.panels.textureslots; 8 import creator.panels; 9 import creator.windows; 10 import creator : incActivePuppet; 11 import bindbc.imgui; 12 import inochi2d; 13 import std.conv; 14 import i18n; 15 16 /** 17 The textures frame 18 */ 19 class TextureSlotsPanel : Panel { 20 private: 21 22 void namedIcon(string name, Texture texture, ImVec2 size) { 23 igBeginChild(("tex_"~name~"\0").ptr, size); 24 if (igSelectable("", false, ImGuiSelectableFlags.None, size)) { 25 incPushWindowList(new TextureViewerWindow(texture)); 26 } 27 igSameLine(0.1, 0); 28 igBeginGroup(); 29 igImage( 30 cast(void*)texture.getTextureId(), 31 ImVec2(size.x, size.y-18), 32 ImVec2(0, 0), 33 ImVec2(1, 1), 34 ImVec4(1, 1, 1, 1), 35 ImVec4(0, 0, 0, 0) 36 ); 37 38 ImVec2 winSize; 39 igGetWindowSize(&winSize); 40 41 float fSize = (igGetFontSize() * name.length) / 2; 42 float fSizeF = (winSize.x/2)+fSize; 43 igIndent(fSizeF); 44 igText((name~"\0").ptr); 45 igUnindent(fSizeF); 46 igEndGroup(); 47 igEndChild(); 48 } 49 50 protected: 51 override 52 void onUpdate() { 53 igBeginChild("TexturesList", ImVec2(0, 0), false, ImGuiWindowFlags.HorizontalScrollbar); 54 ImVec2 avail; 55 igGetContentRegionAvail(&avail); 56 57 foreach(i, texture; incActivePuppet().textureSlots) { 58 namedIcon(i.text, texture, ImVec2(avail.y, avail.y)); 59 igSameLine(0, 4); 60 } 61 igEndChild(); 62 } 63 64 public: 65 this() { 66 super("Texture Slots", _("Texture Slots"), false); 67 } 68 } 69 70 /** 71 Generate logger frame 72 */ 73 mixin incPanel!TextureSlotsPanel; 74 75