Skip to content

Commit

Permalink
1.0.53 release
Browse files Browse the repository at this point in the history
  • Loading branch information
ventoy committed Sep 27, 2021
1 parent 89a34ba commit d72bb15
Show file tree
Hide file tree
Showing 31 changed files with 2,044 additions and 55 deletions.
1,603 changes: 1,603 additions & 0 deletions GRUB2/MOD_SRC/grub-2.04/grub-core/font/font.c

Large diffs are not rendered by default.

31 changes: 25 additions & 6 deletions GRUB2/MOD_SRC/grub-2.04/grub-core/gfxmenu/gui_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,15 @@ struct grub_gui_label
grub_font_t font;
grub_video_rgba_color_t color;
int value;
int vtoytip;
enum align_mode align;
};

typedef struct grub_gui_label *grub_gui_label_t;

extern const char * g_ventoy_tip_msg1;
extern const char * g_ventoy_tip_msg2;

static void
label_destroy (void *vself)
{
Expand All @@ -90,6 +94,7 @@ label_is_instance (void *vself __attribute__((unused)), const char *type)
static void
label_paint (void *vself, const grub_video_rect_t *region)
{
const char *text;
grub_gui_label_t self = vself;

if (! self->visible)
Expand All @@ -98,16 +103,24 @@ label_paint (void *vself, const grub_video_rect_t *region)
if (!grub_video_have_common_points (region, &self->bounds))
return;

if (self->vtoytip == 1) {
text = g_ventoy_tip_msg1 ? g_ventoy_tip_msg1 : "";
} else if (self->vtoytip == 2) {
text = g_ventoy_tip_msg2 ? g_ventoy_tip_msg2 : "";
} else {
text = self->text;
}

/* Calculate the starting x coordinate. */
int left_x;
if (self->align == align_left)
left_x = 0;
else if (self->align == align_center)
left_x = (self->bounds.width
- grub_font_get_string_width (self->font, self->text)) / 2;
- grub_font_get_string_width (self->font, text)) / 2;
else if (self->align == align_right)
left_x = (self->bounds.width
- grub_font_get_string_width (self->font, self->text));
- grub_font_get_string_width (self->font, text));
else
return; /* Invalid alignment. */

Expand All @@ -116,7 +129,7 @@ label_paint (void *vself, const grub_video_rect_t *region)

grub_video_rect_t vpsave;
grub_gui_set_viewport (&self->bounds, &vpsave);
grub_font_draw_string (self->text,
grub_font_draw_string (text,
self->font,
grub_video_map_rgba_color (self->color),
left_x,
Expand Down Expand Up @@ -156,8 +169,8 @@ static void
label_get_minimal_size (void *vself, unsigned *width, unsigned *height)
{
grub_gui_label_t self = vself;
*width = grub_font_get_string_width (self->font, self->text);
*height = (grub_font_get_ascent (self->font)
*width = grub_font_get_string_width (self->font, self->text);
*height = (grub_font_get_ascent (self->font)
+ grub_font_get_descent (self->font));
}

Expand Down Expand Up @@ -255,8 +268,14 @@ label_set_property (void *vself, const char *name, const char *value)
{
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
grub_free (self->id);
if (value)
if (value) {
self->id = grub_strdup (value);
if (grub_strcmp(value, "VTOY_MENU_TIP_1") == 0) {
self->vtoytip = 1;
} else if (grub_strcmp(value, "VTOY_MENU_TIP_2") == 0) {
self->vtoytip = 2;
}
}
else
self->id = 0;
if (self->id && grub_strcmp (self->id, GRUB_GFXMENU_TIMEOUT_COMPONENT_ID)
Expand Down
31 changes: 30 additions & 1 deletion GRUB2/MOD_SRC/grub-2.04/grub-core/gfxmenu/theme_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,8 @@ read_property (struct parsebuf *p)
return grub_errno;
}

extern int g_menu_update_mode;

/* Set properties on the view based on settings from the specified
theme file. */
grub_err_t
Expand All @@ -752,7 +754,7 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
}

p.len = grub_file_size (file);
p.buf = grub_malloc (p.len + 4096);
p.buf = grub_malloc (p.len + 8192);
p.pos = 0;
p.line_num = 1;
p.col_num = 1;
Expand Down Expand Up @@ -781,6 +783,33 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
}
}

{
const char *tip = grub_env_get("VTOY_MENU_TIP_ENABLE");
if (tip && tip[0] == '1')
{
char tmpmsg[512];

grub_memset(tmpmsg, 'w', 500);
tmpmsg[500] = 0;

g_menu_update_mode = 1;
p.len += grub_snprintf(p.buf + p.len, 4096,
"\n+ vbox{\n left = %s\n top = %s\n"
"+ label { id=\"VTOY_MENU_TIP_1\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
"+ label { id=\"VTOY_MENU_TIP_2\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
"}\n",
grub_env_get("VTOY_TIP_LEFT"),
grub_env_get("VTOY_TIP_TOP"),
tmpmsg,
grub_env_get("VTOY_TIP_COLOR"),
grub_env_get("VTOY_TIP_ALIGN"),
tmpmsg,
grub_env_get("VTOY_TIP_COLOR"),
grub_env_get("VTOY_TIP_ALIGN")
);
}
}

if (view->canvas)
view->canvas->component.ops->destroy (view->canvas);

Expand Down
26 changes: 22 additions & 4 deletions GRUB2/MOD_SRC/grub-2.04/grub-core/gfxmenu/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,28 +386,46 @@ redraw_menu_visit (grub_gui_component_t component,
}
}

