Make it easier to customise colours
authorTomas Frydrych <tomas@sleepfive.com>
Thu, 10 May 2012 06:44:18 +0000 (07:44 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 10 May 2012 10:47:29 +0000 (11:47 +0100)
This commit moves colour definitions to psplash-colors.h so that the
colour scheme can be easily modified by replacing this file rather
than having to maintain a patch.

Signed-off-by: Tomas Frydrych <tomas@sleepfive.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Makefile.am
psplash-colors.h [new file with mode: 0644]
psplash.c
psplash.h

index 75d4af3..c90ebfa 100644 (file)
@@ -4,6 +4,7 @@ AM_CFLAGS = $(GCC_FLAGS) -D_GNU_SOURCE
 
 psplash_SOURCES = psplash.c psplash.h psplash-fb.c psplash-fb.h \
                   psplash-console.c psplash-console.h           \
+                 psplash-colors.h                              \
                  psplash-poky-img.h psplash-bar-img.h radeon-font.h
 
 psplash_write_SOURCES = psplash-write.c psplash.h
diff --git a/psplash-colors.h b/psplash-colors.h
new file mode 100644 (file)
index 0000000..d701089
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  pslash - a lightweight framebuffer splashscreen for embedded devices.
+ *
+ *  Copyright (c) 2012 sleep(5) ltd
+ *  Author: Tomas Frydrych <tomas@sleepfive.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ */
+
+#ifndef _HAVE_PSPLASH_COLORS_H
+#define _HAVE_PSPLASH_COLORS_H
+
+/* This is the overall background color */
+#define PSPLASH_BACKGROUND_COLOR 0xec,0xec,0xe1
+
+/* This is the color of any text output */
+#define PSPLASH_TEXT_COLOR 0x6d,0x6d,0x70
+
+/* This is the color of the progress bar indicator */
+#define PSPLASH_BAR_COLOR 0x6d,0x6d,0x70
+
+/* This is the color of the progress bar background */
+#define PSPLASH_BAR_BACKGROUND_COLOR 0xec,0xec,0xe1
+
+#endif
index 2eaa11e..0158628 100644 (file)
--- a/psplash.c
+++ b/psplash.c
@@ -49,12 +49,12 @@ psplash_draw_msg (PSplashFB *fb, const char *msg)
                        fb->height - (fb->height/6) - h, 
                        fb->width,
                        h,
-                       0xec, 0xec, 0xe1);
+                       PSPLASH_BACKGROUND_COLOR);
 
   psplash_fb_draw_text (fb,
                        (fb->width-w)/2, 
                        fb->height - (fb->height/6) - h,
-                       0x6d, 0x6d, 0x70,
+                       PSPLASH_TEXT_COLOR,
                        &radeon_font,
                        msg);
 }
@@ -75,19 +75,19 @@ psplash_draw_progress (PSplashFB *fb, int value)
       barwidth = (CLAMP(value,0,100) * width) / 100;
       psplash_fb_draw_rect (fb, x + barwidth, y, 
                        width - barwidth, height,
-                       0xec, 0xec, 0xe1);
+                       PSPLASH_BAR_BACKGROUND_COLOR);
       psplash_fb_draw_rect (fb, x, y, barwidth,
-                           height, 0x6d, 0x6d, 0x70);
+                           height, PSPLASH_BAR_COLOR);
     }
   else
     {
       barwidth = (CLAMP(-value,0,100) * width) / 100;
       psplash_fb_draw_rect (fb, x, y, 
                        width - barwidth, height,
-                       0xec, 0xec, 0xe1);
+                       PSPLASH_BAR_BACKGROUND_COLOR);
       psplash_fb_draw_rect (fb, x + width - barwidth,
                            y, barwidth, height,
-                           0x6d, 0x6d, 0x70);
+                           PSPLASH_BAR_COLOR);
     }
 
   DBG("value: %i, width: %i, barwidth :%i\n", value, 
@@ -264,7 +264,8 @@ main (int argc, char** argv)
   }
 
   /* Clear the background with #ecece1 */
-  psplash_fb_draw_rect (fb, 0, 0, fb->width, fb->height, 0xec, 0xec, 0xe1);
+  psplash_fb_draw_rect (fb, 0, 0, fb->width, fb->height,
+                        PSPLASH_BACKGROUND_COLOR);
 
   /* Draw the Poky logo  */
   psplash_fb_draw_image (fb, 
index 22d73a3..f78c117 100644 (file)
--- a/psplash.h
+++ b/psplash.h
@@ -83,5 +83,6 @@ PSplashFont;
 
 #include "psplash-fb.h"
 #include "psplash-console.h"
+#include "psplash-colors.h"
 
 #endif