On Fri, 7 Mar 2008 00:44:09 +0100
Jesús Guerrero <[EMAIL PROTECTED]> wrote:

I didn't know about the test tools in the package. The test config
file for the menu certainly probed helpful when testing this patch.

This is the patch to get flat 1pix thick separators in the menus.
Patch attached: FlatSeparators
-- 
Jesús Guerrero <[EMAIL PROTECTED]>
diff -U5 -r 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-07 03:24:46.000000000 +0100
@@ -56,11 +56,11 @@
 MenuFace,
 PopupDelay,
 PopupOffset,
 TitleWarp / !TitleWarp,
 TitleUnderlines0 / TitleUnderlines1 / TitleUnderlines2,
-SeparatorsLong / SeparatorsShort,
+SeparatorsLong / SeparatorsShort / FlatSeparators,
 TrianglesSolid / TrianglesRelief,
 PopupImmediately / PopupDelayed,
 PopdownImmediately / PopdownDelayed,
 PopupActiveArea,
 DoubleClickTime,
@@ -429,10 +429,15 @@
 set the length of menu separators.  Long separators run from the
 left edge all the way to the right edge.  Short separators leave a
 few pixels to the edges of the menu.</para>
 
 <para>
+<fvwmopt cmd="MenuStyle" opt="FlatSeparators"/>
+changes the separators so that they are a single pixel thick and
+colored the same as the text.</para>
+
+<para>
 <fvwmopt cmd="MenuStyle" opt="TrianglesSolid"/> and
 <fvwmopt cmd="MenuStyle" opt="TrianglesRelief"/>
 affect how the small triangles for sub menus is drawn.  Solid
 triangles are filled with a color while relief triangles are
 hollow.</para>
diff -U5 -r fvwm/fvwm/menuitem.c fvwm/fvwm/menuitem.c
--- fvwm/fvwm/menuitem.c	2007-07-26 10:00:43.000000000 +0200
+++ fvwm/fvwm/menuitem.c	2008-03-07 03:18:49.000000000 +0100
@@ -80,14 +80,22 @@
  *
  *  Draws two horizontal lines to form a separator
  *
  */
 static void draw_separator(
-	Window w, GC TopGC, GC BottomGC, int x1, int y, int x2)
+	Window w, GC TopGC, GC BottomGC, GC ForeGC, int x1, int y, int x2,
+	Bool do_flat_separators)
 {
-	XDrawLine(dpy, w, TopGC   , x1,   y,   x2,   y);
-	XDrawLine(dpy, w, BottomGC, x1-1, y+1, x2+1, y+1);
+   if (do_flat_separators)
+   {
+       XDrawLine(dpy, w, ForeGC, x1, y, x2, y);
+   }
+   else
+   {
+       XDrawLine(dpy, w, TopGC   , x1,   y,   x2,   y);
+       XDrawLine(dpy, w, BottomGC, x1-1, y+1, x2+1, y+1);
+   }
 
 	return;
 }
 
 /*
@@ -380,10 +388,11 @@
 	int off_cs;
 	FvwmRenderAttributes fra;
 	/*Pixel fg, fgsh;*/
 	int relief_thickness = ST_RELIEF_THICKNESS(ms);
 	Bool is_item_selected;
+	Bool do_flat_separators;
 	Bool item_cleared = False;
 	Bool xft_clear = False;
 	Bool empty_inter = False;
 	XRectangle b;
 	Region region = None;
@@ -598,10 +607,12 @@
 
 	/*
 	 * Draw the item itself.
 	 */
 
