| 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 "guiConst.h" |
| 22 |
#include "imgui.h" |
| 23 |
#include "imgui_internal.h" |
| 24 |
#include <fmt/printf.h> |
| 25 |
#include "IconsFontAwesome4.h" |
| 26 |
|
| 27 |
const float topKeyStarts[5]={ |
| 28 |
0.9f/7.0f, 2.1f/7.0f, 3.9f/7.0f, 5.0f/7.0f, 6.1f/7.0f |
| 29 |
}; |
| 30 |
|
| 31 |
const int topKeyNotes[5]={ |
| 32 |
1, 3, 6, 8, 10 |
| 33 |
}; |
| 34 |
|
| 35 |
const int bottomKeyNotes[7]={ |
| 36 |
0, 2, 4, 5, 7, 9, 11 |
| 37 |
}; |
| 38 |
|
| 39 |
const bool isTopKey[12]={ |
| 40 |
false, true, false, true, false, false, true, false, true, false, true, false |
| 41 |
}; |
| 42 |
|
| 43 |
#define VALUE_DIGIT(x,label) \ |
| 44 |
if (ImGui::Button(label,buttonSize)) { \ |
| 45 |
if (curWindow==GUI_WINDOW_ORDERS && orderEditMode>0) { \ |
| 46 |
orderInput(x); \ |
| 47 |
} else { \ |
| 48 |
valueInput(x,false); \ |
| 49 |
} \ |
| 50 |
} |
| 51 |
|
| 52 |
void FurnaceGUI::drawPiano() { |
| 53 |
if (nextWindow==GUI_WINDOW_PIANO) { |
| 54 |
pianoOpen=true; |
| 55 |
ImGui::SetNextWindowFocus(); |
| 56 |
nextWindow=GUI_WINDOW_NOTHING; |
| 57 |
} |
| 58 |
if (!pianoOpen) return; |
| 59 |
if (mobileUI) { |
| 60 |
ImGui::SetNextWindowPos(ImVec2(patWindowPos.x,patWindowPos.y+patWindowSize.y)); |
| 61 |
ImGui::SetNextWindowSize(portrait?ImVec2(canvasW,0.4*canvasW):ImVec2(canvasW-(0.16*canvasH),0.3*canvasH)); |
| 62 |
} |
| 63 |
if (ImGui::Begin("Piano",&pianoOpen,((pianoOptions)?0:ImGuiWindowFlags_NoTitleBar)|ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoScrollWithMouse|globalWinFlags,_("Piano"))) { |
| 64 |
bool oldPianoKeyPressed[180]; |
| 65 |
memcpy(oldPianoKeyPressed,pianoKeyPressed,180*sizeof(bool)); |
| 66 |
memset(pianoKeyPressed,0,180*sizeof(bool)); |
| 67 |
if (ImGui::BeginTable("PianoLayout",((pianoOptions && (!mobileUI || !portrait))?2:1),ImGuiTableFlags_BordersInnerV)) { |
| 68 |
int& off=(e->isPlaying() || pianoSharePosition)?pianoOffset:pianoOffsetEdit; |
| 69 |
int& oct=(e->isPlaying() || pianoSharePosition)?pianoOctaves:pianoOctavesEdit; |
| 70 |
bool view=(pianoView==PIANO_LAYOUT_AUTOMATIC)?(!e->isPlaying()):pianoView; |
| 71 |
if (pianoOptions && (!mobileUI || !portrait)) { |
| 72 |
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed); |
| 73 |
} |
| 74 |
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,1.0f); |
| 75 |
|
| 76 |
ImGui::TableNextRow(); |
| 77 |
if (pianoOptions) { |
| 78 |
ImGui::TableNextColumn(); |
| 79 |
float optionSizeY=ImGui::GetContentRegionAvail().y*((mobileUI && portrait)?0.3:0.5)-ImGui::GetStyle().ItemSpacing.y; |
| 80 |
ImVec2 optionSize=ImVec2((mobileUI && portrait)?((ImGui::GetContentRegionAvail().x-ImGui::GetStyle().ItemSpacing.x*5.0f)/6.0f):(1.2f*optionSizeY),optionSizeY); |
| 81 |
if (pianoOptionsSet) { |
| 82 |
if (ImGui::Button("OFF##PianoNOff",optionSize)) { |
| 83 |
if (edit) noteInput(0,GUI_NOTE_OFF); |
| 84 |
} |
| 85 |
ImGui::SameLine(); |
| 86 |
if (ImGui::Button("===##PianoNRel",optionSize)) { |
| 87 |
if (edit) noteInput(0,GUI_NOTE_OFF_RELEASE); |
| 88 |
} |
| 89 |
} else { |
| 90 |
if (ImGui::Button(ICON_FA_ARROW_LEFT "##PianoLeft",optionSize)) { |
| 91 |
off--; |
| 92 |
if (off<0) off=0; |
| 93 |
} |
| 94 |
ImGui::SameLine(); |
| 95 |
if (ImGui::Button(ICON_FA_ARROW_RIGHT "##PianoRight",optionSize)) { |
| 96 |
off++; |
| 97 |
if ((off+oct)>14) off=15-oct; |
| 98 |
} |
| 99 |
} |
| 100 |
ImGui::SameLine(); |
| 101 |
ImGui::Button(ICON_FA_ELLIPSIS_V "##PianoOptions",optionSize); |
| 102 |
if (ImGui::IsItemHovered()) { |
| 103 |
ImGui::SetTooltip(_("Options")); |
| 104 |
} |
| 105 |
if (ImGui::BeginPopupContextItem("PianoOptions",ImGuiPopupFlags_MouseButtonLeft)) { |
| 106 |
ImGui::Text(_("Key layout:")); |
| 107 |
ImGui::Indent(); |
| 108 |
if (ImGui::RadioButton(_("Automatic"),pianoView==PIANO_LAYOUT_AUTOMATIC)) { |
| 109 |
pianoView=PIANO_LAYOUT_AUTOMATIC; |
| 110 |
} |
| 111 |
if (ImGui::RadioButton(_("Standard"),pianoView==PIANO_LAYOUT_STANDARD)) { |
| 112 |
pianoView=PIANO_LAYOUT_STANDARD; |
| 113 |
} |
| 114 |
if (ImGui::RadioButton(_("Continuous"),pianoView==PIANO_LAYOUT_CONTINUOUS)) { |
| 115 |
pianoView=PIANO_LAYOUT_CONTINUOUS; |
| 116 |
} |
| 117 |
ImGui::Unindent(); |
| 118 |
ImGui::Text(_("Value input pad:")); |
| 119 |
ImGui::Indent(); |
| 120 |
if (ImGui::RadioButton(_("Disabled"),pianoInputPadMode==PIANO_INPUT_PAD_DISABLE)) { |
| 121 |
pianoInputPadMode=PIANO_INPUT_PAD_DISABLE; |
| 122 |
} |
| 123 |
if (ImGui::RadioButton(_("Replace piano"),pianoInputPadMode==PIANO_INPUT_PAD_REPLACE)) { |
| 124 |
pianoInputPadMode=PIANO_INPUT_PAD_REPLACE; |
| 125 |
} |
| 126 |
if (ImGui::RadioButton(_("Split (automatic)"),pianoInputPadMode==PIANO_INPUT_PAD_SPLIT_AUTO)) { |
| 127 |
pianoInputPadMode=PIANO_INPUT_PAD_SPLIT_AUTO; |
| 128 |
} |
| 129 |
if (ImGui::RadioButton(_("Split (always visible)"),pianoInputPadMode==PIANO_INPUT_PAD_SPLIT_VISIBLE)) { |
| 130 |
pianoInputPadMode=PIANO_INPUT_PAD_SPLIT_VISIBLE; |
| 131 |
} |
| 132 |
ImGui::Unindent(); |
| 133 |
ImGui::Checkbox(_("Share play/edit offset/range"),&pianoSharePosition); |
| 134 |
ImGui::Checkbox(_("Read-only (can't input notes)"),&pianoReadonly); |
| 135 |
ImGui::EndPopup(); |
| 136 |
} |
| 137 |
|
| 138 |
if (mobileUI && portrait) { |
| 139 |
ImGui::SameLine(); |
| 140 |
} |
| 141 |
|
| 142 |
if (pianoOptionsSet) { |
| 143 |
if (ImGui::Button("REL##PianoNMRel",optionSize)) { |
| 144 |
if (edit) noteInput(0,GUI_NOTE_RELEASE); |
| 145 |
} |
| 146 |
ImGui::SameLine(); |
| 147 |
if (ImGui::Button(ICON_FA_TIMES "##PianoDelP",optionSize)) { |
| 148 |
doDelete(); |
| 149 |
} |
| 150 |
} else { |
| 151 |
if (ImGui::Button(ICON_FA_MINUS "##PianoOctaveDown",optionSize)) { |
| 152 |
oct--; |
| 153 |
if (oct<1) oct=1; |
| 154 |
} |
| 155 |
ImGui::SameLine(); |
| 156 |
if (ImGui::Button(ICON_FA_PLUS "##PianoOctaveUp",optionSize)) { |
| 157 |
oct++; |
| 158 |
if (oct>15) oct=15; |
| 159 |
if ((off+oct)>14) off=15-oct; |
| 160 |
} |
| 161 |
} |
| 162 |
ImGui::SameLine(); |
| 163 |
if (ImGui::Button(ICON_FA_ELLIPSIS_H "##PianoSel",optionSize)) { |
| 164 |
pianoOptionsSet=!pianoOptionsSet; |
| 165 |
} |
| 166 |
} |
| 167 |
|
| 168 |
if (mobileUI && portrait) { |
| 169 |
ImGui::TableNextRow(); |
| 170 |
} |
| 171 |
|
| 172 |
ImGui::TableNextColumn(); |
| 173 |
if (pianoInputPadMode==PIANO_INPUT_PAD_REPLACE && ((cursor.xFine>0 && curWindow==GUI_WINDOW_PATTERN) || (curWindow==GUI_WINDOW_ORDERS && orderEditMode>0))) { |
| 174 |
ImVec2 buttonSize=ImGui::GetContentRegionAvail(); |
| 175 |
if (ImGui::BeginTable("InputPadP",8,ImGuiTableFlags_SizingFixedSame)) { |
| 176 |
ImGui::TableNextRow(); |
| 177 |
ImGui::TableNextColumn(); |
| 178 |
buttonSize.x/=8.0f; |
| 179 |
buttonSize.x-=ImGui::GetStyle().CellPadding.x*2.0f; |
| 180 |
buttonSize.y/=2.0f; |
| 181 |
buttonSize.y-=ImGui::GetStyle().CellPadding.y*2.0f; |
| 182 |
|
| 183 |
VALUE_DIGIT(0,"0"); |
| 184 |
ImGui::TableNextColumn(); |
| 185 |
VALUE_DIGIT(1,"1"); |
| 186 |
ImGui::TableNextColumn(); |
| 187 |
VALUE_DIGIT(2,"2"); |
| 188 |
ImGui::TableNextColumn(); |
| 189 |
VALUE_DIGIT(3,"3"); |
| 190 |
ImGui::TableNextColumn(); |
| 191 |
VALUE_DIGIT(4,"4"); |
| 192 |
ImGui::TableNextColumn(); |
| 193 |
VALUE_DIGIT(5,"5"); |
| 194 |
ImGui::TableNextColumn(); |
| 195 |
VALUE_DIGIT(6,"6"); |
| 196 |
ImGui::TableNextColumn(); |
| 197 |
VALUE_DIGIT(7,"7"); |
| 198 |
|
| 199 |
ImGui::TableNextRow(); |
| 200 |
ImGui::TableNextColumn(); |
| 201 |
VALUE_DIGIT(8,"8"); |
| 202 |
ImGui::TableNextColumn(); |
| 203 |
VALUE_DIGIT(9,"9"); |
| 204 |
ImGui::TableNextColumn(); |
| 205 |
VALUE_DIGIT(10,"A"); |
| 206 |
ImGui::TableNextColumn(); |
| 207 |
VALUE_DIGIT(11,"B"); |
| 208 |
ImGui::TableNextColumn(); |
| 209 |
VALUE_DIGIT(12,"C"); |
| 210 |
ImGui::TableNextColumn(); |
| 211 |
VALUE_DIGIT(13,"D"); |
| 212 |
ImGui::TableNextColumn(); |
| 213 |
VALUE_DIGIT(14,"E"); |
| 214 |
ImGui::TableNextColumn(); |
| 215 |
VALUE_DIGIT(15,"F"); |
| 216 |
|
| 217 |
ImGui::EndTable(); |
| 218 |
} |
| 219 |
} else { |
| 220 |
ImGuiWindow* window=ImGui::GetCurrentWindow(); |
| 221 |
ImVec2 size=ImGui::GetContentRegionAvail(); |
| 222 |
ImDrawList* dl=ImGui::GetWindowDrawList(); |
| 223 |
|
| 224 |
ImVec2 minArea=window->DC.CursorPos; |
| 225 |
ImVec2 maxArea=ImVec2( |
| 226 |
minArea.x+size.x, |
| 227 |
minArea.y+size.y |
| 228 |
); |
| 229 |
ImRect rect=ImRect(minArea,maxArea); |
| 230 |
|
| 231 |
// render piano |
| 232 |
//ImGui::ItemSize(size,ImGui::GetStyle().FramePadding.y); |
| 233 |
if (ImGui::ItemAdd(rect,ImGui::GetID("pianoDisplay"))) { |
| 234 |
bool canInput=false; |
| 235 |
if (!pianoReadonly && ImGui::ItemHoverable(rect,ImGui::GetID("pianoDisplay"),0)) { |
| 236 |
canInput=true; |
| 237 |
ImGui::InhibitInertialScroll(); |
| 238 |
} |
| 239 |
if (view) { |
| 240 |
int notes=oct*12; |
| 241 |
// evaluate input |
| 242 |
if (canInput) for (TouchPoint& i: activePoints) { |
| 243 |
if (rect.Contains(ImVec2(i.x,i.y))) { |
| 244 |
int note=(((i.x-rect.Min.x)/(rect.Max.x-rect.Min.x))*notes)+12*off; |
| 245 |
if (note<0) continue; |
| 246 |
if (note>=180) continue; |
| 247 |
pianoKeyPressed[note]=true; |
| 248 |
} |
| 249 |
} |
| 250 |
|
| 251 |
for (int i=0; i<notes; i++) { |
| 252 |
int note=i+12*off; |
| 253 |
if (note<0) continue; |
| 254 |
if (note>=180) continue; |
| 255 |
float pkh=pianoKeyHit[note]; |
| 256 |
ImVec4 color=isTopKey[i%12]?uiColors[GUI_COLOR_PIANO_KEY_TOP]:uiColors[GUI_COLOR_PIANO_KEY_BOTTOM]; |
| 257 |
if (pianoKeyPressed[note]) { |
| 258 |
color=isTopKey[i%12]?uiColors[GUI_COLOR_PIANO_KEY_TOP_ACTIVE]:uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_ACTIVE]; |
| 259 |
} else { |
| 260 |
ImVec4 colorHit=isTopKey[i%12]?uiColors[GUI_COLOR_PIANO_KEY_TOP_HIT]:uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_HIT]; |
| 261 |
color.x+=(colorHit.x-color.x)*pkh; |
| 262 |
color.y+=(colorHit.y-color.y)*pkh; |
| 263 |
color.z+=(colorHit.z-color.z)*pkh; |
| 264 |
color.w+=(colorHit.w-color.w)*pkh; |
| 265 |
} |
| 266 |
ImVec2 p0=ImLerp(rect.Min,rect.Max,ImVec2((float)i/notes,0.0f)); |
| 267 |
ImVec2 p1=ImLerp(rect.Min,rect.Max,ImVec2((float)(i+1)/notes,1.0f)); |
| 268 |
p1.x-=dpiScale; |
| 269 |
dl->AddRectFilled(p0,p1,ImGui::ColorConvertFloat4ToU32(color)); |
| 270 |
if ((i%12)==0) { |
| 271 |
String label=fmt::sprintf("%d",(note-60)/12); |
| 272 |
ImVec2 pText=ImLerp(p0,p1,ImVec2(0.5f,1.0f)); |
| 273 |
ImVec2 labelSize=ImGui::CalcTextSize(label.c_str()); |
| 274 |
pText.x-=labelSize.x*0.5f; |
| 275 |
pText.y-=labelSize.y+ImGui::GetStyle().ItemSpacing.y; |
| 276 |
dl->AddText(pText,0xff404040,label.c_str()); |
| 277 |
} |
| 278 |
} |
| 279 |
} else { |
| 280 |
int bottomNotes=7*oct; |
| 281 |
// evaluate input |
| 282 |
if (canInput) for (TouchPoint& i: activePoints) { |
| 283 |
if (rect.Contains(ImVec2(i.x,i.y))) { |
| 284 |
// top |
| 285 |
int o=((i.x-rect.Min.x)/(rect.Max.x-rect.Min.x))*oct; |
| 286 |
ImVec2 op0=ImLerp(rect.Min,rect.Max,ImVec2((float)o/oct,0.0f)); |
| 287 |
ImVec2 op1=ImLerp(rect.Min,rect.Max,ImVec2((float)(o+1)/oct,1.0f)); |
| 288 |
bool foundTopKey=false; |
| 289 |
|
| 290 |
for (int j=0; j<5; j++) { |
| 291 |
int note=topKeyNotes[j]+12*(o+off); |
| 292 |
if (note<0) continue; |
| 293 |
if (note>=180) continue; |
| 294 |
ImRect keyRect=ImRect( |
| 295 |
ImLerp(op0,op1,ImVec2(topKeyStarts[j]-0.05f,0.0f)), |
| 296 |
ImLerp(op0,op1,ImVec2(topKeyStarts[j]+0.05f,0.64f)) |
| 297 |
); |
| 298 |
if (keyRect.Contains(ImVec2(i.x,i.y))) { |
| 299 |
pianoKeyPressed[note]=true; |
| 300 |
foundTopKey=true; |
| 301 |
break; |
| 302 |
} |
| 303 |
} |
| 304 |
if (foundTopKey) continue; |
| 305 |
|
| 306 |
// bottom |
| 307 |
int n=((i.x-rect.Min.x)/(rect.Max.x-rect.Min.x))*bottomNotes; |
| 308 |
int note=bottomKeyNotes[n%7]+12*((n/7)+off); |
| 309 |
if (note<0) continue; |
| 310 |
if (note>=180) continue; |
| 311 |
pianoKeyPressed[note]=true; |
| 312 |
} |
| 313 |
} |
| 314 |
|
| 315 |
for (int i=0; i<bottomNotes; i++) { |
| 316 |
int note=bottomKeyNotes[i%7]+12*((i/7)+off); |
| 317 |
if (note<0) continue; |
| 318 |
if (note>=180) continue; |
| 319 |
|
| 320 |
float pkh=pianoKeyHit[note]; |
| 321 |
ImVec4 color=uiColors[GUI_COLOR_PIANO_KEY_BOTTOM]; |
| 322 |
if (pianoKeyPressed[note]) { |
| 323 |
color=uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_ACTIVE]; |
| 324 |
} else { |
| 325 |
ImVec4 colorHit=uiColors[GUI_COLOR_PIANO_KEY_BOTTOM_HIT]; |
| 326 |
color.x+=(colorHit.x-color.x)*pkh; |
| 327 |
color.y+=(colorHit.y-color.y)*pkh; |
| 328 |
color.z+=(colorHit.z-color.z)*pkh; |
| 329 |
color.w+=(colorHit.w-color.w)*pkh; |
| 330 |
} |
| 331 |
|
| 332 |
ImVec2 p0=ImLerp(rect.Min,rect.Max,ImVec2((float)i/bottomNotes,0.0f)); |
| 333 |
ImVec2 p1=ImLerp(rect.Min,rect.Max,ImVec2((float)(i+1)/bottomNotes,1.0f)); |
| 334 |
p1.x-=dpiScale; |
| 335 |
|
| 336 |
dl->AddRectFilled(p0,p1,ImGui::ColorConvertFloat4ToU32(color)); |
| 337 |
if ((i%7)==0) { |
| 338 |
String label=fmt::sprintf("%d",(note-60)/12); |
| 339 |
ImVec2 pText=ImLerp(p0,p1,ImVec2(0.5f,1.0f)); |
| 340 |
ImVec2 labelSize=ImGui::CalcTextSize(label.c_str()); |
| 341 |
pText.x-=labelSize.x*0.5f; |
| 342 |
pText.y-=labelSize.y+ImGui::GetStyle().ItemSpacing.y; |
| 343 |
dl->AddText(pText,0xff404040,label.c_str()); |
| 344 |
} |
| 345 |
} |
| 346 |
|
| 347 |
for (int i=0; i<oct; i++) { |
| 348 |
ImVec2 op0=ImLerp(rect.Min,rect.Max,ImVec2((float)i/oct,0.0f)); |
| 349 |
ImVec2 op1=ImLerp(rect.Min,rect.Max,ImVec2((float)(i+1)/oct,1.0f)); |
| 350 |
|
| 351 |
for (int j=0; j<5; j++) { |
| 352 |
int note=topKeyNotes[j]+12*(i+off); |
| 353 |
if (note<0) continue; |
| 354 |
if (note>=180) continue; |
| 355 |
float pkh=pianoKeyHit[note]; |
| 356 |
ImVec4 color=uiColors[GUI_COLOR_PIANO_KEY_TOP]; |
| 357 |
if (pianoKeyPressed[note]) { |
| 358 |
color=uiColors[GUI_COLOR_PIANO_KEY_TOP_ACTIVE]; |
| 359 |
} else { |
| 360 |
ImVec4 colorHit=uiColors[GUI_COLOR_PIANO_KEY_TOP_HIT]; |
| 361 |
color.x+=(colorHit.x-color.x)*pkh; |
| 362 |
color.y+=(colorHit.y-color.y)*pkh; |
| 363 |
color.z+=(colorHit.z-color.z)*pkh; |
| 364 |
color.w+=(colorHit.w-color.w)*pkh; |
| 365 |
} |
| 366 |
ImVec2 p0=ImLerp(op0,op1,ImVec2(topKeyStarts[j]-0.05f,0.0f)); |
| 367 |
ImVec2 p1=ImLerp(op0,op1,ImVec2(topKeyStarts[j]+0.05f,0.64f)); |
| 368 |
dl->AddRectFilled(p0,p1,ImGui::GetColorU32(uiColors[GUI_COLOR_PIANO_BACKGROUND])); |
| 369 |
p0.x+=dpiScale; |
| 370 |
p1.x-=dpiScale; |
| 371 |
p1.y-=dpiScale; |
| 372 |
dl->AddRectFilled(p0,p1,ImGui::ColorConvertFloat4ToU32(color)); |
| 373 |
} |
| 374 |
} |
| 375 |
} |
| 376 |
|
| 377 |
const float reduction=ImGui::GetIO().DeltaTime*60.0f*0.12; |
| 378 |
for (int i=0; i<180; i++) { |
| 379 |
pianoKeyHit[i]-=reduction; |
| 380 |
if (pianoKeyHit[i]<0) pianoKeyHit[i]=0; |
| 381 |
} |
| 382 |
} |
| 383 |
|
| 384 |
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { |
| 385 |
pianoOptions=!pianoOptions; |
| 386 |
} |
| 387 |
|
| 388 |
// first check released keys |
| 389 |
for (int i=0; i<180; i++) { |
| 390 |
int note=i-60; |
| 391 |
if (!pianoKeyPressed[i]) { |
| 392 |
if (pianoKeyPressed[i]!=oldPianoKeyPressed[i]) { |
| 393 |
switch (curWindow) { |
| 394 |
case GUI_WINDOW_WAVE_LIST: |
| 395 |
case GUI_WINDOW_WAVE_EDIT: |
| 396 |
e->stopWavePreview(); |
| 397 |
break; |
| 398 |
case GUI_WINDOW_SAMPLE_LIST: |
| 399 |
case GUI_WINDOW_SAMPLE_EDIT: |
| 400 |
e->stopSamplePreview(); |
| 401 |
break; |
| 402 |
default: |
| 403 |
e->synchronized([this,note]() { |
| 404 |
e->autoNoteOff(-1,note); |
| 405 |
failedNoteOn=false; |
| 406 |
}); |
| 407 |
break; |
| 408 |
} |
| 409 |
} |
| 410 |
} |
| 411 |
} |
| 412 |
// then pressed ones |
| 413 |
for (int i=0; i<180; i++) { |
| 414 |
int note=i-60; |
| 415 |
if (pianoKeyPressed[i]) { |
| 416 |
if (pianoKeyPressed[i]!=oldPianoKeyPressed[i]) { |
| 417 |
switch (curWindow) { |
| 418 |
case GUI_WINDOW_WAVE_LIST: |
| 419 |
case GUI_WINDOW_WAVE_EDIT: |
| 420 |
e->previewWave(curWave,note); |
| 421 |
break; |
| 422 |
case GUI_WINDOW_SAMPLE_LIST: |
| 423 |
case GUI_WINDOW_SAMPLE_EDIT: |
| 424 |
e->previewSample(curSample,note); |
| 425 |
break; |
| 426 |
default: |
| 427 |
if (sampleMapWaitingInput) { |
| 428 |
alterSampleMap(1,note); |
| 429 |
} else { |
| 430 |
e->synchronized([this,note]() { |
| 431 |
if (!e->autoNoteOn(-1,curIns,note)) failedNoteOn=true; |
| 432 |
}); |
| 433 |
if (edit && curWindow!=GUI_WINDOW_INS_LIST && curWindow!=GUI_WINDOW_INS_EDIT) noteInput(note,0); |
| 434 |
} |
| 435 |
break; |
| 436 |
} |
| 437 |
} |
| 438 |
} |
| 439 |
} |
| 440 |
} |
| 441 |
|
| 442 |
ImGui::EndTable(); |
| 443 |
} |
| 444 |
} |
| 445 |
// don't worry about it |
| 446 |
//if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_PIANO; |
| 447 |
ImGui::End(); |
| 448 |
|
| 449 |
// draw input pad if necessary |
| 450 |
if ((curWindow==GUI_WINDOW_ORDERS || curWindow==GUI_WINDOW_PATTERN || !mobileUI) && ((pianoInputPadMode==PIANO_INPUT_PAD_SPLIT_AUTO && (cursor.xFine>0 || (curWindow==GUI_WINDOW_ORDERS && orderEditMode>0))) || pianoInputPadMode==PIANO_INPUT_PAD_SPLIT_VISIBLE)) { |
| 451 |
if (ImGui::Begin("Input Pad",NULL,ImGuiWindowFlags_NoTitleBar)) { |
| 452 |
ImGui::BeginDisabled(cursor.xFine==0 && !(curWindow==GUI_WINDOW_ORDERS && orderEditMode>0)); |
| 453 |
if (ImGui::BeginTable("InputPad",3,ImGuiTableFlags_Borders)) { |
| 454 |
ImGui::TableNextRow(); |
| 455 |
ImGui::TableNextColumn(); |
| 456 |
ImVec2 buttonSize=ImGui::GetContentRegionAvail(); |
| 457 |
buttonSize.y/=6.0f; |
| 458 |
buttonSize.y-=ImGui::GetStyle().CellPadding.y*2.0f; |
| 459 |
|
| 460 |
VALUE_DIGIT(10,"A"); |
| 461 |
ImGui::TableNextColumn(); |
| 462 |
VALUE_DIGIT(11,"B"); |
| 463 |
ImGui::TableNextColumn(); |
| 464 |
VALUE_DIGIT(12,"C"); |
| 465 |
ImGui::TableNextRow(); |
| 466 |
ImGui::TableNextColumn(); |
| 467 |
VALUE_DIGIT(13,"D"); |
| 468 |
ImGui::TableNextColumn(); |
| 469 |
VALUE_DIGIT(14,"E"); |
| 470 |
ImGui::TableNextColumn(); |
| 471 |
VALUE_DIGIT(15,"F"); |
| 472 |
|
| 473 |
ImGui::TableNextRow(); |
| 474 |
ImGui::TableNextColumn(); |
| 475 |
VALUE_DIGIT(1,"1"); |
| 476 |
ImGui::TableNextColumn(); |
| 477 |
VALUE_DIGIT(2,"2"); |
| 478 |
ImGui::TableNextColumn(); |
| 479 |
VALUE_DIGIT(3,"3"); |
| 480 |
ImGui::TableNextRow(); |
| 481 |
ImGui::TableNextColumn(); |
| 482 |
VALUE_DIGIT(4,"4"); |
| 483 |
ImGui::TableNextColumn(); |
| 484 |
VALUE_DIGIT(5,"5"); |
| 485 |
ImGui::TableNextColumn(); |
| 486 |
VALUE_DIGIT(6,"6"); |
| 487 |
ImGui::TableNextRow(); |
| 488 |
ImGui::TableNextColumn(); |
| 489 |
VALUE_DIGIT(7,"7"); |
| 490 |
ImGui::TableNextColumn(); |
| 491 |
VALUE_DIGIT(8,"8"); |
| 492 |
ImGui::TableNextColumn(); |
| 493 |
VALUE_DIGIT(9,"9"); |
| 494 |
ImGui::TableNextRow(); |
| 495 |
ImGui::TableNextColumn(); |
| 496 |
if (ImGui::Button(ICON_FA_TIMES "##PianoDel",buttonSize)) { |
| 497 |
doDelete(); |
| 498 |
} |
| 499 |
ImGui::TableNextColumn(); |
| 500 |
VALUE_DIGIT(0,"0"); |
| 501 |
ImGui::TableNextColumn(); |
| 502 |
|
| 503 |
ImGui::EndTable(); |
| 504 |
} |
| 505 |
ImGui::EndDisabled(); |
| 506 |
} |
| 507 |
// don't worry about it either |
| 508 |
//if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_PIANO; |
| 509 |
ImGui::End(); |
| 510 |
} |
| 511 |
} |