Minor cleanup in keyboard handling

This commit is contained in:
Daniel Collin 2012-11-03 12:47:56 +01:00
parent 2c580d71f5
commit afcaf7775d

View File

@ -141,7 +141,6 @@ void Editor_update()
Emgui_end(); Emgui_end();
} }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static char s_editBuffer[512]; static char s_editBuffer[512];
@ -155,12 +154,23 @@ bool Editor_keyDown(int key, int modifiers)
int active_track = getActiveTrack(); int active_track = getActiveTrack();
int row_pos = s_editorData.trackViewInfo.rowPos; int row_pos = s_editorData.trackViewInfo.rowPos;
if (key == ' ')
{
// TODO: Don't start playing if we are in edit mode (but space shouldn't be added in edit mode but we still
// shouldn't start playing if we do
RemoteConnection_sendPauseCommand(!paused);
Editor_update();
return true;
}
if (!paused)
return false;
switch (key) switch (key)
{ {
case EMGUI_ARROW_DOWN: case EMGUI_ARROW_DOWN:
{ {
if (paused)
{
int row = row_pos; int row = row_pos;
if (modifiers & EDITOR_KEY_ALT) if (modifiers & EDITOR_KEY_ALT)
@ -172,15 +182,12 @@ bool Editor_keyDown(int key, int modifiers)
RemoteConnection_sendSetRowCommand(row); RemoteConnection_sendSetRowCommand(row);
handled_key = true; handled_key = true;
}
break; break;
} }
case EMGUI_ARROW_UP: case EMGUI_ARROW_UP:
{ {
if (paused)
{
int row = row_pos; int row = row_pos;
if (modifiers & EDITOR_KEY_ALT) if (modifiers & EDITOR_KEY_ALT)
@ -198,14 +205,12 @@ bool Editor_keyDown(int key, int modifiers)
RemoteConnection_sendSetRowCommand(row); RemoteConnection_sendSetRowCommand(row);
handled_key = true; handled_key = true;
}
break; break;
} }
case EMGUI_ARROW_LEFT: case EMGUI_ARROW_LEFT:
{ {
if (paused)
{
int track = getActiveTrack(); track--; int track = getActiveTrack(); track--;
if (modifiers & EDITOR_KEY_COMMAND) if (modifiers & EDITOR_KEY_COMMAND)
@ -214,15 +219,12 @@ bool Editor_keyDown(int key, int modifiers)
setActiveTrack(track < 0 ? 0 : track); setActiveTrack(track < 0 ? 0 : track);
handled_key = true; handled_key = true;
}
break; break;
} }
case EMGUI_ARROW_RIGHT: case EMGUI_ARROW_RIGHT:
{ {
if (paused)
{
int track = getActiveTrack(); track++; int track = getActiveTrack(); track++;
int track_count = getTrackCount(); int track_count = getTrackCount();
@ -235,7 +237,6 @@ bool Editor_keyDown(int key, int modifiers)
setActiveTrack(track); setActiveTrack(track);
handled_key = true; handled_key = true;
}
break; break;
} }
@ -245,8 +246,6 @@ bool Editor_keyDown(int key, int modifiers)
// do edit here // do edit here
if (paused)
{
if ((key >= '0' && key <= '9') || key == '.' || key == '-') if ((key >= '0' && key <= '9') || key == '.' || key == '-')
{ {
if (!is_editing) if (!is_editing)
@ -300,16 +299,6 @@ bool Editor_keyDown(int key, int modifiers)
handled_key = true; handled_key = true;
} }
}
if (key == ' ')
{
// TODO: Don't start playing if we are in edit mode (but space shouldn't be added in edit mode but we still
// shouldn't start playing if we do
RemoteConnection_sendPauseCommand(!paused);
handled_key = true;
}
if (handled_key) if (handled_key)
Editor_update(); Editor_update();