+	do_flat_separators = ST_DO_FLAT_SEPARATOR(ms);
+	
 	/* Calculate the separator offsets. */
 	if (ST_HAS_LONG_SEPARATORS(ms))
 	{
 		sx1 = MDIM_ITEM_X_OFFSET(*dim) + relief_thickness;
 		sx2 = MDIM_ITEM_X_OFFSET(*dim) + MDIM_ITEM_WIDTH(*dim) - 1 -
@@ -618,13 +629,13 @@
 	{
 		if (sx1 < sx2)
 		{
 			/* It's a separator. */
 			draw_separator(
-				mpip->w, gcs.shadow_gc, gcs.hilight_gc, sx1,
-				y_offset + y_height - MENU_SEPARATOR_HEIGHT,
-				sx2);
+				mpip->w, gcs.shadow_gc, gcs.hilight_gc, gcs.fore_gc,
+				sx1, y_offset + y_height - MENU_SEPARATOR_HEIGHT,
+				sx2, do_flat_separators);
 			/* Nothing else to do. */
 		}
 		return;
 	}
 	else if (MI_IS_TEAR_OFF_BAR(mi))
@@ -660,12 +671,12 @@
 			text_y += MENU_SEPARATOR_HEIGHT + add;
 			y = y_offset + add;
 			if (sx1 < sx2)
 			{
 				draw_separator(
-					mpip->w, gcs.shadow_gc, gcs.hilight_gc,
-					sx1, y, sx2);
+					mpip->w, gcs.shadow_gc, gcs.hilight_gc, gcs.fore_gc,
+					sx1, y, sx2, do_flat_separators);
 			}
 		}
 		/* Underline the title. */
 		switch (ST_TITLE_UNDERLINES(ms))
 		{
@@ -674,12 +685,12 @@
 		case 1:
 			if (MI_NEXT_ITEM(mi) != NULL)
 			{
 				y = y_offset + y_height - MENU_SEPARATOR_HEIGHT;
 				draw_separator(
-					mpip->w, gcs.shadow_gc, gcs.hilight_gc,
-					sx1, y, sx2);
+					mpip->w, gcs.shadow_gc, gcs.hilight_gc, gcs.fore_gc,
+					sx1, y, sx2, do_flat_separators);
 			}
 			break;
 		default:
 			for (i = ST_TITLE_UNDERLINES(ms); i-- > 0; )
 			{
diff -U5 -r fvwm/fvwm/menus.c fvwm/fvwm/menus.c
--- fvwm/fvwm/menus.c	2007-11-23 11:12:54.000000000 +0100
+++ fvwm/fvwm/menus.c	2008-03-07 03:18:49.000000000 +0100
@@ -1601,10 +1601,14 @@
 		int separator_height;
 
 		separator_height = (last_item_has_relief) ?
 			MENU_SEPARATOR_HEIGHT + relief_thickness :
 			MENU_SEPARATOR_TOTAL_HEIGHT;
+		if (MST_DO_FLAT_SEPARATOR(msp->menu))
+		{
+			separator_height += 1;
+		}
 		MI_Y_OFFSET(mi) = y;
 		if (MI_IS_TITLE(mi))
 		{
 			MI_HEIGHT(mi) = MST_PTITLEFONT(msp->menu)->height +
 				MST_TITLE_GAP_ABOVE(msp->menu) +
diff -U5 -r fvwm/fvwm/menustyle.c fvwm/fvwm/menustyle.c
--- fvwm/fvwm/menustyle.c	2007-08-07 22:17:43.000000000 +0200
+++ fvwm/fvwm/menustyle.c	2008-03-07 03:18:49.000000000 +0100
@@ -403,11 +403,11 @@
 		"PopupActiveArea",
 		"PopupIgnore", "PopupClose",
 		"MouseWheel", "ScrollOffPage",
 		"TrianglesUseFore",
 		"TitleColorset", "HilightTitleBack",
-		"TitleFont",
+		"TitleFont", "FlatSeparators",
 		NULL
 	};
 
 	return GetTokenIndex(option, optlist, 0, NULL);
 }
@@ -878,10 +878,11 @@
 			ST_POPDOWN_DELAY(tmpms) = DEFAULT_POPDOWN_DELAY;
 			ST_MOUSE_WHEEL(tmpms) = MMW_POINTER;
 			ST_SCROLL_OFF_PAGE(tmpms) = 1;
 			ST_DO_HILIGHT_TITLE_BACK(tmpms) = 0;
 			ST_USING_DEFAULT_TITLEFONT(tmpms) = True;
