diff options
| author | Jonathan Gordon <rockbox@jdgordon.info> | 2012-08-13 15:01:31 +1000 |
|---|---|---|
| committer | Jonathan Gordon <rockbox@jdgordon.info> | 2012-08-13 15:03:12 +1000 |
| commit | bd6e6ed40385c5d5f357a39909ae6a5db60f7ce9 (patch) | |
| tree | 5aeb6c05b307eadb2129b0b0d575c1e133deaa13 /apps/gui/folder_select.c | |
| parent | ca35628dc50689a526505489e0a34373cfa6f6d9 (diff) | |
| download | rockbox-bd6e6ed40385c5d5f357a39909ae6a5db60f7ce9.zip rockbox-bd6e6ed40385c5d5f357a39909ae6a5db60f7ce9.tar.gz rockbox-bd6e6ed40385c5d5f357a39909ae6a5db60f7ce9.tar.bz2 rockbox-bd6e6ed40385c5d5f357a39909ae6a5db60f7ce9.tar.xz | |
folder selector: handle long press to invert selection/select all.
Doing a LONG PRESS on a:
- unopened folder will select all its sub-folders
- opened folder will invert the selection of its sub-folders
Change-Id: Ia7fd8dc3b940f60adee3f0314bf6bba5eb2c7b3b
Diffstat (limited to 'apps/gui/folder_select.c')
| -rw-r--r-- | apps/gui/folder_select.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/apps/gui/folder_select.c b/apps/gui/folder_select.c index 512b73f..05354c4 100644 --- a/apps/gui/folder_select.c +++ b/apps/gui/folder_select.c @@ -300,11 +300,12 @@ static enum themable_icons folder_get_icon(int selected_item, void * data) static int folder_action_callback(int action, struct gui_synclist *list) { struct folder *root = (struct folder*)list->data; + struct folder *parent; + struct child *this = find_index(root, list->selected_item, &parent), *child; + int i; if (action == ACTION_STD_OK) { - struct folder *parent; - struct child *this = find_index(root, list->selected_item, &parent); switch (this->state) { case EXPANDED: @@ -321,11 +322,49 @@ static int folder_action_callback(int action, struct gui_synclist *list) break; case EACCESS: /* cannot open, do nothing */ + return action; + } + list->nb_items = count_items(root); + return ACTION_REDRAW; + } + else if (action == ACTION_STD_CONTEXT) + { + switch (this->state) + { + case EXPANDED: + for (i = 0; i < this->folder->children_count; i++) + { + child = &this->folder->children[i]; + if (child->state == SELECTED || + child->state == EXPANDED) + child->state = COLLAPSED; + else if (child->state == COLLAPSED) + child->state = SELECTED; + } break; + case SELECTED: + case COLLAPSED: + if (this->folder == NULL) + this->folder = load_folder(parent, this->name); + this->state = this->folder ? (this->folder->children_count == 0 ? + SELECTED : EXPANDED) : EACCESS; + if (this->state == EACCESS) + break; + for (i = 0; i < this->folder->children_count; i++) + { + child = &this->folder->children[i]; + child->state = SELECTED; + } + break; + case EACCESS: + /* cannot open, do nothing */ + return action; } list->nb_items = count_items(root); return ACTION_REDRAW; } + + return action; } |