extern int g_menu_update_mode;

static void grub_gfxmenu_update_all(grub_gfxmenu_view_t view)
{
grub_video_set_area_status(GRUB_VIDEO_AREA_DISABLED);
grub_gfxmenu_view_redraw(view, &view->screen);
}

void
grub_gfxmenu_redraw_menu (grub_gfxmenu_view_t view)
{
update_menu_components (view);

grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
redraw_menu_visit, view);
if (g_menu_update_mode)
grub_gfxmenu_update_all(view);
else
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
redraw_menu_visit, view);

grub_video_swap_buffers ();
if (view->double_repaint)
{
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
redraw_menu_visit, view);
if (g_menu_update_mode)
grub_gfxmenu_update_all(view);
else
grub_gui_iterate_recursively ((grub_gui_component_t) view->canvas,
redraw_menu_visit, view);
}
}


void
grub_gfxmenu_set_chosen_entry (int entry, void *data)
{
grub_gfxmenu_view_t view = data;

view->selected = entry;
grub_gfxmenu_redraw_menu (view);


}

static void
Expand Down
35 changes: 28 additions & 7 deletions GRUB2/MOD_SRC/grub-2.04/grub-core/normal/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#include <grub/gfxterm.h>
#include <grub/dl.h>
#include <grub/env.h>
#include <grub/extcmd.h>
#include <grub/ventoy.h>
#include "ventoy/ventoy_def.h"

int g_ventoy_menu_refresh = 0;
int g_ventoy_memdisk_mode = 0;
Expand Down Expand Up @@ -381,10 +384,28 @@ grub_menu_execute_with_fallback (grub_menu_t menu,

static struct grub_menu_viewer *viewers;

int g_menu_update_mode = 0;
int g_ventoy_tip_label_enable = 0;
const char * g_ventoy_tip_msg1 = NULL;
const char * g_ventoy_tip_msg2 = NULL;

static void
menu_set_chosen_entry (int entry)
menu_set_chosen_entry (grub_menu_t menu, int entry)
{
struct grub_menu_viewer *cur;
img_info *img;
grub_menu_entry_t e = grub_menu_get_entry (menu, entry);

g_ventoy_tip_msg1 = g_ventoy_tip_msg2 = NULL;
if (e && e->id && grub_strncmp(e->id, "VID_", 4) == 0) {
img = (img_info *)(void *)grub_strtoul(e->id + 4, NULL, 16);
if (img)
{
g_ventoy_tip_msg1 = img->tip1;
g_ventoy_tip_msg2 = img->tip2;
}
}

for (cur = viewers; cur; cur = cur->next)
cur->set_chosen_entry (entry, cur->data);
}
Expand Down Expand Up @@ -732,29 +753,29 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
case GRUB_TERM_KEY_HOME:
case GRUB_TERM_CTRL | 'a':
current_entry = 0;
menu_set_chosen_entry (current_entry);
menu_set_chosen_entry (menu, current_entry);
break;

case GRUB_TERM_KEY_END:
case GRUB_TERM_CTRL | 'e':
current_entry = menu->size - 1;
menu_set_chosen_entry (current_entry);
menu_set_chosen_entry (menu, current_entry);
break;

case GRUB_TERM_KEY_UP:
case GRUB_TERM_CTRL | 'p':
case '^':
if (current_entry > 0)
current_entry--;
menu_set_chosen_entry (current_entry);
menu_set_chosen_entry (menu, current_entry);
break;

case GRUB_TERM_CTRL | 'n':
case GRUB_TERM_KEY_DOWN:
case 'v':
if (current_entry < menu->size - 1)
current_entry++;
menu_set_chosen_entry (current_entry);
menu_set_chosen_entry (menu, current_entry);
break;

case GRUB_TERM_CTRL | 'g':
Expand All @@ -763,7 +784,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
current_entry = 0;
else
current_entry -= GRUB_MENU_PAGE_SIZE;
menu_set_chosen_entry (current_entry);
menu_set_chosen_entry (menu, current_entry);
break;

case GRUB_TERM_CTRL | 'c':
Expand All @@ -772,7 +793,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
current_entry += GRUB_MENU_PAGE_SIZE;
else
current_entry = menu->size - 1;
menu_set_chosen_entry (current_entry);
menu_set_chosen_entry (menu, current_entry);
break;

case '\n':
Expand Down
Loading

0 comments on commit d72bb15

Please sign in to comment.