From 5a2201537f5f0a1cbb814a1d2702590cc5e34c34 Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Sun, 25 Nov 2012 16:32:25 +0100 Subject: [PATCH] Support for trackpad scrolling --- ogl_editor/src/Editor.c | 16 ++++++++++++++-- ogl_editor/src/Editor.h | 1 + ogl_editor/src/macosx/RocketView.m | 8 ++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ogl_editor/src/Editor.c b/ogl_editor/src/Editor.c index 6a91325..40d4dcb 100644 --- a/ogl_editor/src/Editor.c +++ b/ogl_editor/src/Editor.c @@ -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; diff --git a/ogl_editor/src/Editor.h b/ogl_editor/src/Editor.h index e522931..c0bafa9 100644 --- a/ogl_editor/src/Editor.h +++ b/ogl_editor/src/Editor.h @@ -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 { diff --git a/ogl_editor/src/macosx/RocketView.m b/ogl_editor/src/macosx/RocketView.m index a3e5864..b1bb1a8 100644 --- a/ogl_editor/src/macosx/RocketView.m +++ b/ogl_editor/src/macosx/RocketView.m @@ -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);