summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Soffke <christian.soffke@gmail.com>2024-07-26 20:16:56 +0200
committerChristian Soffke <christian.soffke@gmail.com>2024-07-28 20:18:43 +0200
commit70b96193e7950391e7fcbdabad6daebe8b87e4f5 (patch)
tree0e5c1272fd9dffe5230917240be01aac6c64f487
parent545271c4de82c3b5da05ca91629d0de150c90d21 (diff)
downloadrockbox-70b96193e7.tar.gz
rockbox-70b96193e7.zip
plugins: properties: use UI viewport for displaying progress
Prevent switching to a fullscreen view when scanning a directory, which could be a bit jarring, depending on your theme of choice. Also pop context menu activity immediately, without refreshing, so it isn't redrawn when returning from plugin. Change-Id: I021e5880505e7f121163851ae732eb47509cc5d8
-rw-r--r--apps/onplay.c10
-rw-r--r--apps/plugins/lib/mul_id3.c72
-rw-r--r--apps/plugins/properties.c82
3 files changed, 86 insertions, 78 deletions
diff --git a/apps/onplay.c b/apps/onplay.c
index d468c0a545..4f748204df 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -138,7 +138,7 @@ static bool clipboard_clip(struct clipboard *clip, const char *path,
static int bookmark_load_menu_wrapper(void)
{
if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* get rid of parent activity */
- pop_current_activity_without_refresh(); /* when called from ctxt menu */
+ pop_current_activity_without_refresh(); /* when called from ctxt menu */
return bookmark_load_menu();
}
@@ -689,7 +689,7 @@ MENUITEM_FUNCTION(view_cue_item, 0, ID2P(LANG_BROWSE_CUESHEET),
static int browse_id3_wrapper(void)
{
if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* get rid of parent activity */
- pop_current_activity_without_refresh(); /* when called from ctxt menu */
+ pop_current_activity_without_refresh(); /* when called from ctxt menu */
if (browse_id3(audio_current_track(),
playlist_get_display_index(),
@@ -806,6 +806,10 @@ static bool onplay_load_plugin(void *param)
if (!prepare_database_sel(param))
return false;
#endif
+
+ if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* get rid of parent activity */
+ pop_current_activity_without_refresh(); /* when called from ctxt menu */
+
int ret = filetype_load_plugin((const char*)param, selected_file.path);
if (ret == PLUGIN_USB_CONNECTED)
onplay_result = ONPLAY_RELOAD_DIR;
@@ -1299,7 +1303,7 @@ int onplay(char* file, int attr, int from_context, bool hotkey)
menu_selection = do_menu(menu, NULL, NULL, false);
if (get_current_activity() == ACTIVITY_CONTEXTMENU) /* Activity may have been */
- pop_current_activity(); /* popped already by menu item */
+ pop_current_activity(); /* popped already by menu item */
if (menu_selection == GO_TO_WPS)
diff --git a/apps/plugins/lib/mul_id3.c b/apps/plugins/lib/mul_id3.c
index c4b511c626..e88bbfe417 100644
--- a/apps/plugins/lib/mul_id3.c
+++ b/apps/plugins/lib/mul_id3.c
@@ -196,52 +196,45 @@ static const char *image_exts[] = {"bmp","jpg","jpe","jpeg","png","ppm"};
/* and videos */
static const char *video_exts[] = {"mpg","mpeg","mpv","m2v"};
-static void prn(const char *str, int y)
+static void display_dir_stats_vp(struct dir_stats *stats, struct viewport *vp,
+ struct screen *display)
{
- rb->lcd_puts(0, y, str);
-#ifdef HAVE_REMOTE_LCD
- rb->lcd_remote_puts(0, y, str);
-#endif
-}
-
-void display_dir_stats(struct dir_stats *stats)
-{
- char buf[32];
+ static bool initialized;
int32_t lang_size_unit;
unsigned long display_size = human_size(stats->byte_count, &lang_size_unit);
- rb->lcd_clear_display();
-#ifdef HAVE_REMOTE_LCD
- rb->lcd_remote_clear_display();
-#endif
- rb->snprintf(buf, sizeof(buf), "Files: %d (%lu %s)", stats->file_count,
- display_size, rb->str(lang_size_unit));
- prn(buf, 0);
- rb->snprintf(buf, sizeof(buf), "Audio: %d", stats->audio_file_count);
- prn(buf, 1);
- if (stats->count_all)
+ struct viewport *last_vp = display->set_viewport(vp);
+ display->clear_viewport();
+ if (initialized)
{
- rb->snprintf(buf, sizeof(buf), "Playlists: %d", stats->m3u_file_count);
- prn(buf, 2);
- rb->snprintf(buf, sizeof(buf), "Images: %d", stats->img_file_count);
- prn(buf, 3);
- rb->snprintf(buf, sizeof(buf), "Videos: %d", stats->vid_file_count);
- prn(buf, 4);
- rb->snprintf(buf, sizeof(buf), "Directories: %d", stats->dir_count);
- prn(buf, 5);
- rb->snprintf(buf, sizeof(buf), "Max files in Dir: %d",
- stats->max_files_in_dir);
- prn(buf, 6);
+ display->putsf(0, 0, "Files: %d (%lu %s)", stats->file_count,
+ display_size, rb->str(lang_size_unit));
+ display->putsf(0, 1, "Audio: %d", stats->audio_file_count);
+ if (stats->count_all)
+ {
+ display->putsf(0, 2, "Playlists: %d", stats->m3u_file_count);
+ display->putsf(0, 3, "Images: %d", stats->img_file_count);
+ display->putsf(0, 4, "Videos: %d", stats->vid_file_count);
+ display->putsf(0, 5, "Directories: %d", stats->dir_count);
+ display->putsf(0, 6, "Max files in Dir: %d", stats->max_files_in_dir);
+ }
+ else
+ display->putsf(0, 2, "Directories: %d", stats->dir_count);
}
else
+ initialized = true;
+
+ display->update_viewport();
+ display->set_viewport(last_vp);
+}
+
+void display_dir_stats(struct dir_stats *stats)
+{
+ struct viewport vps[NB_SCREENS];
+ FOR_NB_SCREENS(i)
{
- rb->snprintf(buf, sizeof(buf), "Directories: %d", stats->dir_count);
- prn(buf, 2);
+ rb->viewport_set_defaults(&vps[i], i);
+ display_dir_stats_vp(stats, &vps[i], rb->screens[i]);
}
- rb->lcd_update();
-#ifdef HAVE_REMOTE_LCD
- rb->lcd_remote_update();
-#endif
-
}
/* Recursively scans directories in search of files
@@ -281,8 +274,7 @@ bool collect_dir_stats(struct dir_stats *stats, bool (*id3_cb)(const char*))
stats->dir_count++; /* new directory */
if (*rb->current_tick - last_displayed > (HZ/2))
{
- if (last_displayed)
- display_dir_stats(stats);
+ display_dir_stats(stats);
last_displayed = *(rb->current_tick);
}
}
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c
index c932474f8c..2f18d94d9f 100644
--- a/apps/plugins/properties.c
+++ b/apps/plugins/properties.c
@@ -35,6 +35,7 @@ enum props_types {
static int props_type;
+static struct gui_synclist properties_lists;
static struct mp3entry id3;
static int mul_id3_count;
static int skipped_count;
@@ -53,7 +54,7 @@ static int32_t lang_size_unit;
static struct tm tm;
#define NUM_FILE_PROPERTIES 5
-#define NUM_PLAYLIST_PROPERTIES 1 + NUM_FILE_PROPERTIES
+#define NUM_PLAYLIST_PROPERTIES (1 + NUM_FILE_PROPERTIES)
static const unsigned char* const props_file[] =
{
ID2P(LANG_PROPERTIES_PATH), str_dirname,
@@ -66,7 +67,7 @@ static const unsigned char* const props_file[] =
};
#define NUM_DIR_PROPERTIES 4
-#define NUM_AUDIODIR_PROPERTIES 1 + NUM_DIR_PROPERTIES
+#define NUM_AUDIODIR_PROPERTIES (1 + NUM_DIR_PROPERTIES)
static const unsigned char* const props_dir[] =
{
ID2P(LANG_PROPERTIES_PATH), str_dirname,
@@ -220,41 +221,40 @@ static int speak_property_selection(int selected_item, void *data)
return 0;
}
-static int browse_file_or_dir(struct dir_stats *stats)
+static void setup_properties_list(struct dir_stats *stats)
{
- struct gui_synclist properties_lists;
- int button, nb_items;
-
+ int nb_props;
if (props_type == PROPS_FILE)
- nb_items = NUM_FILE_PROPERTIES;
+ nb_props = NUM_FILE_PROPERTIES;
else if (props_type == PROPS_PLAYLIST)
- nb_items = NUM_PLAYLIST_PROPERTIES;
- else if (stats->audio_file_count)
- nb_items = NUM_AUDIODIR_PROPERTIES;
+ nb_props = NUM_PLAYLIST_PROPERTIES;
else
- nb_items = NUM_DIR_PROPERTIES;
-
- nb_items *= 2;
-
+ nb_props = NUM_DIR_PROPERTIES;
+
rb->gui_synclist_init(&properties_lists, &get_props, stats, false, 2, NULL);
rb->gui_synclist_set_title(&properties_lists,
rb->str(props_type == PROPS_DIR ?
- LANG_PROPERTIES_DIRECTORY_PROPERTIES :
- LANG_PROPERTIES_FILE_PROPERTIES),
+ LANG_PROPERTIES_DIRECTORY_PROPERTIES :
+ LANG_PROPERTIES_FILE_PROPERTIES),
NOICON);
- rb->gui_synclist_set_icon_callback(&properties_lists, NULL);
if (rb->global_settings->talk_menu)
rb->gui_synclist_set_voice_callback(&properties_lists, speak_property_selection);
- rb->gui_synclist_set_nb_items(&properties_lists, nb_items);
- rb->gui_synclist_select_item(&properties_lists, 0);
+ rb->gui_synclist_set_nb_items(&properties_lists, nb_props*2);
+}
+
+static int browse_file_or_dir(struct dir_stats *stats)
+{
+ int button;
+
+ if (props_type == PROPS_DIR && stats->audio_file_count)
+ rb->gui_synclist_set_nb_items(&properties_lists, NUM_AUDIODIR_PROPERTIES*2);
rb->gui_synclist_draw(&properties_lists);
rb->gui_synclist_speak_item(&properties_lists);
-
while(true)
{
button = rb->get_action(CONTEXT_LIST, HZ);
/* HZ so the status bar redraws corectly */
- if (rb->gui_synclist_do_button(&properties_lists,&button))
+ if (rb->gui_synclist_do_button(&properties_lists, &button))
continue;
switch(button)
{
@@ -356,12 +356,14 @@ static bool assemble_track_info(const char *filename, struct dir_stats *stats)
enum plugin_status plugin_start(const void* parameter)
{
- int ret;
+ int ret = 0;
static struct dir_stats stats;
const char *file = parameter;
if(!parameter)
return PLUGIN_ERROR;
+ FOR_NB_SCREENS(i)
+ rb->viewportmanager_theme_enable(i, true, NULL);
#ifdef HAVE_TOUCHSCREEN
rb->touchscreen_set_mode(rb->global_settings->touch_mode);
#endif
@@ -374,34 +376,44 @@ enum plugin_status plugin_start(const void* parameter)
if(!determine_file_or_dir())
{
- /* weird: we couldn't find the entry. This Should Never Happen (TM) */
rb->splashf(0, "File/Dir not found: %s", file);
rb->action_userabort(TIMEOUT_BLOCK);
- return PLUGIN_OK;
+ goto exit;
}
- if (props_type == PROPS_FILE && has_pl_extension(file))
- props_type = PROPS_PLAYLIST;
+ if (props_type == PROPS_FILE)
+ {
+ if (has_pl_extension(file))
+ props_type = PROPS_PLAYLIST;
+
+ ret = !file_properties(file);
+ }
- if(!(props_type == PROPS_DIR ?
- dir_properties(file, &stats, NULL) : file_properties(file)))
+ if (props_type != PROPS_ID3) /* i.e. not handled by browse_id3 */
{
+ setup_properties_list(&stats); /* Show title during dir scan */
+ if (props_type == PROPS_DIR)
+ ret = !dir_properties(file, &stats, NULL);
+ }
+ if (ret)
+ {
+ ret = 0;
if (!stats.canceled)
{
- /* something went wrong (to do: tell user what it was (nesting,...) */
+ /* TODO: describe error */
rb->splash(0, ID2P(LANG_PROPERTIES_FAIL));
rb->action_userabort(TIMEOUT_BLOCK);
}
- return PLUGIN_OK;
+ goto exit;
}
}
/* database table selected */
else if (rb->strcmp(file, MAKE_ACT_STR(ACTIVITY_DATABASEBROWSER))
|| !assemble_track_info(NULL, NULL))
- return PLUGIN_ERROR;
-
- FOR_NB_SCREENS(i)
- rb->viewportmanager_theme_enable(i, true, NULL);
+ {
+ ret = -1;
+ goto exit;
+ }
if (props_type == PROPS_ID3)
ret = rb->browse_id3(&id3, 0, 0, &tm, 1); /* Track Info for single file */
@@ -411,7 +423,7 @@ enum plugin_status plugin_start(const void* parameter)
ret = assemble_track_info(file, &stats) ? /* playlist or folder tracks */
rb->browse_id3(&id3, 0, 0, NULL, mul_id3_count) :
(stats.canceled ? 0 : -1);
-
+exit:
FOR_NB_SCREENS(i)
rb->viewportmanager_theme_undo(i, false);