From 54cbacc96339be309a84b963c5c1eac169b4e241 Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Fri, 18 Oct 2013 19:45:40 +0200 Subject: [PATCH] Implemented 2x highlight row jump with PageUp/Down Closes #77 --- ogl_editor/emgui/include/emgui/Emgui.h | 3 +++ ogl_editor/emgui/src/Emgui.h | 3 +++ ogl_editor/src/Editor.c | 2 ++ ogl_editor/src/Menu.c | 2 ++ ogl_editor/src/Menu.h | 2 ++ ogl_editor/src/macosx/RocketView.m | 44 ++++++++++++++++++---------------- ogl_editor/src/windows/RocketWindow.c | 4 ++++ 7 files changed, 40 insertions(+), 20 deletions(-) diff --git a/ogl_editor/emgui/include/emgui/Emgui.h b/ogl_editor/emgui/include/emgui/Emgui.h index 5a7c186..9ae98c5 100644 --- a/ogl_editor/emgui/include/emgui/Emgui.h +++ b/ogl_editor/emgui/include/emgui/Emgui.h @@ -24,6 +24,9 @@ enum EmguiSpecialKey EMGUI_KEY_ARROW_RIGHT, EMGUI_KEY_ARROW_LEFT, + EMGUI_KEY_PAGE_UP, + EMGUI_KEY_PAGE_DOWN, + EMGUI_KEY_ESC, EMGUI_KEY_TAB, EMGUI_KEY_BACKSPACE, diff --git a/ogl_editor/emgui/src/Emgui.h b/ogl_editor/emgui/src/Emgui.h index b51f7db..1e5e8c0 100644 --- a/ogl_editor/emgui/src/Emgui.h +++ b/ogl_editor/emgui/src/Emgui.h @@ -22,6 +22,9 @@ enum EmguiSpecialKey EMGUI_KEY_ARROW_RIGHT, EMGUI_KEY_ARROW_LEFT, + EMGUI_KEY_PAGE_DOWN, + EMGUI_KEY_PAGE_UP, + EMGUI_KEY_ESC, EMGUI_KEY_TAB, EMGUI_KEY_BACKSPACE, diff --git a/ogl_editor/src/Editor.c b/ogl_editor/src/Editor.c index 3eb3ee4..83bf888 100644 --- a/ogl_editor/src/Editor.c +++ b/ogl_editor/src/Editor.c @@ -1475,6 +1475,8 @@ void Editor_menuEvent(int menuItem) case EDITOR_MENU_PLAY : onPlay(); break; case EDITOR_MENU_ROWS_UP : onRowStep(-highlightRowStep , NO_SELECTION); break; case EDITOR_MENU_ROWS_DOWN : onRowStep(highlightRowStep , NO_SELECTION); break; + case EDITOR_MENU_ROWS_2X_UP : onRowStep(-highlightRowStep * 2 , NO_SELECTION); break; + case EDITOR_MENU_ROWS_2X_DOWN : onRowStep(highlightRowStep * 2 , NO_SELECTION); break; case EDITOR_MENU_PREV_BOOKMARK : onBookmarkDir(ARROW_UP, NO_SELECTION); break; case EDITOR_MENU_NEXT_BOOKMARK : onBookmarkDir(ARROW_DOWN, NO_SELECTION); break; case EDITOR_MENU_FIRST_TRACK : onTrackSide(ARROW_LEFT, true, NO_SELECTION); break; diff --git a/ogl_editor/src/Menu.c b/ogl_editor/src/Menu.c index f626f6d..56dcbe0 100644 --- a/ogl_editor/src/Menu.c +++ b/ogl_editor/src/Menu.c @@ -55,6 +55,8 @@ MenuDescriptor g_viewMenu[] = { _T(""), EDITOR_MENU_SEPARATOR, 0, 0, 0 }, { _T("Jump 8 rows up"), EDITOR_MENU_ROWS_UP, EMGUI_KEY_ARROW_UP, EMGUI_KEY_ALT, EMGUI_KEY_ALT }, { _T("Jump 8 rows down"), EDITOR_MENU_ROWS_DOWN, EMGUI_KEY_ARROW_DOWN, EMGUI_KEY_ALT, EMGUI_KEY_ALT }, + { _T("Jump 16 rows up"), EDITOR_MENU_ROWS_2X_UP, EMGUI_KEY_PAGE_UP, 0, 0 }, + { _T("Jump 16 rows down"), EDITOR_MENU_ROWS_2X_DOWN, EMGUI_KEY_PAGE_DOWN, 0, 0 }, { _T("Jump to previous bookmark"), EDITOR_MENU_PREV_BOOKMARK, EMGUI_KEY_ARROW_UP, EMGUI_KEY_COMMAND, EMGUI_KEY_ALT | EMGUI_KEY_CTRL }, { _T("Jump to next bookmark"), EDITOR_MENU_NEXT_BOOKMARK, EMGUI_KEY_ARROW_DOWN, EMGUI_KEY_COMMAND, EMGUI_KEY_ALT | EMGUI_KEY_CTRL }, { _T("Jump to first track"), EDITOR_MENU_FIRST_TRACK, EMGUI_KEY_ARROW_LEFT, EMGUI_KEY_COMMAND, EMGUI_KEY_CTRL }, diff --git a/ogl_editor/src/Menu.h b/ogl_editor/src/Menu.h index 369a0a3..ee94b6d 100644 --- a/ogl_editor/src/Menu.h +++ b/ogl_editor/src/Menu.h @@ -61,6 +61,8 @@ enum EDITOR_MENU_TRACK_RIGHT, EDITOR_MENU_ROWS_DOWN, EDITOR_MENU_ROWS_UP, + EDITOR_MENU_ROWS_2X_DOWN, + EDITOR_MENU_ROWS_2X_UP, EDITOR_MENU_PREV_BOOKMARK, EDITOR_MENU_NEXT_BOOKMARK, EDITOR_MENU_FIRST_TRACK, diff --git a/ogl_editor/src/macosx/RocketView.m b/ogl_editor/src/macosx/RocketView.m index ba5106f..9d731e4 100644 --- a/ogl_editor/src/macosx/RocketView.m +++ b/ogl_editor/src/macosx/RocketView.m @@ -48,17 +48,17 @@ void Window_setTitle(const char* title); - (id)initWithFrame:(NSRect)frame { - self = [super initWithFrame:frame]; - if (self == nil) - return nil; + self = [super initWithFrame:frame]; + if (self == nil) + return nil; - NSOpenGLPixelFormatAttribute attributes[4]; + NSOpenGLPixelFormatAttribute attributes[4]; - attributes[0] = NSOpenGLPFADoubleBuffer; - attributes[1] = 0; + attributes[0] = NSOpenGLPFADoubleBuffer; + attributes[1] = 0; - NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; - oglContext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:nil]; + NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; + oglContext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:nil]; [oglContext makeCurrentContext]; g_context = oglContext; @@ -71,8 +71,8 @@ void Window_setTitle(const char* title); const float framerate = 60; const float frequency = 1.0f/framerate; [NSTimer scheduledTimerWithTimeInterval:frequency - target:self selector:@selector(updateEditor) - userInfo:nil repeats:YES]; + target:self selector:@selector(updateEditor) + userInfo:nil repeats:YES]; return self; } @@ -81,26 +81,26 @@ void Window_setTitle(const char* title); - (void)lockFocus { - NSOpenGLContext* context = oglContext; - - [super lockFocus]; - - if ([context view] != self) - [context setView:self]; - - [context makeCurrentContext]; + NSOpenGLContext* context = oglContext; + + [super lockFocus]; + + if ([context view] != self) + [context setView:self]; + + [context makeCurrentContext]; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - (void)drawRect:(NSRect)frameRect { - [oglContext update]; + [oglContext update]; g_window = [self window]; EMGFXBackend_updateViewPort((int)frameRect.size.width, (int)frameRect.size.height); Editor_setWindowSize((int)frameRect.size.width, (int)frameRect.size.height); - Editor_update(); + Editor_update(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -156,6 +156,8 @@ static int getModifierFlags(int flags) case KEY_DELETE : keyCode = EMGUI_KEY_BACKSPACE; break; case KEY_RETURN : keyCode = EMGUI_KEY_ENTER; break; case KEY_ESCAPE : keyCode = EMGUI_KEY_ESC; break; + case NSPageDownFunctionKey: keyCode = EMGUI_KEY_PAGE_DOWN; break; + case NSPageUpFunctionKey: keyCode = EMGUI_KEY_PAGE_UP; break; } } @@ -381,6 +383,8 @@ NSString* convertKeyCodeToString(int key) case EMGUI_KEY_SPACE : return @" "; case EMGUI_KEY_BACKSPACE : return [NSString stringWithFormat:@"%C",(uint16_t)0x232b]; case EMGUI_KEY_TAB : return [NSString stringWithFormat:@"%C",(uint16_t)0x21e4]; + case EMGUI_KEY_PAGE_UP : return [NSString stringWithFormat:@"%C",(uint16_t)0x21de]; + case EMGUI_KEY_PAGE_DOWN : return [NSString stringWithFormat:@"%C",(uint16_t)0x21df]; } } diff --git a/ogl_editor/src/windows/RocketWindow.c b/ogl_editor/src/windows/RocketWindow.c index 8de0247..3a15412 100644 --- a/ogl_editor/src/windows/RocketWindow.c +++ b/ogl_editor/src/windows/RocketWindow.c @@ -219,6 +219,8 @@ static void formatName(wchar_t* outName, int keyMod, int key, const wchar_t* nam case EMGUI_KEY_BACKSPACE: wcscpy_s(keyName, sizeof(keyName), L"Delete"); break; case EMGUI_KEY_ENTER: wcscpy_s(keyName, sizeof(keyName), L"Enter"); break; case EMGUI_KEY_SPACE: wcscpy_s(keyName, sizeof(keyName), L"Space"); break; + case EMGUI_KEY_PAGE_UP: wcscpy_s(keyName, sizeof(keyName), L"Page Up"); break; + case EMGUI_KEY_PAGE_DOWN: wcscpy_s(keyName, sizeof(keyName), L"Page Down"); break; } } @@ -268,6 +270,8 @@ static void addAccelarator(const MenuDescriptor* desc) case EMGUI_KEY_BACKSPACE: accel->key = VK_BACK; break; case EMGUI_KEY_ENTER: accel->key = VK_RETURN; break; case EMGUI_KEY_SPACE: accel->key = VK_SPACE; break; + case EMGUI_KEY_PAGE_DOWN: accel->key = VK_PAGE_DOWN; break; + case EMGUI_KEY_PAGE_UP: accel->key = VK_PAGE_UP; break; } }