GUI: move all preview actions to callback
This commit is contained in:
		
							parent
							
								
									6b294933bc
								
							
						
					
					
						commit
						a81393472c
					
				|  | @ -1179,45 +1179,6 @@ void FurnaceGUI::keyDown(SDL_Event& ev) { | ||||||
|     } |     } | ||||||
|   } catch (std::out_of_range& e) { |   } catch (std::out_of_range& e) { | ||||||
|   } |   } | ||||||
| 
 |  | ||||||
|   // PER-WINDOW PREVIEW KEYS
 |  | ||||||
|   // TODO: move this to new event handler
 |  | ||||||
|   switch (curWindow) { |  | ||||||
|     case GUI_WINDOW_SAMPLE_EDIT: |  | ||||||
|     case GUI_WINDOW_SAMPLE_LIST: |  | ||||||
|       if (!ev.key.repeat) { |  | ||||||
|         try { |  | ||||||
|           int key=noteKeys.at(ev.key.keysym.scancode); |  | ||||||
|           int num=12*curOctave+key; |  | ||||||
|           if (key!=100 && key!=101 && key!=102) { |  | ||||||
|             e->previewSample(curSample,num); |  | ||||||
|             samplePreviewOn=true; |  | ||||||
|             samplePreviewKey=ev.key.keysym.scancode; |  | ||||||
|             samplePreviewNote=num; |  | ||||||
|           } |  | ||||||
|         } catch (std::out_of_range& e) { |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|       break; |  | ||||||
|     case GUI_WINDOW_WAVE_LIST: |  | ||||||
|     case GUI_WINDOW_WAVE_EDIT: |  | ||||||
|       if (!ev.key.repeat) { |  | ||||||
|         try { |  | ||||||
|           int key=noteKeys.at(ev.key.keysym.scancode); |  | ||||||
|           int num=12*curOctave+key; |  | ||||||
|           if (key!=100 && key!=101 && key!=102) { |  | ||||||
|             e->previewWave(curWave,num); |  | ||||||
|             wavePreviewOn=true; |  | ||||||
|             wavePreviewKey=ev.key.keysym.scancode; |  | ||||||
|             wavePreviewNote=num; |  | ||||||
|           } |  | ||||||
|         } catch (std::out_of_range& e) { |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|       break; |  | ||||||
|     default: |  | ||||||
|       break; |  | ||||||
|   } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void FurnaceGUI::keyUp(SDL_Event& ev) { | void FurnaceGUI::keyUp(SDL_Event& ev) { | ||||||
|  | @ -1998,7 +1959,39 @@ int _processEvent(void* instance, SDL_Event* event) { | ||||||
| 
 | 
 | ||||||
| int FurnaceGUI::processEvent(SDL_Event* ev) { | int FurnaceGUI::processEvent(SDL_Event* ev) { | ||||||
|   if (ev->type==SDL_KEYDOWN) { |   if (ev->type==SDL_KEYDOWN) { | ||||||
|     if (!ev->key.repeat) { |     if (!ev->key.repeat && !wantCaptureKeyboard) { | ||||||
|  |       switch (curWindow) { | ||||||
|  |         case GUI_WINDOW_SAMPLE_EDIT: | ||||||
|  |         case GUI_WINDOW_SAMPLE_LIST: | ||||||
|  |           try { | ||||||
|  |             int key=noteKeys.at(ev->key.keysym.scancode); | ||||||
|  |             int num=12*curOctave+key; | ||||||
|  |             if (key!=100 && key!=101 && key!=102) { | ||||||
|  |               e->previewSample(curSample,num); | ||||||
|  |               samplePreviewOn=true; | ||||||
|  |               samplePreviewKey=ev->key.keysym.scancode; | ||||||
|  |               samplePreviewNote=num; | ||||||
|  |             } | ||||||
|  |           } catch (std::out_of_range& e) { | ||||||
|  |           } | ||||||
|  |           break; | ||||||
|  |         case GUI_WINDOW_WAVE_LIST: | ||||||
|  |         case GUI_WINDOW_WAVE_EDIT: | ||||||
|  |           try { | ||||||
|  |             int key=noteKeys.at(ev->key.keysym.scancode); | ||||||
|  |             int num=12*curOctave+key; | ||||||
|  |             if (key!=100 && key!=101 && key!=102) { | ||||||
|  |               e->previewWave(curWave,num); | ||||||
|  |               wavePreviewOn=true; | ||||||
|  |               wavePreviewKey=ev->key.keysym.scancode; | ||||||
|  |               wavePreviewNote=num; | ||||||
|  |             } | ||||||
|  |           } catch (std::out_of_range& e) { | ||||||
|  |           } | ||||||
|  |           break; | ||||||
|  |         case GUI_WINDOW_ORDERS: // ignore here
 | ||||||
|  |           break; | ||||||
|  |         default: | ||||||
|           try { |           try { | ||||||
|             int key=noteKeys.at(ev->key.keysym.scancode); |             int key=noteKeys.at(ev->key.keysym.scancode); | ||||||
|             int num=12*curOctave+key; |             int num=12*curOctave+key; | ||||||
|  | @ -2011,6 +2004,8 @@ int FurnaceGUI::processEvent(SDL_Event* ev) { | ||||||
|             } |             } | ||||||
|           } catch (std::out_of_range& e) { |           } catch (std::out_of_range& e) { | ||||||
|           } |           } | ||||||
|  |           break; | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   } else if (ev->type==SDL_KEYUP) { |   } else if (ev->type==SDL_KEYUP) { | ||||||
|     stopPreviewNote(ev->key.keysym.scancode,true); |     stopPreviewNote(ev->key.keysym.scancode,true); | ||||||
|  | @ -2168,6 +2163,8 @@ bool FurnaceGUI::loop() { | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     wantCaptureKeyboard=ImGui::GetIO().WantCaptureKeyboard; | ||||||
|  |      | ||||||
|     while (true) { |     while (true) { | ||||||
|       midiLock.lock(); |       midiLock.lock(); | ||||||
|       if (midiQueue.empty()) { |       if (midiQueue.empty()) { | ||||||
|  | @ -3417,6 +3414,7 @@ FurnaceGUI::FurnaceGUI(): | ||||||
|   displayError(false), |   displayError(false), | ||||||
|   displayExporting(false), |   displayExporting(false), | ||||||
|   vgmExportLoop(true), |   vgmExportLoop(true), | ||||||
|  |   wantCaptureKeyboard(false), | ||||||
|   displayNew(false), |   displayNew(false), | ||||||
|   vgmExportVersion(0x171), |   vgmExportVersion(0x171), | ||||||
|   curFileDialog(GUI_FILE_OPEN), |   curFileDialog(GUI_FILE_OPEN), | ||||||
|  |  | ||||||
|  | @ -711,7 +711,7 @@ class FurnaceGUI { | ||||||
|   String mmlString[17]; |   String mmlString[17]; | ||||||
|   String mmlStringW; |   String mmlStringW; | ||||||
| 
 | 
 | ||||||
|   bool quit, warnQuit, willCommit, edit, modified, displayError, displayExporting, vgmExportLoop; |   bool quit, warnQuit, willCommit, edit, modified, displayError, displayExporting, vgmExportLoop, wantCaptureKeyboard; | ||||||
|   bool displayNew; |   bool displayNew; | ||||||
|   bool willExport[32]; |   bool willExport[32]; | ||||||
|   int vgmExportVersion; |   int vgmExportVersion; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 tildearrow
						tildearrow