Support for trackpad scrolling

This commit is contained in:
Daniel Collin 2012-11-25 16:32:25 +01:00
parent 5f1b90ee93
commit 5a2201537f
3 changed files with 23 additions and 2 deletions

View File

@ -168,7 +168,6 @@ void Editor_init()
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static char s_currentTrack[64] = "0";
static char s_currentRow[64] = "0";
static char s_startRow[64] = "0";
static char s_endRow[64] = "10000";
@ -278,7 +277,6 @@ static void drawStatus()
size = drawConnectionStatus(0, sizeY);
size += drawCurrentValue(size, sizeY);
size += drawNameValue("Track", size, sizeY, &s_editorData.trackData.activeTrack, 0, emaxi(0, getTrackCount() - 1), s_currentTrack);
size += drawNameValue("Row", size, sizeY, &s_editorData.trackViewInfo.rowPos, 0, 20000 - 1, s_currentRow);
size += drawNameValue("Start Row", size, sizeY, &s_editorData.trackViewInfo.startRow, 0, 10000000, s_startRow);
size += drawNameValue("End Row", size, sizeY, &s_editorData.trackViewInfo.endRow, 0, 10000000, s_endRow);
@ -839,6 +837,20 @@ bool Editor_keyDown(int key, int modifiers)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Editor_scrollRow(int delta)
{
int current_row = s_editorData.trackViewInfo.rowPos;
TrackViewInfo* viewInfo = &s_editorData.trackViewInfo;
current_row += delta;
s_editorData.trackViewInfo.rowPos = eclampi(current_row, viewInfo->startRow, viewInfo->endRow);
Editor_update();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static int processCommands()
{
int strLen, newRow, serverIndex;

View File

@ -10,6 +10,7 @@ void Editor_timedUpdate();
bool Editor_keyDown(int keyCode, int mod);
void Editor_setWindowSize(int x, int y);
void Editor_menuEvent(int menuItem);
void Editor_scrollRow(int delta);
enum
{

View File

@ -148,6 +148,14 @@ NSOpenGLContext* g_context = 0;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- (void)scrollWheel:(NSEvent *)theEvent
{
float f = (float)[theEvent deltaY];
Editor_scrollRow((int)-f);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- (void)mouseUp:(NSEvent *)event
{
Emgui_setMouseLmb(0);