Commit 146e4eee authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/core/Makefile.am new files with coode split out of

2005-05-19  Sven Neumann  <sven@gimp.org>

	* app/core/Makefile.am
	* app/core/gimpdashpattern.[ch]: new files with coode split out of
	gimpstrokeoptions.c.

	* app/core/gimpstrokeoptions.c: use gimp_dash_pattern_from_preset().
parent e68d749a
2005-05-19 Sven Neumann <sven@gimp.org>
* app/core/Makefile.am
* app/core/gimpdashpattern.[ch]: new files with coode split out of
gimpstrokeoptions.c.
* app/core/gimpstrokeoptions.c: use gimp_dash_pattern_from_preset().
2005-05-19 Michael Natterer <mitch@gimp.org>
* tools/test-clipboard.c: don't allow copy and paste at the same
......
......@@ -70,6 +70,8 @@ libappcore_a_sources = \
gimpcontext.h \
gimpcoords.c \
gimpcoords.h \
gimpdashpattern.c \
gimpdashpattern.h \
gimpdata.c \
gimpdata.h \
gimpdatafactory.c \
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
*
* gimpdashpattern.c
* Copyright (C) 2003 Simon Budig
* Copyright (C) 2005 Sven Neumann
*
* 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 of the License, 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "core-types.h"
#include "gimpdashpattern.h"
GArray *
gimp_dash_pattern_from_preset (GimpDashPreset preset)
{
GArray *pattern;
gdouble dash;
gint i;
pattern = g_array_new (FALSE, FALSE, sizeof (gdouble));
switch (preset)
{
case GIMP_DASH_LINE:
break;
case GIMP_DASH_LONG_DASH:
dash = 9.0; g_array_append_val (pattern, dash);
dash = 3.0; g_array_append_val (pattern, dash);
break;
case GIMP_DASH_MEDIUM_DASH:
dash = 6.0; g_array_append_val (pattern, dash);
dash = 6.0; g_array_append_val (pattern, dash);
break;
case GIMP_DASH_SHORT_DASH:
dash = 3.0; g_array_append_val (pattern, dash);
dash = 9.0; g_array_append_val (pattern, dash);
break;
case GIMP_DASH_SPARSE_DOTS:
for (i = 0; i < 2; i++)
{
dash = 1.0; g_array_append_val (pattern, dash);
dash = 5.0; g_array_append_val (pattern, dash);
}
break;
case GIMP_DASH_NORMAL_DOTS:
for (i = 0; i < 3; i++)
{
dash = 1.0; g_array_append_val (pattern, dash);
dash = 3.0; g_array_append_val (pattern, dash);
}
break;
case GIMP_DASH_DENSE_DOTS:
for (i = 0; i < 12; i++)
{
dash = 1.0; g_array_append_val (pattern, dash);
}
break;
case GIMP_DASH_STIPPLES:
for (i = 0; i < 24; i++)
{
dash = 0.5; g_array_append_val (pattern, dash);
}
break;
case GIMP_DASH_DASH_DOT:
dash = 7.0; g_array_append_val (pattern, dash);
dash = 2.0; g_array_append_val (pattern, dash);
dash = 1.0; g_array_append_val (pattern, dash);
dash = 2.0; g_array_append_val (pattern, dash);
break;
case GIMP_DASH_DASH_DOT_DOT:
dash = 7.0; g_array_append_val (pattern, dash);
for (i=0; i < 5; i++)
{
dash = 1.0; g_array_append_val (pattern, dash);
}
break;
case GIMP_DASH_CUSTOM:
g_warning ("GIMP_DASH_CUSTOM passed to gimp_dash_pattern_from_preset()");
}
if (pattern->len < 2)
{
g_array_free (pattern, TRUE);
return NULL;
}
return pattern;
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
*
* gimpdashpattern.h
* Copyright (C) 2003 Simon Budig
* Copyright (C) 2005 Sven Neumann
*
* 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 of the License, 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DASH_PATTERN_H__
#define __GIMP_DASH_PATTERN_H__
GArray * gimp_dash_pattern_from_preset (GimpDashPreset preset);
#endif /* __GIMP_DASH_PATTERN_H__ */
......@@ -28,6 +28,7 @@
#include "core-types.h"
#include "gimpdashpattern.h"
#include "gimpmarshal.h"
#include "gimpstrokeoptions.h"
......@@ -318,82 +319,13 @@ void
gimp_stroke_options_set_dash_preset (GimpStrokeOptions *options,
GimpDashPreset preset)
{
GArray *new_pattern;
gdouble dash;
gint i;
if (preset == GIMP_DASH_CUSTOM)
return;
new_pattern = g_array_new (FALSE, FALSE, sizeof (gdouble));
switch (preset)
{
case GIMP_DASH_LINE:
break;
case GIMP_DASH_LONG_DASH:
dash = 9.0; g_array_append_val (new_pattern, dash);
dash = 3.0; g_array_append_val (new_pattern, dash);
break;
case GIMP_DASH_MEDIUM_DASH:
dash = 6.0; g_array_append_val (new_pattern, dash);
dash = 6.0; g_array_append_val (new_pattern, dash);
break;
case GIMP_DASH_SHORT_DASH:
dash = 3.0; g_array_append_val (new_pattern, dash);
dash = 9.0; g_array_append_val (new_pattern, dash);
break;
case GIMP_DASH_SPARSE_DOTS:
for (i = 0; i < 2; i++)
{
dash = 1.0; g_array_append_val (new_pattern, dash);
dash = 5.0; g_array_append_val (new_pattern, dash);
}
break;
case GIMP_DASH_NORMAL_DOTS:
for (i = 0; i < 3; i++)
{
dash = 1.0; g_array_append_val (new_pattern, dash);
dash = 3.0; g_array_append_val (new_pattern, dash);
}
break;
case GIMP_DASH_DENSE_DOTS:
for (i = 0; i < 12; i++)
{
dash = 1.0; g_array_append_val (new_pattern, dash);
}
break;
case GIMP_DASH_STIPPLES:
for (i = 0; i < 24; i++)
{
dash = 0.5; g_array_append_val (new_pattern, dash);
}
break;
case GIMP_DASH_DASH_DOT:
dash = 7.0; g_array_append_val (new_pattern, dash);
dash = 2.0; g_array_append_val (new_pattern, dash);
dash = 1.0; g_array_append_val (new_pattern, dash);
dash = 2.0; g_array_append_val (new_pattern, dash);
break;
case GIMP_DASH_DASH_DOT_DOT:
dash = 7.0; g_array_append_val (new_pattern, dash);
for (i=0; i < 5; i++)
{
dash = 1.0; g_array_append_val (new_pattern, dash);
}
break;
default:
g_printerr ("Unknown Dash pattern: %d\n", preset);
}
if (options->dash_info != NULL)
g_array_free (options->dash_info, TRUE);
options->dash_info = NULL;
if (new_pattern->len >= 2)
options->dash_info = new_pattern;
else
g_array_free (new_pattern, TRUE);
options->dash_info = gimp_dash_pattern_from_preset (preset);
g_signal_emit (options,
stroke_options_signals [DASH_INFO_CHANGED], 0,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment