Skip to content

Commit e23c11b

Browse files
committed
GUI: prepare to add different piano label modes
1 parent a7324cc commit e23c11b

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

src/gui/gui.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8351,6 +8351,7 @@ void FurnaceGUI::syncState() {
83518351
pianoOffsetEdit=e->getConfInt("pianoOffsetEdit",pianoOffsetEdit);
83528352
pianoView=e->getConfInt("pianoView",pianoView);
83538353
pianoInputPadMode=e->getConfInt("pianoInputPadMode",pianoInputPadMode);
8354+
pianoLabelsMode=e->getConfInt("pianoLabelsMode",pianoLabelsMode);
83548355

83558356
chanOscCols=e->getConfInt("chanOscCols",3);
83568357
chanOscAutoColsType=e->getConfInt("chanOscAutoColsType",0);
@@ -8512,6 +8513,7 @@ void FurnaceGUI::commitState(DivConfig& conf) {
85128513
conf.set("pianoOffsetEdit",pianoOffsetEdit);
85138514
conf.set("pianoView",pianoView);
85148515
conf.set("pianoInputPadMode",pianoInputPadMode);
8516+
conf.set("pianoLabelsMode",pianoLabelsMode);
85158517

85168518
// commit per-chan osc state
85178519
conf.set("chanOscCols",chanOscCols);
@@ -9164,6 +9166,7 @@ FurnaceGUI::FurnaceGUI():
91649166
pianoOffsetEdit(9),
91659167
pianoView(PIANO_LAYOUT_AUTOMATIC),
91669168
pianoInputPadMode(PIANO_INPUT_PAD_SPLIT_AUTO),
9169+
pianoLabelsMode(PIANO_LABELS_OCTAVE),
91679170
#else
91689171
pianoOctaves(7),
91699172
pianoOctavesEdit(4),
@@ -9174,6 +9177,7 @@ FurnaceGUI::FurnaceGUI():
91749177
pianoOffsetEdit(6),
91759178
pianoView(PIANO_LAYOUT_STANDARD),
91769179
pianoInputPadMode(PIANO_INPUT_PAD_DISABLE),
9180+
pianoLabelsMode(PIANO_LABELS_OCTAVE),
91779181
#endif
91789182
hasACED(false),
91799183
waveGenBaseShape(0),

src/gui/gui.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2777,13 +2777,21 @@ class FurnaceGUI {
27772777
PIANO_INPUT_PAD_MAX
27782778
};
27792779

2780+
enum PianoLabelsMode {
2781+
PIANO_LABELS_OFF=0,
2782+
PIANO_LABELS_OCTAVE,
2783+
PIANO_LABELS_NOTE,
2784+
PIANO_LABELS_OCTAVE_C,
2785+
PIANO_LABELS_OCTAVE_NOTE
2786+
};
2787+
27802788
int pianoOctaves, pianoOctavesEdit;
27812789
bool pianoOptions, pianoSharePosition, pianoOptionsSet;
27822790
float pianoKeyHit[180];
27832791
bool pianoKeyPressed[180];
27842792
bool pianoReadonly;
27852793
int pianoOffset, pianoOffsetEdit;
2786-
int pianoView, pianoInputPadMode;
2794+
int pianoView, pianoInputPadMode, pianoLabelsMode;
27872795

27882796
// effect sorting / searching
27892797
bool effectsShow[10];

src/gui/piano.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,24 @@ void FurnaceGUI::drawPiano() {
130130
pianoInputPadMode=PIANO_INPUT_PAD_SPLIT_VISIBLE;
131131
}
132132
ImGui::Unindent();
133+
ImGui::Text(_("Key labels:"));
134+
ImGui::Indent();
135+
if (ImGui::RadioButton(_("Disabled"),pianoLabelsMode==PIANO_LABELS_OFF)) {
136+
pianoLabelsMode=PIANO_LABELS_OFF;
137+
}
138+
if (ImGui::RadioButton(_("Octaves"),pianoLabelsMode==PIANO_LABELS_OCTAVE)) {
139+
pianoLabelsMode=PIANO_LABELS_OCTAVE;
140+
}
141+
if (ImGui::RadioButton(_("Notes"),pianoLabelsMode==PIANO_LABELS_NOTE)) {
142+
pianoLabelsMode=PIANO_LABELS_NOTE;
143+
}
144+
if (ImGui::RadioButton(_("Octaves (with C)"),pianoLabelsMode==PIANO_LABELS_OCTAVE_C)) {
145+
pianoLabelsMode=PIANO_LABELS_OCTAVE_C;
146+
}
147+
if (ImGui::RadioButton(_("Notes + Octaves"),pianoLabelsMode==PIANO_LABELS_OCTAVE_NOTE)) {
148+
pianoLabelsMode=PIANO_LABELS_OCTAVE_NOTE;
149+
}
150+
ImGui::Unindent();
133151
ImGui::Checkbox(_("Share play/edit offset/range"),&pianoSharePosition);
134152
ImGui::Checkbox(_("Read-only (can't input notes)"),&pianoReadonly);
135153
ImGui::EndPopup();
@@ -268,7 +286,12 @@ void FurnaceGUI::drawPiano() {
268286
p1.x-=dpiScale;
269287
dl->AddRectFilled(p0,p1,ImGui::ColorConvertFloat4ToU32(color));
270288
if ((i%12)==0) {
271-
String label=fmt::sprintf("%d",(note-60)/12);
289+
String label="";
290+
switch (pianoLabelsMode) {
291+
case PIANO_LABELS_OCTAVE:
292+
label=fmt::sprintf("%d",(note-60)/12);
293+
break;
294+
}
272295
ImVec2 pText=ImLerp(p0,p1,ImVec2(0.5f,1.0f));
273296
ImVec2 labelSize=ImGui::CalcTextSize(label.c_str());
274297
pText.x-=labelSize.x*0.5f;

0 commit comments

Comments
 (0)