Exemplo n.º 1
0
static void
view_animate_at_time (view_t *view,
                      double  time)
{
        ply_boot_splash_plugin_t *plugin;
        ply_list_node_t *node;
        double logo_opacity;
        long logo_x, logo_y;
        long logo_width, logo_height;
        unsigned long screen_width, screen_height;
        unsigned long star_width, star_height;

        plugin = view->plugin;

        logo_width = ply_image_get_width (plugin->logo_image);
        logo_height = ply_image_get_height (plugin->logo_image);

        screen_width = ply_pixel_display_get_width (view->display);
        screen_height = ply_pixel_display_get_height (view->display);

        logo_x = (screen_width / 2) - (logo_width / 2);
        logo_y = (screen_height / 2) - (logo_height / 2);

        star_width = ply_image_get_width (plugin->star_image);
        star_height = ply_image_get_height (plugin->star_image);

        node = ply_list_get_first_node (view->stars);
        while (node != NULL) {
                ply_list_node_t *next_node;
                star_t *star;

                star = (star_t *) ply_list_node_get_data (node);
                next_node = ply_list_get_next_node (view->stars, node);

                star->opacity = .5 * sin (((plugin->now - star->start_time) / star->speed) * (2 * M_PI)) + .5;
                star->opacity = CLAMP (star->opacity, 0, 1.0);

                ply_pixel_display_draw_area (view->display,
                                             star->x, star->y,
                                             star_width, star_height);
                node = next_node;
        }

        logo_opacity = .5 * sin ((time / 5) * (2 * M_PI)) + .8;
        logo_opacity = CLAMP (logo_opacity, 0, 1.0);

        if (plugin->mode == PLY_BOOT_SPLASH_MODE_SHUTDOWN)
                logo_opacity = 1.0;

        if (fabs (logo_opacity - view->logo_opacity) <= DBL_MIN)
                return;

        view->logo_opacity = logo_opacity;

        ply_pixel_display_draw_area (view->display,
                                     logo_x, logo_y,
                                     logo_width, logo_height);
}
Exemplo n.º 2
0
static bool
animate_at_time (ply_throbber_t *throbber,
                 double          time)
{
        int number_of_frames;
        ply_pixel_buffer_t *const *frames;
        bool should_continue;
        double percent_in_sequence;

        number_of_frames = ply_array_get_size (throbber->frames);

        if (number_of_frames == 0)
                return true;

        should_continue = true;
        percent_in_sequence = fmod (time, THROBBER_DURATION) / THROBBER_DURATION;
        throbber->frame_number = (int) (number_of_frames * percent_in_sequence);

        if (throbber->stop_trigger != NULL)
                if (throbber->frame_number == number_of_frames - 1)
                        should_continue = false;

        frames = (ply_pixel_buffer_t *const *) ply_array_get_pointer_elements (throbber->frames);
        ply_pixel_buffer_get_size (frames[throbber->frame_number], &throbber->frame_area);
        throbber->frame_area.x = throbber->x;
        throbber->frame_area.y = throbber->y;
        ply_pixel_display_draw_area (throbber->display,
                                     throbber->x, throbber->y,
                                     throbber->frame_area.width,
                                     throbber->frame_area.height);

        return should_continue;
}
Exemplo n.º 3
0
static void
ply_entry_draw (ply_entry_t *entry)
{
  ply_pixel_display_draw_area (entry->display,
                               entry->area.x,
                               entry->area.y,
                               entry->area.width,
                               entry->area.height);
}
Exemplo n.º 4
0
static void
view_redraw (view_t *view)
{
  unsigned long screen_width, screen_height;

  screen_width = ply_pixel_display_get_width (view->display);
  screen_height = ply_pixel_display_get_height (view->display);

  ply_pixel_display_draw_area (view->display, 0, 0,
                               screen_width, screen_height);
}
Exemplo n.º 5
0
static void
view_start_animation (view_t *view)
{
        unsigned long screen_width, screen_height;

        assert (view != NULL);

        screen_width = ply_pixel_display_get_width (view->display);
        screen_height = ply_pixel_display_get_height (view->display);

        ply_pixel_display_draw_area (view->display, 0, 0,
                                     screen_width, screen_height);
}
Exemplo n.º 6
0
void
ply_progress_bar_draw (ply_progress_bar_t *progress_bar)
{
  if (progress_bar->is_hidden)
    return;

  ply_progress_bar_update_area (progress_bar, progress_bar->area.x, progress_bar->area.y);
  ply_pixel_display_draw_area (progress_bar->display,
                               progress_bar->area.x,
                               progress_bar->area.y,
                               progress_bar->area.width,
                               progress_bar->area.height);
}
Exemplo n.º 7
0
void
ply_progress_bar_hide (ply_progress_bar_t *progress_bar)
{
  if (progress_bar->is_hidden)
    return;

  progress_bar->is_hidden = true;
  ply_pixel_display_draw_area (progress_bar->display,
                               progress_bar->area.x, progress_bar->area.y,
                               progress_bar->area.width, progress_bar->area.height);

  progress_bar->display = NULL;

}
Exemplo n.º 8
0
static void
view_start_progress_animation (view_t *view)
{
  ply_boot_splash_plugin_t *plugin;

  long x, y;
  long width, height;
  unsigned long screen_width, screen_height;

  assert (view != NULL);

  plugin = view->plugin;

  plugin->is_idle = false;

  screen_width = ply_pixel_display_get_width (view->display);
  screen_height = ply_pixel_display_get_height (view->display);

  ply_pixel_display_draw_area (view->display, 0, 0,
                               screen_width, screen_height);

  if (plugin->mode == PLY_BOOT_SPLASH_MODE_SHUTDOWN)
    {
      view_start_end_animation (view, NULL);
      return;
    }

  width = ply_progress_animation_get_width (view->progress_animation);
  height = ply_progress_animation_get_height (view->progress_animation);
  x = plugin->animation_horizontal_alignment * screen_width - width / 2.0;
  y = plugin->animation_vertical_alignment * screen_height - height / 2.0;
  ply_progress_animation_show (view->progress_animation,
                               view->display, x, y);

  ply_pixel_display_draw_area (view->display, x, y, width, height);
}
Exemplo n.º 9
0
void
ply_progress_animation_hide (ply_progress_animation_t *progress_animation)
{
        if (progress_animation->is_hidden)
                return;

        progress_animation->is_hidden = true;
        if (progress_animation->frame_area.width > 0) {
                ply_pixel_display_draw_area (progress_animation->display,
                                             progress_animation->area.x, progress_animation->area.y,
                                             progress_animation->frame_area.width,
                                             progress_animation->frame_area.height);
        }

        progress_animation->display = NULL;
}
Exemplo n.º 10
0
static void
ply_throbber_stop_now (ply_throbber_t *throbber)
{
        throbber->is_stopped = true;

        ply_pixel_display_draw_area (throbber->display,
                                     throbber->x,
                                     throbber->y,
                                     throbber->frame_area.width,
                                     throbber->frame_area.height);
        if (throbber->loop != NULL) {
                ply_event_loop_stop_watching_for_timeout (throbber->loop,
                                                          (ply_event_loop_timeout_handler_t)
                                                          on_timeout, throbber);
                throbber->loop = NULL;
        }
        throbber->display = NULL;
}
Exemplo n.º 11
0
static void
view_start_animation (view_t *view)
{
        ply_boot_splash_plugin_t *plugin;

        unsigned long screen_width, screen_height;
        long width, height;
        long x,y;
        int number_of_frames;
        int yoffset = 0;

        assert (view != NULL);

        plugin = view->plugin;

        assert (plugin != NULL);
        assert (plugin->loop != NULL);

        screen_width = ply_pixel_display_get_width (view->display);
        screen_height = ply_pixel_display_get_height (view->display);

        ply_pixel_display_draw_area (view->display, 0, 0,
                                     screen_width, screen_height);

        if (plugin->mode == PLY_BOOT_SPLASH_MODE_SHUTDOWN && 
                plugin->shutdown_font != NULL && plugin->shutdown_text != NULL) {
                ply_label_set_text (view->shutdown_label, plugin->shutdown_text);
                ply_label_set_font (view->shutdown_label, plugin->shutdown_font);
                ply_label_set_color(view->shutdown_label,
                        ((plugin->shutdown_color >> 16) & 0xff) / 255.0f,
                        ((plugin->shutdown_color >> 8) & 0xff) / 255.0f,
                        (plugin->shutdown_color & 0xff) / 255.0f,
                        1.0f);
                int label_width = screen_width;
                ply_label_set_width (view->shutdown_label, label_width);
                ply_label_set_alignment (view->shutdown_label, PLY_LABEL_ALIGN_CENTER);

                x = 0;
                y = screen_height / 2;
                ply_label_show (view->shutdown_label, view->display, x, y);
                yoffset = ply_label_get_height(view->shutdown_label) * 2;
        }
Exemplo n.º 12
0
static void
show_message (ply_boot_splash_plugin_t *plugin,
              const char               *message)
{
        ply_trace ("Showing message '%s'", message);
        ply_list_node_t *node;
        node = ply_list_get_first_node (plugin->views);
        while (node != NULL) {
                ply_list_node_t *next_node;
                view_t *view;

                view = ply_list_node_get_data (node);
                next_node = ply_list_get_next_node (plugin->views, node);
                ply_label_set_text (view->message_label, message);
                ply_label_show (view->message_label, view->display, 10, 10);

                ply_pixel_display_draw_area (view->display, 10, 10,
                                             ply_label_get_width (view->message_label),
                                             ply_label_get_height (view->message_label));
                node = next_node;
        }
}
Exemplo n.º 13
0
void
ply_seat_refresh_displays (ply_seat_t *seat)
{
        ply_list_node_t *node;

        node = ply_list_get_first_node (seat->pixel_displays);
        while (node != NULL) {
                ply_pixel_display_t *display;
                ply_list_node_t *next_node;
                unsigned long width, height;

                display = ply_list_node_get_data (node);
                next_node = ply_list_get_next_node (seat->pixel_displays, node);

                width = ply_pixel_display_get_width (display);
                height = ply_pixel_display_get_height (display);

                ply_pixel_display_draw_area (display, 0, 0, width, height);
                node = next_node;
        }

        node = ply_list_get_first_node (seat->text_displays);
        while (node != NULL) {
                ply_text_display_t *display;
                ply_list_node_t *next_node;
                int number_of_columns, number_of_rows;

                display = ply_list_node_get_data (node);
                next_node = ply_list_get_next_node (seat->text_displays, node);

                number_of_columns = ply_text_display_get_number_of_columns (display);
                number_of_rows = ply_text_display_get_number_of_rows (display);

                ply_text_display_draw_area (display, 0, 0,
                                            number_of_columns,
                                            number_of_rows);
                node = next_node;
        }
}
Exemplo n.º 14
0
static void
view_start_animation (view_t *view)
{
        ply_boot_splash_plugin_t *plugin;

        unsigned long screen_width, screen_height;
        long width, height;

        assert (view != NULL);

        plugin = view->plugin;

        assert (plugin != NULL);
        assert (plugin->loop != NULL);

        screen_width = ply_pixel_display_get_width (view->display);
        screen_height = ply_pixel_display_get_height (view->display);

        ply_pixel_display_draw_area (view->display, 0, 0,
                                     screen_width, screen_height);

        if (plugin->mode == PLY_BOOT_SPLASH_MODE_SHUTDOWN)
                return;

        plugin->is_idle = false;

        width = ply_throbber_get_width (view->throbber);
        height = ply_throbber_get_height (view->throbber);
        ply_throbber_start (view->throbber,
                            plugin->loop,
                            view->display,
                            screen_width / 2.0 - width / 2.0,
                            view->logo_area.y + view->logo_area.height + height / 2);
        ply_progress_bar_show (view->progress_bar,
                               view->display,
                               0, screen_height - ply_progress_bar_get_height (view->progress_bar));
        view_redraw (view);
}
Exemplo n.º 15
0
static bool
animate_at_time (ply_animation_t *animation,
                 double           time)
{
  int number_of_frames;
  ply_image_t * const * frames;
  bool should_continue;

  number_of_frames = ply_array_get_size (animation->frames);

  if (number_of_frames == 0)
    return false;

  should_continue = true;

  if (animation->frame_number > number_of_frames - 1)
    return false;

  if (animation->stop_requested)
    should_continue = false;

  frames = (ply_image_t * const *) ply_array_get_elements (animation->frames);

  animation->frame_area.x = animation->x;
  animation->frame_area.y = animation->y;
  animation->frame_area.width = ply_image_get_width (frames[animation->frame_number]);
  animation->frame_area.height = ply_image_get_height (frames[animation->frame_number]);

  ply_pixel_display_draw_area (animation->display,
                               animation->x, animation->y,
                               animation->frame_area.width,
                               animation->frame_area.height);

  animation->frame_number++;

  return should_continue;
}
Exemplo n.º 16
0
static bool
animate_at_time (ply_throbber_t *throbber,
                 double      time)
{
  int number_of_frames;
  ply_image_t * const * frames;
  bool should_continue;

  number_of_frames = ply_array_get_size (throbber->frames);

  if (number_of_frames == 0)
    return true;

  should_continue = true;

  throbber->frame_number = (.5 * sin (time) + .5) * number_of_frames;

  if (throbber->stop_trigger != NULL)
    {
      if (throbber->frame_number == number_of_frames - 1)
        should_continue = false;
    }

  frames = (ply_image_t * const *) ply_array_get_elements (throbber->frames);

  throbber->frame_area.x = throbber->x;
  throbber->frame_area.y = throbber->y;
  throbber->frame_area.width = ply_image_get_width (frames[throbber->frame_number]);
  throbber->frame_area.height = ply_image_get_height (frames[throbber->frame_number]);
  ply_pixel_display_draw_area (throbber->display,
                               throbber->x, throbber->y,
                               throbber->frame_area.width,
                               throbber->frame_area.height);

  return should_continue;
}
Exemplo n.º 17
0
void
ply_progress_animation_draw (ply_progress_animation_t *progress_animation)
{
  int number_of_frames;
  int frame_number;
  ply_image_t * const * frames;
  uint32_t *previous_frame_data, *frame_data;

  if (progress_animation->is_hidden)
    return;

  number_of_frames = ply_array_get_size (progress_animation->frames);

  if (number_of_frames == 0)
    return;

  frame_number = progress_animation->percent_done * (number_of_frames - 1);

  if (progress_animation->previous_frame_number != frame_number &&
      progress_animation->transition != PLY_PROGRESS_ANIMATION_TRANSITION_NONE &&
      progress_animation->transition_duration > 0.0)
    {
      progress_animation->is_transitioning = true;
      progress_animation->transition_start_time = ply_get_timestamp ();
    }

  frames = (ply_image_t * const *) ply_array_get_elements (progress_animation->frames);

  progress_animation->frame_area.x = progress_animation->area.x;
  progress_animation->frame_area.y = progress_animation->area.y;
  frame_data = ply_image_get_data (frames[frame_number]);

  if (progress_animation->is_transitioning)
    {
      double now;
      double fade_percentage;
      double fade_out_opacity;
      int width, height;
      uint32_t* faded_data;
      now = ply_get_timestamp ();

      fade_percentage = (now - progress_animation->transition_start_time) / progress_animation->transition_duration;

      if (fade_percentage >= 1.0)
        progress_animation->is_transitioning = false;
      fade_percentage = CLAMP (fade_percentage, 0.0, 1.0);

      if (progress_animation->transition == PLY_PROGRESS_ANIMATION_TRANSITION_MERGE_FADE)
        {
          width = MAX(ply_image_get_width (frames[frame_number]), ply_image_get_width (frames[frame_number - 1]));
          height = MAX(ply_image_get_height (frames[frame_number]), ply_image_get_width (frames[frame_number - 1]));
          progress_animation->frame_area.width = width;
          progress_animation->frame_area.height = height;

          ply_pixel_buffer_free (progress_animation->last_rendered_frame);
          progress_animation->last_rendered_frame = ply_pixel_buffer_new (width, height);
          faded_data = ply_pixel_buffer_get_argb32_data (progress_animation->last_rendered_frame);

          image_fade_merge (frames[frame_number - 1], frames[frame_number], fade_percentage, width, height, faded_data);

          ply_pixel_display_draw_area (progress_animation->display,
                                       progress_animation->frame_area.x,
                                       progress_animation->frame_area.y,
                                       progress_animation->frame_area.width,
                                       progress_animation->frame_area.height);
        }
      else
        {
          ply_rectangle_t fill_area;

          previous_frame_data = ply_image_get_data (frames[frame_number - 1]);
          if (progress_animation->transition == PLY_PROGRESS_ANIMATION_TRANSITION_FADE_OVER)
            {
              ply_pixel_buffer_free (progress_animation->last_rendered_frame);
              progress_animation->frame_area.width = ply_image_get_width (frames[frame_number - 1]);
              progress_animation->frame_area.height = ply_image_get_height (frames[frame_number - 1]);

              progress_animation->last_rendered_frame = ply_pixel_buffer_new (progress_animation->frame_area.width,
                                                                              progress_animation->frame_area.height);
              fill_area.x = 0;
              fill_area.y = 0;
              fill_area.width = progress_animation->frame_area.width;
              fill_area.height = progress_animation->frame_area.height;
              ply_pixel_buffer_fill_with_argb32_data (progress_animation->last_rendered_frame,
                                                      &fill_area, 0, 0,
                                                      previous_frame_data);
            }
          else
            {
              fade_out_opacity = 1.0 - fade_percentage;
              progress_animation->frame_area.width = ply_image_get_width (frames[frame_number - 1]);
              progress_animation->frame_area.height = ply_image_get_height (frames[frame_number - 1]);

              fill_area.x = 0;
              fill_area.y = 0;
              fill_area.width = progress_animation->frame_area.width;
              fill_area.height = progress_animation->frame_area.height;
              ply_pixel_buffer_fill_with_argb32_data_at_opacity (progress_animation->last_rendered_frame,
                                                                 &fill_area, 0, 0,
                                                                 previous_frame_data, fade_out_opacity);
            }

          progress_animation->frame_area.width = ply_image_get_width (frames[frame_number]);
          progress_animation->frame_area.height = ply_image_get_height (frames[frame_number]);
          fill_area.x = 0;
          fill_area.y = 0;
          fill_area.width = progress_animation->frame_area.width;
          fill_area.height = progress_animation->frame_area.height;
          ply_pixel_buffer_fill_with_argb32_data_at_opacity (progress_animation->last_rendered_frame,
                                                             &fill_area, 0, 0,
                                                             frame_data, fade_percentage);

          width = MAX(ply_image_get_width (frames[frame_number]), ply_image_get_width (frames[frame_number - 1]));
          height = MAX(ply_image_get_height (frames[frame_number]), ply_image_get_width (frames[frame_number - 1]));
          progress_animation->frame_area.width = width;
          progress_animation->frame_area.height = height;
        }
    }
  else
    {
      ply_rectangle_t fill_area;

      ply_pixel_buffer_free (progress_animation->last_rendered_frame);
      progress_animation->frame_area.width = ply_image_get_width (frames[frame_number]);
      progress_animation->frame_area.height = ply_image_get_height (frames[frame_number]);
      progress_animation->last_rendered_frame = ply_pixel_buffer_new (progress_animation->frame_area.width,
                                                                      progress_animation->frame_area.height);

      fill_area.x = 0;
      fill_area.y = 0;
      fill_area.width = progress_animation->frame_area.width;
      fill_area.height = progress_animation->frame_area.height;
      ply_pixel_buffer_fill_with_argb32_data (progress_animation->last_rendered_frame,
                                              &fill_area, 0, 0,
                                              frame_data);
    }

  progress_animation->previous_frame_number = frame_number;

  ply_pixel_display_draw_area (progress_animation->display,
                               progress_animation->frame_area.x,
                               progress_animation->frame_area.y,
                               progress_animation->frame_area.width,
                               progress_animation->frame_area.height);
}