+			ST_DO_FLAT_SEPARATOR(tmpms) = 0;
 			has_gc_changed = True;
 			option = "fvwm";
 		}
 		else
 		{
@@ -1565,11 +1566,13 @@
 				ST_PTITLEFONT(tmpms) = new_font;
 				ST_USING_DEFAULT_TITLEFONT(tmpms) = False;
 			}
 			has_gc_changed = True;
 			break;
-
+		case 62: /* FlatSeparators */
+			ST_DO_FLAT_SEPARATOR(tmpms) = on;
+			break;
 
 #if 0
 		case 99: /* PositionHints */
 			/* to be implemented */
 			break;
@@ -1819,10 +1822,12 @@
 	ST_SCROLL_OFF_PAGE(destms) = ST_SCROLL_OFF_PAGE(origms);
 	/* TrianglesUseFore */
 	ST_TRIANGLES_USE_FORE(destms) = ST_TRIANGLES_USE_FORE(origms);
 	/* Title */
 	ST_DO_HILIGHT_TITLE_BACK(destms) = ST_DO_HILIGHT_TITLE_BACK(origms);
+	/* FlatSeparators */
+	ST_DO_FLAT_SEPARATOR(destms) = ST_DO_FLAT_SEPARATOR(origms);
 
 	menustyle_update(destms);
 
 	return;
 }
diff -U5 -r fvwm/fvwm/menustyle.h fvwm/fvwm/menustyle.h
--- fvwm/fvwm/menustyle.h	2007-01-13 16:07:14.000000000 +0100
+++ fvwm/fvwm/menustyle.h	2008-03-07 03:18:49.000000000 +0100
@@ -21,10 +21,12 @@
 /* look */
 #define ST_FACE(s)                    ((s)->look.face)
 #define MST_FACE(m)                   ((m)->s->ms->look.face)
 #define ST_DO_HILIGHT_BACK(s)         ((s)->look.flags.do_hilight_back)
 #define MST_DO_HILIGHT_BACK(m)        ((m)->s->ms->look.flags.do_hilight_back)
+#define ST_DO_FLAT_SEPARATOR(s)       ((s)->look.flags.do_flat_separator)
+#define MST_DO_FLAT_SEPARATOR(m)      ((m)->s->ms->look.flags.do_flat_separator)
 #define ST_DO_HILIGHT_FORE(s)         ((s)->look.flags.do_hilight_fore)
 #define MST_DO_HILIGHT_FORE(m)        ((m)->s->ms->look.flags.do_hilight_fore)
 #define ST_DO_HILIGHT_TITLE_BACK(s)   ((s)->look.flags.do_hilight_title_back)
 #define MST_DO_HILIGHT_TITLE_BACK(m)			\
 	((m)->s->ms->look.flags.do_hilight_title_back)
@@ -273,10 +275,11 @@
 		unsigned using_default_font : 1;
 		unsigned triangles_use_fore : 1;
 		unsigned has_title_cset : 1;
 		unsigned do_hilight_title_back : 1;
 		unsigned using_default_titlefont : 1;
+		unsigned do_flat_separator : 1;
 	} flags;
 	unsigned char ReliefThickness;
 	unsigned char TitleUnderlines;
 	unsigned char BorderWidth;
 	struct
diff -U5 -r 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-07 03:31:28.000000000 +0100
@@ -6,11 +6,11 @@
 
 # Tested menu styles and parameters
 #
 # - SidePic
 # - SideColor
-# - SeparatorsLong / SeparatorsShort
+# - SeparatorsLong / SeparatorsShort / FlatSeparators
 # - TitleUnderlines0 / TitleUnderlines1 / TitleUnderlines2
 # - VerticalItemSpacing
 # - VerticalTitleSpacing
 # - BorderWidth
 # - Hilight3DThickness / Hilight3DThick / Hilight3DThin / Hilight3DOff
