fixed item-height, item-spacing, max-elements-shown etc
Quoted 3 lines
I am not sure whether it is appropriate fix. After your patch "box effect" on selected item is effectively lost (it makes
selected_item_boxthe same height as selected item itself).
About "box effect" - there is no "box effect" in menu_box. The menu's box is drawn inside given area. So the idea of "box effect" was unclear to me. (Also, the height of selected element (with box) is item_height + box_pad_top + box_pad_bottom - 1... that "-1" makes the "box effect" totally unclear. My idea was to make GRUB theme be countable to pixel. Also, with my patch (when we can have a box for every unselected element) item_spacing loses it's meaning totally. It has uncertain meaning in current GRUB state too.
I thought that idea of menu's box was more valuable because it has influence to the code.
So, when we need to calculate exact values so the result will request our expectations, the idea of item_height as total height is more acceptable.
Also I have in mind some more changes:
- width of scrollbar (similar but a little trickier)
- move scrollbar (small fix, now scrollbar will be drawn only if we have east
slice of the menu's bitmap.
- if we move scrollbar then we should cut a little items' width (also if
scrollbar's width is total scrollbar width (I mean if we use east and\or west slices of scrollbar_thumb or scrollbar_frame) then it will be easier to calculate)
- also if we move scrollbar then the total idea of the scrollbar will become
more intuitive (like if we work with something in a "window" and it's height is too big then scrollbar will appear in the same "window" and cut the "window's" width.) Mean the scrollbar will appear inside the "window" but not outside.
- now the distance between right side of the selected item's box and the
scrollbar is exactly 2 pixels.
I see two solutions for the last problem.
1) make item_spacing be really space between elements and also the space between menu_items and scrollbar
2) make additional option "scrollbar_spacing"
The first idea seems to me more adequate and simple.
So the idea of making item_height be total height is interconnected with other ideas.
Quoted 2 lines
The actual fix looks much simpler -
get_num_shown_items()should additionally account forself->selected_item_box->get_op_pad().
Also we will need:
1) update menu_box (throuhout code) so it also will have "boxing effect"
2) update height of the selected element
because of menu's box update fix won't look much simplier
Quoted 1 line
Could you make available theme that demonstrates this problem?
Yep, here's the example. Item's height is 20, item's spacing is 10. so in 110px height menu there will be exactly 4 items (20*4+10*(4-1) == 110)
Let's suppose that we install grub2 into /boot/grub2 directory.
1. unpack test.tar.gz to /boot/grub2/test/
2. set GRUB_THEME="/boot/grub2/themes/test/theme.txt" in /etc/default/grub
3. run update-grub2 (or grub-mkconfig -o /boot/grub2/grub.cfg)
4. add "dummy" entries in /boot/grub2/grub.cfg if needed
so we see result on test_2.png - when we move to the bottom - the box of the selected item is not fully drawn
P.S.
Sorry, for the big message.
There are some more ideas how to make grub2 theming better. I really would like to discuss (the ones I've mentioned and the ones I did not).
I have working solutions for the ideas I had mentioned.
Signature · 4 lines
With best regards, _______________________________ Vladimir Testov, ROSA Laboratory. www.rosalab.ru
Sorry for delay.
В Thu, 07 Feb 2013 14:07:08 +0400
Vladimir Testov <[email protected]> пишет:
Quoted 8 lines
Quoted 3 lines
I am not sure whether it is appropriate fix. After your patch "box effect" on selected item is effectively lost (it makes
selected_item_boxthe same height as selected item itself).About "box effect" - there is no "box effect" in
menu_box. The menu's box is drawn inside given area. So the idea of "box effect" was unclear to me. (Also, the height of selected element (with box) isitem_height+box_pad_top+box_pad_bottom- 1... that "-1" makes the "box effect" totally unclear. My idea was to make GRUB theme be countable to pixel.
But it is. You know exactly which size you need. But in practice most themes would probably use dynamic sizing by specifying screen size percentage. I am not sure if grub2 currently dynamically adjusts size to ensure whole number of items fit into it.
Quoted 4 lines
Also, with my patch (when we can
have a box for every unselected element)item_spacingloses it's meaning totally. It has uncertain meaning in current GRUB state too.
It is pretty much certain meaning. Of course I agree that having more detailed "style guide" for writing grub theme would definitely help.
As I understand current code, it lays out quite predictably
outer image top border
selected item box top border
item 1
inter-item space
item 2
iter-item space
...
item n
selected item box lower border
outer image lower border
selected item box itself is overlayed (or, rather, underlayed). It does not change layout. So you, as theme author, has to ensure suitable space to draw selected item box so that it fits without changing existing layout.
Your patch changes text layout for selected item (by reducing available space). As text is vertically aligned, this results in "jumping effect" or part of text may be cut off.
In your example setting menu size to 118 provides for full 4 items + selected item box.
Quoted 6 lines
I thought that idea of menu's box was more valuable because it has influence to the code.
So, when we need to calculate exact values so the result will request our expectations, the idea of
item_heightas total height is more acceptable.
selected item box is not really used to layout items. Only to adjust where the first item is placed, to allow for full top border to be displayed. Patch I just sent also adds space for lower border.
Anyway, this is just my 2c. Hopefully somebody with commit rights or one of original theme authors can chime in :)
PATCH 1/1 fix selected item's height
Quoted 4 lines
selected item box is not really used to layout items. Only to adjust where the first item is placed, to allow for full top border to be displayed. Patch I just sent also adds space for lower border.
By the way, your patch is not absolutely correct. We should correct selected item's height. The formula you have presented do not consider the fact that selected item's height is decreased by 1.
Patch included.
Signature · 4 lines
With best regards, _______________________________ Vladimir Testov, ROSA Laboratory. www.rosalab.ru
grub-core/gfxmenu/gui_list.c +1 -1
@@ -252,7 +252,7 @@int cwidth = oviewport.width -2 * boxpad -2 ;if (selbox->get_border_width) cwidth -= selbox->get_border_width (selbox); - selbox->set_content_size (selbox, cwidth, item_height -1 ); + selbox->set_content_size (selbox, cwidth, item_height); selbox->draw (selbox,0 , item_top - sel_toppad); }
Thanks for the anwser! :)
Quoted 2 lines · Andrey Borzenkov
It is pretty much certain meaning. Of course I agree that having more detailed "style guide" for writing grub theme would definitely help.
I'm just writing that kind of thing right now. With details and schemes. :) It will take some time to finish.
Signature · 4 lines
With best regards, _______________________________ Vladimir Testov, ROSA Laboratory. www.rosalab.ru