diff options
author | Daniel van Vugt <daniel.van.vugt@canonical.com> | 2020-04-21 13:38:21 +0800 |
---|---|---|
committer | Daniel van Vugt <daniel.van.vugt@canonical.com> | 2020-04-21 13:38:21 +0800 |
commit | 6e8542f95f6e70f521f5ae8895352a9f9b18352b (patch) | |
tree | 245864348586f8a8d6295e762dc13e6762b1e5db /src | |
parent | 14e91cc8d2495b13a45c5b69f9ca96cbd3e72148 (diff) |
Rename 'percent_done' to 'fraction_done'
Because they are not percentages but fractional values in the range [0,1]
Diffstat (limited to 'src')
-rw-r--r-- | src/libply-splash-core/ply-boot-splash-plugin.h | 2 | ||||
-rw-r--r-- | src/libply-splash-core/ply-text-progress-bar.c | 18 | ||||
-rw-r--r-- | src/libply-splash-core/ply-text-progress-bar.h | 6 | ||||
-rw-r--r-- | src/libply-splash-core/ply-text-step-bar.c | 14 | ||||
-rw-r--r-- | src/libply-splash-core/ply-text-step-bar.h | 6 | ||||
-rw-r--r-- | src/libply-splash-graphics/ply-progress-animation.c | 16 | ||||
-rw-r--r-- | src/libply-splash-graphics/ply-progress-animation.h | 6 | ||||
-rw-r--r-- | src/libply-splash-graphics/ply-progress-bar.c | 16 | ||||
-rw-r--r-- | src/libply-splash-graphics/ply-progress-bar.h | 6 | ||||
-rw-r--r-- | src/plugins/splash/script/plugin.c | 4 | ||||
-rw-r--r-- | src/plugins/splash/space-flares/plugin.c | 6 | ||||
-rw-r--r-- | src/plugins/splash/text/plugin.c | 8 | ||||
-rw-r--r-- | src/plugins/splash/tribar/plugin.c | 8 | ||||
-rw-r--r-- | src/plugins/splash/two-step/plugin.c | 26 |
14 files changed, 71 insertions, 71 deletions
diff --git a/src/libply-splash-core/ply-boot-splash-plugin.h b/src/libply-splash-core/ply-boot-splash-plugin.h index 227147fa..c80770c4 100644 --- a/src/libply-splash-core/ply-boot-splash-plugin.h +++ b/src/libply-splash-core/ply-boot-splash-plugin.h @@ -78,7 +78,7 @@ typedef struct size_t size); void (*on_boot_progress)(ply_boot_splash_plugin_t *plugin, double duration, - double percent_done); + double fraction_done); void (*on_root_mounted)(ply_boot_splash_plugin_t *plugin); void (*hide_splash_screen)(ply_boot_splash_plugin_t *plugin, ply_event_loop_t *loop); diff --git a/src/libply-splash-core/ply-text-progress-bar.c b/src/libply-splash-core/ply-text-progress-bar.c index dc275137..a7175c88 100644 --- a/src/libply-splash-core/ply-text-progress-bar.c +++ b/src/libply-splash-core/ply-text-progress-bar.c @@ -67,7 +67,7 @@ struct _ply_text_progress_bar int number_of_rows; int number_of_columns; - double percent_done; + double fraction_done; uint32_t is_hidden : 1; }; @@ -186,9 +186,9 @@ ply_text_progress_bar_draw (ply_text_progress_bar_t *progress_bar) progress_bar->column, progress_bar->row); - brown_fraction = -(progress_bar->percent_done * progress_bar->percent_done) + 2 * progress_bar->percent_done; - blue_fraction = progress_bar->percent_done; - white_fraction = progress_bar->percent_done * progress_bar->percent_done; + brown_fraction = -(progress_bar->fraction_done * progress_bar->fraction_done) + 2 * progress_bar->fraction_done; + blue_fraction = progress_bar->fraction_done; + white_fraction = progress_bar->fraction_done * progress_bar->fraction_done; for (i = 0; i < width; i++) { double f; @@ -262,16 +262,16 @@ ply_text_progress_bar_hide (ply_text_progress_bar_t *progress_bar) } void -ply_text_progress_bar_set_percent_done (ply_text_progress_bar_t *progress_bar, - double percent_done) +ply_text_progress_bar_set_fraction_done (ply_text_progress_bar_t *progress_bar, + double fraction_done) { - progress_bar->percent_done = percent_done; + progress_bar->fraction_done = fraction_done; } double -ply_text_progress_bar_get_percent_done (ply_text_progress_bar_t *progress_bar) +ply_text_progress_bar_get_fraction_done (ply_text_progress_bar_t *progress_bar) { - return progress_bar->percent_done; + return progress_bar->fraction_done; } int diff --git a/src/libply-splash-core/ply-text-progress-bar.h b/src/libply-splash-core/ply-text-progress-bar.h index 10a127d9..fe6e6667 100644 --- a/src/libply-splash-core/ply-text-progress-bar.h +++ b/src/libply-splash-core/ply-text-progress-bar.h @@ -42,10 +42,10 @@ void ply_text_progress_bar_show (ply_text_progress_bar_t *progress_bar, ply_text_display_t *display); void ply_text_progress_bar_hide (ply_text_progress_bar_t *progress_bar); -void ply_text_progress_bar_set_percent_done (ply_text_progress_bar_t *progress_bar, - double percent_done); +void ply_text_progress_bar_set_fraction_done (ply_text_progress_bar_t *progress_bar, + double fraction_done); -double ply_text_progress_bar_get_percent_done (ply_text_progress_bar_t *progress_bar); +double ply_text_progress_bar_get_fraction_done (ply_text_progress_bar_t *progress_bar); int ply_text_progress_bar_get_number_of_rows (ply_text_progress_bar_t *progress_bar); int ply_text_progress_bar_get_number_of_columns (ply_text_progress_bar_t *progress_bar); diff --git a/src/libply-splash-core/ply-text-step-bar.c b/src/libply-splash-core/ply-text-step-bar.c index 568b9a21..f54fc56f 100644 --- a/src/libply-splash-core/ply-text-step-bar.c +++ b/src/libply-splash-core/ply-text-step-bar.c @@ -37,7 +37,7 @@ struct _ply_text_step_bar int number_of_rows; int number_of_columns; - double percent_done; + double fraction_done; uint32_t is_hidden : 1; }; @@ -81,7 +81,7 @@ ply_text_step_bar_draw (ply_text_step_bar_t *step_bar) step_bar->column, step_bar->row); - cur = step_bar->percent_done * step_bar->number_of_columns; + cur = step_bar->fraction_done * step_bar->number_of_columns; for (i = 0; i < step_bar->number_of_columns; i++) { if (i == cur) ply_text_display_set_foreground_color (step_bar->display, @@ -132,16 +132,16 @@ ply_text_step_bar_hide (ply_text_step_bar_t *step_bar) } void -ply_text_step_bar_set_percent_done (ply_text_step_bar_t *step_bar, - double percent_done) +ply_text_step_bar_set_fraction_done (ply_text_step_bar_t *step_bar, + double fraction_done) { - step_bar->percent_done = percent_done; + step_bar->fraction_done = fraction_done; } double -ply_text_step_bar_get_percent_done (ply_text_step_bar_t *step_bar) +ply_text_step_bar_get_fraction_done (ply_text_step_bar_t *step_bar) { - return step_bar->percent_done; + return step_bar->fraction_done; } int diff --git a/src/libply-splash-core/ply-text-step-bar.h b/src/libply-splash-core/ply-text-step-bar.h index e5dce91f..f0aa4a6c 100644 --- a/src/libply-splash-core/ply-text-step-bar.h +++ b/src/libply-splash-core/ply-text-step-bar.h @@ -36,10 +36,10 @@ void ply_text_step_bar_show (ply_text_step_bar_t *step_bar, ply_text_display_t *display); void ply_text_step_bar_hide (ply_text_step_bar_t *step_bar); -void ply_text_step_bar_set_percent_done (ply_text_step_bar_t *step_bar, - double percent_done); +void ply_text_step_bar_set_fraction_done (ply_text_step_bar_t *step_bar, + double fraction_done); -double ply_text_step_bar_get_percent_done (ply_text_step_bar_t *step_bar); +double ply_text_step_bar_get_fraction_done (ply_text_step_bar_t *step_bar); int ply_text_step_bar_get_number_of_rows (ply_text_step_bar_t *step_bar); int ply_text_step_bar_get_number_of_columns (ply_text_step_bar_t *step_bar); diff --git a/src/libply-splash-graphics/ply-progress-animation.c b/src/libply-splash-graphics/ply-progress-animation.c index bcbca3fc..aebc7f6f 100644 --- a/src/libply-splash-graphics/ply-progress-animation.c +++ b/src/libply-splash-graphics/ply-progress-animation.c @@ -62,7 +62,7 @@ struct _ply_progress_animation ply_rectangle_t area; ply_rectangle_t frame_area; - double percent_done; + double fraction_done; int previous_frame_number; double transition_start_time; @@ -88,7 +88,7 @@ ply_progress_animation_new (const char *image_dir, progress_animation->frames_prefix = strdup (frames_prefix); progress_animation->image_dir = strdup (image_dir); progress_animation->is_hidden = true; - progress_animation->percent_done = 0.0; + progress_animation->fraction_done = 0.0; progress_animation->area.x = 0; progress_animation->area.y = 0; progress_animation->area.width = 0; @@ -216,7 +216,7 @@ ply_progress_animation_draw (ply_progress_animation_t *progress_animation) if (number_of_frames == 0) return; - frame_number = progress_animation->percent_done * (number_of_frames - 1); + frame_number = progress_animation->fraction_done * (number_of_frames - 1); if (progress_animation->previous_frame_number != frame_number && progress_animation->transition != PLY_PROGRESS_ANIMATION_TRANSITION_NONE && @@ -456,17 +456,17 @@ ply_progress_animation_get_height (ply_progress_animation_t *progress_animation) } void -ply_progress_animation_set_percent_done (ply_progress_animation_t *progress_animation, - double percent_done) +ply_progress_animation_set_fraction_done (ply_progress_animation_t *progress_animation, + double fraction_done) { - progress_animation->percent_done = percent_done; + progress_animation->fraction_done = fraction_done; ply_progress_animation_draw (progress_animation); } double -ply_progress_animation_get_percent_done (ply_progress_animation_t *progress_animation) +ply_progress_animation_get_fraction_done (ply_progress_animation_t *progress_animation) { - return progress_animation->percent_done; + return progress_animation->fraction_done; } /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */ diff --git a/src/libply-splash-graphics/ply-progress-animation.h b/src/libply-splash-graphics/ply-progress-animation.h index d10c5172..aefe7c9b 100644 --- a/src/libply-splash-graphics/ply-progress-animation.h +++ b/src/libply-splash-graphics/ply-progress-animation.h @@ -64,9 +64,9 @@ bool ply_progress_animation_is_hidden (ply_progress_animation_t *progress_animat long ply_progress_animation_get_width (ply_progress_animation_t *progress_animation); long ply_progress_animation_get_height (ply_progress_animation_t *progress_animation); -void ply_progress_animation_set_percent_done (ply_progress_animation_t *progress_animation, - double percent_done); -double ply_progress_animation_get_percent_done (ply_progress_animation_t *progress_animation); +void ply_progress_animation_set_fraction_done (ply_progress_animation_t *progress_animation, + double fraction_done); +double ply_progress_animation_get_fraction_done (ply_progress_animation_t *progress_animation); #endif diff --git a/src/libply-splash-graphics/ply-progress-bar.c b/src/libply-splash-graphics/ply-progress-bar.c index 369255af..5938dd6a 100644 --- a/src/libply-splash-graphics/ply-progress-bar.c +++ b/src/libply-splash-graphics/ply-progress-bar.c @@ -58,7 +58,7 @@ struct _ply_progress_bar uint32_t fg_color; uint32_t bg_color; - double percent_done; + double fraction_done; uint32_t is_hidden : 1; }; @@ -73,7 +73,7 @@ ply_progress_bar_new (void) progress_bar->is_hidden = true; progress_bar->fg_color = 0xffffffff; /* Solid white */ progress_bar->bg_color = 0x01000000; /* Transparent */ - progress_bar->percent_done = 0.0; + progress_bar->fraction_done = 0.0; return progress_bar; } @@ -105,7 +105,7 @@ ply_progress_bar_draw_area (ply_progress_bar_t *progress_bar, */ fill_area = progress_bar->area; - fill_area.width = progress_bar->area.width * progress_bar->percent_done; + fill_area.width = progress_bar->area.width * progress_bar->fraction_done; ply_pixel_buffer_fill_with_hex_color (buffer, &fill_area, progress_bar->fg_color); fill_area.x = fill_area.x + fill_area.width; @@ -179,17 +179,17 @@ ply_progress_bar_get_height (ply_progress_bar_t *progress_bar) } void -ply_progress_bar_set_percent_done (ply_progress_bar_t *progress_bar, - double percent_done) +ply_progress_bar_set_fraction_done (ply_progress_bar_t *progress_bar, + double fraction_done) { - progress_bar->percent_done = percent_done; + progress_bar->fraction_done = fraction_done; ply_progress_bar_draw (progress_bar); } double -ply_progress_bar_get_percent_done (ply_progress_bar_t *progress_bar) +ply_progress_bar_get_fraction_done (ply_progress_bar_t *progress_bar) { - return progress_bar->percent_done; + return progress_bar->fraction_done; } void diff --git a/src/libply-splash-graphics/ply-progress-bar.h b/src/libply-splash-graphics/ply-progress-bar.h index 55f5a480..e7dbf57b 100644 --- a/src/libply-splash-graphics/ply-progress-bar.h +++ b/src/libply-splash-graphics/ply-progress-bar.h @@ -56,9 +56,9 @@ bool ply_progress_bar_is_hidden (ply_progress_bar_t *bar); long ply_progress_bar_get_width (ply_progress_bar_t *bar); long ply_progress_bar_get_height (ply_progress_bar_t *bar); -void ply_progress_bar_set_percent_done (ply_progress_bar_t *bar, - double percent_done); -double ply_progress_bar_get_percent_done (ply_progress_bar_t *bar); +void ply_progress_bar_set_fraction_done (ply_progress_bar_t *bar, + double fraction_done); +double ply_progress_bar_get_fraction_done (ply_progress_bar_t *bar); void ply_progress_bar_set_colors (ply_progress_bar_t *bar, uint32_t fg_color, diff --git a/src/plugins/splash/script/plugin.c b/src/plugins/splash/script/plugin.c index 8be19f1e..492f4937 100644 --- a/src/plugins/splash/script/plugin.c +++ b/src/plugins/splash/script/plugin.c @@ -237,12 +237,12 @@ on_timeout (ply_boot_splash_plugin_t *plugin) static void on_boot_progress (ply_boot_splash_plugin_t *plugin, double duration, - double percent_done) + double fraction_done) { script_lib_plymouth_on_boot_progress (plugin->script_state, plugin->script_plymouth_lib, duration, - percent_done); + fraction_done); } static bool diff --git a/src/plugins/splash/space-flares/plugin.c b/src/plugins/splash/space-flares/plugin.c index 1b28268f..b362b470 100644 --- a/src/plugins/splash/space-flares/plugin.c +++ b/src/plugins/splash/space-flares/plugin.c @@ -1149,11 +1149,11 @@ on_timeout (ply_boot_splash_plugin_t *plugin) static void on_boot_progress (ply_boot_splash_plugin_t *plugin, double duration, - double percent_done) + double fraction_done) { if (plugin->progress_target < 0) - plugin->progress = percent_done; - plugin->progress_target = percent_done; + plugin->progress = fraction_done; + plugin->progress_target = fraction_done; } static void diff --git a/src/plugins/splash/text/plugin.c b/src/plugins/splash/text/plugin.c index 7298f5a3..7805b9e8 100644 --- a/src/plugins/splash/text/plugin.c +++ b/src/plugins/splash/text/plugin.c @@ -536,16 +536,16 @@ update_status (ply_boot_splash_plugin_t *plugin, static void on_boot_progress (ply_boot_splash_plugin_t *plugin, double duration, - double percent_done) + double fraction_done) { ply_list_node_t *node; double total_duration; - total_duration = duration / percent_done; + total_duration = duration / fraction_done; /* Fun made-up smoothing function to make the growth asymptotic: * fraction(time,estimate)=1-2^(-(time^1.45)/estimate) */ - percent_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - percent_done); + fraction_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - fraction_done); node = ply_list_get_first_node (plugin->views); @@ -556,7 +556,7 @@ on_boot_progress (ply_boot_splash_plugin_t *plugin, view = ply_list_node_get_data (node); next_node = ply_list_get_next_node (plugin->views, node); - ply_text_step_bar_set_percent_done (view->step_bar, percent_done); + ply_text_step_bar_set_fraction_done (view->step_bar, fraction_done); if (plugin->is_animating) ply_text_step_bar_draw (view->step_bar); diff --git a/src/plugins/splash/tribar/plugin.c b/src/plugins/splash/tribar/plugin.c index bbf5d472..1778822a 100644 --- a/src/plugins/splash/tribar/plugin.c +++ b/src/plugins/splash/tribar/plugin.c @@ -542,16 +542,16 @@ update_status (ply_boot_splash_plugin_t *plugin, static void on_boot_progress (ply_boot_splash_plugin_t *plugin, double duration, - double percent_done) + double fraction_done) { ply_list_node_t *node; double total_duration; - total_duration = duration / percent_done; + total_duration = duration / fraction_done; /* Fun made-up smoothing function to make the growth asymptotic: * fraction(time,estimate)=1-2^(-(time^1.45)/estimate) */ - percent_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - percent_done); + fraction_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - fraction_done); node = ply_list_get_first_node (plugin->views); @@ -562,7 +562,7 @@ on_boot_progress (ply_boot_splash_plugin_t *plugin, view = ply_list_node_get_data (node); next_node = ply_list_get_next_node (plugin->views, node); - ply_text_progress_bar_set_percent_done (view->progress_bar, percent_done); + ply_text_progress_bar_set_fraction_done (view->progress_bar, fraction_done); if (plugin->is_animating) ply_text_progress_bar_draw (view->progress_bar); diff --git a/src/plugins/splash/two-step/plugin.c b/src/plugins/splash/two-step/plugin.c index 2d7ee162..2899b225 100644 --- a/src/plugins/splash/two-step/plugin.c +++ b/src/plugins/splash/two-step/plugin.c @@ -68,8 +68,8 @@ #define FRAMES_PER_SECOND 30 #endif -#ifndef SHOW_ANIMATION_PERCENT -#define SHOW_ANIMATION_PERCENT 0.9 +#ifndef SHOW_ANIMATION_FRACTION +#define SHOW_ANIMATION_FRACTION 0.9 #endif #define PROGRESS_BAR_WIDTH 400 @@ -1707,7 +1707,7 @@ on_animation_stopped (ply_boot_splash_plugin_t *plugin) static void update_progress_animation (ply_boot_splash_plugin_t *plugin, - double percent_done) + double fraction_done) { ply_list_node_t *node; view_t *view; @@ -1718,13 +1718,13 @@ update_progress_animation (ply_boot_splash_plugin_t *plugin, view = ply_list_node_get_data (node); if (view->progress_animation != NULL) - ply_progress_animation_set_percent_done (view->progress_animation, - percent_done); + ply_progress_animation_set_fraction_done (view->progress_animation, + fraction_done); - ply_progress_bar_set_percent_done (view->progress_bar, percent_done); + ply_progress_bar_set_fraction_done (view->progress_bar, fraction_done); if (!ply_progress_bar_is_hidden (view->progress_bar) && plugin->mode_settings[plugin->mode].progress_bar_show_percent_complete) { - snprintf (buf, sizeof(buf), _("%d%% complete"), (int)(percent_done * 100)); + snprintf (buf, sizeof(buf), _("%d%% complete"), (int)(fraction_done * 100)); view_show_message (view, buf); } @@ -1735,7 +1735,7 @@ update_progress_animation (ply_boot_splash_plugin_t *plugin, static void on_boot_progress (ply_boot_splash_plugin_t *plugin, double duration, - double percent_done) + double fraction_done) { if (plugin->mode == PLY_BOOT_SPLASH_MODE_UPDATES || plugin->mode == PLY_BOOT_SPLASH_MODE_SYSTEM_UPGRADE || @@ -1753,7 +1753,7 @@ on_boot_progress (ply_boot_splash_plugin_t *plugin, * become_idle gets called. */ if (plugin->mode_settings[plugin->mode].use_end_animation && - percent_done >= SHOW_ANIMATION_PERCENT) { + fraction_done >= SHOW_ANIMATION_FRACTION) { if (plugin->stop_trigger == NULL) { ply_trace ("boot progressed to end"); @@ -1767,21 +1767,21 @@ on_boot_progress (ply_boot_splash_plugin_t *plugin, } else { double total_duration; - percent_done *= (1 / SHOW_ANIMATION_PERCENT); + fraction_done *= (1 / SHOW_ANIMATION_FRACTION); switch (plugin->progress_function) { /* Fun made-up smoothing function to make the growth asymptotic: * fraction(time,estimate)=1-2^(-(time^1.45)/estimate) */ case PROGRESS_FUNCTION_TYPE_WWOODS: - total_duration = duration / percent_done; - percent_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - percent_done); + total_duration = duration / fraction_done; + fraction_done = 1.0 - pow (2.0, -pow (duration, 1.45) / total_duration) * (1.0 - fraction_done); break; case PROGRESS_FUNCTION_TYPE_LINEAR: break; } - update_progress_animation (plugin, percent_done); + update_progress_animation (plugin, fraction_done); } } |