diff options
| author | Jens Arnold <amiconn@rockbox.org> | 2005-04-10 17:36:55 +0000 |
|---|---|---|
| committer | Jens Arnold <amiconn@rockbox.org> | 2005-04-10 17:36:55 +0000 |
| commit | cef15c6efc2a0720a8b9b27cea036fc6ac82c829 (patch) | |
| tree | 0d0471293e7d14b39a56084c7876f749d15248cf | |
| parent | 06068b451d80a5949b080d756e082126245da180 (diff) | |
| download | rockbox-cef15c6efc2a0720a8b9b27cea036fc6ac82c829.zip rockbox-cef15c6efc2a0720a8b9b27cea036fc6ac82c829.tar.gz rockbox-cef15c6efc2a0720a8b9b27cea036fc6ac82c829.tar.bz2 rockbox-cef15c6efc2a0720a8b9b27cea036fc6ac82c829.tar.xz | |
FM preset menu: Set cursor to the current preset on enter. Added a generic function to the menu system which allows for setting the position.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6264 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | apps/menu.c | 12 | ||||
| -rw-r--r-- | apps/menu.h | 1 | ||||
| -rw-r--r-- | apps/recorder/radio.c | 2 |
3 files changed, 14 insertions, 1 deletions
diff --git a/apps/menu.c b/apps/menu.c index e483ad7..68b9d0d 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -166,7 +166,7 @@ void menu_draw(int m) #endif /* Adjust cursor pos if it's below the screen */ if (menus[m].cursor - menus[m].top >= menu_lines) - menus[m].top++; + menus[m].top = menus[m].cursor - (menu_lines - 1); /* Adjust cursor pos if it's above the screen */ if(menus[m].cursor < menus[m].top) @@ -508,3 +508,13 @@ bool menu_movedown(int menu) return true; } + +/* + * Allows to set the cursor position. Doesn't redraw by itself. + */ + +void menu_set_cursor(int menu, int position) +{ + menus[menu].cursor = position; +} + diff --git a/apps/menu.h b/apps/menu.h index 1171f0e..046153b 100644 --- a/apps/menu.h +++ b/apps/menu.h @@ -90,5 +90,6 @@ bool menu_moveup(int menu); bool menu_movedown(int menu); void menu_draw(int menu); void menu_insert(int menu, int position, char *desc, bool (*function) (void)); +void menu_set_cursor(int menu, int position); #endif /* End __MENU_H__ */ diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index 10a513f..59dd9dc 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c @@ -817,6 +817,8 @@ bool handle_radio_presets(void) str(LANG_FM_BUTTONBAR_ADD), str(LANG_FM_BUTTONBAR_EXIT), str(LANG_FM_BUTTONBAR_ACTION)); + if (curr_preset >= 0) + menu_set_cursor(preset_menu, curr_preset); result = menu_show(preset_menu); menu_exit(preset_menu); if (result == MENU_SELECTED_EXIT) |