fix menu size calculation in presence of selected item pixmap
PATCH 1/1 fix menu size calculation in presence of selected item pixmap
draw_menu() acconted for upper border of selected item pixmap, but not for lower. So it could happen that lower border was visually cut off.
Also various calculations of menu vertical size did not account for space for lower border
--- grub-core/gfxmenu/gui_list.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
grub-core/gfxmenu/gui_list.c +9 -2
@@ -97,8 +97,14 @@ get_num_shown_items (list_impl_t self)grub_gfxmenu_box_t box = self->menu_box;int box_top_pad = box->get_top_pad (box);int box_bottom_pad = box->get_bottom_pad (box); + +grub_gfxmenu_box_t selbox = self->selected_item_box; +int sel_top_pad = selbox->get_top_pad (selbox); +int sel_bottom_pad = selbox->get_bottom_pad (selbox); +return (self->bounds.height + item_vspace -2 * boxpad + - sel_top_pad - sel_bottom_pad - box_top_pad - box_bottom_pad) / (item_height + item_vspace); }
@@ -392,7 +398,8 @@ list_get_minimal_size (void *vself, unsigned *width, unsigned *height)unsigned width_s;grub_gfxmenu_box_t selbox = self->selected_item_box; -int sel_toppad = selbox->get_top_pad (selbox); +int sel_top_pad = selbox->get_top_pad (selbox); +int sel_bottom_pad = selbox->get_bottom_pad (selbox); *width =grub_font_get_string_width (self->item_font,"Typical OS" ); width_s = grub_font_get_string_width (self->selected_item_font,
@@ -406,7 +413,7 @@ list_get_minimal_size (void *vself, unsigned *width, unsigned *height) *height = (item_height * num_items + item_vspace * (num_items -1 ) +2 * boxpad - + box_top_pad + box_bottom_pad + sel_toppad); + + box_top_pad + box_bottom_pad + sel_top_pad + sel_bottom_pad); }else {
Signature · 1 line
tg: (cc35b49..) e/menu-selected-pad (depends on: master)
Quoted 18 lines · Andrey Borzenkov
draw_menu()acconted for upper border of selected item pixmap, but not for lower. So it could happen that lower border was visually cut off.Also various calculations of menu vertical size did not account for space for lower border
Signed-off-by Andrey Borzenkov <[email protected]>--- grub-core/gfxmenu/gui_list.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)grub-core/gfxmenu/gui_list.c +0
-0@@ -97,8 +97,14 @@ get_num_shown_items (list_impl_t self)grub_gfxmenu_box_t box = self->menu_box;
grub-core/gfxmenu/gui_list.c get_num_shown_items (list_impl_t self) · line 107
Quoted 10 lines
grub-core/gfxmenu/gui_list.c +6
-0int box_top_pad = box->get_top_pad (box);int box_bottom_pad = box->get_bottom_pad (box); + +grub_gfxmenu_box_t selbox = self->selected_item_box; +int sel_top_pad = selbox->get_top_pad (selbox); +int sel_bottom_pad = selbox->get_bottom_pad (selbox); +return (self->bounds.height + item_vspace -2 * boxpad + - sel_top_pad - sel_bottom_pad
I don't see the logic behind this. item_top in draw_menu doesn't increase more on selected item than on any other one.
Quoted 22 lines
grub-core/gfxmenu/gui_list.c +3
-2- box_top_pad - box_bottom_pad) / (item_height + item_vspace); }@@ -392,7 +398,8 @@ list_get_minimal_size (void *vself, unsigned *width, unsigned *height)unsigned width_s;grub_gfxmenu_box_t selbox = self->selected_item_box; -int sel_toppad = selbox->get_top_pad (selbox); +int sel_top_pad = selbox->get_top_pad (selbox); +int sel_bottom_pad = selbox->get_bottom_pad (selbox); *width =grub_font_get_string_width (self->item_font,"Typical OS" ); width_s = grub_font_get_string_width (self->selected_item_font,@@ -406,7 +413,7 @@ list_get_minimal_size (void *vself, unsigned *width, unsigned *height) *height = (item_height * num_items + item_vspace * (num_items -1 ) +2 * boxpad - + box_top_pad + box_bottom_pad + sel_toppad); + + box_top_pad + box_bottom_pad + sel_top_pad + sel_bottom_pad); }else {
В Mon, 08 Apr 2013 20:51:17 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:
Quoted 28 lines · Andrey Borzenkov
Quoted 27 lines
draw_menu()acconted for upper border of selected item pixmap, but not for lower. So it could happen that lower border was visually cut off.Also various calculations of menu vertical size did not account for space for lower border
Signed-off-by Andrey Borzenkov <[email protected]>--- grub-core/gfxmenu/gui_list.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)grub-core/gfxmenu/gui_list.c +5
-0@@ -97,8 +97,14 @@ get_num_shown_items (list_impl_t self)grub_gfxmenu_box_t box = self->menu_box;int box_top_pad = box->get_top_pad (box);int box_bottom_pad = box->get_bottom_pad (box); + +grub_gfxmenu_box_t selbox = self->selected_item_box; +int sel_top_pad = selbox->get_top_pad (selbox); +int sel_bottom_pad = selbox->get_bottom_pad (selbox); +
Quoted 6 lines
grub-core/gfxmenu/gui_list.c get_num_shown_items (list_impl_t self) · line 107
Quoted 2 lines
grub-core/gfxmenu/gui_list.c +1
-0return (self->bounds.height + item_vspace -2 * boxpad + - sel_top_pad - sel_bottom_padI don't see the logic behind this.
item_topindraw_menudoesn't increase more on selected item than on any other one.
Layout of menu entries used by draw_menu
sel_top_pad
entry 1item_vspace
entry 2item_vspace
...
entry nsel_bottom_pad
draw_menu() explicitly offsets start of the first menu entry by sel_top_pad (int item_top = sel_toppad;)
Currently get_num_shown_items can return more items than would fit using above scheme. Which results in cut off image below last visible entry. The updated formula ensures all elements are always displayed in full.
Vladimir already demonstrated it a while back with screenshots.
Quoted 25 lines
Quoted 22 lines
grub-core/gfxmenu/gui_list.c +3
-2- box_top_pad - box_bottom_pad) / (item_height + item_vspace); }@@ -392,7 +398,8 @@ list_get_minimal_size (void *vself, unsigned *width, unsigned *height)unsigned width_s;grub_gfxmenu_box_t selbox = self->selected_item_box; -int sel_toppad = selbox->get_top_pad (selbox); +int sel_top_pad = selbox->get_top_pad (selbox); +int sel_bottom_pad = selbox->get_bottom_pad (selbox); *width =grub_font_get_string_width (self->item_font,"Typical OS" ); width_s = grub_font_get_string_width (self->selected_item_font,@@ -406,7 +413,7 @@ list_get_minimal_size (void *vself, unsigned *width, unsigned *height) *height = (item_height * num_items + item_vspace * (num_items -1 ) +2 * boxpad - + box_top_pad + box_bottom_pad + sel_toppad); + + box_top_pad + box_bottom_pad + sel_top_pad + sel_bottom_pad); }else {