Support scrolling in X and Y

This commit is contained in:
Daniel Collin 2012-11-25 16:44:20 +01:00
parent 5a2201537f
commit 447a86b2b1
3 changed files with 20 additions and 6 deletions

View File

@ -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();
}

View File

@ -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
{

View File

@ -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);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////