All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Testov <vladimir.testov@rosalab.ru>
To: grub-devel@gnu.org
Subject: [PATCH] [3/11] [gfxmenu/list] some code cleaning
Date: Thu, 11 Apr 2013 15:03:07 +0400	[thread overview]
Message-ID: <1996048.qASZFuLNxs@icedphoenix> (raw)

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

reduce number of calculations, make the code more clear

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

[-- Attachment #2: grub-2.00-list-some-cleaning.patch --]
[-- Type: text/x-patch, Size: 2676 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-03-26 17:12:24.522409216 +0400
+++ grub-new4/grub-core/gfxmenu/gui_list.c	2013-03-26 18:03:19.746373903 +0400
@@ -269,6 +269,19 @@
   sviewport.width = cwidth + sel_leftpad - string_left_offset;
   sviewport.height = item_height;
 
+  grub_font_t font, item_font, selected_item_font;
+  grub_video_color_t color, item_color, selected_item_color;
+  item_font = self->item_font;
+  if (self->selected_item_font)
+    selected_item_font = self->selected_item_font;
+  else
+    selected_item_font = item_font;
+  item_color = grub_video_map_rgba_color (self->item_color);
+  if (self->selected_item_color_set)
+    selected_item_color = grub_video_map_rgba_color (self->selected_item_color);
+  else
+    selected_item_color = item_color;
+
   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++)
@@ -280,6 +293,13 @@
         {
           selbox->draw (selbox, 0,
                         item_top - sel_toppad);
+          font = selected_item_font;
+          color = selected_item_color;
+        }
+      else
+        {
+          font = item_font;
+          color = item_color;
         }
 
       icon = get_item_icon (self, menu_index);
@@ -291,20 +311,12 @@
 
       const char *item_title =
         grub_menu_get_entry (self->view->menu, menu_index)->title;
-      grub_font_t font =
-        (is_selected && self->selected_item_font
-         ? self->selected_item_font
-         : self->item_font);
-      grub_video_rgba_color_t text_color =
-        ((is_selected && self->selected_item_color_set)
-         ? self->selected_item_color
-         : self->item_color);
       sviewport.y = item_top;
       if (self->list_version == 0)
         {
           grub_font_draw_string (item_title,
                                  font,
-                                 grub_video_map_rgba_color (text_color),
+                                 color,
                                  string_left_offset,
                                  (item_top + string_top_offset));
         }
@@ -313,7 +325,7 @@
           grub_gui_set_viewport (&sviewport, &svpsave);
           grub_font_draw_string (item_title,
                                  font,
-                                 grub_video_map_rgba_color (text_color),
+                                 color,
                                  0,
                                  string_top_offset);
           grub_gui_restore_viewport (&svpsave);

                 reply	other threads:[~2013-04-11 11:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1996048.qASZFuLNxs@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.