Example #1
0
static void glui_render_menu_list(glui_handle_t *glui,
      menu_handle_t *menu,
      uint32_t normal_color,
      uint32_t hover_color)
{
   unsigned width, height;
   size_t i               = 0;
   uint64_t frame_count   = video_driver_get_frame_count();
   size_t          end    = menu_entries_get_end();
   menu_display_t *disp   = menu_display_get_ptr();

   if (!menu_display_update_pending())
      return;

   video_driver_get_size(&width, &height);

   glui->list_block.carr.coords.vertices = 0;

   for (i = menu_entries_get_start(); i < end; i++)
   {
      bool entry_selected;
      char entry_path[PATH_MAX_LENGTH];
      char entry_value[PATH_MAX_LENGTH];
      char message[PATH_MAX_LENGTH];
      char entry_title_buf[PATH_MAX_LENGTH];
      char type_str_buf[PATH_MAX_LENGTH];
      int y = disp->header_height - menu->scroll_y + (glui->line_height * i);

      if (y > (int)height || ((y + (int)glui->line_height) < 0))
         continue;

      entry_path[0]      = '\0';
      entry_value[0]     = '\0';
      message[0]         = '\0';
      entry_title_buf[0] = '\0';
      type_str_buf[0]    = '\0';

      entry_selected = menu_entry_is_currently_selected(i);
      menu_entry_get_value(i, entry_value, sizeof(entry_value));
      menu_entry_get_path(i, entry_path, sizeof(entry_path));

      menu_animation_ticker_line(entry_title_buf, glui->ticker_limit,
            frame_count / 100, entry_path, entry_selected);
      menu_animation_ticker_line(type_str_buf, glui->ticker_limit,
            frame_count / 100, entry_value, entry_selected);

      strlcpy(message, entry_title_buf, sizeof(message));

      glui_blit_line(glui->margin, y, message,
            entry_selected ? hover_color : normal_color, TEXT_ALIGN_LEFT);

      glui_blit_line(width - glui->margin, y, type_str_buf,
            entry_selected ? hover_color : normal_color, TEXT_ALIGN_RIGHT);
   }
}
Example #2
0
int menu_entry_get_current_id(bool use_representation)
{
   size_t i;
   menu_list_t   *menu_list = menu_list_get_ptr();
   size_t               end = menu_list_get_size(menu_list);

   for (i = 0; i < end; i++)
   {
      menu_entry_t entry = {{0}};
      menu_entry_get(&entry, i, NULL, use_representation);

      if (menu_entry_is_currently_selected(entry.idx))
         return i;
   }

   return -1;
}
Example #3
0
static void rmenu_render(void)
{
   bool msg_force;
   size_t begin, end, i, j, selection;
   struct font_params font_parms = {0};
   char title[256]               = {0};
   char title_buf[256]           = {0};
   char title_msg[64]            = {0};
   menu_handle_t *menu           = menu_driver_get_ptr();
   file_list_t *selection_buf    = menu_entries_get_selection_buf_ptr();
   uint64_t *frame_count         = video_driver_get_frame_count();
   size_t  entries_end           = menu_entries_get_end();

   if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
      return;

   if (!menu)
      return;

   if (!render_normal)
   {
      render_normal = true;
      return;
   }

   menu_display_ctl(MENU_DISPLAY_CTL_MSG_FORCE, &msg_force);

   if (menu_entries_needs_refresh() && menu_driver_alive() 
         && !msg_force)
      return;

   menu_display_fb_unset_dirty();
   menu_animation_clear_active();

   if (!selection_buf)
      return;

   begin = (selection >= (ENTRIES_HEIGHT / 2)) ? 
      (selection - (ENTRIES_HEIGHT / 2)) : 0;
   end   = ((selection + ENTRIES_HEIGHT) <= entries_end)
      ? selection + ENTRIES_HEIGHT : entries_end;

   if (entries_end <= ENTRIES_HEIGHT)
      begin = 0;

   if (end - begin > ENTRIES_HEIGHT)
      end = begin + ENTRIES_HEIGHT;
   
   menu_entries_get_title(title, sizeof(title));

   menu_animation_ticker_str(title_buf, RMENU_TERM_WIDTH,
         *frame_count / 15, title, true);

   font_parms.x = POSITION_EDGE_MIN + POSITION_OFFSET;
   font_parms.y = POSITION_EDGE_MIN + POSITION_RENDER_OFFSET
      - (POSITION_OFFSET*2);
   font_parms.scale = FONT_SIZE_NORMAL;
   font_parms.color = WHITE;

   video_driver_set_osd_msg(title_buf, &font_parms, NULL);

   font_parms.x = POSITION_EDGE_MIN + POSITION_OFFSET;
   font_parms.y = POSITION_EDGE_MAX - (POSITION_OFFSET*2);
   font_parms.scale = FONT_SIZE_NORMAL;
   font_parms.color = WHITE;

   menu_entries_get_core_title(title_msg, sizeof(title_msg));

   video_driver_set_osd_msg(title_msg, &font_parms, NULL);

   j = 0;

   for (i = begin; i < end; i++, j++)
   {
      char entry_path[PATH_MAX_LENGTH]      = {0};
      char entry_value[PATH_MAX_LENGTH]     = {0};
      char message[PATH_MAX_LENGTH]         = {0};
      char entry_title_buf[PATH_MAX_LENGTH] = {0};
      char type_str_buf[PATH_MAX_LENGTH]    = {0};
      unsigned entry_spacing                = menu_entry_get_spacing(i);
      bool entry_selected                   = menu_entry_is_currently_selected(i);

      menu_entry_get_value(i, entry_value, sizeof(entry_value));
      menu_entry_get_path(i, entry_path, sizeof(entry_path));

      menu_animation_ticker_str(entry_title_buf, RMENU_TERM_WIDTH - (entry_spacing + 1 + 2),
            *frame_count / 15, entry_path, entry_selected);
      menu_animation_ticker_str(type_str_buf, entry_spacing,
            *frame_count / 15, entry_value, entry_selected);

      snprintf(message, sizeof(message), "%c %s",
            entry_selected ? '>' : ' ', entry_title_buf);

      font_parms.x = POSITION_EDGE_MIN + POSITION_OFFSET;
      font_parms.y = POSITION_EDGE_MIN + POSITION_RENDER_OFFSET
         + (POSITION_OFFSET * j);
      font_parms.scale = FONT_SIZE_NORMAL;
      font_parms.color = WHITE;

      video_driver_set_osd_msg(message, &font_parms, NULL);

      font_parms.x = POSITION_EDGE_CENTER + POSITION_OFFSET;

      video_driver_set_osd_msg(type_str_buf, &font_parms, NULL);
   }
}
Example #4
0
static void rmenu_render(void)
{
   size_t begin, end, i, j;
   struct font_params font_parms = {0};
   char title[256]               = {0};
   char title_buf[256]           = {0};
   char title_msg[64]            = {0};
   menu_handle_t *menu           = menu_driver_get_ptr();
   menu_display_t *disp          = menu_display_get_ptr();
   menu_animation_t *anim        = menu_animation_get_ptr();
   menu_list_t *menu_list        = menu_list_get_ptr();
   menu_navigation_t *nav        = menu_navigation_get_ptr();
   global_t    *global           = global_get_ptr();
   uint64_t frame_count          = video_driver_get_frame_count();
   size_t  entries_end           = menu_entries_get_end();

   if (!menu)
      return;

   if (!render_normal)
   {
      render_normal = true;
      return;
   }

   if (menu_entries_needs_refresh() && menu_driver_alive() 
         && !disp->msg_force)
      return;

   menu_display_fb_unset_dirty();
   anim->is_active           = false;
   anim->label.is_updated    = false;

   if (!menu_list->selection_buf)
      return;

   begin = (nav->selection_ptr >= (ENTRIES_HEIGHT / 2)) ? 
      (nav->selection_ptr - (ENTRIES_HEIGHT / 2)) : 0;
   end   = ((nav->selection_ptr + ENTRIES_HEIGHT) <= entries_end)
      ? nav->selection_ptr + ENTRIES_HEIGHT : entries_end;

   if (entries_end <= ENTRIES_HEIGHT)
      begin = 0;

   if (end - begin > ENTRIES_HEIGHT)
      end = begin + ENTRIES_HEIGHT;
   
   rmenu_render_background();

   menu_entries_get_title(title, sizeof(title));

   menu_animation_ticker_line(title_buf, RMENU_TERM_WIDTH,
         frame_count / 15, title, true);

   font_parms.x = POSITION_EDGE_MIN + POSITION_OFFSET;
   font_parms.y = POSITION_EDGE_MIN + POSITION_RENDER_OFFSET
      - (POSITION_OFFSET*2);
   font_parms.scale = FONT_SIZE_NORMAL;
   font_parms.color = WHITE;

   video_driver_set_osd_msg(title_buf, &font_parms, NULL);

   font_parms.x = POSITION_EDGE_MIN + POSITION_OFFSET;
   font_parms.y = POSITION_EDGE_MAX - (POSITION_OFFSET*2);
   font_parms.scale = FONT_SIZE_NORMAL;
   font_parms.color = WHITE;

   menu_entries_get_core_title(title_msg, sizeof(title_msg));

   video_driver_set_osd_msg(title_msg, &font_parms, NULL);

   j = 0;

   for (i = begin; i < end; i++, j++)
   {
      char entry_path[PATH_MAX_LENGTH]      = {0};
      char entry_value[PATH_MAX_LENGTH]     = {0};
      char message[PATH_MAX_LENGTH]         = {0};
      char entry_title_buf[PATH_MAX_LENGTH] = {0};
      char type_str_buf[PATH_MAX_LENGTH]    = {0};
      unsigned entry_spacing                = menu_entry_get_spacing(i);
      bool entry_selected                   = menu_entry_is_currently_selected(i);

      menu_entry_get_value(i, entry_value, sizeof(entry_value));
      menu_entry_get_path(i, entry_path, sizeof(entry_path));

      menu_animation_ticker_line(entry_title_buf, RMENU_TERM_WIDTH - (entry_spacing + 1 + 2),
            frame_count / 15, entry_path, entry_selected);
      menu_animation_ticker_line(type_str_buf, entry_spacing,
            frame_count / 15, entry_value, entry_selected);

      snprintf(message, sizeof(message), "%c %s",
            entry_selected ? '>' : ' ', entry_title_buf);

      font_parms.x = POSITION_EDGE_MIN + POSITION_OFFSET;
      font_parms.y = POSITION_EDGE_MIN + POSITION_RENDER_OFFSET
         + (POSITION_OFFSET * j);
      font_parms.scale = FONT_SIZE_NORMAL;
      font_parms.color = WHITE;

      video_driver_set_osd_msg(message, &font_parms, NULL);

      font_parms.x = POSITION_EDGE_CENTER + POSITION_OFFSET;

      video_driver_set_osd_msg(type_str_buf, &font_parms, NULL);
   }
}