ply_window_t *window;
ply_frame_buffer_t *frame_buffer;
ply_frame_buffer_area_t frame_area;
+ ply_trigger_t *stop_trigger;
long x, y;
long width, height;
- double start_time, now;
+ double start_time, previous_time, now;
};
ply_throbber_t *
throbber->frame_area.height);
}
-static void
+static bool
animate_at_time (ply_throbber_t *throbber,
double time)
{
int frame_number;
ply_image_t * const * frames;
uint32_t *frame_data;
+ bool should_continue;
ply_window_set_mode (throbber->window, PLY_WINDOW_MODE_GRAPHICS);
number_of_frames = ply_array_get_size (throbber->frames);
if (number_of_frames == 0)
- return;
+ return true;
+
+ should_continue = true;
frame_number = (.5 * sin (time) + .5) * number_of_frames;
+ if (throbber->stop_trigger != NULL)
+ {
+ if ((time - throbber->previous_time) >= 2 * M_PI)
+ frame_number = number_of_frames - 1;
+ should_continue = false;
+ }
+
ply_frame_buffer_pause_updates (throbber->frame_buffer);
if (throbber->frame_area.width > 0)
draw_background (throbber);
&throbber->frame_area, 0, 0,
frame_data);
ply_frame_buffer_unpause_updates (throbber->frame_buffer);
+
+ return should_continue;
}
static void
on_timeout (ply_throbber_t *throbber)
{
double sleep_time;
+ bool should_continue;
+ throbber->previous_time = throbber->now;
throbber->now = ply_get_timestamp ();
#ifdef REAL_TIME_ANIMATION
- animate_at_time (throbber,
- throbber->now - throbber->start_time);
+ should_continue = animate_at_time (throbber,
+ throbber->now - throbber->start_time);
#else
static double time = 0.0;
time += 1.0 / FRAMES_PER_SECOND;
- animate_at_time (throbber, time);
+ should_continue = animate_at_time (throbber, time);
#endif
sleep_time = 1.0 / FRAMES_PER_SECOND;
sleep_time = MAX (sleep_time - (ply_get_timestamp () - throbber->now),
0.005);
- ply_event_loop_watch_for_timeout (throbber->loop,
- sleep_time,
- (ply_event_loop_timeout_handler_t)
- on_timeout, throbber);
+ if (!should_continue)
+ {
+
+ draw_background (throbber);
+
+ if (throbber->stop_trigger != NULL)
+ {
+ ply_trigger_pull (throbber->stop_trigger, NULL);
+ throbber->stop_trigger = NULL;
+ }
+ }
+ else
+ {
+ ply_event_loop_watch_for_timeout (throbber->loop,
+ sleep_time,
+ (ply_event_loop_timeout_handler_t)
+ on_timeout, throbber);
+ }
}
static bool
return true;
}
-void
-ply_throbber_stop (ply_throbber_t *throbber)
+static void
+ply_throbber_stop_now (ply_throbber_t *throbber)
{
if (throbber->frame_area.width > 0)
draw_background (throbber);
}
}
+void
+ply_throbber_stop (ply_throbber_t *throbber,
+ ply_trigger_t *stop_trigger)
+{
+
+ if (stop_trigger == NULL)
+ {
+ ply_throbber_stop_now (throbber);
+ return;
+ }
+
+ throbber->stop_trigger = stop_trigger;
+}
+
long
ply_throbber_get_width (ply_throbber_t *throbber)
{
ply_label_t *label;
ply_answer_t *pending_password_answer;
+ ply_trigger_t *idle_trigger;
uint32_t root_is_mounted : 1;
uint32_t is_visible : 1;
}
static void
-stop_animation (ply_boot_splash_plugin_t *plugin)
+stop_animation (ply_boot_splash_plugin_t *plugin,
+ ply_trigger_t *trigger)
{
int i;
assert (plugin != NULL);
assert (plugin->loop != NULL);
- ply_throbber_stop (plugin->throbber);
+ ply_throbber_stop (plugin->throbber, trigger);
#ifdef ENABLE_FADE_OUT
for (i = 0; i < 10; i++)
on_interrupt (ply_boot_splash_plugin_t *plugin)
{
ply_event_loop_exit (plugin->loop, 1);
- stop_animation (plugin);
+ stop_animation (plugin, NULL);
ply_window_set_mode (plugin->window, PLY_WINDOW_MODE_TEXT);
}
if (plugin->loop != NULL)
{
- stop_animation (plugin);
+ stop_animation (plugin, NULL);
ply_event_loop_stop_watching_for_exit (plugin->loop, (ply_event_loop_exit_handler_t)
detach_from_event_loop,
if (ply_entry_is_hidden (plugin->entry))
{
- stop_animation (plugin);
+ stop_animation (plugin, NULL);
show_password_prompt (plugin, prompt);
}
else
plugin->root_is_mounted = true;
}
+void
+become_idle (ply_boot_splash_plugin_t *plugin,
+ ply_trigger_t *idle_trigger)
+{
+ stop_animation (plugin, idle_trigger);
+}
+
ply_boot_splash_plugin_interface_t *
ply_boot_splash_plugin_get_interface (void)
{
.update_status = update_status,
.hide_splash_screen = hide_splash_screen,
.ask_for_password = ask_for_password,
- .on_root_mounted = on_root_mounted
+ .on_root_mounted = on_root_mounted,
+ .become_idle = become_idle
};
return &plugin_interface;