diff options
author | Ramiro Estrugo <ramiro@src.gnome.org> | 2001-02-13 12:01:16 +0000 |
---|---|---|
committer | Ramiro Estrugo <ramiro@src.gnome.org> | 2001-02-13 12:01:16 +0000 |
commit | b075065c7fbd08a6c7de5c196412015436951ba2 (patch) | |
tree | 43df6f3e8319af5e514f53d3b1831e1eaa466c32 /test | |
parent | 25dcf28b44ff1d4bb0dce83270677d071cd1fa81 (diff) | |
download | nautilus-b075065c7fbd08a6c7de5c196412015436951ba2.tar.gz |
reviewed by: Maciej Stachowiak <mjs@eazel.com>
* libnautilus-extensions/Makefile.am:
* libnautilus-extensions/nautilus-glyph.h:
* libnautilus-extensions/nautilus-glyph.c:
New class. A wrapper on RsvgGlyph that makes it simple and fast
to draw smooth text on pixbufs
* libnautilus-extensions/nautilus-clickable-image.c:
(nautilus_clickable_image_initialize_class),
(nautilus_clickable_image_realize):
Remove unrealize() method that was a noop.
* libnautilus-extensions/nautilus-debug-drawing.c:
(nautilus_debug_pixbuf_draw_point),
(nautilus_debug_pixbuf_draw_rectangle),
(nautilus_debug_pixbuf_draw_rectangle_inset):
* libnautilus-extensions/nautilus-debug-drawing.h:
Add some pixbuf drawing functions to debug clip areas in pixbufs.
* libnautilus-extensions/nautilus-image-table.c:
(nautilus_image_table_initialize_class),
(nautilus_image_table_remove):
Remove add() method that was a noop.
* test/.cvsignore:
* test/Makefile.am:
* test/test-nautilus-font-simple.c: (main):
* test/test-nautilus-font.c: (main):
* test/test-nautilus-glyph-simple.c: (glyph_new), (main):
* test/test-nautilus-glyph.c: (glyph_new), (main):
* test/test.c: (test_window_set_title_with_pid),
(test_pixbuf_draw_rectangle_tiled):
* test/test.h:
New NautilusGlyph tests. Also remove the broken pixbuf drawing
debug code. Use the debugging code in nautilus-debug-drawing.[ch]
instead.
Diffstat (limited to 'test')
-rw-r--r-- | test/.cvsignore | 2 | ||||
-rw-r--r-- | test/Makefile.am | 4 | ||||
-rw-r--r-- | test/test-nautilus-font-simple.c | 13 | ||||
-rw-r--r-- | test/test-nautilus-font.c | 141 | ||||
-rw-r--r-- | test/test-nautilus-glyph-simple.c | 95 | ||||
-rw-r--r-- | test/test-nautilus-glyph.c | 150 | ||||
-rw-r--r-- | test/test.c | 259 | ||||
-rw-r--r-- | test/test.h | 9 |
8 files changed, 375 insertions, 298 deletions
diff --git a/test/.cvsignore b/test/.cvsignore index a65fe4fd3..e0c642411 100644 --- a/test/.cvsignore +++ b/test/.cvsignore @@ -10,6 +10,8 @@ test-nautilus-clickable-image test-nautilus-font test-nautilus-font-picker test-nautilus-font-simple +test-nautilus-glyph +test-nautilus-glyph-simple test-nautilus-image test-nautilus-image-background test-nautilus-image-scrolled diff --git a/test/Makefile.am b/test/Makefile.am index 66af2532f..4a5e8e548 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -35,6 +35,8 @@ noinst_PROGRAMS =\ test-nautilus-font \ test-nautilus-font-picker \ test-nautilus-font-simple \ + test-nautilus-glyph \ + test-nautilus-glyph-simple \ test-nautilus-image \ test-nautilus-image-background \ test-nautilus-image-scrolled \ @@ -66,6 +68,8 @@ test_nautilus_clickable_image_SOURCES = test-nautilus-clickable-image.c test.c test_nautilus_font_SOURCES = test-nautilus-font.c test.c test_nautilus_font_picker_SOURCES = test-nautilus-font-picker.c test_nautilus_font_simple_SOURCES = test-nautilus-font-simple.c test.c +test_nautilus_glyph_SOURCES = test-nautilus-glyph.c test.c +test_nautilus_glyph_simple_SOURCES = test-nautilus-glyph-simple.c test.c test_nautilus_image_SOURCES = test-nautilus-image.c test_nautilus_image_background_SOURCES = test-nautilus-image-background.c test.c test_nautilus_image_scrolled_SOURCES = test-nautilus-image-scrolled.c test.c diff --git a/test/test-nautilus-font-simple.c b/test/test-nautilus-font-simple.c index 2d6812ba3..c7bab0fe7 100644 --- a/test/test-nautilus-font-simple.c +++ b/test/test-nautilus-font-simple.c @@ -12,19 +12,18 @@ main (int argc, char* argv[]) NautilusScalableFont *font; test_init (&argc, &argv); - + font = nautilus_scalable_font_get_default_font (); g_assert (font != NULL); pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 800, 400); g_assert (pixbuf != NULL); - test_pixbuf_draw_rectangle (pixbuf, - -1, -1, -1, -1, - 0, - TRUE, - NAUTILUS_RGB_COLOR_WHITE, - NAUTILUS_OPACITY_FULLY_OPAQUE); + nautilus_debug_pixbuf_draw_rectangle (pixbuf, + TRUE, + -1, -1, -1, -1, + NAUTILUS_RGB_COLOR_WHITE, + NAUTILUS_OPACITY_FULLY_OPAQUE); nautilus_scalable_font_draw_text (font, pixbuf, diff --git a/test/test-nautilus-font.c b/test/test-nautilus-font.c index f16e5ce82..c0bfe070c 100644 --- a/test/test-nautilus-font.c +++ b/test/test-nautilus-font.c @@ -36,12 +36,11 @@ main (int argc, char* argv[]) pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, pixbuf_width, pixbuf_height); g_assert (pixbuf != NULL); - test_pixbuf_draw_rectangle (pixbuf, - -1, -1, -1, -1, - 0, - TRUE, - NAUTILUS_RGB_COLOR_WHITE, - NAUTILUS_OPACITY_FULLY_OPAQUE); + nautilus_debug_pixbuf_draw_rectangle (pixbuf, + TRUE, + -1, -1, -1, -1, + NAUTILUS_RGB_COLOR_WHITE, + NAUTILUS_OPACITY_FULLY_OPAQUE); multi_lines_area.x0 = multi_line_x; multi_lines_area.y0 = multi_line_y; @@ -88,30 +87,30 @@ main (int argc, char* argv[]) clip_area.x1 = clip_area.x0 + 100; clip_area.y1 = clip_area.y0 + 30; - test_pixbuf_draw_rectangle (pixbuf, - clip_area.x0, - clip_area.y0, - clip_area.x1, - clip_area.y1, - -1, - FALSE, - NAUTILUS_RGBA_COLOR_OPAQUE_RED, - NAUTILUS_OPACITY_FULLY_OPAQUE); - + nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf, + FALSE, + clip_area.x0, + clip_area.y0, + clip_area.x1, + clip_area.y1, + NAUTILUS_RGBA_COLOR_OPAQUE_RED, + NAUTILUS_OPACITY_FULLY_OPAQUE, + 1); + whole_area.x0 = 0; whole_area.y0 = 0; whole_area.x1 = whole_area.x0 + pixbuf_width; whole_area.y1 = whole_area.y0 + pixbuf_height; - test_pixbuf_draw_rectangle (pixbuf, - multi_lines_area.x0, - multi_lines_area.y0, - multi_lines_area.x1, - multi_lines_area.y1, - -1, - FALSE, - NAUTILUS_RGBA_COLOR_OPAQUE_RED, - NAUTILUS_OPACITY_FULLY_OPAQUE); + nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf, + FALSE, + multi_lines_area.x0, + multi_lines_area.y0, + multi_lines_area.x1, + multi_lines_area.y1, + NAUTILUS_RGBA_COLOR_OPAQUE_RED, + NAUTILUS_OPACITY_FULLY_OPAQUE, + -1); /* * Multiple text lines test. @@ -156,22 +155,22 @@ main (int argc, char* argv[]) ArtIRect composited_area; GdkPixbuf *tile_pixbuf; - tile_pixbuf = test_pixbuf_new_named ("patterns/pale_coins.png", 1.0); + tile_pixbuf = test_pixbuf_new_named ("patterns/purple_marble.png", 1.0); composited_area.x0 = 270; composited_area.y0 = 80; composited_area.x1 = composited_area.x0 + 200; composited_area.y1 = composited_area.y0 + 200; - test_pixbuf_draw_rectangle (pixbuf, - composited_area.x0, - composited_area.y0, - composited_area.x1, - composited_area.y1, - -1, - FALSE, - NAUTILUS_RGBA_COLOR_OPAQUE_RED, - NAUTILUS_OPACITY_FULLY_OPAQUE); + nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf, + FALSE, + composited_area.x0, + composited_area.y0, + composited_area.x1, + composited_area.y1, + NAUTILUS_RGBA_COLOR_OPAQUE_RED, + NAUTILUS_OPACITY_FULLY_OPAQUE, + -1); nautilus_gdk_pixbuf_draw_to_pixbuf_tiled (tile_pixbuf, pixbuf, @@ -210,15 +209,15 @@ main (int argc, char* argv[]) layout_area.x1 = layout_area.x0 + max_text_width; layout_area.y1 = layout_area.y0 + 130; - test_pixbuf_draw_rectangle (pixbuf, - layout_area.x0, - layout_area.y0, - layout_area.x1, - layout_area.y1, - -1, - FALSE, - NAUTILUS_RGBA_COLOR_OPAQUE_RED, - NAUTILUS_OPACITY_FULLY_OPAQUE); + nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf, + FALSE, + layout_area.x0, + layout_area.y0, + layout_area.x1, + layout_area.y1, + NAUTILUS_RGBA_COLOR_OPAQUE_RED, + NAUTILUS_OPACITY_FULLY_OPAQUE, + -1); nautilus_text_layout_paint (text_layout, pixbuf, @@ -231,15 +230,15 @@ main (int argc, char* argv[]) layout_area.x0 += (max_text_width + 20); layout_area.x1 += (max_text_width + 20); - test_pixbuf_draw_rectangle (pixbuf, - layout_area.x0, - layout_area.y0, - layout_area.x1, - layout_area.y1, - -1, - FALSE, - NAUTILUS_RGBA_COLOR_OPAQUE_RED, - NAUTILUS_OPACITY_FULLY_OPAQUE); + nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf, + FALSE, + layout_area.x0, + layout_area.y0, + layout_area.x1, + layout_area.y1, + NAUTILUS_RGBA_COLOR_OPAQUE_RED, + NAUTILUS_OPACITY_FULLY_OPAQUE, + -1); nautilus_text_layout_paint (text_layout, pixbuf, @@ -252,15 +251,15 @@ main (int argc, char* argv[]) layout_area.x0 += (max_text_width + 20); layout_area.x1 += (max_text_width + 20); - test_pixbuf_draw_rectangle (pixbuf, - layout_area.x0, - layout_area.y0, - layout_area.x1, - layout_area.y1, - -1, - FALSE, - NAUTILUS_RGBA_COLOR_OPAQUE_RED, - NAUTILUS_OPACITY_FULLY_OPAQUE); + nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf, + FALSE, + layout_area.x0, + layout_area.y0, + layout_area.x1, + layout_area.y1, + NAUTILUS_RGBA_COLOR_OPAQUE_RED, + NAUTILUS_OPACITY_FULLY_OPAQUE, + -1); nautilus_text_layout_paint (text_layout, pixbuf, @@ -297,15 +296,15 @@ main (int argc, char* argv[]) layout_area.x1 = layout_area.x0 + text_layout->width; layout_area.y1 = layout_area.y0 + text_layout->height; - test_pixbuf_draw_rectangle (pixbuf, - layout_area.x0, - layout_area.y0, - layout_area.x1, - layout_area.y1, - -1, - FALSE, - NAUTILUS_RGBA_COLOR_OPAQUE_RED, - NAUTILUS_OPACITY_FULLY_OPAQUE); + nautilus_debug_pixbuf_draw_rectangle_inset (pixbuf, + FALSE, + layout_area.x0, + layout_area.y0, + layout_area.x1, + layout_area.y1, + NAUTILUS_RGBA_COLOR_OPAQUE_RED, + NAUTILUS_OPACITY_FULLY_OPAQUE, + -1); nautilus_text_layout_paint (text_layout, pixbuf, diff --git a/test/test-nautilus-glyph-simple.c b/test/test-nautilus-glyph-simple.c new file mode 100644 index 000000000..2c8ed8039 --- /dev/null +++ b/test/test-nautilus-glyph-simple.c @@ -0,0 +1,95 @@ + +#include <config.h> + +#include "test.h" + +#include <libnautilus-extensions/nautilus-glyph.h> + +static NautilusGlyph * +glyph_new (const char *text, int font_size) +{ + NautilusScalableFont *font; + NautilusGlyph *glyph; + + g_return_val_if_fail (text != NULL, NULL); + g_return_val_if_fail (text[0] != '\0', NULL); + g_return_val_if_fail (font_size >= 5, NULL); + g_return_val_if_fail (font_size <= 200, NULL); + + font = nautilus_scalable_font_get_default_font (); + g_return_val_if_fail (font != NULL, NULL); + + glyph = nautilus_glyph_new (font, text, strlen (text), font_size); + g_return_val_if_fail (glyph != NULL, NULL); + + gtk_object_unref (GTK_OBJECT (font)); + + return glyph; +} + +int +main (int argc, char* argv[]) +{ + GdkPixbuf *pixbuf; + NautilusScalableFont *font; + ArtIRect clip_area; + NautilusGlyph *glyph; + const guint font_size = 60; + const int opacity = NAUTILUS_OPACITY_FULLY_OPAQUE; + + const guint pixbuf_width = 640; + const guint pixbuf_height = 480; + const gboolean has_alpha = FALSE; + const guint32 background_color = NAUTILUS_RGB_COLOR_WHITE; + const char text[] = "Something"; + + test_init (&argc, &argv); + + font = nautilus_scalable_font_get_default_font (); + g_assert (font != NULL); + + pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, has_alpha, 8, pixbuf_width, pixbuf_height); + g_assert (pixbuf != NULL); + + nautilus_debug_pixbuf_draw_rectangle (pixbuf, + TRUE, + -1, -1, -1, -1, + background_color, + NAUTILUS_OPACITY_FULLY_OPAQUE); + + nautilus_art_irect_assign (&clip_area, + 60, + 20, + 200, + 100); + + if (0) nautilus_debug_pixbuf_draw_rectangle (pixbuf, + FALSE, + clip_area.x0, + clip_area.y0, + clip_area.x1, + clip_area.y1, + NAUTILUS_RGBA_COLOR_OPAQUE_GREEN, + NAUTILUS_OPACITY_FULLY_OPAQUE); + + glyph = glyph_new (text, font_size); + + nautilus_glyph_draw_to_pixbuf (glyph, + pixbuf, + 30, + 40, + NULL, //&clip_area, + NAUTILUS_RGBA_COLOR_OPAQUE_GREEN, + opacity); + + nautilus_glyph_free (glyph); + + nautilus_debug_show_pixbuf_in_eog (pixbuf); + + gdk_pixbuf_unref (pixbuf); + gtk_object_unref (GTK_OBJECT (font)); + + test_quit (0); + + return 0; +} diff --git a/test/test-nautilus-glyph.c b/test/test-nautilus-glyph.c new file mode 100644 index 000000000..a86bd17cb --- /dev/null +++ b/test/test-nautilus-glyph.c @@ -0,0 +1,150 @@ + +#include <config.h> + +#include "test.h" + +#include <libnautilus-extensions/nautilus-glyph.h> + +static NautilusGlyph * +glyph_new (const char *text, int font_size) +{ + NautilusScalableFont *font; + NautilusGlyph *glyph; + + g_return_val_if_fail (text != NULL, NULL); + g_return_val_if_fail (text[0] != '\0', NULL); + g_return_val_if_fail (font_size >= 5, NULL); + g_return_val_if_fail (font_size <= 200, NULL); + + font = nautilus_scalable_font_get_default_font (); + g_return_val_if_fail (font != NULL, NULL); + + glyph = nautilus_glyph_new (font, text, strlen (text), font_size); + g_return_val_if_fail (glyph != NULL, NULL); + + gtk_object_unref (GTK_OBJECT (font)); + + return glyph; +} + +// static GdkPixbuf * +// glyph_pixbuf_new (const char *text, +// int font_size, +// guint32 text_color) +// { +// NautilusGlyph *glyph; +// GdkPixbuf *pixbuf; + +// g_return_val_if_fail (text != NULL, NULL); +// g_return_val_if_fail (text[0] != '\0', NULL); +// g_return_val_if_fail (font_size >= 5, NULL); +// g_return_val_if_fail (font_size <= 200, NULL); + +// glyph = glyph_new (text, font_size); +// g_return_val_if_fail (glyph != NULL, NULL); + +// pixbuf = nautilus_glyph_as_alpha_pixbuf (glyph, text_color); +// g_return_val_if_fail (pixbuf != NULL, NULL); + +// nautilus_glyph_free (glyph); + +// return pixbuf; +// } + +int +main (int argc, char* argv[]) +{ + GdkPixbuf *pixbuf; + NautilusScalableFont *font; + guint i; + int x; + int y; + + const guint pixbuf_width = 640; + const guint pixbuf_height = 480; + const guint num_glyphs = 1; + const gboolean has_alpha = TRUE; + const guint32 background_color = NAUTILUS_RGB_COLOR_WHITE; + const char text[] = "Something"; + + test_init (&argc, &argv); + + font = nautilus_scalable_font_get_default_font (); + g_assert (font != NULL); + + pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, has_alpha, 8, pixbuf_width, pixbuf_height); + g_assert (pixbuf != NULL); + + if (0) { + nautilus_debug_pixbuf_draw_rectangle (pixbuf, + TRUE, + -1, -1, -1, -1, + background_color, + NAUTILUS_OPACITY_FULLY_OPAQUE); + } else { + test_pixbuf_draw_rectangle_tiled (pixbuf, + "patterns/brushed_metal.png", + -1, -1, -1, -1, + NAUTILUS_OPACITY_FULLY_OPAQUE); + } + + x = 10; + y = 50; + + for (i = 0; i < num_glyphs; i++) { + ArtIRect clip_area; + NautilusGlyph *glyph; + + const guint font_size = 100; + const int opacity = NAUTILUS_OPACITY_FULLY_OPAQUE; + + nautilus_art_irect_assign (&clip_area, + 0, + 0, + 1000, + 1000); + + nautilus_debug_pixbuf_draw_rectangle (pixbuf, + FALSE, + clip_area.x0, + clip_area.y0, + clip_area.x1, + clip_area.y1, + NAUTILUS_RGBA_COLOR_OPAQUE_GREEN, + NAUTILUS_OPACITY_FULLY_OPAQUE); + + glyph = glyph_new (text, font_size); + + nautilus_glyph_draw_to_pixbuf (glyph, + pixbuf, + x, + y, + NULL, + NAUTILUS_RGBA_COLOR_OPAQUE_RED, + opacity); + + nautilus_glyph_free (glyph); + + nautilus_scalable_font_draw_text (font, + pixbuf, + x, + y + font_size + 4, + NULL, + font_size, + font_size, + text, + strlen (text), + NAUTILUS_RGBA_COLOR_OPAQUE_RED, + opacity); + } + + nautilus_debug_show_pixbuf_in_eog (pixbuf); + + gdk_pixbuf_unref (pixbuf); + + gtk_object_unref (GTK_OBJECT (font)); + + test_quit (0); + + return 0; +} diff --git a/test/test.c b/test/test.c index ad1ba0be8..c32b84313 100644 --- a/test/test.c +++ b/test/test.c @@ -212,217 +212,6 @@ test_label_new (const char *text, return label; } -static void -rgba_run_alpha (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int alpha, int n) -{ - int i; - int v; - - for (i = 0; i < n; i++) - { - v = *buf; - *buf++ = v + (((r - v) * alpha + 0x80) >> 8); - v = *buf; - *buf++ = v + (((g - v) * alpha + 0x80) >> 8); - v = *buf; - *buf++ = v + (((b - v) * alpha + 0x80) >> 8); - - *buf++ = 255; - } -} - -typedef void (*FillRunCallback) (art_u8 *buf, art_u8 r, art_u8 g, art_u8 b, int alpha, int n); - -/* This function is totally broken. - * Amongst other interesting things it will write outside - * the pixbufs pixels. - */ -static void -pixbuf_draw_rectangle (GdkPixbuf *pixbuf, - const ArtIRect *rectangle, - guint32 color, - gboolean filled) -{ - guchar r; - guchar g; - guchar b; - guchar opacity; - - guint width; - guint height; - guchar *pixels; - guint rowstride; - int y; - gboolean has_alpha; - guint pixel_offset; - guchar *offset; - - guint rect_width; - guint rect_height; - - ArtIRect draw_area; - - FillRunCallback fill_run_callback; - - g_return_if_fail (pixbuf != NULL); - - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - pixels = gdk_pixbuf_get_pixels (pixbuf); - rowstride = gdk_pixbuf_get_rowstride (pixbuf); - has_alpha = gdk_pixbuf_get_has_alpha (pixbuf); - pixel_offset = has_alpha ? 4 : 3; - - r = NAUTILUS_RGBA_COLOR_GET_R (color); - g = NAUTILUS_RGBA_COLOR_GET_G (color); - b = NAUTILUS_RGBA_COLOR_GET_B (color); - opacity = NAUTILUS_RGBA_COLOR_GET_A (color); - - fill_run_callback = has_alpha ? rgba_run_alpha : art_rgb_run_alpha; - - if (rectangle != NULL) { - g_return_if_fail (rectangle->x1 > rectangle->x0); - g_return_if_fail (rectangle->y1 > rectangle->y0); - - rect_width = rectangle->x1 - rectangle->x0; - rect_height = rectangle->y1 - rectangle->y0; - - draw_area = *rectangle; - } - else { - rect_width = width; - rect_height = height; - - draw_area.x0 = 0; - draw_area.y0 = 0; - draw_area.x1 = width; - draw_area.y1 = height; - } - - if (filled) { - offset = pixels + (draw_area.y0 * rowstride) + (draw_area.x0 * pixel_offset); - - for (y = draw_area.y0; y < draw_area.y1; y++) { - (* fill_run_callback) (offset, r, g, b, opacity, rect_width); - offset += rowstride; - } - } - else { - /* top */ - offset = pixels + (draw_area.y0 * rowstride) + (draw_area.x0 * pixel_offset); - (* fill_run_callback) (offset, r, g, b, opacity, rect_width); - - /* bottom */ - offset += ((rect_height - 1) * rowstride); - (* fill_run_callback) (offset, r, g, b, opacity, rect_width); - - for (y = draw_area.y0 + 1; y < (draw_area.y1 - 1); y++) { - /* left */ - offset = pixels + (y * rowstride) + (draw_area.x0 * pixel_offset); - (* fill_run_callback) (offset, r, g, b, opacity, 1); - - /* right */ - offset += (rect_width - 1) * pixel_offset; - (* fill_run_callback) (offset, r, g, b, opacity, 1); - } - } -} - -void -test_pixbuf_draw_rectangle (GdkPixbuf *pixbuf, - int x0, - int y0, - int x1, - int y1, - int inset, - gboolean filled, - guint32 color, - int opacity) -{ - - g_return_if_fail (nautilus_gdk_pixbuf_is_valid (pixbuf)); - g_return_if_fail (opacity > NAUTILUS_OPACITY_FULLY_TRANSPARENT); - g_return_if_fail (opacity <= NAUTILUS_OPACITY_FULLY_OPAQUE); - - color = NAUTILUS_RGBA_COLOR_PACK (NAUTILUS_RGBA_COLOR_GET_R (color), - NAUTILUS_RGBA_COLOR_GET_G (color), - NAUTILUS_RGBA_COLOR_GET_B (color), - opacity); - - if (x0 == -1 && y0 == -1 && x1 == -1 && y1 == -1) { - pixbuf_draw_rectangle (pixbuf, NULL, color, filled); - } else { - ArtIRect rect; - - g_return_if_fail (x0 >= 0); - g_return_if_fail (y0 >= 0); - g_return_if_fail (x1 > x0); - g_return_if_fail (y1 > y0); - - rect.x0 = x0; - rect.y0 = y0; - rect.x1 = x1; - rect.y1 = y1; - - rect.x0 += inset; - rect.y0 += inset; - rect.x1 -= inset; - rect.y1 -= inset; - - g_return_if_fail (!art_irect_empty (&rect)); - - pixbuf_draw_rectangle (pixbuf, &rect, color, filled); - } -} - -void -test_pixbuf_draw_rectangle_tiled (GdkPixbuf *pixbuf, - const char *tile_name, - int x0, - int y0, - int x1, - int y1, - int opacity) -{ - ArtIRect area; - GdkPixbuf *tile_pixbuf; - - g_return_if_fail (nautilus_gdk_pixbuf_is_valid (pixbuf)); - g_return_if_fail (tile_name != NULL); - g_return_if_fail (opacity > NAUTILUS_OPACITY_FULLY_TRANSPARENT); - g_return_if_fail (opacity <= NAUTILUS_OPACITY_FULLY_OPAQUE); - - tile_pixbuf = test_pixbuf_new_named (tile_name, 1.0); - - g_return_if_fail (tile_pixbuf != NULL); - - if (x0 == -1 && y0 == -1 && x1 == -1 && y1 == -1) { - area = nautilus_gdk_pixbuf_get_frame (pixbuf); - } else { - g_return_if_fail (x0 >= 0); - g_return_if_fail (y0 >= 0); - g_return_if_fail (x1 > x0); - g_return_if_fail (y1 > y0); - - area.x0 = x0; - area.y0 = y0; - area.x1 = x1; - area.y1 = y1; - } - - nautilus_gdk_pixbuf_draw_to_pixbuf_tiled (tile_pixbuf, - pixbuf, - &area, - gdk_pixbuf_get_width (tile_pixbuf), - gdk_pixbuf_get_height (tile_pixbuf), - x0, - y0, - opacity, - GDK_INTERP_NEAREST); - - gdk_pixbuf_unref (tile_pixbuf); -} - /* Preferences hacks */ void test_text_caption_set_text_for_int_preferences (NautilusTextCaption *text_caption, @@ -521,3 +310,51 @@ test_window_set_title_with_pid (GtkWindow *window, gtk_window_set_title (GTK_WINDOW (window), tmp); g_free (tmp); } + +void +test_pixbuf_draw_rectangle_tiled (GdkPixbuf *pixbuf, + const char *tile_name, + int x0, + int y0, + int x1, + int y1, + int opacity) +{ + ArtIRect area; + GdkPixbuf *tile_pixbuf; + + g_return_if_fail (nautilus_gdk_pixbuf_is_valid (pixbuf)); + g_return_if_fail (tile_name != NULL); + g_return_if_fail (opacity > NAUTILUS_OPACITY_FULLY_TRANSPARENT); + g_return_if_fail (opacity <= NAUTILUS_OPACITY_FULLY_OPAQUE); + + tile_pixbuf = test_pixbuf_new_named (tile_name, 1.0); + + g_return_if_fail (tile_pixbuf != NULL); + + if (x0 == -1 && y0 == -1 && x1 == -1 && y1 == -1) { + area = nautilus_gdk_pixbuf_get_frame (pixbuf); + } else { + g_return_if_fail (x0 >= 0); + g_return_if_fail (y0 >= 0); + g_return_if_fail (x1 > x0); + g_return_if_fail (y1 > y0); + + area.x0 = x0; + area.y0 = y0; + area.x1 = x1; + area.y1 = y1; + } + + nautilus_gdk_pixbuf_draw_to_pixbuf_tiled (tile_pixbuf, + pixbuf, + &area, + gdk_pixbuf_get_width (tile_pixbuf), + gdk_pixbuf_get_height (tile_pixbuf), + x0, + y0, + opacity, + GDK_INTERP_NEAREST); + + gdk_pixbuf_unref (tile_pixbuf); +} diff --git a/test/test.h b/test/test.h index f2f123203..0e7aefc0b 100644 --- a/test/test.h +++ b/test/test.h @@ -50,15 +50,6 @@ GtkWidget *test_label_new (const char *te const char *tile_name, gboolean with_background, int num_sizes_larger); -void test_pixbuf_draw_rectangle (GdkPixbuf *pixbuf, - int x0, - int y0, - int x1, - int y1, - int inset, - gboolean filled, - guint32 color, - int opacity); void test_pixbuf_draw_rectangle_tiled (GdkPixbuf *pixbuf, const char *tile_name, int x0, |