Просмотр исходного кода

Tweak the window close button and centre its x

Use a slightly brighter red and move the x one pixel right so it is centred in the 16-pixel button.  The ring-3 WM and the kernel fallback match.
Johannes Zellner 2 недель назад
Родитель
Сommit
f7d40ba22d
2 измененных файлов с 27 добавлено и 20 удалено
  1. 25 18
      ucmd_wm.c
  2. 2 2
      wm.c

+ 25 - 18
ucmd_wm.c

@@ -11,7 +11,7 @@
 #define COL_BORDER    0xC8C8C8u
 #define COL_BORDER    0xC8C8C8u
 #define COL_TITLE_ON  0x465A96u
 #define COL_TITLE_ON  0x465A96u
 #define COL_TITLE_OFF 0x646464u
 #define COL_TITLE_OFF 0x646464u
-#define COL_CLOSE     0xBE3C3Cu
+#define COL_CLOSE     0xC64040u
 #define COL_WHITE     0xFFFFFFu
 #define COL_WHITE     0xFFFFFFu
 #define COL_BANNER    0x55FF55u
 #define COL_BANNER    0x55FF55u
 
 
@@ -63,6 +63,26 @@ static unsigned int rgb16(unsigned int r, unsigned int g, unsigned int b)
 	return (r << 16) | (g << 8) | b;
 	return (r << 16) | (g << 8) | b;
 }
 }
 
 
+/* Rainbow gradient: hue 0..1535 (6*256) maps to R→Y→G→C→B→M→R, the same
+ * integer interpolation the kernel bar uses. */
+static unsigned int rainbow_rgb(unsigned int hue)
+{
+	unsigned int seg = hue / 256, f = hue % 256;
+	unsigned int r1, g1, b1, r2, g2, b2;
+
+	switch (seg) {
+	case 0: r1=255; g1=0;   b1=0;   r2=255; g2=255; b2=0;   break;
+	case 1: r1=255; g1=255; b1=0;   r2=0;   g2=255; b2=0;   break;
+	case 2: r1=0;   g1=255; b1=0;   r2=0;   g2=255; b2=255; break;
+	case 3: r1=0;   g1=255; b1=255; r2=0;   g2=0;   b2=255; break;
+	case 4: r1=0;   g1=0;   b1=255; r2=255; g2=0;   b2=255; break;
+	default:r1=255; g1=0;   b1=255; r2=255; g2=0;   b2=0;   break;
+	}
+	return rgb16((r1 * (256 - f) + r2 * f) / 256,
+		     (g1 * (256 - f) + g2 * f) / 256,
+		     (b1 * (256 - f) + b2 * f) / 256);
+}
+
 static void fill_clip(int x, int y, unsigned int w, unsigned int h,
 static void fill_clip(int x, int y, unsigned int w, unsigned int h,
 		      unsigned int rgb, int cx, int cy,
 		      unsigned int rgb, int cx, int cy,
 		      unsigned int cw, unsigned int ch)
 		      unsigned int cw, unsigned int ch)
@@ -148,23 +168,10 @@ static void draw_bar(void)
 
 
 	/* Rainbow separator (same y as the kernel's old bar). */
 	/* Rainbow separator (same y as the kernel's old bar). */
 	for (x = 0; x < fbw; x++) {
 	for (x = 0; x < fbw; x++) {
-		unsigned int seg = (x * (6 * 256)) / (fbw ? fbw : 1);
-		unsigned int s = seg / 256, f = seg % 256;
-		unsigned int r1, g1, b1, r2, g2, b2, r, g, b;
-
-		switch (s) {
-		case 0: r1=255; g1=0;   b1=0;   r2=255; g2=255; b2=0;   break;
-		case 1: r1=255; g1=255; b1=0;   r2=0;   g2=255; b2=0;   break;
-		case 2: r1=0;   g1=255; b1=0;   r2=0;   g2=255; b2=255; break;
-		case 3: r1=0;   g1=255; b1=255; r2=0;   g2=0;   b2=255; break;
-		case 4: r1=0;   g1=0;   b1=255; r2=255; g2=0;   b2=255; break;
-		default:r1=255; g1=0;   b1=255; r2=255; g2=0;   b2=0;   break;
-		}
-		r = (r1 * (256 - f) + r2 * f) / 256;
-		g = (g1 * (256 - f) + g2 * f) / 256;
-		b = (b1 * (256 - f) + b2 * f) / 256;
+		unsigned int c = rainbow_rgb((x * (6 * 256)) / (fbw ? fbw : 1));
+
 		for (y = WM_BAR_H - 5; y < WM_BAR_H - 3; y++)
 		for (y = WM_BAR_H - 5; y < WM_BAR_H - 3; y++)
-			usurf_fill(&screen, (int)x, (int)y, 1, 1, rgb16(r, g, b));
+			usurf_fill(&screen, (int)x, (int)y, 1, 1, c);
 	}
 	}
 
 
 	if (bar_kexec_busy) {
 	if (bar_kexec_busy) {
@@ -227,7 +234,7 @@ static void draw_window_clip(unsigned int idx, int cx, int cy,
 		   cx, cy, cw, ch);
 		   cx, cy, cw, ch);
 	fill_clip((int)bx, y + 1, WM_CLOSE_W, WM_TITLE_H, COL_CLOSE,
 	fill_clip((int)bx, y + 1, WM_CLOSE_W, WM_TITLE_H, COL_CLOSE,
 		  cx, cy, cw, ch);
 		  cx, cy, cw, ch);
-	usurf_text(&screen, (int)bx + 3, y + 3, "x", COL_WHITE,
+	usurf_text(&screen, (int)bx + 4, y + 3, "x", COL_WHITE,
 		   cx, cy, cw, ch);
 		   cx, cy, cw, ch);
 
 
 	/* Content. */
 	/* Content. */

+ 2 - 2
wm.c

@@ -1679,8 +1679,8 @@ static void wm_draw_window_clip(struct window *w, unsigned int cx, unsigned int
 
 
 	/* Close button. */
 	/* Close button. */
 	wm_fill_rect_clip(bx, w->y + 1, WM_CLOSE_W, WM_TITLE_H,
 	wm_fill_rect_clip(bx, w->y + 1, WM_CLOSE_W, WM_TITLE_H,
-		cx, cy, cw, ch, 190, 60, 60);
-	fbtext_draw_string_xy_clip(bx + 3, w->y + 3, "x", 255, 255, 255,
+		cx, cy, cw, ch, 198, 64, 64);
+	fbtext_draw_string_xy_clip(bx + 4, w->y + 3, "x", 255, 255, 255,
 		cx, cy, cw, ch);
 		cx, cy, cw, ch);
 
 
 	/* Content: text cells or the gfx canvas. */
 	/* Content: text cells or the gfx canvas. */