All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Testov <vladimir.testov@rosalab.ru>
To: grub-devel@gnu.org
Subject: [PATCH] [10/11] [gfxmenu/list] item_pixmap_style
Date: Thu, 11 Apr 2013 15:40:22 +0400	[thread overview]
Message-ID: <1934013.VOSfu0R28i@icedphoenix> (raw)

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

remake of one of my previous patches

Now it is much better.

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

[-- Attachment #2: grub-2.00-list-item-pixmap-style.patch --]
[-- Type: text/x-patch, Size: 7304 bytes --]

diff -Naur grub-new9/grub-core/gfxmenu/gui_list.c grub-newA/grub-core/gfxmenu/gui_list.c
--- grub-new9/grub-core/gfxmenu/gui_list.c	2013-03-27 11:27:43.851690260 +0400
+++ grub-newA/grub-core/gfxmenu/gui_list.c	2013-04-10 12:51:47.579232188 +0400
@@ -66,9 +66,11 @@
   int need_to_recreate_boxes;
   char *theme_dir;
   char *menu_box_pattern;
+  char *item_box_pattern;
   char *selected_item_box_pattern;
   grub_gfxmenu_box_t menu_box;
   grub_gfxmenu_box_t selected_item_box;
+  grub_gfxmenu_box_t item_box;
 
   grub_gfxmenu_icon_manager_t icon_manager;
 
@@ -89,6 +91,8 @@
     self->menu_box->destroy (self->menu_box);
   if (self->selected_item_box)
     self->selected_item_box->destroy (self->selected_item_box);
+  if (self->item_box)
+    self->item_box-> destroy (self->item_box);
   if (self->icon_manager)
     grub_gfxmenu_icon_manager_destroy (self->icon_manager);
 
@@ -108,6 +112,9 @@
   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);
+  grub_gfxmenu_box_t itbox = self->item_box;
+  int it_top_pad = itbox->get_top_pad (itbox);
+  int it_bottom_pad = itbox->get_bottom_pad (itbox);
       
   if (self->list_version == 0)
     {
@@ -116,8 +123,10 @@
     }
   else
     {
+      int total_top_pad = grub_max (sel_top_pad, it_top_pad);
+      int total_bottom_pad = grub_max (sel_bottom_pad, it_bottom_pad);
       return (self->bounds.height + item_vspace - 2 * boxpad
-              - sel_top_pad - sel_bottom_pad
+              - total_top_pad - total_bottom_pad
               - box_top_pad - box_bottom_pad) / (item_height + item_vspace);
     }
 }
@@ -135,10 +144,15 @@
                              self->selected_item_box_pattern,
                              self->theme_dir);
 
+      grub_gui_recreate_box (&self->item_box,
+                             self->item_box_pattern,
+                             self->theme_dir);
+
       self->need_to_recreate_boxes = 0;
     }
 
-  return (self->menu_box != 0 && self->selected_item_box != 0);
+  return (self->menu_box != 0 && self->selected_item_box != 0
+          && self->item_box != 0);
 }
 
 static int
@@ -237,7 +251,7 @@
 static void
 draw_menu (list_impl_t self, int num_shown_items)
 {
-  if (! self->menu_box || ! self->selected_item_box)
+  if (! self->menu_box || ! self->selected_item_box || ! self->item_box)
     return;
 
   int boxpad = self->item_padding;
@@ -251,9 +265,17 @@
   make_selected_item_visible (self);
 
   grub_gfxmenu_box_t selbox = self->selected_item_box;
-  int sel_leftpad = selbox->get_left_pad (selbox);
+  grub_gfxmenu_box_t itbox = self->item_box;
   int sel_toppad = selbox->get_top_pad (selbox);
+  int it_toppad = itbox->get_top_pad (itbox);
   int item_top = sel_toppad;
+  if ((self->list_version > 0) && (it_toppad > item_top))
+    item_top = it_toppad;
+  int sel_leftpad = selbox->get_left_pad (selbox);
+  int it_leftpad = itbox->get_left_pad (itbox);
+  int total_leftpad = sel_leftpad;
+  if ((self->list_version > 0) && (it_leftpad > total_leftpad))
+    total_leftpad = it_leftpad;
   int menu_index;
   int visible_index;
   struct grub_video_rect oviewport;
@@ -266,25 +288,43 @@
 			   oviewport.height - 2 * boxpad);
 
   int cwidth;
