From 447a86b2b1c9f79b3c46610d736dd28e27785bdf Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Sun, 25 Nov 2012 16:44:20 +0100 Subject: [PATCH] Support scrolling in X and Y --- ogl_editor/src/Editor.c | 17 ++++++++++++++--- ogl_editor/src/Editor.h | 2 +- ogl_editor/src/macosx/RocketView.m | 7 +++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ogl_editor/src/Editor.c b/ogl_editor/src/Editor.c index 40d4dcb..f55edda 100644 --- a/ogl_editor/src/Editor.c +++ b/ogl_editor/src/Editor.c @@ -837,15 +837,26 @@ bool Editor_keyDown(int key, int modifiers) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void Editor_scrollRow(int delta) +void Editor_scroll(int deltaX, int deltaY) { - int current_row = s_editorData.trackViewInfo.rowPos; + int i, current_row = s_editorData.trackViewInfo.rowPos; TrackViewInfo* viewInfo = &s_editorData.trackViewInfo; - current_row += delta; + current_row += deltaY; s_editorData.trackViewInfo.rowPos = eclampi(current_row, viewInfo->startRow, viewInfo->endRow); + if (deltaX < 0) + { + for (i = 0; i < -deltaX; ++i) + setActiveTrack(getPrevTrack()); + } + else if (deltaX > 0) + { + for (i = 0; i < deltaX; ++i) + setActiveTrack(getNextTrack()); + } + Editor_update(); } diff --git a/ogl_editor/src/Editor.h b/ogl_editor/src/Editor.h index c0bafa9..4e4da23 100644 --- a/ogl_editor/src/Editor.h +++ b/ogl_editor/src/Editor.h @@ -10,7 +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); +void Editor_scroll(int deltaX, int deltaY); enum { diff --git a/ogl_editor/src/macosx/RocketView.m b/ogl_editor/src/macosx/RocketView.m index b1bb1a8..558f450 100644 --- a/ogl_editor/src/macosx/RocketView.m +++ b/ogl_editor/src/macosx/RocketView.m @@ -150,8 +150,11 @@ NSOpenGLContext* g_context = 0; - (void)scrollWheel:(NSEvent *)theEvent { - float f = (float)[theEvent deltaY]; - Editor_scrollRow((int)-f); + float x = (float)[theEvent deltaX]; + float y = (float)[theEvent deltaY]; + + printf("%f %f\n", x, y); + Editor_scroll((int)-x, (int)-y); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////