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.widgets.toolbar; 8 import creator.viewport; 9 import creator.widgets; 10 import creator.core; 11 import creator; 12 import i18n; 13 14 void incToolbar() { 15 auto flags = 16 ImGuiWindowFlags.NoSavedSettings | 17 ImGuiWindowFlags.NoScrollbar | 18 ImGuiWindowFlags.MenuBar; 19 20 igPushStyleVar(ImGuiStyleVar.FramePadding, ImVec2(0, 10)); 21 if (igBeginViewportSideBar("##Toolbar", igGetMainViewport(), ImGuiDir.Up, 32, flags)) { 22 23 if (igBeginMenuBar()) { 24 igPopStyleVar(); 25 26 27 // Render toolbar 28 igPushStyleVar(ImGuiStyleVar.FramePadding, ImVec2(0, 0)); 29 igPushStyleVar(ImGuiStyleVar.FrameRounding, 0); 30 igPushFont(incIconFont()); 31 32 if (incButtonColored("", ImVec2(32, 32), incActivePuppet().enableDrivers ? ImVec4.init : ImVec4(0.6f, 0.6f, 0.6f, 1f))) { 33 incActivePuppet().enableDrivers = !incActivePuppet().enableDrivers; 34 } 35 incTooltip(_("Enable physics")); 36 37 if (incButtonColored("", ImVec2(32, 32), ImVec4.init)) { 38 incActivePuppet().resetDrivers(); 39 } 40 incTooltip(_("Reset physics")); 41 42 // Draw the toolbar relevant for that viewport 43 incViewportToolbar(); 44 igPopFont(); 45 igPopStyleVar(2); 46 47 // Render mode switch buttons 48 ImVec2 avail; 49 igGetContentRegionAvail(&avail); 50 igDummy(ImVec2(avail.x-(32*3)-8, 0)); 51 52 igPushStyleVar(ImGuiStyleVar.FramePadding, ImVec2(0, 0)); 53 igPushStyleVar(ImGuiStyleVar.FrameRounding, 0); 54 igPushFont(incIconFont()); 55 igPushStyleVar(ImGuiStyleVar.ItemSpacing, ImVec2(0, 0)); 56 if(incEditMode != EditMode.VertexEdit) { 57 if (incButtonColored("", ImVec2(32, 32), incEditMode == EditMode.ModelEdit ? ImVec4.init : ImVec4(0.6f, 0.6f, 0.6f, 1f))) { 58 incSetEditMode(EditMode.ModelEdit); 59 } 60 incTooltip(_("Edit Puppet")); 61 62 if (incButtonColored("", ImVec2(32, 32), incEditMode == EditMode.AnimEdit ? ImVec4.init : ImVec4(0.6f, 0.6f, 0.6f, 1f))) { 63 incSetEditMode(EditMode.AnimEdit); 64 } 65 incTooltip(_("Edit Animation")); 66 67 if (incButtonColored("", ImVec2(32, 32), incEditMode == EditMode.ModelTest ? ImVec4.init : ImVec4(0.6f, 0.6f, 0.6f, 1f))) { 68 incSetEditMode(EditMode.ModelTest); 69 } 70 incTooltip(_("Test Puppet")); 71 } 72 igPopStyleVar(); 73 74 igPopFont(); 75 igPopStyleVar(2); 76 77 igEndMenuBar(); 78 } else { 79 igPopStyleVar(); 80 } 81 82 igEnd(); 83 } else { 84 igPopStyleVar(); 85 } 86 }