Hi again,
I attach an updated version of the patch, with test cases, docs, Changelog
and NEWS included. I hope everything is correct. If not, just let me know.
I hope to sort the separators padding stuff as well. So, if this patch is
right, let me know your thoughts about that. But this is for another thread,
so I will open a new one.
Thanks again.
--
Jesús Guerrero <[EMAIL PROTECTED]>
diff -r -U5 fvwm/fvwm/menus.c fvwm/fvwm/menus.c
--- fvwm/fvwm/menus.c 2008-03-11 17:09:42.000000000 +0100
+++ fvwm/fvwm/menus.c 2008-03-11 18:02:52.000000000 +0100
@@ -1601,11 +1603,11 @@
int separator_height;
separator_height = (last_item_has_relief) ?
MENU_SEPARATOR_HEIGHT + relief_thickness :
MENU_SEPARATOR_TOTAL_HEIGHT;
- MI_Y_OFFSET(mi) = y;
+ MI_Y_OFFSET(mi) = y + MST_VERTICAL_MARGIN_TOP(msp->menu);
if (MI_IS_TITLE(mi))
{
MI_HEIGHT(mi) = MST_PTITLEFONT(msp->menu)->height +
MST_TITLE_GAP_ABOVE(msp->menu) +
MST_TITLE_GAP_BELOW(msp->menu);
@@ -1796,11 +1798,13 @@
if (MR_LAST_ITEM(msp->menu) != NULL &&
MI_IS_SELECTABLE(MR_LAST_ITEM(msp->menu)))
{
y += relief_thickness;
}
- MR_HEIGHT(msp->menu) = y + MST_BORDER_WIDTH(msp->menu);
+ MR_HEIGHT(msp->menu) = y + MST_BORDER_WIDTH(msp->menu)
+ + MST_VERTICAL_MARGIN_TOP(msp->menu)
+ + MST_VERTICAL_MARGIN_BOTTOM(msp->menu);
return has_continuation_menu;
}
/*
diff -r -U5 fvwm/fvwm/menustyle.c fvwm/fvwm/menustyle.c
--- fvwm/fvwm/menustyle.c 2008-03-11 17:09:44.000000000 +0100
+++ fvwm/fvwm/menustyle.c 2008-03-11 16:23:16.000000000 +0100
@@ -303,10 +303,31 @@
*below = val[1];
return;
}
+static void parse_vertical_margins_line(
+ char *args, signed char *top, signed char *bottom,
+ signed char top_default, signed char bottom_default)
+{
+ int val[2];
+
+ if (GetIntegerArguments(args, NULL, val, 2) != 2 ||
+ val[0] < 0 || val[0] > MAX_MENU_MARGIN ||
+ val[1] < 0 || val[1] > MAX_MENU_MARGIN)
+ {
+ /* illegal or missing parameters, return to default */
+ *top = top_default;
+ *bottom = bottom_default;
+ return;
+ }
+ *top = val[0];
+ *bottom = val[1];
+
+ return;
+}
+
static MenuStyle *menustyle_parse_old_style(F_CMD_ARGS)
{
char *buffer, *rest;
char *fore, *back, *stipple, *font, *style, *animated;
MenuStyle *ms = NULL;
@@ -404,10 +425,11 @@
"PopupIgnore", "PopupClose",
"MouseWheel", "ScrollOffPage",
"TrianglesUseFore",
"TitleColorset", "HilightTitleBack",
"TitleFont",
+ "VerticalMargins",
NULL
};
return GetTokenIndex(option, optlist, 0, NULL);
}
@@ -957,10 +979,12 @@
ST_DO_HILIGHT_BACK(tmpms) = 1;
ST_DO_HILIGHT_FORE(tmpms) = 1;
}
/* common settings */
+ ST_VERTICAL_MARGIN_TOP(tmpms) = 0;
+ ST_VERTICAL_MARGIN_BOTTOM(tmpms) = 0;
ST_CSET_MENU(tmpms) = 0;
ST_HAS_MENU_CSET(tmpms) = 0;
ST_CSET_ACTIVE(tmpms) = 0;
ST_HAS_ACTIVE_CSET(tmpms) = 0;
ST_CSET_GREYED(tmpms) = 0;
@@ -1565,11 +1589,16 @@
ST_PTITLEFONT(tmpms) = new_font;
ST_USING_DEFAULT_TITLEFONT(tmpms) = False;
}
has_gc_changed = True;
break;
-
+ case 62: /* VerticalMargins */
+ parse_vertical_margins_line(
+ args, &ST_VERTICAL_MARGIN_TOP(tmpms),
+ &ST_VERTICAL_MARGIN_BOTTOM(tmpms),
+ 0, 0);
+ break;
#if 0
case 99: /* PositionHints */
/* to be implemented */
break;
@@ -1741,10 +1770,13 @@
ST_HAS_TRIANGLE_RELIEF(destms) = ST_HAS_TRIANGLE_RELIEF(origms);
/* PopupDelayed */
ST_DO_POPUP_IMMEDIATELY(destms) = ST_DO_POPUP_IMMEDIATELY(origms);
/* DoubleClickTime */
ST_DOUBLE_CLICK_TIME(destms) = ST_DOUBLE_CLICK_TIME(origms);
+ /* VerticalMargins */
+ ST_VERTICAL_MARGIN_TOP(destms) = ST_VERTICAL_MARGIN_TOP(origms);
+ ST_VERTICAL_MARGIN_BOTTOM(destms) = ST_VERTICAL_MARGIN_BOTTOM(origms);
/* SidePic */
if (ST_SIDEPIC(destms))
{
PDestroyFvwmPicture(dpy, ST_SIDEPIC(destms));
diff -r -U5 fvwm/fvwm/menustyle.h fvwm/fvwm/menustyle.h
--- fvwm/fvwm/menustyle.h 2008-03-11 17:09:44.000000000 +0100
+++ fvwm/fvwm/menustyle.h 2008-03-11 16:13:20.000000000 +0100
@@ -171,10 +171,14 @@
#define MST_DOUBLE_CLICK_TIME(m) ((m)->s->ms->feel.DoubleClickTime)
#define ST_ITEM_FORMAT(s) ((s)->feel.item_format)
#define MST_ITEM_FORMAT(m) ((m)->s->ms->feel.item_format)
#define ST_SELECT_ON_RELEASE_KEY(s) ((s)->feel.select_on_release_key)
#define MST_SELECT_ON_RELEASE_KEY(m) ((m)->s->ms->feel.select_on_release_key)
+#define ST_VERTICAL_MARGIN_TOP(s) ((s)->look.vertical_margins.top)
+#define MST_VERTICAL_MARGIN_TOP(m) ((m)->s->ms->look.vertical_margins.top)
+#define ST_VERTICAL_MARGIN_BOTTOM(s) ((s)->look.vertical_margins.bottom)
+#define MST_VERTICAL_MARGIN_BOTTOM(m) ((m)->s->ms->look.vertical_margins.bottom)
/* ---------------------------- type definitions --------------------------- */
typedef enum
{
@@ -288,10 +292,15 @@
signed char separator_above;
signed char separator_below;
} vertical_spacing;
struct
{
+ unsigned char top;
+ unsigned char bottom;
+ } vertical_margins;
+ struct
+ {
int menu;
int active;
int greyed;
int title;
} cset;
diff -r -U5 fvwm/libs/defaults.h fvwm/libs/defaults.h
--- fvwm/libs/defaults.h 2008-03-11 17:09:46.000000000 +0100
+++ fvwm/libs/defaults.h 2008-03-11 16:21:12.000000000 +0100
@@ -87,10 +87,12 @@
#define DEFAULT_MENU_TITLE_TEXT_Y_OFFSET2 (DEFAULT_MENU_ITEM_TEXT_Y_OFFSET2)
/* minimum for above value */
#define MIN_VERTICAL_SPACING -100 /* pixels */
/* maximum for above value */
#define MAX_VERTICAL_SPACING 100 /* pixels */
+/* maximum for above value */
+#define MAX_MENU_MARGIN 50 /* pixels */
/* width of a tab in the item format of a menu */
#define MENU_TAB_WIDTH 8 /* spaces */
/* This is the tile width or height for V and H gradients. I guess this should
* better be a power of two. A value of 5 definitely causes XFree 3.3.3.1 to
* screw up the V_GRADIENT on an 8 bit display, but 4, 6, 7 etc. work well. */
diff -r -U5 fvwm/doc/commands/MenuStyle.xml fvwm/doc/commands/MenuStyle.xml
--- fvwm/doc/commands/MenuStyle.xml 2007-08-18 00:36:49.000000000 +0200
+++ fvwm/doc/commands/MenuStyle.xml 2008-03-12 00:20:57.000000000 +0100
@@ -70,10 +70,11 @@
RemoveSubmenus / HoldSubmenus,
SubmenusRight / SubmenusLeft,
SelectOnRelease,
ItemFormat,
VerticalItemSpacing,
+VerticalMargins,
VerticalTitleSpacing,
AutomaticHotkeys / !AutomaticHotkeys,
MouseWheel,
ScrollOffPage / !ScrollOffPage,
TrianglesUseFore / !TrianglesUseFore.</para>
@@ -684,10 +685,19 @@
may screw up the menu completely. If no arguments are given or
the given arguments are invalid, the built-in defaults are used:
one pixel above the item or title and two below.</para>
<para>
+<fvwmopt cmd="MenuStyle" opt="VerticalMargins"/>
+can be used to add some padding on the top and bottom borders of
+the menus. It takes two numeric arguments that must be positive
+integers. If the number of arguments or its values are incorrect,
+fvwm defaults both to 0, which means no padding at all. If the
+values are correct, the first one is used for the top margin, and
+the second one is used for the bottom margin.</para>
+
+<para>
<fvwmopt cmd="MenuStyle" opt="SubmenusLeft"/>
mirrors the menu layout and behavior. Sub menus pop up to the
left, the sub menu triangle is drawn left and the mini icon and
side picture are drawn at the right side of the menu. The default
is
diff -r -U5 fvwm/tests/menus/menus.read fvwm/tests/menus/menus.read
--- fvwm/tests/menus/menus.read 2001-07-21 21:29:27.000000000 +0200
+++ fvwm/tests/menus/menus.read 2008-03-12 00:25:34.000000000 +0100
@@ -10,10 +10,11 @@
# - SideColor
# - SeparatorsLong / SeparatorsShort
# - TitleUnderlines0 / TitleUnderlines1 / TitleUnderlines2
# - VerticalItemSpacing
# - VerticalTitleSpacing
+# - VerticalMargins
# - BorderWidth
# - Hilight3DThickness / Hilight3DThick / Hilight3DThin / Hilight3DOff
# - ItemFormat:
# %l %c %r %i %| %< %> %s %(left).(right)(...) [%](space) [%](tab) %p
# - Empty menus, items, formats and missing parts in the menus, separators
@@ -129,10 +130,28 @@
UseDefaultItems
DoTest
NewTest "%s%.1|%.5i%.5l%.5l%.5r%.5i%2.3>%1|" ", titleunderlines1, verticalitemspacing 1 -1" "vis 1 -1" "vis 1 -1"
UseDefaultItems
DoTest
+NewTest "%s%.1|%.5i%.5l%.5l%.5r%.5i%2.3>%1|" ", titleunderlines1, verticalmargins 10 20" "vis 10 20" "vis 10 20"
+UseDefaultItems
+DoTest
+NewTest "%s%.1|%.5i%.5l%.5l%.5r%.5i%2.3>%1|" ", titleunderlines2, verticalmargins 0 0" "vis 10 20" "vis 10 20"
+UseDefaultItems
+DoTest
+NewTest "%s%.1|%.5i%.5l%.5l%.5r%.5i%2.3>%1|" ", titleunderlines1, verticalmargins" "vis 10 20" "vis 10 20"
+UseDefaultItems
+DoTest
+NewTest "%s%.1|%.5i%.5l%.5l%.5r%.5i%2.3>%1|" ", titleunderlines2, verticalmargins -10 -20" "vis 10 20" "vis 10 20"
+UseDefaultItems
+DoTest
+NewTest "%s%.1|%.5i%.5l%.5l%.5r%.5i%2.3>%1|" ", titleunderlines1, verticalmargins -10 20" "vis 10 20" "vis 10 20"
+UseDefaultItems
+DoTest
+NewTest "%s%.1|%.5i%.5l%.5l%.5r%.5i%2.3>%1|" ", titleunderlines2, verticalmargins 10 -20" "vis 10 20" "vis 10 20"
+UseDefaultItems
+DoTest
#
# Submenus
#
Echo ***
diff -r -U5 fvwm/tests/menus/README fvwm/tests/menus/README
--- fvwm/tests/menus/README 2001-01-21 14:40:17.000000000 +0100
+++ fvwm/tests/menus/README 2008-03-12 00:27:16.000000000 +0100
@@ -21,10 +21,11 @@
SideColor
SeparatorsLong / SeparatorsShort
TitleUnderlines0 / TitleUnderlines1 / TitleUnderlines2
VerticalItemSpacing
VerticalTitleSpacing
+ VerticalMargins
BorderWidth
Hilight3DThickness / Hilight3DThick / Hilight3DThin / Hilight3DOff
ItemFormat:
%l %c %r %i %| %< %> %s %(left).(right)(...) [%](space) [%](tab) %p
- Empty menus, items, formats and missing parts in the menus, separators
diff -r -U5 fvwm/tests/purify/purify.fvwm2rc fvwm/tests/purify/purify.fvwm2rc
--- fvwm/tests/purify/purify.fvwm2rc 2004-05-30 16:05:49.000000000 +0200
+++ fvwm/tests/purify/purify.fvwm2rc 2008-03-12 00:32:35.000000000 +0100
@@ -350,13 +350,17 @@
AddTest "Test MenuStyle" MenuStyle-Func
AddToFunc MenuStyle-Func
# Attempt to use every option:
+ I MenuStyle FvwmStyle Fvwm, BorderWidth 10, Foreground black, Background Gray
+ I MenuStyle FvwmStyle Greyed blue, HilightBack, ActiveFore, Hilight3DThick
+ + I MenuStyle FvwmStyle VerticalMargins 0 0
+ I MenuStyle FvwmStyle Animation, Font "xft:monospace;9x15bold/iso8859-1"
+ + I MenuStyle FvwmStyle VerticalMargins -1 1
+ I MenuStyle FvwmStyle PopupOffset 2 2, TitleWarp, DoubleClickTime 500
+ + I MenuStyle FvwmStyle VerticalMargins 1 -1
+ I MenuStyle FvwmStyle PopupImmediately, PopdownImmediately
+ + I MenuStyle FvwmStyle VerticalMargins -1 -1
+ I MenuStyle FvwmStyle TitleUnderlines0, SeparatorsLong, TrianglesSolid
+ I MenuStyle FvwmStyle AutomaticHotkeys, PopupAsRootMenu, RemoveSubmenus
+ I MenuStyle FvwmStyle SubmenusRight, SelectOnRelease Alt, VerticalItemSpacing -2
+ I MenuStyle MwmStyle Mwm, HilightBackOff, ActiveForeOff, Hilight3DThin
--- fvwm/NEWS 2008-03-10 12:16:07.000000000 +0100
+++ fvwm/NEWS 2008-03-12 01:13:21.000000000 +0100
@@ -5,6 +5,10 @@
Changes in beta release 2.5.26 (not released yet)
+* New features:
+
+ - New MenuStyle: VerticalMargins
+
* Bug fixes:
- Fixed crash in ARGB visual detection code.
--- fvwm/ChangeLog 2008-03-10 12:16:07.000000000 +0100
+++ fvwm/ChangeLog 2008-03-12 01:12:03.000000000 +0100
@@ -1,3 +1,38 @@
+2008-03-12 Jesús Guerrero <i92guboj(at)terra(dot)es>
+
+ * fvwm/menus.c (size_menu_vertically):
+ added paddings at the top and bottom of the menus
+
+ *fvwm/menustyle.c (parse_vertical_margins_line):
+ new function to parse the VerticalMargins new MenuStyle
+ command
+
+ *fvwm/menustyle.c (menustyle_get_styleopt_index):
+ added the VerticalMargins option to the list
+
+ *fvwm/menustyle.c (menustyle_parse_style):
+ added default values for the padding, and a case clause
+ for the specific case when you invoke the VerticalMargins
+ MenuStyle
+
+ *fvwm/menustyle.c (menustyle_copy):
+ added two lines to copy the menu styles from origin to destiny
+
+ *fvwm/menustyle.h:
+ added macros for the vertical padding stuff
+
+ *fvwm/menustyle.h (struct MenuLook):
+ added sub-structure to hold the VerticalMargins
+
+ *fvwm/libs/defaults.h:
+ added one define for MAX_MENU_MARGIN
+
+ *doc/commands/MenuStyle.xml:
+ *tests/menus/menus.read:
+ *tests/menus/README:
+ *tests/purify/purify.fvwm2rc:
+ documentation and test stuff for VerticalMargins
+
2008-03-09 Dominik Vogt <dominik(dot)vogt(at)gmx(dot)de>
* fvwm/menuitem.c (draw_highlight_background):