From 368d401585e079d52cc57a32b53b70d71ae55acc Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Sat, 9 Feb 2002 18:20:45 +0000 Subject: [PATCH] Add tools and images used for creating the check/radio button images in Sat Feb 9 13:19:20 2002 Owen Taylor * configure.in gtk/Makefile.am gtk/theme-bits/*: Add tools and images used for creating the check/radio button images in the default theme. --- configure.in | 1 + gtk/Makefile.am | 2 +- gtk/theme-bits/.cvsignore | 5 + gtk/theme-bits/Makefile.am | 11 +++ gtk/theme-bits/README | 29 ++++++ gtk/theme-bits/check-13.png | Bin 0 -> 267 bytes gtk/theme-bits/decompose-bits.c | 157 ++++++++++++++++++++++++++++++++ gtk/theme-bits/radio-13.png | Bin 0 -> 306 bytes 8 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 gtk/theme-bits/.cvsignore create mode 100644 gtk/theme-bits/Makefile.am create mode 100644 gtk/theme-bits/README create mode 100644 gtk/theme-bits/check-13.png create mode 100644 gtk/theme-bits/decompose-bits.c create mode 100644 gtk/theme-bits/radio-13.png diff --git a/configure.in b/configure.in index 7295a1c7e..a14539bba 100644 --- a/configure.in +++ b/configure.in @@ -1343,6 +1343,7 @@ gtk/makefile.msc gtk/gtkversion.h gtk/gtk-win32.rc gtk/stock-icons/Makefile +gtk/theme-bits/Makefile modules/Makefile modules/input/Makefile contrib/Makefile diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 8299e45a1..f7c3145ce 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -1,6 +1,6 @@ # Makefile.am for gtk+/gtk -SUBDIRS=stock-icons +SUBDIRS=stock-icons theme-bits INCLUDES = @STRIP_BEGIN@ \ -DG_LOG_DOMAIN=\"Gtk\" \ diff --git a/gtk/theme-bits/.cvsignore b/gtk/theme-bits/.cvsignore new file mode 100644 index 000000000..2e8c3f87e --- /dev/null +++ b/gtk/theme-bits/.cvsignore @@ -0,0 +1,5 @@ +.xvpics +Makefile +Makefile.in +*.lo +decompose-bits diff --git a/gtk/theme-bits/Makefile.am b/gtk/theme-bits/Makefile.am new file mode 100644 index 000000000..47cd0b023 --- /dev/null +++ b/gtk/theme-bits/Makefile.am @@ -0,0 +1,11 @@ +INCLUDES = -I$(top_srcdir) -I$(top_builddir) \ + -DG_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + @GDK_PIXBUF_DEP_CFLAGS@ + +noinst_PROGRAMS = decompose-bits + +decompose_bits_SOURCES = decompose-bits.c +decompose_bits_LDADD = $(top_builddir)/gdk-pixbuf/libgdk_pixbuf-1.3.la + +EXTRA_DIST = check-13.png radio-13.png diff --git a/gtk/theme-bits/README b/gtk/theme-bits/README new file mode 100644 index 000000000..bbb3758c8 --- /dev/null +++ b/gtk/theme-bits/README @@ -0,0 +1,29 @@ +This directory contains bits and pieces used in the default theme. +Right now, it contains a tool for extracting individual part +bitmaps from a composed image, and source images for the default +check and radio buttons. + +The decompose-bits tools takes an image where the first line contains +the colors for each part, and the rest of the image is the actual +image. + +The colors on the first line are: + + pixel 0: black + pixel 1: dark + pixel 2: mid + pixel 3: light + pixel 4: text + pixel 5: text_aa + pixel 6: base + +The generated XBM bits for the base part include the bits for text and +text_aa as well; this is so that the result can be drawn either +with or without the text/text_aa indicator. + +Make sure that any PNG images added to this directory are added with +'cvs add -kb'. + +Owen Taylor +9 February 2002 + diff --git a/gtk/theme-bits/check-13.png b/gtk/theme-bits/check-13.png new file mode 100644 index 0000000000000000000000000000000000000000..50622eff597dec3c3f3df09e3d573c4ceeb58ccc GIT binary patch literal 267 zcmeAS@N?(olHy`uVBq!ia0vp@K+MO%1SG3v8C!uAOS+@4BLl<6e(pbstUx|zfk$L9 z0|U1Z2s2)~TlWVj$X?><>&kwKiBpJQ(=X}AWuVY3PZ!6KiaEU#4EYW#@VM^RZkwkb z#CF7R*QW9Z3?~H>+NBFbrz{Lw|AcRuXE5U_`8WC>Q|f&flDev{UABo-dcJV_rwX;=+BGs@JfopWj)$;F$fajI-*;Wjq)Yo*A+{U|yqY;>@u~{{YaH44$rj JF6*2UngEM6UBdtX literal 0 HcmV?d00001 diff --git a/gtk/theme-bits/decompose-bits.c b/gtk/theme-bits/decompose-bits.c new file mode 100644 index 000000000..0a49bda11 --- /dev/null +++ b/gtk/theme-bits/decompose-bits.c @@ -0,0 +1,157 @@ +#include +#include +#include +#include + +#define BYTES_PER_OUTPUT_LINE 15 + +static gint +output_byte (guchar byte, + gint online) +{ + if (online == BYTES_PER_OUTPUT_LINE) + { + printf (",\n "); + online = 0; + } + else if (online) + { + printf (","); + } + + printf ("0x%02x", byte); + return online + 1; +} + +static void +do_part (GdkPixbuf *pixbuf, + gint part1_index, + gint part2_index, + gint part3_index, + const char *base_name, + const char *part_name) +{ + const guchar *pixels = gdk_pixbuf_get_pixels (pixbuf); + const guchar *color1; + const guchar *color2; + const guchar *color3; + gint rowstride = gdk_pixbuf_get_rowstride (pixbuf); + gint n_channels = gdk_pixbuf_get_n_channels (pixbuf); + gint width = gdk_pixbuf_get_width (pixbuf); + gint height = gdk_pixbuf_get_height (pixbuf); + gint online = 0; + + color1 = pixels + part1_index * n_channels; + color2 = pixels + part2_index * n_channels; + color3 = pixels + part3_index * n_channels; + pixels += rowstride; + + printf ("static char %s_%s_bits[] = {\n", base_name, part_name); + printf (" "); + + while (height--) + { + guchar bit = 1; + guchar byte = 0; + const guchar *p = pixels; + gint n = width; + + while (n--) + { + if ((part1_index > 0 && memcmp (p, color1, n_channels) == 0) || + (part2_index > 0 && memcmp (p, color2, n_channels) == 0) || + (part3_index > 0 && memcmp (p, color3, n_channels) == 0)) + byte |= bit; + + if (bit == 0x80) + { + online = output_byte (byte, online); + byte = 0; + bit = 1; + } + else + bit <<= 1; + + p += n_channels; + } + + if (width & 7) /* a leftover partial byte */ + online = output_byte (byte, online); + + pixels += rowstride; + } + + printf ("};\n"); +} + +typedef enum { + PART_BLACK, + PART_DARK, + PART_MID, + PART_LIGHT, + PART_TEXT, + PART_TEXT_AA, + PART_BASE, + PART_LAST +} Part; + +const char *part_names[PART_LAST] = { + "black", + "dark", + "mid", + "light", + "text", + "aa", + "base", +}; + +int main (int argc, char **argv) +{ + gchar *progname = g_path_get_basename (argv[0]); + GdkPixbuf *pixbuf; + GError *error = NULL; + gint i; + + if (argc != 3) + { + fprintf (stderr, "%s: Usage: %s FILE BASE\n", progname, progname); + exit (1); + } + + g_type_init (); + + pixbuf = gdk_pixbuf_new_from_file (argv[1], &error); + if (!pixbuf) + { + fprintf (stderr, "%s: cannot open file '%s': %s\n", progname, argv[1], error->message); + exit (1); + } + + if (gdk_pixbuf_get_width (pixbuf) < PART_LAST) + { + fprintf (stderr, "%s: source image must be at least %d pixels wide\n", progname, PART_LAST); + exit (1); + } + + if (gdk_pixbuf_get_height (pixbuf) < 1) + { + fprintf (stderr, "%s: source image must be at least 1 pixel height\n", progname); + exit (1); + } + + printf ("/*\n * Extracted from %s, width=%d, height=%d\n */\n", argv[1], + gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf) - 1); + + for (i = 0; i < PART_LAST; i++) + { + /* As a bit of a hack, we want the base image to extend over the text + * and text_aa parts so that we can draw the image either with or without + * the indicator + */ + if (i == PART_BASE) + do_part (pixbuf, PART_BASE, PART_TEXT_AA, PART_TEXT, argv[2], part_names[i]); + else + do_part (pixbuf, i, -1, -1, argv[2], part_names[i]); + } + return 0; +} diff --git a/gtk/theme-bits/radio-13.png b/gtk/theme-bits/radio-13.png new file mode 100644 index 0000000000000000000000000000000000000000..410fd50a1e309ec5ff5d50a95546b9500c9e513c GIT binary patch literal 306 zcmeAS@N?(olHy`uVBq!ia0vp@K+MO%1SG3v8C!uAOS+@4BLl<6e(pbstUx|zfk$L9 z0|U1Z2s2)~TlWVj$X?><>&kwKiBnKtW8LzgeL$guo-U3d6?2kP5)x(@m3A#%xpd;n zKpy4fGWO=wpBEo|@nZ`)up{+-w8is-y-!aRaY;=qFyr2|XwDm%l+xg3N>er|X#e{E zU!yCw=UTy1pB*BG1_ll;d*-$%wD~u3I0l$7GqW6YJvYzl_y7O(YAMV~5^FbZTKG+f z`9#ommXq4v0eg=wS|Dhds>Q6l*z`zw#--4U2C@AY6j~W~D6z4zF*uv0@+KYRxDNCTgQu&X%Q~loCII8`ZQcL? literal 0 HcmV?d00001