All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Testov <vladimir.testov@rosalab.ru>
To: grub-devel@gnu.org
Subject: [PATCH] [4/?] grub-core/gfxmenu/gui_list.c - baseline centering bug
Date: Mon, 15 Jul 2013 17:35:15 +0400	[thread overview]
Message-ID: <1673590.C5H8tbIV1b@icedphoenix> (raw)

[-- Attachment #1: Type: text/plain, Size: 329 bytes --]

See screenshots included.

If the selected entry font is specified and the font has different size than 
non-selected entry's font size (e.g. selected entry has larger font) then the 
baseline of the font will be misaligned.

-- 
With best regards,
_______________________________
Vladimir Testov, ROSA Laboratory.
www.rosalab.ru

[-- Attachment #2: before-list-baseline-bug.png --]
[-- Type: image/png, Size: 5890 bytes --]

[-- Attachment #3: after-list-baseline.png --]
[-- Type: image/png, Size: 4011 bytes --]

[-- Attachment #4: grub-list-baseline-fix.patch --]
[-- Type: text/x-patch, Size: 2313 bytes --]

diff -Naur grub-new3/grub-core/gfxmenu/gui_list.c grub-new4/grub-core/gfxmenu/gui_list.c
--- grub-new3/grub-core/gfxmenu/gui_list.c	2013-07-15 15:30:26.585116409 +0400
+++ grub-new4/grub-core/gfxmenu/gui_list.c	2013-07-15 16:36:34.544169956 +0400
@@ -273,16 +273,30 @@
     cwidth -= selbox->get_border_width (selbox);
   selbox->set_content_size (selbox, cwidth, item_height);
 
-  int string_left_offset = self->icon_width + icon_text_space;
-  int string_top_offset = (item_height - (ascent + descent)) / 2 + ascent;
+  int item_left_offset = self->icon_width + icon_text_space;
+  int item_top_offset = (item_height - (ascent + descent)) / 2 + ascent;
+  int sel_item_top_offset;
+  int top_offset;
 
   grub_video_rect_t svpsave, sviewport;
-  sviewport.x = sel_leftpad + string_left_offset;
-  sviewport.width = cwidth - string_left_offset;
+  sviewport.x = sel_leftpad + item_left_offset;
+  sviewport.width = cwidth - item_left_offset;
   sviewport.height = item_height;
 
   check_colors (self);
 
+  if (self->selected_item_font_set)
+    {
+      int sel_ascent = grub_font_get_ascent (self->selected_item_font);
+      int sel_descent = grub_font_get_descent (self->selected_item_font);
+      sel_item_top_offset = (item_height - (sel_ascent + sel_descent)) / 2 
+                        + sel_ascent;
+    }
+  else
+    {
+      sel_item_top_offset = item_top_offset;
+    }
+
   for (visible_index = 0, menu_index = self->first_shown_index;
        visible_index < num_shown_items && menu_index < self->view->menu->size;
        visible_index++, menu_index++)
@@ -297,11 +311,13 @@
           selbox->draw (selbox, 0, item_top - sel_toppad);
           font = self->selected_item_font;
           color = self->selected_item_color;
+          top_offset = sel_item_top_offset;
         }
       else
         {
           font = self->item_font;
           color = self->item_color;
+          top_offset = item_top_offset;
         }
 
       icon = get_item_icon (self, menu_index);
@@ -320,7 +336,7 @@
                              font,
                              color,
                              0,
-                             string_top_offset);
+                             top_offset);
       grub_gui_restore_viewport (&svpsave);
 
       item_top += item_height + item_vspace;

             reply	other threads:[~2013-07-15 13:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-15 13:35 Vladimir Testov [this message]
2013-07-16  8:02 ` [PATCH] [4/?] grub-core/gfxmenu/gui_list.c - baseline centering bug Vladimir Testov
2013-07-20 13:47 ` Andrey Borzenkov
2013-07-22  7:47   ` Vladimir Testov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1673590.C5H8tbIV1b@icedphoenix \
    --to=vladimir.testov@rosalab.ru \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.