| 1 |
/** |
| 2 |
* Furnace Tracker - multi-system chiptune tracker |
| 3 |
* Copyright (C) 2021-2025 tildearrow and contributors |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 2 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License along |
| 16 |
* with this program; if not, write to the Free Software Foundation, Inc., |
| 17 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "gui.h" |
| 21 |
#include "IconsFontAwesome4.h" |
| 22 |
#include "misc/cpp/imgui_stdlib.h" |
| 23 |
#include "plot_nolerp.h" |
| 24 |
#include "guiConst.h" |
| 25 |
#include "../ta-log.h" |
| 26 |
#include <fmt/printf.h> |
| 27 |
#include <imgui.h> |
| 28 |
#include <imgui_internal.h> |
| 29 |
|
| 30 |
const char* sampleNote[12]={ |
| 31 |
"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" |
| 32 |
}; |
| 33 |
|
| 34 |
#define DIR_DRAG_SOURCE(_d,_a,_c) \ |
| 35 |
if (ImGui::BeginDragDropSource()) { \ |
| 36 |
dirToMove=_d; \ |
| 37 |
assetToMove=_a; \ |
| 38 |
ImGui::SetDragDropPayload(_c,NULL,0,ImGuiCond_Once); \ |
| 39 |
ImGui::Button(ICON_FA_ARROWS "##AssetDrag"); \ |
| 40 |
ImGui::EndDragDropSource(); \ |
| 41 |
} |
| 42 |
|
| 43 |
#define DIR_DRAG_TARGET(_d,_a,_type,_c) \ |
| 44 |
if (ImGui::BeginDragDropTarget()) { \ |
| 45 |
const ImGuiPayload* dragItem=ImGui::AcceptDragDropPayload(_c); \ |
| 46 |
if (dragItem!=NULL) { \ |
| 47 |
if (dragItem->IsDataType(_c)) { \ |
| 48 |
if (assetToMove==-1) { \ |
| 49 |
if (dirToMove!=_d && _a==-1) { \ |
| 50 |
e->lockEngine([&]() { \ |
| 51 |
DivAssetDir val=_type[dirToMove]; \ |
| 52 |
_type.erase(_type.begin()+dirToMove); \ |
| 53 |
_type.insert(_type.begin()+_d,val); \ |
| 54 |
}); \ |
| 55 |
} \ |
| 56 |
} else { \ |
| 57 |
if (dirToMove!=_d || assetToMove!=_a) { \ |
| 58 |
logV("%d/%d -> %d/%d",dirToMove,assetToMove,_d,_a); \ |
| 59 |
e->lockEngine([&]() { \ |
| 60 |
int val=_type[dirToMove].entries[assetToMove]; \ |
| 61 |
_type[dirToMove].entries.erase(_type[dirToMove].entries.begin()+assetToMove); \ |
| 62 |
_type[_d].entries.insert((_a<0)?(_type[_d].entries.end()):(_type[_d].entries.begin()+_a),val); \ |
| 63 |
}); \ |
| 64 |
} \ |
| 65 |
} \ |
| 66 |
dirToMove=-1; \ |
| 67 |
assetToMove=-1; \ |
| 68 |
} \ |
| 69 |
} \ |
| 70 |
ImGui::EndDragDropTarget(); \ |
| 71 |
} |
| 72 |
|
| 73 |
#define SIMPLE_DRAG_SOURCE(_c,_toMoveVar) \ |
| 74 |
if (settings.draggableDataView) { \ |
| 75 |
if (ImGui::BeginDragDropSource()) { \ |
| 76 |
_toMoveVar=i; \ |
| 77 |
ImGui::SetDragDropPayload(_c,NULL,0,ImGuiCond_Once); \ |
| 78 |
ImGui::Button(ICON_FA_ARROWS "##AssetDrag"); \ |
| 79 |
ImGui::EndDragDropSource(); \ |
| 80 |
} \ |
| 81 |
} |
| 82 |
|
| 83 |
#define SIMPLE_DRAG_TARGET(_c,_toMoveVar,_curVar,_swapFn,_moveUpFn,_moveDownFn) \ |
| 84 |
if (settings.draggableDataView) { \ |
| 85 |
if (ImGui::BeginDragDropTarget()) { \ |
| 86 |
const ImGuiPayload* payload=ImGui::AcceptDragDropPayload(_c); \ |
| 87 |
if (payload!=NULL) { \ |
| 88 |
int target=i; \ |
| 89 |
bool markModified=false; \ |
| 90 |
if (_toMoveVar!=target) { \ |
| 91 |
if (ImGui::IsKeyDown(ImGuiKey_ModCtrl)) { \ |
| 92 |
markModified=_swapFn(_toMoveVar,target); \ |
| 93 |
} else { \ |
| 94 |
while (_toMoveVar>target) { \ |
| 95 |
if (_moveUpFn(_toMoveVar)) { \ |
| 96 |
_toMoveVar--; \ |
| 97 |
markModified=true; \ |
| 98 |
} else { \ |
| 99 |
break; \ |
| 100 |
} \ |
| 101 |
} \ |
| 102 |
while (_toMoveVar<target) { \ |
| 103 |
if (_moveDownFn(_toMoveVar)) { \ |
| 104 |
_toMoveVar++; \ |
| 105 |
markModified=true; \ |
| 106 |
} else { \ |
| 107 |
break; \ |
| 108 |
} \ |
| 109 |
} \ |
| 110 |
} \ |
| 111 |
_curVar=target; \ |
| 112 |
} \ |
| 113 |
if (markModified) { \ |
| 114 |
MARK_MODIFIED; \ |
| 115 |
} \ |
| 116 |
_toMoveVar=-1; \ |
| 117 |
} \ |
| 118 |
ImGui::EndDragDropTarget(); \ |
| 119 |
} \ |
| 120 |
} |
| 121 |
|
| 122 |
void FurnaceGUI::insListItem(int i, int dir, int asset) { |
| 123 |
ImGui::PushID(i); |
| 124 |
String name=(settings.insIconsStyle==0)?"":ICON_FA_CIRCLE_O; |
| 125 |
const char* insType=_("Bug!"); |
| 126 |
if (i>=0 && i<e->song.insLen) { |
| 127 |
DivInstrument* ins=e->song.ins[i]; |
| 128 |
insType=(ins->type>=DIV_INS_MAX)?_("Unknown"):_(insTypes[ins->type][0]); |
| 129 |
const char** insIcon=NULL; |
| 130 |
|
| 131 |
if (ins->type>=DIV_INS_MAX) { |
| 132 |
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_UNKNOWN]); |
| 133 |
insIcon=insTypes[DIV_INS_MAX]; |
| 134 |
} else { |
| 135 |
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_STD+ins->type]); |
| 136 |
insIcon=insTypes[ins->type]; |
| 137 |
} |
| 138 |
|
| 139 |
switch (settings.insIconsStyle) { |
| 140 |
case 1: |
| 141 |
name=fmt::sprintf("%s##_INS%d",insIcon[1],i); |
| 142 |
break; |
| 143 |
case 2: |
| 144 |
name=fmt::sprintf("%s##_INS%d",insIcon[2],i); |
| 145 |
break; |
| 146 |
default: |
| 147 |
name=fmt::sprintf("##_INS%d",i); |
| 148 |
break; |
| 149 |
} |
| 150 |
} else { |
| 151 |
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_TEXT]); |
| 152 |
} |
| 153 |
bool insReleased=ImGui::Selectable(name.c_str(),(i==-1)?(curIns<0 || curIns>=e->song.insLen):(curIns==i)); |
| 154 |
bool insPressed=ImGui::IsItemActivated(); |
| 155 |
if (insReleased || (!insListDir && insPressed && !settings.draggableDataView)) { |
| 156 |
curIns=i; |
| 157 |
if (!insReleased || insListDir || settings.draggableDataView) { |
| 158 |
wavePreviewInit=true; |
| 159 |
updateFMPreview=true; |
| 160 |
} |
| 161 |
lastAssetType=0; |
| 162 |
if (settings.insFocusesPattern && patternOpen) |
| 163 |
nextWindow=GUI_WINDOW_PATTERN; |
| 164 |
} |
| 165 |
if (wantScrollListIns && curIns==i) ImGui::SetScrollHereY(); |
| 166 |
if (ImGui::IsItemHovered() && i>=0 && !mobileUI) { |
| 167 |
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_TEXT]); |
| 168 |
ImGui::SetTooltip("%s",insType); |
| 169 |
ImGui::PopStyleColor(); |
| 170 |
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { |
| 171 |
nextWindow=GUI_WINDOW_INS_EDIT; |
| 172 |
} |
| 173 |
} |
| 174 |
if (i>=0) { |
| 175 |
if (insListDir) { |
| 176 |
DIR_DRAG_SOURCE(dir,asset,"FUR_INSDIR"); |
| 177 |
DIR_DRAG_TARGET(dir,asset,e->song.insDir,"FUR_INSDIR"); |
| 178 |
} else { |
| 179 |
SIMPLE_DRAG_SOURCE("FUR_INS",insToMove); |
| 180 |
SIMPLE_DRAG_TARGET("FUR_INS",insToMove,curIns,e->swapInstruments,e->moveInsUp,e->moveInsDown); |
| 181 |
} |
| 182 |
|
| 183 |
if (ImGui::BeginPopupContextItem("InsRightMenu")) { |
| 184 |
curIns=i; |
| 185 |
updateFMPreview=true; |
| 186 |
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_TEXT]); |
| 187 |
if (ImGui::MenuItem(_("edit"))) { |
| 188 |
nextWindow=GUI_WINDOW_INS_EDIT; |
| 189 |
} |
| 190 |
if (ImGui::MenuItem(_("duplicate"))) { |
| 191 |
doAction(GUI_ACTION_INS_LIST_DUPLICATE); |
| 192 |
} |
| 193 |
if (ImGui::MenuItem(_("replace..."))) { |
| 194 |
doAction((curIns>=0 && curIns<(int)e->song.ins.size())?GUI_ACTION_INS_LIST_OPEN_REPLACE:GUI_ACTION_INS_LIST_OPEN); |
| 195 |
} |
| 196 |
if (ImGui::MenuItem(_("save"))) { |
| 197 |
doAction(GUI_ACTION_INS_LIST_SAVE); |
| 198 |
} |
| 199 |
if (ImGui::MenuItem(_("save (.dmp)"))) { |
| 200 |
doAction(GUI_ACTION_INS_LIST_SAVE_DMP); |
| 201 |
} |
| 202 |
if (ImGui::MenuItem(_("delete"))) { |
| 203 |
doAction(GUI_ACTION_INS_LIST_DELETE); |
| 204 |
} |
| 205 |
ImGui::PopStyleColor(); |
| 206 |
ImGui::EndPopup(); |
| 207 |
} |
| 208 |
} |
| 209 |
if (i>=0) { |
| 210 |
if (i<(int)e->song.ins.size()) { |
| 211 |
DivInstrument* ins=e->song.ins[i]; |
| 212 |
ImGui::SameLine(); |
| 213 |
ImGui::TextNoHashHide("%.2X: %s",i,ins->name.c_str()); |
| 214 |
} else { |
| 215 |
ImGui::SameLine(); |
| 216 |
ImGui::TextNoHashHide("%.2X: <INVALID>",i); |
| 217 |
} |
| 218 |
} else { |
| 219 |
ImGui::SameLine(); |
| 220 |
ImGui::TextNoHashHide("- None -"); |
| 221 |
} |
| 222 |
ImGui::PopID(); |
| 223 |
ImGui::PopStyleColor(); |
| 224 |
} |
| 225 |
|
| 226 |
void FurnaceGUI::waveListItem(int i, float* wavePreview, int dir, int asset) { |
| 227 |
DivWavetable* wave=e->song.wave[i]; |
| 228 |
for (int i=0; i<wave->len; i++) { |
| 229 |
wavePreview[i]=wave->data[i]; |
| 230 |
} |
| 231 |
if (wave->len>0) wavePreview[wave->len]=wave->data[wave->len-1]; |
| 232 |
ImVec2 curPos=ImGui::GetCursorPos(); |
| 233 |
ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign,ImVec2(0,0.5f)); |
| 234 |
if (ImGui::Selectable(fmt::sprintf(" %d##_WAVE%d\n",i,i).c_str(),curWave==i,0,ImVec2(0,ImGui::GetFrameHeight()))) { |
| 235 |
curWave=i; |
| 236 |
lastAssetType=1; |
| 237 |
} |
| 238 |
ImGui::PopStyleVar(); |
| 239 |
curPos.x+=ImGui::CalcTextSize("2").x*(2+((int)log10(MAX(1,e->song.waveLen-1)))); |
| 240 |
if (wantScrollListWave && curWave==i) ImGui::SetScrollHereY(); |
| 241 |
if (ImGui::IsItemHovered()) { |
| 242 |
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { |
| 243 |
nextWindow=GUI_WINDOW_WAVE_EDIT; |
| 244 |
} |
| 245 |
} |
| 246 |
if (waveListDir || (settings.unifiedDataView && insListDir)) { |
| 247 |
DIR_DRAG_SOURCE(dir,asset,"FUR_WAVEDIR"); |
| 248 |
DIR_DRAG_TARGET(dir,asset,e->song.waveDir,"FUR_WAVEDIR"); |
| 249 |
} else { |
| 250 |
SIMPLE_DRAG_SOURCE("FUR_WAVE",waveToMove); |
| 251 |
SIMPLE_DRAG_TARGET("FUR_WAVE",waveToMove,curWave,e->swapWaves,e->moveWaveUp,e->moveWaveDown); |
| 252 |
} |
| 253 |
ImGui::SameLine(); |
| 254 |
ImGui::SetCursorPos(curPos); |
| 255 |
PlotNoLerp(fmt::sprintf("##_WAVEP%d",i).c_str(),wavePreview,wave->len+1,0,NULL,0,wave->max,ImVec2(ImGui::GetContentRegionAvail().x,ImGui::GetFrameHeight())); |
| 256 |
} |
| 257 |
|
| 258 |
void FurnaceGUI::sampleListItem(int i, int dir, int asset) { |
| 259 |
bool memWarning=false; |
| 260 |
|
| 261 |
ImGui::PushID(i); |
| 262 |
|
| 263 |
DivSample* sample=e->song.sample[i]; |
| 264 |
for (int j=0; j<e->song.systemLen; j++) { |
| 265 |
DivDispatch* dispatch=e->getDispatch(j); |
| 266 |
if (dispatch==NULL) continue; |
| 267 |
|
| 268 |
for (int k=0; k<DIV_MAX_SAMPLE_TYPE; k++) { |
| 269 |
if (dispatch->getSampleMemCapacity(k)==0) continue; |
| 270 |
if (!dispatch->isSampleLoaded(k,i) && sample->renderOn[k][j]) { |
| 271 |
memWarning=true; |
| 272 |
break; |
| 273 |
} |
| 274 |
} |
| 275 |
if (memWarning) break; |
| 276 |
} |
| 277 |
if (memWarning) ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_SAMPLE_CHIP_WARNING]); |
| 278 |
if (ImGui::Selectable(fmt::sprintf("%d:##_SAM%d",i,i).c_str(),curSample==i)) { |
| 279 |
curSample=i; |
| 280 |
samplePos=0; |
| 281 |
updateSampleTex=true; |
| 282 |
lastAssetType=2; |
| 283 |
} |
| 284 |
if (ImGui::IsItemHovered() && !mobileUI) { |
| 285 |
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { |
| 286 |
nextWindow=GUI_WINDOW_SAMPLE_EDIT; |
| 287 |
} |
| 288 |
} |
| 289 |
if (sampleListDir || (settings.unifiedDataView && insListDir)) { |
| 290 |
DIR_DRAG_SOURCE(dir,asset,"FUR_SDIR"); |
| 291 |
DIR_DRAG_TARGET(dir,asset,e->song.sampleDir,"FUR_SDIR"); |
| 292 |
} else { |
| 293 |
SIMPLE_DRAG_SOURCE("FUR_SAMPLE",sampleToMove); |
| 294 |
SIMPLE_DRAG_TARGET("FUR_SAMPLE",sampleToMove,curSample,e->swapSamples,e->moveSampleUp,e->moveSampleDown); |
| 295 |
} |
| 296 |
ImGui::SameLine(); |
| 297 |
ImGui::TextNoHashHide("%s",sample->name.c_str()); |
| 298 |
if (memWarning) { |
| 299 |
ImGui::SameLine(); |
| 300 |
ImGui::Text(ICON_FA_EXCLAMATION_TRIANGLE); |
| 301 |
if (ImGui::IsItemHovered() && !mobileUI) { |
| 302 |
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_TEXT]); |
| 303 |
ImGui::SetTooltip(_("out of memory for this sample!")); |
| 304 |
ImGui::PopStyleColor(); |
| 305 |
} |
| 306 |
ImGui::PopStyleColor(); |
| 307 |
} |
| 308 |
if (ImGui::BeginPopupContextItem("SampleRightMenu")) { |
| 309 |
curSample=i; |
| 310 |
samplePos=0; |
| 311 |
updateSampleTex=true; |
| 312 |
lastAssetType=2; |
| 313 |
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_TEXT]); |
| 314 |
if (ImGui::MenuItem(_("edit"))) { |
| 315 |
nextWindow=GUI_WINDOW_SAMPLE_EDIT; |
| 316 |
} |
| 317 |
if (ImGui::MenuItem(_("make instrument"))) { |
| 318 |
doAction(GUI_ACTION_SAMPLE_MAKE_INS); |
| 319 |
} |
| 320 |
if (ImGui::MenuItem(_("make me a drum kit"))) { |
| 321 |
doAction(GUI_ACTION_SAMPLE_LIST_MAKE_MAP); |
| 322 |
} |
| 323 |
if (ImGui::MenuItem(_("duplicate"))) { |
| 324 |
doAction(GUI_ACTION_SAMPLE_LIST_DUPLICATE); |
| 325 |
} |
| 326 |
if (ImGui::MenuItem(_("replace..."))) { |
| 327 |
doAction((curSample>=0 && curSample<(int)e->song.sample.size())?GUI_ACTION_SAMPLE_LIST_OPEN_REPLACE:GUI_ACTION_SAMPLE_LIST_OPEN); |
| 328 |
} |
| 329 |
if (ImGui::MenuItem(_("save"))) { |
| 330 |
doAction(GUI_ACTION_SAMPLE_LIST_SAVE); |
| 331 |
} |
| 332 |
if (ImGui::MenuItem(_("delete"))) { |
| 333 |
doAction(GUI_ACTION_SAMPLE_LIST_DELETE); |
| 334 |
} |
| 335 |
ImGui::PopStyleColor(); |
| 336 |
ImGui::EndPopup(); |
| 337 |
} |
| 338 |
if (wantScrollListSample && curSample==i) ImGui::SetScrollHereY(); |
| 339 |
ImGui::PopID(); |
| 340 |
} |
| 341 |
|
| 342 |
void FurnaceGUI::drawInsList(bool asChild) { |
| 343 |
if (nextWindow==GUI_WINDOW_INS_LIST) { |
| 344 |
insListOpen=true; |
| 345 |
ImGui::SetNextWindowFocus(); |
| 346 |
nextWindow=GUI_WINDOW_NOTHING; |
| 347 |
} |
| 348 |
if (!insListOpen && !asChild) return; |
| 349 |
bool began=false; |
| 350 |
if (asChild) { |
| 351 |
began=ImGui::BeginChild("Instruments"); |
| 352 |
} else { |
| 353 |
began=ImGui::Begin("Instruments",&insListOpen,globalWinFlags,_("Instruments")); |
| 354 |
} |
| 355 |
if (began) { |
| 356 |
if (settings.unifiedDataView) settings.horizontalDataView=0; |
| 357 |
if (ImGui::Button(ICON_FA_PLUS "##InsAdd")) { |
| 358 |
if (settings.unifiedDataView) { |
| 359 |
switch (lastAssetType) { |
| 360 |
case 0: |
| 361 |
doAction(GUI_ACTION_INS_LIST_ADD); |
| 362 |
break; |
| 363 |
case 1: |
| 364 |
doAction(GUI_ACTION_WAVE_LIST_ADD); |
| 365 |
break; |
| 366 |
case 2: |
| 367 |
doAction(GUI_ACTION_SAMPLE_LIST_ADD); |
| 368 |
break; |
| 369 |
} |
| 370 |
} else { |
| 371 |
doAction(GUI_ACTION_INS_LIST_ADD); |
| 372 |
} |
| 373 |
} |
| 374 |
if (ImGui::IsItemHovered()) { |
| 375 |
ImGui::SetTooltip(_("Add")); |
| 376 |
} |
| 377 |
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { |
| 378 |
makeInsTypeList=e->getPossibleInsTypes(); |
| 379 |
displayInsTypeList=true; |
| 380 |
displayInsTypeListMakeInsSample=-1; |
| 381 |
} |
| 382 |
ImGui::SameLine(); |
| 383 |
if (ImGui::Button(ICON_FA_FILES_O "##InsClone")) { |
| 384 |
if (settings.unifiedDataView) { |
| 385 |
switch (lastAssetType) { |
| 386 |
case 0: |
| 387 |
doAction(GUI_ACTION_INS_LIST_DUPLICATE); |
| 388 |
break; |
| 389 |
case 1: |
| 390 |
doAction(GUI_ACTION_WAVE_LIST_DUPLICATE); |
| 391 |
break; |
| 392 |
case 2: |
| 393 |
doAction(GUI_ACTION_SAMPLE_LIST_DUPLICATE); |
| 394 |
break; |
| 395 |
} |
| 396 |
} else { |
| 397 |
doAction(GUI_ACTION_INS_LIST_DUPLICATE); |
| 398 |
} |
| 399 |
} |
| 400 |
if (ImGui::IsItemHovered()) { |
| 401 |
ImGui::SetTooltip(_("Duplicate")); |
| 402 |
} |
| 403 |
ImGui::SameLine(); |
| 404 |
if (ImGui::Button(ICON_FA_FOLDER_OPEN "##InsLoad")) { |
| 405 |
if (settings.unifiedDataView) { |
| 406 |
switch (lastAssetType) { |
| 407 |
case 0: |
| 408 |
doAction(GUI_ACTION_INS_LIST_OPEN); |
| 409 |
break; |
| 410 |
case 1: |
| 411 |
doAction(GUI_ACTION_WAVE_LIST_OPEN); |
| 412 |
break; |
| 413 |
case 2: |
| 414 |
doAction(GUI_ACTION_SAMPLE_LIST_OPEN); |
| 415 |
break; |
| 416 |
} |
| 417 |
} else { |
| 418 |
doAction(GUI_ACTION_INS_LIST_OPEN); |
| 419 |
} |
| 420 |
} |
| 421 |
if (ImGui::IsItemHovered()) { |
| 422 |
ImGui::SetTooltip(_("Open")); |
| 423 |
} |
| 424 |
if (ImGui::BeginPopupContextItem("InsOpenOpt")) { |
| 425 |
if (settings.unifiedDataView) { |
| 426 |
if (ImGui::MenuItem(_("replace instrument..."))) { |
| 427 |
doAction((curIns>=0 && curIns<(int)e->song.ins.size())?GUI_ACTION_INS_LIST_OPEN_REPLACE:GUI_ACTION_INS_LIST_OPEN); |
| 428 |
} |
| 429 |
if (ImGui::MenuItem(_("load instrument from TX81Z"))) { |
| 430 |
doAction(GUI_ACTION_TX81Z_REQUEST); |
| 431 |
} |
| 432 |
|
| 433 |
ImGui::Separator(); |
| 434 |
|
| 435 |
if (ImGui::MenuItem(_("replace wavetable..."))) { |
| 436 |
doAction((curWave>=0 && curWave<(int)e->song.wave.size())?GUI_ACTION_WAVE_LIST_OPEN_REPLACE:GUI_ACTION_WAVE_LIST_OPEN); |
| 437 |
} |
| 438 |
|
| 439 |
ImGui::Separator(); |
| 440 |
|
| 441 |
if (ImGui::MenuItem(_("replace sample..."))) { |
| 442 |
doAction((curSample>=0 && curSample<(int)e->song.sample.size())?GUI_ACTION_SAMPLE_LIST_OPEN_REPLACE:GUI_ACTION_SAMPLE_LIST_OPEN); |
| 443 |
} |
| 444 |
if (ImGui::MenuItem(_("import raw sample..."))) { |
| 445 |
doAction(GUI_ACTION_SAMPLE_LIST_OPEN_RAW); |
| 446 |
} |
| 447 |
if (ImGui::MenuItem(_("import raw sample (replace)..."))) { |
| 448 |
doAction((curSample>=0 && curSample<(int)e->song.sample.size())?GUI_ACTION_SAMPLE_LIST_OPEN_REPLACE_RAW:GUI_ACTION_SAMPLE_LIST_OPEN_RAW); |
| 449 |
} |
| 450 |
} else { |
| 451 |
if (ImGui::MenuItem(_("replace..."))) { |
| 452 |
doAction((curIns>=0 && curIns<(int)e->song.ins.size())?GUI_ACTION_INS_LIST_OPEN_REPLACE:GUI_ACTION_INS_LIST_OPEN); |
| 453 |
} |
| 454 |
ImGui::Separator(); |
| 455 |
if (ImGui::MenuItem(_("load from TX81Z"))) { |
| 456 |
doAction(GUI_ACTION_TX81Z_REQUEST); |
| 457 |
} |
| 458 |
} |
| 459 |
ImGui::EndPopup(); |
| 460 |
} |
| 461 |
if (ImGui::IsItemHovered()) { |
| 462 |
ImGui::SetTooltip(_("Open (insert; right-click to replace)")); |
| 463 |
} |
| 464 |
ImGui::SameLine(); |
| 465 |
if (ImGui::Button(ICON_FA_FLOPPY_O "##InsSave")) { |
| 466 |
if (settings.unifiedDataView) { |
| 467 |
switch (lastAssetType) { |
| 468 |
case 0: |
| 469 |
doAction(GUI_ACTION_INS_LIST_SAVE); |
| 470 |
break; |
| 471 |
case 1: |
| 472 |
doAction(GUI_ACTION_WAVE_LIST_SAVE); |
| 473 |
break; |
| 474 |
case 2: |
| 475 |
doAction(GUI_ACTION_SAMPLE_LIST_SAVE); |
| 476 |
break; |
| 477 |
} |
| 478 |
} else { |
| 479 |
doAction(GUI_ACTION_INS_LIST_SAVE); |
| 480 |
} |
| 481 |
} |
| 482 |
if (ImGui::IsItemHovered()) { |
| 483 |
ImGui::SetTooltip(_("Save")); |
| 484 |
} |
| 485 |
if (ImGui::BeginPopupContextItem("InsSaveFormats",ImGuiMouseButton_Right)) { |
| 486 |
if (settings.unifiedDataView) { |
| 487 |
if (ImGui::MenuItem(_("save instrument as .dmp..."))) { |
| 488 |
doAction(GUI_ACTION_INS_LIST_SAVE_DMP); |
| 489 |
} |
| 490 |
|
| 491 |
ImGui::Separator(); |
| 492 |
|
| 493 |
if (ImGui::MenuItem(_("save wavetable as .dmw..."))) { |
| 494 |
doAction(GUI_ACTION_WAVE_LIST_SAVE_DMW); |
| 495 |
} |
| 496 |
if (ImGui::MenuItem(_("save raw wavetable..."))) { |
| 497 |
doAction(GUI_ACTION_WAVE_LIST_SAVE_RAW); |
| 498 |
} |
| 499 |
|
| 500 |
ImGui::Separator(); |
| 501 |
|
| 502 |
if (ImGui::MenuItem(_("save raw sample..."))) { |
| 503 |
doAction(GUI_ACTION_SAMPLE_LIST_SAVE_RAW); |
| 504 |
} |
| 505 |
|
| 506 |
ImGui::Separator(); |
| 507 |
|
| 508 |
if (ImGui::MenuItem(_("save all instruments..."))) { |
| 509 |
doAction(GUI_ACTION_INS_LIST_SAVE_ALL); |
| 510 |
} |
| 511 |
if (ImGui::MenuItem(_("save all wavetables..."))) { |
| 512 |
doAction(GUI_ACTION_WAVE_LIST_SAVE_ALL); |
| 513 |
} |
| 514 |
if (ImGui::MenuItem(_("save all samples..."))) { |
| 515 |
doAction(GUI_ACTION_SAMPLE_LIST_SAVE_ALL); |
| 516 |
} |
| 517 |
} else { |
| 518 |
if (ImGui::MenuItem(_("save as .dmp..."))) { |
| 519 |
doAction(GUI_ACTION_INS_LIST_SAVE_DMP); |
| 520 |
} |
| 521 |
|
| 522 |
if (ImGui::MenuItem(_("save all..."))) { |
| 523 |
doAction(GUI_ACTION_INS_LIST_SAVE_ALL); |
| 524 |
} |
| 525 |
} |
| 526 |
ImGui::EndPopup(); |
| 527 |
} |
| 528 |
ImGui::SameLine(); |
| 529 |
pushToggleColors(insListDir); |
| 530 |
if (ImGui::Button(ICON_FA_SITEMAP "##DirMode")) { |
| 531 |
doAction(GUI_ACTION_INS_LIST_DIR_VIEW); |
| 532 |
} |
| 533 |
popToggleColors(); |
| 534 |
if (ImGui::IsItemHovered()) { |
| 535 |
ImGui::SetTooltip(_("Toggle folders/standard view")); |
| 536 |
} |
| 537 |
if (!insListDir) { |
| 538 |
ImGui::SameLine(); |
| 539 |
if (ImGui::Button(ICON_FA_ARROW_UP "##InsUp")) { |
| 540 |
if (settings.unifiedDataView) { |
| 541 |
switch (lastAssetType) { |
| 542 |
case 0: |
| 543 |
doAction(GUI_ACTION_INS_LIST_MOVE_UP); |
| 544 |
break; |
| 545 |
case 1: |
| 546 |
doAction(GUI_ACTION_WAVE_LIST_MOVE_UP); |
| 547 |
break; |
| 548 |
case 2: |
| 549 |
doAction(GUI_ACTION_SAMPLE_LIST_MOVE_UP); |
| 550 |
break; |
| 551 |
} |
| 552 |
} else { |
| 553 |
doAction(GUI_ACTION_INS_LIST_MOVE_UP); |
| 554 |
} |
| 555 |
} |
| 556 |
if (ImGui::IsItemHovered()) { |
| 557 |
ImGui::SetTooltip(_("Move up")); |
| 558 |
} |
| 559 |
ImGui::SameLine(); |
| 560 |
if (ImGui::Button(ICON_FA_ARROW_DOWN "##InsDown")) { |
| 561 |
if (settings.unifiedDataView) { |
| 562 |
switch (lastAssetType) { |
| 563 |
case 0: |
| 564 |
doAction(GUI_ACTION_INS_LIST_MOVE_DOWN); |
| 565 |
break; |
| 566 |
case 1: |
| 567 |
doAction(GUI_ACTION_WAVE_LIST_MOVE_DOWN); |
| 568 |
break; |
| 569 |
case 2: |
| 570 |
doAction(GUI_ACTION_SAMPLE_LIST_MOVE_DOWN); |
| 571 |
break; |
| 572 |
} |
| 573 |
} else { |
| 574 |
doAction(GUI_ACTION_INS_LIST_MOVE_DOWN); |
| 575 |
} |
| 576 |
} |
| 577 |
if (ImGui::IsItemHovered()) { |
| 578 |
ImGui::SetTooltip(_("Move down")); |
| 579 |
} |
| 580 |
} else { |
| 581 |
ImGui::SameLine(); |
| 582 |
if (ImGui::Button(ICON_FA_FOLDER "##InsFolder")) { |
| 583 |
folderString=""; |
| 584 |
} |
| 585 |
if (ImGui::BeginPopupContextItem("NewInsFolder",ImGuiMouseButton_Left)) { |
| 586 |
ImGui::InputText("##FolderName",&folderString); |
| 587 |
ImGui::SameLine(); |
| 588 |
ImGui::BeginDisabled(folderString.empty()); |
| 589 |
if (ImGui::Button(_("Create"))) { |
| 590 |
if (settings.unifiedDataView) { |
| 591 |
switch (lastAssetType) { |
| 592 |
case 0: |
| 593 |
e->lockEngine([this]() { |
| 594 |
e->song.insDir.push_back(DivAssetDir(folderString)); |
| 595 |
}); |
| 596 |
break; |
| 597 |
case 1: |
| 598 |
e->lockEngine([this]() { |
| 599 |
e->song.waveDir.push_back(DivAssetDir(folderString)); |
| 600 |
}); |
| 601 |
break; |
| 602 |
case 2: |
| 603 |
e->lockEngine([this]() { |
| 604 |
e->song.sampleDir.push_back(DivAssetDir(folderString)); |
| 605 |
}); |
| 606 |
break; |
| 607 |
} |
| 608 |
} else { |
| 609 |
e->lockEngine([this]() { |
| 610 |
e->song.insDir.push_back(DivAssetDir(folderString)); |
| 611 |
}); |
| 612 |
} |
| 613 |
ImGui::CloseCurrentPopup(); |
| 614 |
} |
| 615 |
ImGui::EndDisabled(); |
| 616 |
ImGui::EndPopup(); |
| 617 |
} |
| 618 |
if (ImGui::IsItemHovered()) { |
| 619 |
ImGui::SetTooltip(_("New folder")); |
| 620 |
} |
| 621 |
} |
| 622 |
if (lastAssetType==2) { |
| 623 |
ImGui::SameLine(); |
| 624 |
if (ImGui::Button(ICON_FA_VOLUME_UP "##PreviewSampleL")) { |
| 625 |
doAction(GUI_ACTION_SAMPLE_LIST_PREVIEW); |
| 626 |
} |
| 627 |
if (ImGui::IsItemHovered()) { |
| 628 |
ImGui::SetTooltip(_("Preview (right click to stop)")); |
| 629 |
} |
| 630 |
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { |
| 631 |
doAction(GUI_ACTION_SAMPLE_LIST_STOP_PREVIEW); |
| 632 |
} |
| 633 |
} |
| 634 |
ImGui::SameLine(); |
| 635 |
pushDestColor(); |
| 636 |
if (ImGui::Button(ICON_FA_TIMES "##InsDelete")) { |
| 637 |
if (settings.unifiedDataView) { |
| 638 |
switch (lastAssetType) { |
| 639 |
case 0: |
| 640 |
doAction(GUI_ACTION_INS_LIST_DELETE); |
| 641 |
break; |
| 642 |
case 1: |
| 643 |
doAction(GUI_ACTION_WAVE_LIST_DELETE); |
| 644 |
break; |
| 645 |
case 2: |
| 646 |
doAction(GUI_ACTION_SAMPLE_LIST_DELETE); |
| 647 |
break; |
| 648 |
} |
| 649 |
} else { |
| 650 |
doAction(GUI_ACTION_INS_LIST_DELETE); |
| 651 |
} |
| 652 |
} |
| 653 |
popDestColor(); |
| 654 |
if (ImGui::IsItemHovered()) { |
| 655 |
ImGui::SetTooltip(_("Delete")); |
| 656 |
} |
| 657 |
ImGui::Separator(); |
| 658 |
int availableRows=ImGui::GetContentRegionAvail().y/ImGui::GetFrameHeight(); |
| 659 |
if (availableRows<1) availableRows=1; |
| 660 |
int columns=settings.horizontalDataView?(int)(ceil((double)(e->song.ins.size()+1)/(double)availableRows)):1; |
| 661 |
if (columns<1) columns=1; |
| 662 |
if (columns>64) columns=64; |
| 663 |
if (insListDir) columns=1; |
| 664 |
if (ImGui::BeginTable("InsListScroll",columns,(settings.horizontalDataView?ImGuiTableFlags_ScrollX:0)|ImGuiTableFlags_ScrollY)) { |
| 665 |
if (settings.unifiedDataView) { |
| 666 |
ImGui::TableNextRow(); |
| 667 |
ImGui::TableNextColumn(); |
| 668 |
if (ImGui::Selectable(ICON_FA_TASKS "##Instruments",lastAssetType==0)) { |
| 669 |
lastAssetType=0; |
| 670 |
} |
| 671 |
ImGui::SameLine(); |
| 672 |
ImGui::Text(_("Instruments")); |
| 673 |
ImGui::Indent(); |
| 674 |
} |
| 675 |
|
| 676 |
if (settings.horizontalDataView && !insListDir) { |
| 677 |
ImGui::TableNextRow(); |
| 678 |
} |
| 679 |
|
| 680 |
if (insListDir) { |
| 681 |
ImGui::TableNextRow(); |
| 682 |
ImGui::TableNextColumn(); |
| 683 |
insListItem(-1,-1,-1); |
| 684 |
int dirIndex=0; |
| 685 |
int dirToDelete=-1; |
| 686 |
for (DivAssetDir& i: e->song.insDir) { |
| 687 |
String nodeName=fmt::sprintf("%s %s##_ADI%d",i.name.empty()?ICON_FA_FOLDER_O:ICON_FA_FOLDER,i.name.empty()?_("<uncategorized>"):i.name,i.name.empty()?-1:dirIndex); |
| 688 |
String popupID=fmt::sprintf("DirRightMenu%d",dirIndex); |
| 689 |
bool treeNode=ImGui::TreeNodeEx(nodeName.c_str(),ImGuiTreeNodeFlags_SpanAvailWidth|(i.name.empty()?ImGuiTreeNodeFlags_DefaultOpen:0)); |
| 690 |
DIR_DRAG_SOURCE(dirIndex,-1,"FUR_INSDIR"); |
| 691 |
DIR_DRAG_TARGET(dirIndex,-1,e->song.insDir,"FUR_INSDIR"); |
| 692 |
if (ImGui::BeginPopupContextItem(popupID.c_str())) { |
| 693 |
if (ImGui::MenuItem(_("rename..."))) { |
| 694 |
editStr(&i.name); |
| 695 |
} |
| 696 |
if (ImGui::MenuItem(_("delete"))) { |
| 697 |
dirToDelete=dirIndex; |
| 698 |
} |
| 699 |
ImGui::EndPopup(); |
| 700 |
} |
| 701 |
if (treeNode) { |
| 702 |
int assetIndex=0; |
| 703 |
for (int j: i.entries) { |
| 704 |
insListItem(j,dirIndex,assetIndex); |
| 705 |
assetIndex++; |
| 706 |
} |
| 707 |
ImGui::TreePop(); |
| 708 |
} |
| 709 |
dirIndex++; |
| 710 |
} |
| 711 |
if (dirToDelete!=-1) { |
| 712 |
e->lockEngine([this,dirToDelete]() { |
| 713 |
e->song.insDir.erase(e->song.insDir.begin()+dirToDelete); |
| 714 |
e->checkAssetDir(e->song.insDir,e->song.ins.size()); |
| 715 |
}); |
| 716 |
} |
| 717 |
} else { |
| 718 |
int curRow=0; |
| 719 |
for (int i=-1; i<(int)e->song.ins.size(); i++) { |
| 720 |
if (!settings.horizontalDataView) { |
| 721 |
ImGui::TableNextRow(); |
| 722 |
ImGui::TableNextColumn(); |
| 723 |
} else if (curRow==0) { |
| 724 |
ImGui::TableNextColumn(); |
| 725 |
} |
| 726 |
insListItem(i,-1,-1); |
| 727 |
if (settings.horizontalDataView) { |
| 728 |
if (++curRow>=availableRows) curRow=0; |
| 729 |
} |
| 730 |
} |
| 731 |
} |
| 732 |
|
| 733 |
if (settings.unifiedDataView) { |
| 734 |
ImGui::Unindent(); |
| 735 |
|
| 736 |
ImGui::TableNextRow(); |
| 737 |
ImGui::TableNextColumn(); |
| 738 |
if (ImGui::Selectable(ICON_FA_AREA_CHART "##Wavetables",lastAssetType==1)) { |
| 739 |
lastAssetType=1; |
| 740 |
} |
| 741 |
ImGui::SameLine(); |
| 742 |
ImGui::Text(_("Wavetables")); |
| 743 |
ImGui::Indent(); |
| 744 |
actualWaveList(); |
| 745 |
ImGui::Unindent(); |
| 746 |
|
| 747 |
ImGui::TableNextRow(); |
| 748 |
ImGui::TableNextColumn(); |
| 749 |
if (ImGui::Selectable(ICON_FA_VOLUME_UP "##Samples",lastAssetType==2)) { |
| 750 |
lastAssetType=2; |
| 751 |
} |
| 752 |
ImGui::SameLine(); |
| 753 |
ImGui::Text(_("Samples")); |
| 754 |
ImGui::Indent(); |
| 755 |
actualSampleList(); |
| 756 |
ImGui::Unindent(); |
| 757 |
} |
| 758 |
|
| 759 |
ImGui::EndTable(); |
| 760 |
} |
| 761 |
} |
| 762 |
if (asChild) { |
| 763 |
ImGui::EndChild(); |
| 764 |
} else { |
| 765 |
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_INS_LIST; |
| 766 |
ImGui::End(); |
| 767 |
} |
| 768 |
} |
| 769 |
|
| 770 |
void FurnaceGUI::drawWaveList(bool asChild) { |
| 771 |
if (nextWindow==GUI_WINDOW_WAVE_LIST) { |
| 772 |
waveListOpen=true; |
| 773 |
if (settings.unifiedDataView) { |
| 774 |
ImGui::SetWindowFocus("Instruments"); |
| 775 |
} else { |
| 776 |
ImGui::SetNextWindowFocus(); |
| 777 |
} |
| 778 |
nextWindow=GUI_WINDOW_NOTHING; |
| 779 |
} |
| 780 |
if (settings.unifiedDataView) return; |
| 781 |
if (!waveListOpen && !asChild) return; |
| 782 |
bool began=false; |
| 783 |
if (asChild) { |
| 784 |
began=ImGui::BeginChild("Wavetables"); |
| 785 |
} else { |
| 786 |
began=ImGui::Begin("Wavetables",&waveListOpen,globalWinFlags,_("Wavetables")); |
| 787 |
} |
| 788 |
if (began) { |
| 789 |
// hide buttons if there isn't enough space |
| 790 |
// buttons and their space requirements: |
| 791 |
// - new: 2 |
| 792 |
// - duplicate: 6 |
| 793 |
// - open: 3 |
| 794 |
// - save: 5 |
| 795 |
// - folder view: 7 |
| 796 |
// - move up: 8 |
| 797 |
// - move down: 8 |
| 798 |
// - delete: 4 |
| 799 |
float buttonSize=ImGui::GetStyle().FramePadding.x*2.0f+settings.iconSize*dpiScale+ImGui::GetStyle().ItemSpacing.x; |
| 800 |
float buttonSpace=ImGui::GetContentRegionAvail().x/MAX(1.0f,buttonSize); |
| 801 |
bool mustOpenNewFolder=false; |
| 802 |
|
| 803 |
if (buttonSpace>=2.0f) { |
| 804 |
// add |
| 805 |
if (ImGui::Button(ICON_FA_PLUS "##WaveAdd")) { |
| 806 |
doAction(GUI_ACTION_WAVE_LIST_ADD); |
| 807 |
} |
| 808 |
if (ImGui::IsItemHovered()) { |
| 809 |
ImGui::SetTooltip(_("Add")); |
| 810 |
} |
| 811 |
ImGui::SameLine(); |
| 812 |
} |
| 813 |
|
| 814 |
if (buttonSpace>=6.0f) { |
| 815 |
// duplicate |
| 816 |
if (ImGui::Button(ICON_FA_FILES_O "##WaveClone")) { |
| 817 |
doAction(GUI_ACTION_WAVE_LIST_DUPLICATE); |
| 818 |
} |
| 819 |
if (ImGui::IsItemHovered()) { |
| 820 |
ImGui::SetTooltip(_("Duplicate")); |
| 821 |
} |
| 822 |
ImGui::SameLine(); |
| 823 |
} |
| 824 |
|
| 825 |
if (buttonSpace>=3.0f) { |
| 826 |
// open |
| 827 |
if (ImGui::Button(ICON_FA_FOLDER_OPEN "##WaveLoad")) { |
| 828 |
doAction(GUI_ACTION_WAVE_LIST_OPEN); |
| 829 |
} |
| 830 |
if (ImGui::IsItemHovered()) { |
| 831 |
ImGui::SetTooltip(_("Open")); |
| 832 |
} |
| 833 |
if (ImGui::BeginPopupContextItem("WaveOpenOpt")) { |
| 834 |
if (ImGui::MenuItem(_("replace..."))) { |
| 835 |
doAction((curWave>=0 && curWave<(int)e->song.wave.size())?GUI_ACTION_WAVE_LIST_OPEN_REPLACE:GUI_ACTION_WAVE_LIST_OPEN); |
| 836 |
} |
| 837 |
ImGui::EndPopup(); |
| 838 |
} |
| 839 |
ImGui::SameLine(); |
| 840 |
} |
| 841 |
|
| 842 |
if (buttonSpace>=5.0f) { |
| 843 |
// save |
| 844 |
if (ImGui::Button(ICON_FA_FLOPPY_O "##WaveSave")) { |
| 845 |
doAction(GUI_ACTION_WAVE_LIST_SAVE); |
| 846 |
} |
| 847 |
if (ImGui::IsItemHovered()) { |
| 848 |
ImGui::SetTooltip(_("Save")); |
| 849 |
} |
| 850 |
if (!settings.unifiedDataView) { |
| 851 |
if (ImGui::BeginPopupContextItem("WaveSaveFormats",ImGuiMouseButton_Right)) { |
| 852 |
if (ImGui::MenuItem(_("save as .dmw..."))) { |
| 853 |
doAction(GUI_ACTION_WAVE_LIST_SAVE_DMW); |
| 854 |
} |
| 855 |
if (ImGui::MenuItem(_("save raw..."))) { |
| 856 |
doAction(GUI_ACTION_WAVE_LIST_SAVE_RAW); |
| 857 |
} |
| 858 |
if (ImGui::MenuItem(_("save all..."))) { |
| 859 |
doAction(GUI_ACTION_WAVE_LIST_SAVE_ALL); |
| 860 |
} |
| 861 |
ImGui::EndPopup(); |
| 862 |
} |
| 863 |
} |
| 864 |
ImGui::SameLine(); |
| 865 |
} |
| 866 |
|
| 867 |
if (buttonSpace>=7.0f) { |
| 868 |
// dir mode |
| 869 |
pushToggleColors(waveListDir); |
| 870 |
if (ImGui::Button(ICON_FA_SITEMAP "##WaveDirMode")) { |
| 871 |
doAction(GUI_ACTION_WAVE_LIST_DIR_VIEW); |
| 872 |
} |
| 873 |
popToggleColors(); |
| 874 |
if (ImGui::IsItemHovered()) { |
| 875 |
ImGui::SetTooltip(_("Toggle folders/standard view")); |
| 876 |
} |
| 877 |
ImGui::SameLine(); |
| 878 |
} |
| 879 |
|
| 880 |
if (buttonSpace>=(waveListDir?7.0f:8.0f)) { |
| 881 |
// move up/down |
| 882 |
if (!waveListDir) { |
| 883 |
if (ImGui::Button(ICON_FA_ARROW_UP "##WaveUp")) { |
| 884 |
doAction(GUI_ACTION_WAVE_LIST_MOVE_UP); |
| 885 |
} |
| 886 |
if (ImGui::IsItemHovered()) { |
| 887 |
ImGui::SetTooltip(_("Move up")); |
| 888 |
} |
| 889 |
ImGui::SameLine(); |
| 890 |
if (ImGui::Button(ICON_FA_ARROW_DOWN "##WaveDown")) { |
| 891 |
doAction(GUI_ACTION_WAVE_LIST_MOVE_DOWN); |
| 892 |
} |
| 893 |
if (ImGui::IsItemHovered()) { |
| 894 |
ImGui::SetTooltip(_("Move down")); |
| 895 |
} |
| 896 |
} else { |
| 897 |
if (ImGui::Button(ICON_FA_FOLDER "##WaveFolder")) { |
| 898 |
mustOpenNewFolder=true; |
| 899 |
} |
| 900 |
if (ImGui::IsItemHovered()) { |
| 901 |
ImGui::SetTooltip(_("New folder")); |
| 902 |
} |
| 903 |
} |
| 904 |
ImGui::SameLine(); |
| 905 |
} |
| 906 |
|
| 907 |
if (buttonSpace>=4.0f) { |
| 908 |
// delete |
| 909 |
pushDestColor(); |
| 910 |
if (ImGui::Button(ICON_FA_TIMES "##WaveDelete")) { |
| 911 |
doAction(GUI_ACTION_WAVE_LIST_DELETE); |
| 912 |
} |
| 913 |
popDestColor(); |
| 914 |
if (ImGui::IsItemHovered()) { |
| 915 |
ImGui::SetTooltip(_("Delete")); |
| 916 |
} |
| 917 |
if (buttonSpace<8.0f) { |
| 918 |
ImGui::SameLine(); |
| 919 |
} |
| 920 |
} |
| 921 |
|
| 922 |
if (buttonSpace<(waveListDir?7.0f:8.0f)) { |
| 923 |
if (ImGui::Button(ICON_FA_ELLIPSIS_H "##WaveMore")) { |
| 924 |
} |
| 925 |
if (ImGui::BeginPopupContextItem("WaveListMore",ImGuiMouseButton_Left)) { |
| 926 |
if (buttonSpace<2.0f) if (ImGui::MenuItem("add")) { |
| 927 |
doAction(GUI_ACTION_WAVE_LIST_ADD); |
| 928 |
} |
| 929 |
if (buttonSpace<6.0f) if (ImGui::MenuItem("duplicate")) { |
| 930 |
doAction(GUI_ACTION_WAVE_LIST_DUPLICATE); |
| 931 |
} |
| 932 |
if (buttonSpace<3.0f) { |
| 933 |
if (ImGui::MenuItem("open...")) { |
| 934 |
doAction(GUI_ACTION_WAVE_LIST_OPEN); |
| 935 |
} |
| 936 |
if (ImGui::MenuItem("replace...")) { |
| 937 |
doAction((curWave>=0 && curWave<(int)e->song.wave.size())?GUI_ACTION_WAVE_LIST_OPEN_REPLACE:GUI_ACTION_WAVE_LIST_OPEN); |
| 938 |
} |
| 939 |
} |
| 940 |
if (buttonSpace<5.0f) { |
| 941 |
if (ImGui::MenuItem("save...")) { |
| 942 |
doAction(GUI_ACTION_WAVE_LIST_SAVE); |
| 943 |
} |
| 944 |
if (ImGui::MenuItem(_("save as .dmw..."))) { |
| 945 |
doAction(GUI_ACTION_WAVE_LIST_SAVE_DMW); |
| 946 |
} |
| 947 |
if (ImGui::MenuItem(_("save raw..."))) { |
| 948 |
doAction(GUI_ACTION_WAVE_LIST_SAVE_RAW); |
| 949 |
} |
| 950 |
if (ImGui::MenuItem(_("save all..."))) { |
| 951 |
doAction(GUI_ACTION_WAVE_LIST_SAVE_ALL); |
| 952 |
} |
| 953 |
} |
| 954 |
if (buttonSpace<7.0f) if (ImGui::MenuItem("folder view",NULL,waveListDir)) { |
| 955 |
doAction(GUI_ACTION_WAVE_LIST_DIR_VIEW); |
| 956 |
} |
| 957 |
if (buttonSpace<(waveListDir?7.0f:8.0f)) { |
| 958 |
if (!waveListDir) { |
| 959 |
if (ImGui::MenuItem("move up")) { |
| 960 |
doAction(GUI_ACTION_WAVE_LIST_MOVE_UP); |
| 961 |
} |
| 962 |
if (ImGui::MenuItem("move down")) { |
| 963 |
doAction(GUI_ACTION_WAVE_LIST_MOVE_DOWN); |
| 964 |
} |
| 965 |
} else { |
| 966 |
if (ImGui::MenuItem("new folder")) { |
| 967 |
mustOpenNewFolder=true; |
| 968 |
} |
| 969 |
} |
| 970 |
} |
| 971 |
if (buttonSpace<4.0f) if (ImGui::MenuItem("delete")) { |
| 972 |
doAction(GUI_ACTION_WAVE_LIST_DELETE); |
| 973 |
} |
| 974 |
ImGui::EndPopup(); |
| 975 |
} |
| 976 |
} |
| 977 |
|
| 978 |
if (mustOpenNewFolder) { |
| 979 |
folderString=""; |
| 980 |
ImGui::OpenPopup("NewWaveFolder"); |
| 981 |
} |
| 982 |
|
| 983 |
if (ImGui::BeginPopup("NewWaveFolder",ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) { |
| 984 |
ImGui::InputText("##FolderName",&folderString); |
| 985 |
ImGui::SameLine(); |
| 986 |
ImGui::BeginDisabled(folderString.empty()); |
| 987 |
if (ImGui::Button(_("Create"))) { |
| 988 |
e->lockEngine([this]() { |
| 989 |
e->song.waveDir.push_back(DivAssetDir(folderString)); |
| 990 |
}); |
| 991 |
ImGui::CloseCurrentPopup(); |
| 992 |
} |
| 993 |
ImGui::EndDisabled(); |
| 994 |
ImGui::EndPopup(); |
| 995 |
} |
| 996 |
|
| 997 |
ImGui::Separator(); |
| 998 |
if (ImGui::BeginTable("WaveListScroll",1,ImGuiTableFlags_ScrollY)) { |
| 999 |
actualWaveList(); |
| 1000 |
ImGui::EndTable(); |
| 1001 |
} |
| 1002 |
} |
| 1003 |
if (asChild) { |
| 1004 |
ImGui::EndChild(); |
| 1005 |
} else { |
| 1006 |
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_WAVE_LIST; |
| 1007 |
ImGui::End(); |
| 1008 |
} |
| 1009 |
} |
| 1010 |
|
| 1011 |
void FurnaceGUI::drawSampleList(bool asChild) { |
| 1012 |
if (nextWindow==GUI_WINDOW_SAMPLE_LIST) { |
| 1013 |
sampleListOpen=true; |
| 1014 |
if (settings.unifiedDataView) { |
| 1015 |
ImGui::SetWindowFocus("Instruments"); |
| 1016 |
} else { |
| 1017 |
ImGui::SetNextWindowFocus(); |
| 1018 |
} |
| 1019 |
nextWindow=GUI_WINDOW_NOTHING; |
| 1020 |
} |
| 1021 |
if (settings.unifiedDataView) return; |
| 1022 |
if (!sampleListOpen && !asChild) return; |
| 1023 |
bool began=false; |
| 1024 |
if (asChild) { |
| 1025 |
began=ImGui::BeginChild("Samples"); |
| 1026 |
} else { |
| 1027 |
began=ImGui::Begin("Samples",&sampleListOpen,globalWinFlags,_("Samples")); |
| 1028 |
} |
| 1029 |
if (began) { |
| 1030 |
// hide buttons if there isn't enough space |
| 1031 |
// buttons and their space requirements: |
| 1032 |
// - new: 2 |
| 1033 |
// - duplicate: 7 |
| 1034 |
// - open: 3 |
| 1035 |
// - save: 5 |
| 1036 |
// - folder view: 8 |
| 1037 |
// - move up: 9 |
| 1038 |
// - move down: 9 |
| 1039 |
// - preview: 6 |
| 1040 |
// - delete: 4 |
| 1041 |
float buttonSize=ImGui::GetStyle().FramePadding.x*2.0f+settings.iconSize*dpiScale+ImGui::GetStyle().ItemSpacing.x; |
| 1042 |
float buttonSpace=ImGui::GetContentRegionAvail().x/MAX(1.0f,buttonSize); |
| 1043 |
bool mustOpenNewFolder=false; |
| 1044 |
|
| 1045 |
if (buttonSpace>=2.0f) { |
| 1046 |
// add |
| 1047 |
if (ImGui::Button(ICON_FA_FILE "##SampleAdd")) { |
| 1048 |
doAction(GUI_ACTION_SAMPLE_LIST_ADD); |
| 1049 |
} |
| 1050 |
if (ImGui::IsItemHovered()) { |
| 1051 |
ImGui::SetTooltip(_("Add")); |
| 1052 |
} |
| 1053 |
ImGui::SameLine(); |
| 1054 |
} |
| 1055 |
|
| 1056 |
if (buttonSpace>=7.0f) { |
| 1057 |
// duplicate |
| 1058 |
if (ImGui::Button(ICON_FA_FILES_O "##SampleClone")) { |
| 1059 |
doAction(GUI_ACTION_SAMPLE_LIST_DUPLICATE); |
| 1060 |
} |
| 1061 |
if (ImGui::IsItemHovered()) { |
| 1062 |
ImGui::SetTooltip(_("Duplicate")); |
| 1063 |
} |
| 1064 |
ImGui::SameLine(); |
| 1065 |
} |
| 1066 |
|
| 1067 |
if (buttonSpace>=3.0f) { |
| 1068 |
// open |
| 1069 |
if (ImGui::Button(ICON_FA_FOLDER_OPEN "##SampleLoad")) { |
| 1070 |
doAction(GUI_ACTION_SAMPLE_LIST_OPEN); |
| 1071 |
} |
| 1072 |
if (ImGui::IsItemHovered()) { |
| 1073 |
ImGui::SetTooltip(_("Open")); |
| 1074 |
} |
| 1075 |
if (mobileUI && ImGui::IsItemActive() && CHECK_LONG_HOLD) { |
| 1076 |
ImGui::OpenPopup("SampleOpenOpt"); |
| 1077 |
NOTIFY_LONG_HOLD; |
| 1078 |
} |
| 1079 |
if (ImGui::BeginPopupContextItem("SampleOpenOpt")) { |
| 1080 |
if (ImGui::MenuItem(_("replace..."))) { |
| 1081 |
doAction((curSample>=0 && curSample<(int)e->song.sample.size())?GUI_ACTION_SAMPLE_LIST_OPEN_REPLACE:GUI_ACTION_SAMPLE_LIST_OPEN); |
| 1082 |
} |
| 1083 |
ImGui::Separator(); |
| 1084 |
if (ImGui::MenuItem(_("import raw..."))) { |
| 1085 |
doAction(GUI_ACTION_SAMPLE_LIST_OPEN_RAW); |
| 1086 |
} |
| 1087 |
if (ImGui::MenuItem(_("import raw (replace)..."))) { |
| 1088 |
doAction((curSample>=0 && curSample<(int)e->song.sample.size())?GUI_ACTION_SAMPLE_LIST_OPEN_REPLACE_RAW:GUI_ACTION_SAMPLE_LIST_OPEN_RAW); |
| 1089 |
} |
| 1090 |
ImGui::EndPopup(); |
| 1091 |
} |
| 1092 |
ImGui::SameLine(); |
| 1093 |
} |
| 1094 |
|
| 1095 |
if (buttonSpace>=5.0f) { |
| 1096 |
// save |
| 1097 |
if (ImGui::Button(ICON_FA_FLOPPY_O "##SampleSave")) { |
| 1098 |
doAction(GUI_ACTION_SAMPLE_LIST_SAVE); |
| 1099 |
} |
| 1100 |
if (ImGui::IsItemHovered()) { |
| 1101 |
ImGui::SetTooltip(_("Save")); |
| 1102 |
} |
| 1103 |
if (mobileUI && ImGui::IsItemActive() && CHECK_LONG_HOLD) { |
| 1104 |
ImGui::OpenPopup("SampleSaveOpt"); |
| 1105 |
NOTIFY_LONG_HOLD; |
| 1106 |
} |
| 1107 |
if (ImGui::BeginPopupContextItem("SampleSaveOpt")) { |
| 1108 |
if (ImGui::MenuItem(_("save raw..."))) { |
| 1109 |
doAction(GUI_ACTION_SAMPLE_LIST_SAVE_RAW); |
| 1110 |
} |
| 1111 |
if (ImGui::MenuItem(_("save all..."))) { |
| 1112 |
doAction(GUI_ACTION_SAMPLE_LIST_SAVE_ALL); |
| 1113 |
} |
| 1114 |
ImGui::EndPopup(); |
| 1115 |
} |
| 1116 |
ImGui::SameLine(); |
| 1117 |
} |
| 1118 |
|
| 1119 |
if (buttonSpace>=8.0f) { |
| 1120 |
// dir mode |
| 1121 |
pushToggleColors(sampleListDir); |
| 1122 |
if (ImGui::Button(ICON_FA_SITEMAP "##SampleDirMode")) { |
| 1123 |
doAction(GUI_ACTION_SAMPLE_LIST_DIR_VIEW); |
| 1124 |
} |
| 1125 |
popToggleColors(); |
| 1126 |
if (ImGui::IsItemHovered()) { |
| 1127 |
ImGui::SetTooltip(_("Toggle folders/standard view")); |
| 1128 |
} |
| 1129 |
ImGui::SameLine(); |
| 1130 |
} |
| 1131 |
|
| 1132 |
if (buttonSpace>=(sampleListDir?8.0f:9.0f)) { |
| 1133 |
if (!sampleListDir) { |
| 1134 |
if (ImGui::Button(ICON_FA_ARROW_UP "##SampleUp")) { |
| 1135 |
doAction(GUI_ACTION_SAMPLE_LIST_MOVE_UP); |
| 1136 |
} |
| 1137 |
if (ImGui::IsItemHovered()) { |
| 1138 |
ImGui::SetTooltip(_("Move up")); |
| 1139 |
} |
| 1140 |
ImGui::SameLine(); |
| 1141 |
if (ImGui::Button(ICON_FA_ARROW_DOWN "##SampleDown")) { |
| 1142 |
doAction(GUI_ACTION_SAMPLE_LIST_MOVE_DOWN); |
| 1143 |
} |
| 1144 |
if (ImGui::IsItemHovered()) { |
| 1145 |
ImGui::SetTooltip(_("Move down")); |
| 1146 |
} |
| 1147 |
} else { |
| 1148 |
if (ImGui::Button(ICON_FA_FOLDER "##SampleFolder")) { |
| 1149 |
mustOpenNewFolder=true; |
| 1150 |
} |
| 1151 |
if (ImGui::IsItemHovered()) { |
| 1152 |
ImGui::SetTooltip(_("New folder")); |
| 1153 |
} |
| 1154 |
} |
| 1155 |
ImGui::SameLine(); |
| 1156 |
} |
| 1157 |
|
| 1158 |
if (buttonSpace>=6.0f) { |
| 1159 |
if (ImGui::Button(ICON_FA_VOLUME_UP "##PreviewSampleL")) { |
| 1160 |
doAction(GUI_ACTION_SAMPLE_LIST_PREVIEW); |
| 1161 |
} |
| 1162 |
if (ImGui::IsItemHovered()) { |
| 1163 |
ImGui::SetTooltip(_("Preview (right click to stop)")); |
| 1164 |
} |
| 1165 |
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { |
| 1166 |
doAction(GUI_ACTION_SAMPLE_LIST_STOP_PREVIEW); |
| 1167 |
} |
| 1168 |
ImGui::SameLine(); |
| 1169 |
} |
| 1170 |
|
| 1171 |
if (buttonSpace>=4.0f) { |
| 1172 |
pushDestColor(); |
| 1173 |
if (ImGui::Button(ICON_FA_TIMES "##SampleDelete")) { |
| 1174 |
doAction(GUI_ACTION_SAMPLE_LIST_DELETE); |
| 1175 |
} |
| 1176 |
popDestColor(); |
| 1177 |
if (ImGui::IsItemHovered()) { |
| 1178 |
ImGui::SetTooltip(_("Delete")); |
| 1179 |
} |
| 1180 |
if (buttonSpace<9.0f) { |
| 1181 |
ImGui::SameLine(); |
| 1182 |
} |
| 1183 |
} |
| 1184 |
|
| 1185 |
if (buttonSpace<(sampleListDir?8.0f:9.0f)) { |
| 1186 |
if (ImGui::Button(ICON_FA_ELLIPSIS_H "##SampleMore")) { |
| 1187 |
} |
| 1188 |
if (ImGui::BeginPopupContextItem("SampleListMore",ImGuiMouseButton_Left)) { |
| 1189 |
if (buttonSpace<2.0f) if (ImGui::MenuItem("add")) { |
| 1190 |
doAction(GUI_ACTION_SAMPLE_LIST_ADD); |
| 1191 |
} |
| 1192 |
if (buttonSpace<7.0f) if (ImGui::MenuItem("duplicate")) { |
| 1193 |
doAction(GUI_ACTION_SAMPLE_LIST_DUPLICATE); |
| 1194 |
} |
| 1195 |
if (buttonSpace<3.0f) { |
| 1196 |
if (ImGui::MenuItem("open...")) { |
| 1197 |
doAction(GUI_ACTION_SAMPLE_LIST_OPEN); |
| 1198 |
} |
| 1199 |
if (ImGui::MenuItem("replace...")) { |
| 1200 |
doAction((curSample>=0 && curSample<(int)e->song.sample.size())?GUI_ACTION_SAMPLE_LIST_OPEN_REPLACE:GUI_ACTION_SAMPLE_LIST_OPEN); |
| 1201 |
} |
| 1202 |
if (ImGui::MenuItem("import raw...")) { |
| 1203 |
doAction(GUI_ACTION_SAMPLE_LIST_OPEN_RAW); |
| 1204 |
} |
| 1205 |
if (ImGui::MenuItem("import raw (replace)...")) { |
| 1206 |
doAction((curSample>=0 && curSample<(int)e->song.sample.size())?GUI_ACTION_SAMPLE_LIST_OPEN_REPLACE_RAW:GUI_ACTION_SAMPLE_LIST_OPEN_RAW); |
| 1207 |
} |
| 1208 |
} |
| 1209 |
if (buttonSpace<5.0f) { |
| 1210 |
if (ImGui::MenuItem("save...")) { |
| 1211 |
doAction(GUI_ACTION_SAMPLE_LIST_SAVE); |
| 1212 |
} |
| 1213 |
if (ImGui::MenuItem("save raw...")) { |
| 1214 |
doAction(GUI_ACTION_SAMPLE_LIST_SAVE_RAW); |
| 1215 |
} |
| 1216 |
if (ImGui::MenuItem("save all...")) { |
| 1217 |
doAction(GUI_ACTION_SAMPLE_LIST_SAVE_ALL); |
| 1218 |
} |
| 1219 |
} |
| 1220 |
if (buttonSpace<8.0f) if (ImGui::MenuItem("folder view",NULL,sampleListDir)) { |
| 1221 |
doAction(GUI_ACTION_SAMPLE_LIST_DIR_VIEW); |
| 1222 |
} |
| 1223 |
if (buttonSpace<(sampleListDir?8.0f:9.0f)) { |
| 1224 |
if (!sampleListDir) { |
| 1225 |
if (ImGui::MenuItem("move up")) { |
| 1226 |
doAction(GUI_ACTION_SAMPLE_LIST_MOVE_UP); |
| 1227 |
} |
| 1228 |
if (ImGui::MenuItem("move down")) { |
| 1229 |
doAction(GUI_ACTION_SAMPLE_LIST_MOVE_DOWN); |
| 1230 |
} |
| 1231 |
} else { |
| 1232 |
if (ImGui::MenuItem("new folder")) { |
| 1233 |
mustOpenNewFolder=true; |
| 1234 |
} |
| 1235 |
} |
| 1236 |
} |
| 1237 |
if (buttonSpace<6.0f) { |
| 1238 |
if (ImGui::MenuItem("preview")) { |
| 1239 |
doAction(GUI_ACTION_SAMPLE_LIST_PREVIEW); |
| 1240 |
} |
| 1241 |
if (ImGui::MenuItem("stop preview")) { |
| 1242 |
doAction(GUI_ACTION_SAMPLE_LIST_STOP_PREVIEW); |
| 1243 |
} |
| 1244 |
} |
| 1245 |
if (buttonSpace<4.0f) if (ImGui::MenuItem("delete")) { |
| 1246 |
doAction(GUI_ACTION_SAMPLE_LIST_DELETE); |
| 1247 |
} |
| 1248 |
|
| 1249 |
ImGui::EndPopup(); |
| 1250 |
} |
| 1251 |
} |
| 1252 |
|
| 1253 |
if (mustOpenNewFolder) { |
| 1254 |
folderString=""; |
| 1255 |
ImGui::OpenPopup("NewSampleFolder"); |
| 1256 |
} |
| 1257 |
|
| 1258 |
if (ImGui::BeginPopup("NewSampleFolder",ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) { |
| 1259 |
ImGui::InputText("##FolderName",&folderString); |
| 1260 |
ImGui::SameLine(); |
| 1261 |
ImGui::BeginDisabled(folderString.empty()); |
| 1262 |
if (ImGui::Button(_("Create"))) { |
| 1263 |
e->lockEngine([this]() { |
| 1264 |
e->song.sampleDir.push_back(DivAssetDir(folderString)); |
| 1265 |
}); |
| 1266 |
ImGui::CloseCurrentPopup(); |
| 1267 |
} |
| 1268 |
ImGui::EndDisabled(); |
| 1269 |
ImGui::EndPopup(); |
| 1270 |
} |
| 1271 |
|
| 1272 |
ImGui::Separator(); |
| 1273 |
if (ImGui::BeginTable("SampleListScroll",1,ImGuiTableFlags_ScrollY)) { |
| 1274 |
actualSampleList(); |
| 1275 |
ImGui::EndTable(); |
| 1276 |
} |
| 1277 |
ImGui::Unindent(); |
| 1278 |
} |
| 1279 |
if (asChild) { |
| 1280 |
ImGui::EndChild(); |
| 1281 |
} else { |
| 1282 |
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_SAMPLE_LIST; |
| 1283 |
ImGui::End(); |
| 1284 |
} |
| 1285 |
} |
| 1286 |
|
| 1287 |
// HACK: template. any way to remove it? |
| 1288 |
template<typename func_waveItemData> void FurnaceGUI::waveListHorizontalGroup(float* wavePreview, int dir, int count, const func_waveItemData& waveItemData) { |
| 1289 |
if (count==0) return; |
| 1290 |
|
| 1291 |
float idealWidthMin=225.0f*dpiScale; |
| 1292 |
float idealWidthMax=350.0f*dpiScale; |
| 1293 |
float availX=ImGui::GetContentRegionAvail().x; |
| 1294 |
int columnCount=CLAMP((int)(availX/idealWidthMin),1,count); |
| 1295 |
int rowCount=(int)ceilf(count/(float)columnCount); |
| 1296 |
columnCount=(int)ceilf(count/(float)rowCount); |
| 1297 |
float columnWidth=MIN(CLAMP(availX/columnCount,idealWidthMin,idealWidthMax),availX); |
| 1298 |
if (ImGui::BeginTable("##waveListGroupTable",columnCount,ImGuiTableFlags_SizingFixedSame)) { |
| 1299 |
for (int col=0; col<columnCount; col++) { |
| 1300 |
ImGui::TableSetupColumn("##column",ImGuiTableColumnFlags_WidthFixed,columnWidth); |
| 1301 |
} |
| 1302 |
for (int row=0; row<rowCount; row++) { |
| 1303 |
ImGui::TableNextRow(); |
| 1304 |
for (int col=0; col<columnCount; col++) { |
| 1305 |
ImGui::TableNextColumn(); |
| 1306 |
int idx=row+col*rowCount; |
| 1307 |
if (idx>=count) continue; |
| 1308 |
|
| 1309 |
int waveIdx, asset; |
| 1310 |
waveItemData(row+col*rowCount,&waveIdx,&asset); |
| 1311 |
waveListItem(waveIdx,wavePreview,dir,asset); |
| 1312 |
} |
| 1313 |
} |
| 1314 |
ImGui::EndTable(); |
| 1315 |
} |
| 1316 |
} |
| 1317 |
|
| 1318 |
void FurnaceGUI::actualWaveList() { |
| 1319 |
float wavePreview[257]; |
| 1320 |
|
| 1321 |
if (waveListDir || (settings.unifiedDataView && insListDir)) { |
| 1322 |
ImGui::TableNextRow(); |
| 1323 |
ImGui::TableNextColumn(); |
| 1324 |
int dirIndex=0; |
| 1325 |
int dirToDelete=-1; |
| 1326 |
for (DivAssetDir& i: e->song.waveDir) { |
| 1327 |
String nodeName=fmt::sprintf("%s %s##_ADW%d",i.name.empty()?ICON_FA_FOLDER_O:ICON_FA_FOLDER,i.name.empty()?_("<uncategorized>"):i.name,i.name.empty()?-1:dirIndex); |
| 1328 |
String popupID=fmt::sprintf("DirRightMenu%d",dirIndex); |
| 1329 |
bool treeNode=ImGui::TreeNodeEx(nodeName.c_str(),ImGuiTreeNodeFlags_SpanAvailWidth|(i.name.empty()?ImGuiTreeNodeFlags_DefaultOpen:0)); |
| 1330 |
DIR_DRAG_SOURCE(dirIndex,-1,"FUR_WAVEDIR"); |
| 1331 |
DIR_DRAG_TARGET(dirIndex,-1,e->song.waveDir,"FUR_WAVEDIR"); |
| 1332 |
if (ImGui::BeginPopupContextItem(popupID.c_str())) { |
| 1333 |
if (ImGui::MenuItem(_("rename..."))) { |
| 1334 |
editStr(&i.name); |
| 1335 |
} |
| 1336 |
if (ImGui::MenuItem(_("delete"))) { |
| 1337 |
dirToDelete=dirIndex; |
| 1338 |
} |
| 1339 |
ImGui::EndPopup(); |
| 1340 |
} |
| 1341 |
if (treeNode) { |
| 1342 |
if (settings.horizontalDataView) { |
| 1343 |
waveListHorizontalGroup(wavePreview,dirIndex,i.entries.size(),[&](int i_, int* waveIdx, int* asset) { |
| 1344 |
*waveIdx=i.entries[i_]; |
| 1345 |
*asset=i_; |
| 1346 |
}); |
| 1347 |
} else { |
| 1348 |
int assetIndex=0; |
| 1349 |
for (int j: i.entries) { |
| 1350 |
waveListItem(j,wavePreview,dirIndex,assetIndex); |
| 1351 |
assetIndex++; |
| 1352 |
} |
| 1353 |
} |
| 1354 |
ImGui::TreePop(); |
| 1355 |
} |
| 1356 |
dirIndex++; |
| 1357 |
} |
| 1358 |
if (dirToDelete!=-1) { |
| 1359 |
e->lockEngine([this,dirToDelete]() { |
| 1360 |
e->song.waveDir.erase(e->song.waveDir.begin()+dirToDelete); |
| 1361 |
e->checkAssetDir(e->song.waveDir,e->song.wave.size()); |
| 1362 |
}); |
| 1363 |
} |
| 1364 |
} else { |
| 1365 |
if (settings.horizontalDataView) { |
| 1366 |
ImGui::TableNextRow(); |
| 1367 |
ImGui::TableNextColumn(); |
| 1368 |
waveListHorizontalGroup(wavePreview,-1,(int)e->song.wave.size(),[&](int i, int* waveIdx, int* asset) { |
| 1369 |
*waveIdx=i; |
| 1370 |
*asset=-1; |
| 1371 |
}); |
| 1372 |
} else { |
| 1373 |
for (int i=0; i<(int)e->song.wave.size(); i++) { |
| 1374 |
ImGui::TableNextRow(); |
| 1375 |
ImGui::TableNextColumn(); |
| 1376 |
waveListItem(i,wavePreview,-1,-1); |
| 1377 |
} |
| 1378 |
} |
| 1379 |
} |
| 1380 |
} |
| 1381 |
|
| 1382 |
void FurnaceGUI::actualSampleList() { |
| 1383 |
if (sampleListDir || (settings.unifiedDataView && insListDir)) { |
| 1384 |
ImGui::TableNextRow(); |
| 1385 |
ImGui::TableNextColumn(); |
| 1386 |
int dirIndex=0; |
| 1387 |
int dirToDelete=-1; |
| 1388 |
for (DivAssetDir& i: e->song.sampleDir) { |
| 1389 |
String nodeName=fmt::sprintf("%s %s##_ADS%d",i.name.empty()?ICON_FA_FOLDER_O:ICON_FA_FOLDER,i.name.empty()?_("<uncategorized>"):i.name,i.name.empty()?-1:dirIndex); |
| 1390 |
String popupID=fmt::sprintf("DirRightMenu%d",dirIndex); |
| 1391 |
bool treeNode=ImGui::TreeNodeEx(nodeName.c_str(),ImGuiTreeNodeFlags_SpanAvailWidth|(i.name.empty()?ImGuiTreeNodeFlags_DefaultOpen:0)); |
| 1392 |
DIR_DRAG_SOURCE(dirIndex,-1,"FUR_SDIR"); |
| 1393 |
DIR_DRAG_TARGET(dirIndex,-1,e->song.sampleDir,"FUR_SDIR"); |
| 1394 |
if (ImGui::BeginPopupContextItem(popupID.c_str())) { |
| 1395 |
if (ImGui::MenuItem(_("rename..."))) { |
| 1396 |
editStr(&i.name); |
| 1397 |
} |
| 1398 |
if (ImGui::MenuItem(_("delete"))) { |
| 1399 |
dirToDelete=dirIndex; |
| 1400 |
} |
| 1401 |
ImGui::EndPopup(); |
| 1402 |
} |
| 1403 |
if (treeNode) { |
| 1404 |
int assetIndex=0; |
| 1405 |
for (int j: i.entries) { |
| 1406 |
sampleListItem(j,dirIndex,assetIndex); |
| 1407 |
assetIndex++; |
| 1408 |
} |
| 1409 |
ImGui::TreePop(); |
| 1410 |
} |
| 1411 |
dirIndex++; |
| 1412 |
} |
| 1413 |
if (dirToDelete!=-1) { |
| 1414 |
e->lockEngine([this,dirToDelete]() { |
| 1415 |
e->song.sampleDir.erase(e->song.sampleDir.begin()+dirToDelete); |
| 1416 |
e->checkAssetDir(e->song.sampleDir,e->song.sample.size()); |
| 1417 |
}); |
| 1418 |
} |
| 1419 |
} else { |
| 1420 |
for (int i=0; i<(int)e->song.sample.size(); i++) { |
| 1421 |
ImGui::TableNextRow(); |
| 1422 |
ImGui::TableNextColumn(); |
| 1423 |
sampleListItem(i,-1,-1); |
| 1424 |
} |
| 1425 |
} |
| 1426 |
} |