| 1 |
#include "gui.h" |
| 2 |
#include "imgui.h" |
| 3 |
#include "IconsFontAwesome4.h" |
| 4 |
#include "misc/cpp/imgui_stdlib.h" |
| 5 |
#include "intConst.h" |
| 6 |
|
| 7 |
void FurnaceGUI::drawSubSongs(bool asChild) { |
| 8 |
if (nextWindow==GUI_WINDOW_SUBSONGS) { |
| 9 |
subSongsOpen=true; |
| 10 |
ImGui::SetNextWindowFocus(); |
| 11 |
nextWindow=GUI_WINDOW_NOTHING; |
| 12 |
} |
| 13 |
if (!subSongsOpen && !asChild) return; |
| 14 |
if (!asChild) { |
| 15 |
ImGui::SetNextWindowSizeConstraints(ImVec2(64.0f*dpiScale,32.0f*dpiScale),ImVec2(canvasW,canvasH)); |
| 16 |
} |
| 17 |
bool began=asChild?ImGui::BeginChild("Subsongs"):ImGui::Begin("Subsongs",&subSongsOpen,globalWinFlags,_("Subsongs")); |
| 18 |
if (began) { |
| 19 |
char id[1024]; |
| 20 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x-ImGui::GetFrameHeightWithSpacing()*3.0f-ImGui::GetStyle().ItemSpacing.x*2.0f); |
| 21 |
if (e->curSubSong->name.empty()) { |
| 22 |
snprintf(id,1023,_("%d. <no name>"),(int)e->getCurrentSubSong()+1); |
| 23 |
} else { |
| 24 |
snprintf(id,1023,"%d. %s",(int)e->getCurrentSubSong()+1,e->curSubSong->name.c_str()); |
| 25 |
} |
| 26 |
if (ImGui::BeginCombo("##SubSong",id)) { |
| 27 |
if (ImGui::BeginTable("SubSongSelection",2)) { |
| 28 |
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthStretch); |
| 29 |
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed); |
| 30 |
for (size_t i=0; i<e->song.subsong.size(); i++) { |
| 31 |
if (e->song.subsong[i]->name.empty()) { |
| 32 |
snprintf(id,1023,_("%d. <no name>"),(int)i+1); |
| 33 |
} else { |
| 34 |
snprintf(id,1023,"%d. %s",(int)i+1,e->song.subsong[i]->name.c_str()); |
| 35 |
} |
| 36 |
ImGui::TableNextRow(); |
| 37 |
ImGui::TableNextColumn(); |
| 38 |
if (ImGui::Selectable(id,i==e->getCurrentSubSong())) { |
| 39 |
makeCursorUndo(); |
| 40 |
e->changeSongP(i); |
| 41 |
updateScroll(0); |
| 42 |
oldRow=0; |
| 43 |
cursor.xCoarse=0; |
| 44 |
cursor.xFine=0; |
| 45 |
cursor.y=0; |
| 46 |
cursor.order=0; |
| 47 |
selStart=cursor; |
| 48 |
selEnd=cursor; |
| 49 |
curOrder=0; |
| 50 |
} |
| 51 |
ImGui::TableNextColumn(); |
| 52 |
ImGui::PushID(i); |
| 53 |
if (ImGui::SmallButton(ICON_FA_ARROW_UP "##SubUp")) { |
| 54 |
e->moveSubSongUp(i); |
| 55 |
} |
| 56 |
if (ImGui::IsItemHovered()) { |
| 57 |
ImGui::SetTooltip(_("Move up")); |
| 58 |
} |
| 59 |
ImGui::SameLine(); |
| 60 |
if (ImGui::SmallButton(ICON_FA_ARROW_DOWN "##SubDown")) { |
| 61 |
e->moveSubSongDown(i); |
| 62 |
} |
| 63 |
if (ImGui::IsItemHovered()) { |
| 64 |
ImGui::SetTooltip(_("Move down")); |
| 65 |
} |
| 66 |
ImGui::PopID(); |
| 67 |
} |
| 68 |
ImGui::EndTable(); |
| 69 |
} |
| 70 |
ImGui::EndCombo(); |
| 71 |
} |
| 72 |
ImGui::SameLine(); |
| 73 |
if (ImGui::Button(ICON_FA_PLUS "##SubSongAdd")) { |
| 74 |
if (!e->addSubSong()) { |
| 75 |
showError(_("too many subsongs!")); |
| 76 |
} else { |
| 77 |
makeCursorUndo(); |
| 78 |
e->changeSongP(e->song.subsong.size()-1); |
| 79 |
updateScroll(0); |
| 80 |
oldRow=0; |
| 81 |
cursor.xCoarse=0; |
| 82 |
cursor.xFine=0; |
| 83 |
cursor.y=0; |
| 84 |
cursor.order=0; |
| 85 |
selStart=cursor; |
| 86 |
selEnd=cursor; |
| 87 |
curOrder=0; |
| 88 |
MARK_MODIFIED; |
| 89 |
} |
| 90 |
} |
| 91 |
if (ImGui::IsItemHovered()) { |
| 92 |
ImGui::SetTooltip(_("Add")); |
| 93 |
} |
| 94 |
ImGui::SameLine(); |
| 95 |
if (ImGui::Button(ICON_FA_FILES_O "##SubSongDuplicate")) { |
| 96 |
if (!e->duplicateSubSong(e->getCurrentSubSong())) { |
| 97 |
showError(_("too many subsongs!")); |
| 98 |
} else { |
| 99 |
makeCursorUndo(); |
| 100 |
e->changeSongP(e->song.subsong.size()-1); |
| 101 |
updateScroll(0); |
| 102 |
oldRow=0; |
| 103 |
cursor.xCoarse=0; |
| 104 |
cursor.xFine=0; |
| 105 |
cursor.y=0; |
| 106 |
cursor.order=0; |
| 107 |
selStart=cursor; |
| 108 |
selEnd=cursor; |
| 109 |
curOrder=0; |
| 110 |
MARK_MODIFIED; |
| 111 |
} |
| 112 |
} |
| 113 |
if (ImGui::IsItemHovered()) { |
| 114 |
ImGui::SetTooltip(_("Duplicate")); |
| 115 |
} |
| 116 |
ImGui::SameLine(); |
| 117 |
pushDestColor(); |
| 118 |
if (ImGui::Button(ICON_FA_MINUS "##SubSongDel")) { |
| 119 |
if (e->song.subsong.size()<=1) { |
| 120 |
showError(_("this is the only subsong!")); |
| 121 |
} else { |
| 122 |
showWarning(_("are you sure you want to remove this subsong?"),GUI_WARN_SUBSONG_DEL); |
| 123 |
} |
| 124 |
} |
| 125 |
popDestColor(); |
| 126 |
if (ImGui::IsItemHovered()) { |
| 127 |
ImGui::SetTooltip(_("Remove")); |
| 128 |
} |
| 129 |
|
| 130 |
ImGui::AlignTextToFramePadding(); |
| 131 |
ImGui::Text(_("Name")); |
| 132 |
ImGui::SameLine(); |
| 133 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 134 |
if (ImGui::InputText("##SubSongName",&e->curSubSong->name,ImGuiInputTextFlags_UndoRedo)) { |
| 135 |
MARK_MODIFIED; |
| 136 |
} |
| 137 |
|
| 138 |
if (ImGui::GetContentRegionAvail().y>(10.0f*dpiScale)) { |
| 139 |
if (ImGui::InputTextMultiline("##SubSongNotes",&e->curSubSong->notes,ImGui::GetContentRegionAvail(),ImGuiInputTextFlags_UndoRedo|(settings.songNotesWrap?ImGuiInputTextFlags_WordWrapping:0))) { |
| 140 |
MARK_MODIFIED; |
| 141 |
} |
| 142 |
} |
| 143 |
} |
| 144 |
if (!asChild && ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_SUBSONGS; |
| 145 |
if (asChild) { |
| 146 |
ImGui::EndChild(); |
| 147 |
} else { |
| 148 |
ImGui::End(); |
| 149 |
} |
| 150 |
} |