+  int it_cwidth = 0;
   if (self->list_version == 0)
     cwidth = oviewport.width - 2 * boxpad - 2;
   else
-    cwidth = oviewport.width - 2 * boxpad - self->scrollbar_left_pad;
+    {
+      cwidth = oviewport.width - 2 * boxpad - self->scrollbar_left_pad;
+      it_cwidth = cwidth;
+    }
   if (selbox->get_border_width)
     cwidth -= selbox->get_border_width (selbox);
+  if (self->list_version > 0)
+    {
+      if (itbox->get_border_width)
+        it_cwidth -= itbox->get_border_width (itbox);
+    }
   if (self->list_version == 0)
-    selbox->set_content_size (selbox, cwidth, item_height - 1);
+    {
+      selbox->set_content_size (selbox, cwidth, item_height - 1);
+    }
   else
-    selbox->set_content_size (selbox, cwidth, item_height);
+    {
+      selbox->set_content_size (selbox, cwidth, item_height);
+      itbox->set_content_size (itbox, it_cwidth, item_height);
+    }
 
-  int string_left_offset = sel_leftpad + self->icon_width + icon_text_space;
+  int string_left_offset = total_leftpad + self->icon_width + icon_text_space;
   int string_top_offset = (item_height - (ascent + descent)) / 2 + ascent;
   int selected_top_offset;
   int top_offset;
 
+  int total_width = cwidth;
+  if ((self->list_version > 0) && (it_cwidth < total_width))
+    total_width = it_cwidth;
+
   grub_video_rect_t svpsave, sviewport;
   sviewport.x = string_left_offset;
-  sviewport.width = cwidth + sel_leftpad - string_left_offset
+  sviewport.width = total_width + total_leftpad - string_left_offset
                     - self->item_right_space;
   sviewport.height = item_height;
 
@@ -327,6 +367,8 @@
         }
       else
         {
+          if (self->list_version > 0)
+            itbox->draw (itbox, 0, item_top - it_toppad);
           font = item_font;
           color = item_color;
           top_offset = string_top_offset;
@@ -381,7 +423,7 @@
 
   check_boxes (self);
 
-  if (! self->menu_box || ! self->selected_item_box)
+  if (! self->menu_box || ! self->selected_item_box || ! self->item_box)
     return;
 
   grub_gui_set_viewport (&self->bounds, &vpsave);
@@ -492,6 +534,10 @@
       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);
+
+      grub_gfxmenu_box_t itbox = self->item_box;
+      int it_top_pad = itbox->get_top_pad (itbox);
+      int it_bottom_pad = itbox->get_bottom_pad (itbox);
       
       *width = grub_font_get_string_width (self->item_font, "Typical OS");
       width_s = grub_font_get_string_width (self->selected_item_font,
@@ -511,11 +557,13 @@
         }
       else
         {
+          int max_top_pad = grub_max (sel_top_pad, it_top_pad);
+          int max_bottom_pad = grub_max (sel_bottom_pad, it_bottom_pad);
           *height = (item_height * num_items
                      + item_vspace * (num_items - 1)
                      + 2 * boxpad
                      + box_top_pad + box_bottom_pad
-                     + sel_top_pad + sel_bottom_pad);
+                     + max_top_pad + max_bottom_pad);
         }
     }
   else
@@ -601,6 +649,12 @@
       grub_free (self->menu_box_pattern);
       self->menu_box_pattern = value ? grub_strdup (value) : 0;
     }
+  else if (grub_strcmp (name, "item_pixmap_style") == 0)
+    {
+      self->need_to_recreate_boxes = 1;
+      grub_free (self->item_box_pattern);
+      self->item_box_pattern = value ? grub_strdup (value) : 0;
+    }
   else if (grub_strcmp (name, "selected_item_pixmap_style") == 0)
     {
       self->need_to_recreate_boxes = 1;
@@ -754,8 +808,10 @@
   self->need_to_recreate_boxes = 0;
   self->theme_dir = 0;
   self->menu_box_pattern = 0;
+  self->item_box_pattern = 0;
   self->selected_item_box_pattern = 0;
   self->menu_box = grub_gfxmenu_create_box (0, 0);
+  self->item_box = grub_gfxmenu_create_box (0, 0);
   self->selected_item_box = grub_gfxmenu_create_box (0, 0);
 
   self->icon_manager = grub_gfxmenu_icon_manager_new ();

                 reply	other threads:[~2013-04-11 11:40 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=1934013.VOSfu0R28i@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.