Commit c7ba1dfc authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/core/gimpdashpattern.[ch] moved code out of GimpDashEditor to

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

	* app/core/gimpdashpattern.[ch]
	* app/widgets/gimpdasheditor.c: moved code out of GimpDashEditor
	to gimpdashpattern.c.
parent a1030625
2005-05-19 Sven Neumann <sven@gimp.org>
* app/core/gimpdashpattern.[ch]
* app/widgets/gimpdasheditor.c: moved code out of GimpDashEditor
to gimpdashpattern.c.
2005-05-19 Michael Natterer <mitch@gimp.org>
* plug-ins/dbbrowser/Makefile.am
......
......@@ -108,6 +108,46 @@ gimp_dash_pattern_from_preset (GimpDashPreset preset)
return pattern;
}
GArray *
gimp_dash_pattern_from_segments (const gboolean *segments,
gint n_segments,
gdouble dash_length)
{
GArray *pattern;
gint i;
gint count;
gboolean state;
g_return_val_if_fail (segments != NULL || n_segments == 0, NULL);
pattern = g_array_new (FALSE, FALSE, sizeof (gdouble));
for (i = 0, count = 0, state = TRUE; i <= n_segments; i++)
{
if (i < n_segments && segments[i] == state)
{
count++;
}
else
{
gdouble l = (dash_length * count) / n_segments;
pattern = g_array_append_val (pattern, l);
count = 1;
state = ! state;
}
}
if (pattern->len < 2)
{
g_array_free (pattern, TRUE);
return NULL;
}
return pattern;
}
GArray *
gimp_dash_pattern_from_value (const GValue *value)
{
......
......@@ -24,10 +24,13 @@
#define __GIMP_DASH_PATTERN_H__
GArray * gimp_dash_pattern_from_preset (GimpDashPreset preset);
GArray * gimp_dash_pattern_from_value (const GValue *value);
void gimp_dash_pattern_value_set (GArray *pattern,
GValue *value);
GArray * gimp_dash_pattern_from_preset (GimpDashPreset preset);
GArray * gimp_dash_pattern_from_segments (const gboolean *segments,
gint n_segments,
gdouble dash_length);
GArray * gimp_dash_pattern_from_value (const GValue *value);
void gimp_dash_pattern_value_set (GArray *pattern,
GValue *value);
#endif /* __GIMP_DASH_PATTERN_H__ */
......@@ -28,6 +28,7 @@
#include "widgets-types.h"
#include "core/gimpdashpattern.h"
#include "core/gimpstrokeoptions.h"
#include "gimpdasheditor.h"
......@@ -520,60 +521,17 @@ update_segments_from_options (GimpDashEditor *editor)
static void
update_options_from_segments (GimpDashEditor *editor)
{
gint i, count = 0;
gboolean state;
GArray *dash_array;
GArray *dash_info;
dash_array = g_array_new (FALSE, FALSE, sizeof (gdouble));
dash_info = gimp_dash_pattern_from_segments (editor->segments,
editor->n_segments,
editor->dash_length);
state = TRUE;
g_object_set (G_OBJECT (editor->stroke_options),
"dash-info", dash_info,
NULL);
for (i = 0; i <= editor->n_segments; i++)
{
if (i < editor->n_segments && editor->segments[i] == state)
{
count++;
}
else
{
gdouble l = (editor->dash_length * count) / editor->n_segments;
dash_array = g_array_append_val (dash_array, l);
count = 1;
state = ! state;
}
}
if (dash_array->len > 1)
{
GValueArray *val_array;
GValue item = { 0, };
val_array = g_value_array_new (dash_array->len);
g_value_init (&item, G_TYPE_DOUBLE);
for (i = 0; i < dash_array->len; i++)
{
g_value_set_double (&item,
g_array_index (dash_array, gdouble, i));
g_value_array_append (val_array, &item);
}
g_object_set (editor->stroke_options,
"dash-info", val_array,
NULL);
g_value_array_free (val_array);
}
else
{
g_object_set (editor->stroke_options,
"dash-info", NULL,
NULL);
}
g_array_free (dash_array, TRUE);
g_array_free (dash_info, TRUE);
}
static void
......
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