@@ -87,10 +87,13 @@
 UseDefaultItems
 DoTest
 NewTest "%s%.1|%.5i%.5l%.5l%.5r%.5i%2.3>%1|" ", separatorsshort" "separatorsshort" "separatorsshort"
 UseDefaultItems
 DoTest
+NewTest "%s%.1|%.5i%.5l%.5l%.5r%.5i%2.3>%1|" ", flatseparators" "flatseparators" "flatseparators"
+UseDefaultItems
+DoTest
 NewTest "%s%.1|%.5i%.5l%.5l%.5r%.5i%2.3>%1|" ", titleunderlines0" "titleunderlines0" "titleunderlines0"
 UseDefaultItems
 DoTest
 NewTest "%s%.1|%.5i%.5l%.5l%.5r%.5i%2.3>%1|" ", titleunderlines1" "titleunderlines1" "titleunderlines1"
 UseDefaultItems
diff -U5 -r 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-07 03:32:57.000000000 +0100
@@ -17,11 +17,11 @@
 
 - Menu layout code.
 - MenuStyle options:
     SidePic
     SideColor
-    SeparatorsLong / SeparatorsShort
+    SeparatorsLong / SeparatorsShort / FlatSeparators
     TitleUnderlines0 / TitleUnderlines1 / TitleUnderlines2
     VerticalItemSpacing
     VerticalTitleSpacing
     BorderWidth
     Hilight3DThickness / Hilight3DThick / Hilight3DThin / Hilight3DOff
diff -U5 -r 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-07 03:29:07.000000000 +0100
@@ -353,20 +353,20 @@
  + I MenuStyle FvwmStyle Fvwm, BorderWidth 10, Foreground black, Background Gray
  + I MenuStyle FvwmStyle Greyed blue,  HilightBack, ActiveFore, Hilight3DThick
  + I MenuStyle FvwmStyle Animation, Font "xft:monospace;9x15bold/iso8859-1"
  + I MenuStyle FvwmStyle PopupOffset 2 2, TitleWarp, DoubleClickTime 500
  + I MenuStyle FvwmStyle PopupImmediately, PopdownImmediately
- + I MenuStyle FvwmStyle TitleUnderlines0, SeparatorsLong, TrianglesSolid
- + I MenuStyle FvwmStyle AutomaticHotkeys, PopupAsRootMenu, RemoveSubmenus
+ + I MenuStyle FvwmStyle TitleUnderlines0, SeparatorsLong, TrianglesSolid, FlatSeparators
+ + I MenuStyle FvwmStyle AutomaticHotkeys, PopupAsRootMenu, RemoveSubmenus, !FlatSeparators
  + I MenuStyle FvwmStyle SubmenusRight, SelectOnRelease Alt, VerticalItemSpacing -2
 
  + I MenuStyle MwmStyle Mwm, HilightBackOff, ActiveForeOff, Hilight3DThin
  + I MenuStyle MwmStyle AnimationOff, PopupDelayed, PopupDelay 26, TitleWarpOff
  + I MenuStyle MwmStyle PopupDelayed, PopupDelay 26, DoubleClickTime
  + I MenuStyle MwmStyle PopdownDelayed, PopdownDelay 100
  + I MenuStyle MwmStyle Font -*-*-*-*-normal--*-160-75-75-m-50-iso8859-*
- + I MenuStyle MwmStyle TitleUnderlines1, SeparatorsShort, TrianglesRelief
+ + I MenuStyle MwmStyle TitleUnderlines1, SeparatorsShort, TrianglesRelief, FlatSeparators
  + I MenuStyle MwmStyle AutomaticHotkeysOff, PopupAsSubmenu, HoldSubmenus
  + I MenuStyle MwmStyle SubmenusLeft, VerticalTitleSpacing 5
 
  + I MenuStyle WinStyle MenuColorset 0, ActiveColorset 0, GreyedColorset 0
  + I MenuStyle WinStyle Hilight3DOff, PopupImmediately

Reply via email to