@@ -142,12 +142,21 @@ bool NoteControlBar::KeyEvent(Point xy, KeyInfo* keyInfo) {
142142 // Chord Mode
143143 else if (xy == Point (3 , CTL_BAR_Y - 1 )) {
144144 if (keyInfo->State () == PRESSED ) {
145- if (mode == CHORD_MODE ) {
145+ if (ShiftActive ()) {
146+ // Shift click: Toggle the toggle mode (turn on chord mode if off)
147+ if (mode != CHORD_MODE ) {
148+ mode = CHORD_MODE ;
149+ }
150+ chordToggleMode = !chordToggleMode;
151+ ShiftEventOccured ();
152+ }
153+ else if (mode == CHORD_MODE ) {
146154 // Already on: turn off
147155 mode = OFF_MODE ;
148156 } else {
149157 // Off: turn on without toggle mode
150158 mode = CHORD_MODE ;
159+ chordToggleMode = false ;
151160 }
152161 }
153162 return true ;
@@ -243,36 +252,32 @@ bool NoteControlBar::ChordControlKeyEvent(Point xy, KeyInfo* keyInfo) {
243252 ChordCombo combo = notePad[0 ]->rt ->chordEffect .chordCombo ;
244253
245254 if (keyInfo->State () == PRESSED ) {
246- // Count how many chord types are currently on
247- int typeCount = (combo.dim ? 1 : 0 ) + (combo.min ? 1 : 0 ) + (combo.maj ? 1 : 0 ) + (combo.sus ? 1 : 0 );
248-
249- // Check which chord type is currently active
250- int activeChord = -1 ;
251- if (combo.dim ) activeChord = 0 ;
252- else if (combo.min ) activeChord = 1 ;
253- else if (combo.maj ) activeChord = 2 ;
254- else if (combo.sus ) activeChord = 3 ;
255-
256- // If tapping the exact chord that's currently the only one on, disable it
257- if (typeCount == 1 && activeChord == xy.x ) {
258- combo.dim = false ;
259- combo.min = false ;
260- combo.maj = false ;
261- combo.sus = false ;
262- } else {
263- // Otherwise, clear all and set the new one
264- combo.dim = false ;
265- combo.min = false ;
266- combo.maj = false ;
267- combo.sus = false ;
268-
255+ bool chordTypes[4 ] = {combo.dim , combo.min , combo.maj , combo.sus };
256+ bool wasActive = chordTypes[xy.x ];
257+
258+ // Clear all basic chord types
259+ combo.dim = false ;
260+ combo.min = false ;
261+ combo.maj = false ;
262+ combo.sus = false ;
263+
264+ // In toggle mode, only set if wasn't already active
265+ // In momentary mode, always set
266+ if (!chordToggleMode || !wasActive) {
269267 switch (xy.x ) {
270268 case 0 : combo.dim = true ; break ;
271269 case 1 : combo.min = true ; break ;
272270 case 2 : combo.maj = true ; break ;
273271 case 3 : combo.sus = true ; break ;
274272 }
275273 }
274+ } else if (keyInfo->State () == RELEASED && !ShiftActive () && !chordToggleMode) {
275+ switch (xy.x ) {
276+ case 0 : combo.dim = false ; break ;
277+ case 1 : combo.min = false ; break ;
278+ case 2 : combo.maj = false ; break ;
279+ case 3 : combo.sus = false ; break ;
280+ }
276281 } else {
277282 return true ;
278283 }
@@ -286,45 +291,28 @@ bool NoteControlBar::ChordControlKeyEvent(Point xy, KeyInfo* keyInfo) {
286291 ChordCombo combo = notePad[0 ]->rt ->chordEffect .chordCombo ;
287292
288293 if (keyInfo->State () == PRESSED ) {
289- // Check if any extension key is already pressed
290- bool anyKeyPressed = chordExtKeyOn[0 ] || chordExtKeyOn[1 ] || chordExtKeyOn[2 ] || chordExtKeyOn[3 ];
291-
292- // Count how many extensions are currently on
293- int extCount = (combo.ext6 ? 1 : 0 ) + (combo.extMin7 ? 1 : 0 ) + (combo.extMaj7 ? 1 : 0 ) + (combo.ext9 ? 1 : 0 );
294-
295- // Check which extension is currently active
296- int activeExt = -1 ;
297- if (combo.ext6 ) activeExt = 0 ;
298- else if (combo.extMin7 ) activeExt = 1 ;
299- else if (combo.extMaj7 ) activeExt = 2 ;
300- else if (combo.ext9 ) activeExt = 3 ;
301-
302- // If tapping the exact extension that's currently the only one on, disable it
303- if (extCount == 1 && activeExt == xy.x ) {
304- combo.ext6 = false ;
305- combo.extMin7 = false ;
306- combo.extMaj7 = false ;
307- combo.ext9 = false ;
308- } else {
309- // If no keys are pressed, clear all extensions before setting the new one
310- if (!anyKeyPressed) {
311- combo.ext6 = false ;
312- combo.extMin7 = false ;
313- combo.extMaj7 = false ;
314- combo.ext9 = false ;
294+ if (chordToggleMode) {
295+ switch (xy.x ) {
296+ case 0 : combo.ext6 = !combo.ext6 ; break ;
297+ case 1 : combo.extMin7 = !combo.extMin7 ; break ;
298+ case 2 : combo.extMaj7 = !combo.extMaj7 ; break ;
299+ case 3 : combo.ext9 = !combo.ext9 ; break ;
315300 }
316-
317- // Set the pressed key's extension and mark it as pressed
301+ } else {
318302 switch (xy.x ) {
319- case 0 : combo.ext6 = true ; chordExtKeyOn[ 0 ] = true ; break ;
320- case 1 : combo.extMin7 = true ; chordExtKeyOn[ 1 ] = true ; break ;
321- case 2 : combo.extMaj7 = true ; chordExtKeyOn[ 2 ] = true ; break ;
322- case 3 : combo.ext9 = true ; chordExtKeyOn[ 3 ] = true ; break ;
303+ case 0 : combo.ext6 = true ; break ;
304+ case 1 : combo.extMin7 = true ; break ;
305+ case 2 : combo.extMaj7 = true ; break ;
306+ case 3 : combo.ext9 = true ; break ;
323307 }
324308 }
325- } else if (keyInfo->State () == RELEASED ) {
326- // Clear the pressed flag but don't turn off the extension
327- chordExtKeyOn[xy.x ] = false ;
309+ } else if (keyInfo->State () == RELEASED && !ShiftActive () && !chordToggleMode) {
310+ switch (xy.x ) {
311+ case 0 : combo.ext6 = false ; break ;
312+ case 1 : combo.extMin7 = false ; break ;
313+ case 2 : combo.extMaj7 = false ; break ;
314+ case 3 : combo.ext9 = false ; break ;
315+ }
328316 } else {
329317 return true ;
330318 }
@@ -471,7 +459,7 @@ bool NoteControlBar::Render(Point origin) {
471459
472460 Color chordColor;
473461 if (mode == CHORD_MODE ) {
474- chordColor = Color::White;
462+ chordColor = chordToggleMode ? Color ( 0x6060FF ) : Color::White;
475463 } else {
476464 chordColor = Color (0x00FFFF );
477465 }
0 commit comments