From a4358a539718892887aab17607359a522ecd4409 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sun, 14 Nov 1999 11:43:03 +0000 Subject: [PATCH] special handling of a dropped "Standard" brush/pattern/gradient because 1999-11-14 Michael Natterer * app/gimpdnd.c: special handling of a dropped "Standard" brush/pattern/gradient because they are not part of their lists. * app/pattern.c: fill the standard_pattern with a b/w grid. --- ChangeLog | 7 +++++++ app/gimpdnd.c | 17 ++++++++++++++--- app/patterns.c | 30 ++++++++++++++++++------------ app/widgets/gimpdnd.c | 17 ++++++++++++++--- 4 files changed, 53 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index e9870aa56b..dffa66125c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +1999-11-14 Michael Natterer + + * app/gimpdnd.c: special handling of a dropped "Standard" + brush/pattern/gradient because they are not part of their lists. + + * app/pattern.c: fill the standard_pattern with a b/w grid. + 1999-11-14 Michael Natterer * app/airbrush.c diff --git a/app/gimpdnd.c b/app/gimpdnd.c index cb4aa4df70..55fcca4633 100644 --- a/app/gimpdnd.c +++ b/app/gimpdnd.c @@ -823,7 +823,10 @@ gimp_dnd_set_brush_data (GtkWidget *widget, name = (gchar *) vals; - brush = gimp_brush_list_get_brush (brush_list, name); + if (strcmp (name, "Standard") == 0) + brush = brushes_get_standard_brush (); + else + brush = gimp_brush_list_get_brush (brush_list, name); if (brush) (* (GimpDndDropBrushFunc) set_brush_func) (widget, brush, set_brush_data); @@ -927,7 +930,10 @@ gimp_dnd_set_pattern_data (GtkWidget *widget, name = (gchar *) vals; - pattern = pattern_list_get_pattern (pattern_list, name); + if (strcmp (name, "Standard") == 0) + pattern = patterns_get_standard_pattern (); + else + pattern = pattern_list_get_pattern (pattern_list, name); if (pattern) (* (GimpDndDropPatternFunc) set_pattern_func) (widget, pattern, @@ -1032,7 +1038,12 @@ gimp_dnd_set_gradient_data (GtkWidget *widget, name = (gchar *) vals; - if ((gradient = gradient_list_get_gradient (gradients_list, name))) + if (strcmp (name, "Standard") == 0) + gradient = gradients_get_standard_gradient (); + else + gradient = gradient_list_get_gradient (gradients_list, name); + + if (gradient) (* (GimpDndDropGradientFunc) set_gradient_func) (widget, gradient, set_gradient_data); } diff --git a/app/patterns.c b/app/patterns.c index c74ed376a4..b403f1515d 100644 --- a/app/patterns.c +++ b/app/patterns.c @@ -29,27 +29,23 @@ #include #endif -#include "colormaps.h" #include "datafiles.h" -#include "devices.h" #include "patterns.h" #include "pattern_header.h" -#include "colormaps.h" -#include "errors.h" +#include "gimpcontext.h" #include "gimprc.h" -#include "dialog_handler.h" #include "libgimp/gimpintl.h" /* global variables */ -GPattern *active_pattern = NULL; -GSList *pattern_list = NULL; -gint num_patterns = 0; +GPattern *active_pattern = NULL; +GSList *pattern_list = NULL; +gint num_patterns = 0; /* static variables */ static GPattern *standard_pattern = NULL; -/* static function prototypes */ +/* local function prototypes */ static GSList * insert_pattern_in_list (GSList *, GPattern *); static void load_pattern (gchar *); static void pattern_free_func (gpointer, gpointer); @@ -80,7 +76,7 @@ patterns_init (gboolean no_data) } void -patterns_free () +patterns_free (void) { if (pattern_list) { @@ -97,13 +93,23 @@ patterns_get_standard_pattern (void) { if (! standard_pattern) { + guchar *data; + gint row, col; + standard_pattern = g_new (GPattern, 1); standard_pattern->filename = NULL; standard_pattern->name = g_strdup ("Standard"); standard_pattern->index = -1; /* not part of the pattern list */ - /* TODO: fill it with something */ - standard_pattern->mask = temp_buf_new (8, 8, 8, 0, 0, NULL); + standard_pattern->mask = temp_buf_new (32, 32, 3, 0, 0, NULL); + + data = temp_buf_data (standard_pattern->mask); + + for (row = 0; row < standard_pattern->mask->height; row++) + for (col = 0; col < standard_pattern->mask->width; col++) + { + *data++ = *data++ = *data++ = (col % 2) && (row % 2) ? 255 : 0; + } } return standard_pattern; diff --git a/app/widgets/gimpdnd.c b/app/widgets/gimpdnd.c index cb4aa4df70..55fcca4633 100644 --- a/app/widgets/gimpdnd.c +++ b/app/widgets/gimpdnd.c @@ -823,7 +823,10 @@ gimp_dnd_set_brush_data (GtkWidget *widget, name = (gchar *) vals; - brush = gimp_brush_list_get_brush (brush_list, name); + if (strcmp (name, "Standard") == 0) + brush = brushes_get_standard_brush (); + else + brush = gimp_brush_list_get_brush (brush_list, name); if (brush) (* (GimpDndDropBrushFunc) set_brush_func) (widget, brush, set_brush_data); @@ -927,7 +930,10 @@ gimp_dnd_set_pattern_data (GtkWidget *widget, name = (gchar *) vals; - pattern = pattern_list_get_pattern (pattern_list, name); + if (strcmp (name, "Standard") == 0) + pattern = patterns_get_standard_pattern (); + else + pattern = pattern_list_get_pattern (pattern_list, name); if (pattern) (* (GimpDndDropPatternFunc) set_pattern_func) (widget, pattern, @@ -1032,7 +1038,12 @@ gimp_dnd_set_gradient_data (GtkWidget *widget, name = (gchar *) vals; - if ((gradient = gradient_list_get_gradient (gradients_list, name))) + if (strcmp (name, "Standard") == 0) + gradient = gradients_get_standard_gradient (); + else + gradient = gradient_list_get_gradient (gradients_list, name); + + if (gradient) (* (GimpDndDropGradientFunc) set_gradient_func) (widget, gradient, set_gradient_data); }