Commit a3f6b3e6 authored by David Odin's avatar David Odin
Browse files

plug-ins/gfig/gfig-arc.c plug-ins/gfig/gfig-bezier.c

* plug-ins/gfig/gfig-arc.c
* plug-ins/gfig/gfig-bezier.c
* plug-ins/gfig/gfig-circle.c
* plug-ins/gfig/gfig-dialog.c
* plug-ins/gfig/gfig-ellipse.c
* plug-ins/gfig/gfig-line.c
* plug-ins/gfig/gfig-poly.c
* plug-ins/gfig/gfig-spiral.c
* plug-ins/gfig/gfig-star.c
* plug-ins/gfig/gfig-style.c
* plug-ins/gfig/gfig-style.h
* plug-ins/gfig/gfig-types.h
* plug-ins/gfig/gfig.h: added a toggle so we can now choose to stroke
	the painting or not.
parent 81247954
2004-11-16 DindinX <dindinx@gimp.org>
* plug-ins/gfig/gfig-arc.c
* plug-ins/gfig/gfig-bezier.c
* plug-ins/gfig/gfig-circle.c
* plug-ins/gfig/gfig-dialog.c
* plug-ins/gfig/gfig-ellipse.c
* plug-ins/gfig/gfig-line.c
* plug-ins/gfig/gfig-poly.c
* plug-ins/gfig/gfig-spiral.c
* plug-ins/gfig/gfig-star.c
* plug-ins/gfig/gfig-style.c
* plug-ins/gfig/gfig-style.h
* plug-ins/gfig/gfig-types.h
* plug-ins/gfig/gfig.h: added a toggle so we can now choose to stroke
the painting or not.
2004-11-16 DindinX <dindinx@gimp.org>
 
* plug-ins/gfig/gfig-dialog.c: implemented the gradient fill, using a
......
......@@ -498,28 +498,12 @@ d_paint_arc (GfigObject *obj)
reverse_pairs_list (&line_pnts[0], i/2);
/* One go */
if (selvals.painttype == PAINT_BRUSH_TYPE)
if (obj->style.paint_type == PAINT_BRUSH_TYPE)
{
gfig_paint (selvals.brshtype,
gfig_context->drawable_id,
i, line_pnts);
}
else
{
if (selopt.as_pie)
{
/* Add center point - cause a pie like selection... */
line_pnts[i++] = center_pnt.x;
line_pnts[i++] = center_pnt.y;
}
gimp_free_select (gfig_context->image_id,
i, line_pnts,
selopt.type,
selopt.antia,
selopt.feather,
selopt.feather_radius);
}
g_free (line_pnts);
}
......
......@@ -260,21 +260,12 @@ d_paint_bezier (GfigObject *obj)
scale_to_xy (&line_pnts[0], i / 2);
/* One go */
if (selvals.painttype == PAINT_BRUSH_TYPE)
if (obj->style.paint_type == PAINT_BRUSH_TYPE)
{
gfig_paint (selvals.brshtype,
gfig_context->drawable_id,
i, line_pnts);
}
else
{
gimp_free_select (gfig_context->image_id,
i, line_pnts,
selopt.type,
selopt.antia,
selopt.feather,
selopt.feather_radius);
}
g_free (bz_line_pnts);
/* Don't free line_pnts - may need again */
......
......@@ -85,14 +85,6 @@ d_paint_circle (GfigObject *obj)
g_assert (obj != NULL);
if (selvals.approxcircles)
{
obj->type_data = 600;
d_paint_poly (obj);
return;
}
/* Drawing circles is hard .
* 1) select circle
* 2) stroke it
......@@ -131,8 +123,8 @@ d_paint_circle (GfigObject *obj)
paint_layer_fill ();
gimp_edit_stroke (gfig_context->drawable_id);
if (obj->style.paint_type == PAINT_BRUSH_TYPE)
gimp_edit_stroke (gfig_context->drawable_id);
}
static GfigObject*
......
......@@ -115,7 +115,6 @@ SelectItVals selvals =
FALSE, /* reverse lines */
TRUE, /* Scale to image when painting */
1.0, /* Scale to image fp */
FALSE, /* Approx circles by drawing lines */
BRUSH_BRUSH_TYPE, /* Default to use a brush */
LINE /* Initial object type */
};
......@@ -373,7 +372,18 @@ gfig_dialog (void)
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
/* foreground color button in Style frame*/
gfig_context->paint_type_toggle =
gtk_check_button_new_with_mnemonic (_("Stro_ke"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gfig_context->paint_type_toggle),
selvals.painttype);
g_signal_connect (gfig_context->paint_type_toggle, "toggled",
G_CALLBACK (set_paint_type_callback),
NULL);
gtk_box_pack_start (GTK_BOX (vbox), gfig_context->paint_type_toggle,
FALSE, FALSE, 0);
gtk_widget_show (gfig_context->paint_type_toggle);
/* foreground color button in Stroke frame*/
gfig_context->fg_color = g_new (GimpRGB, 1);
gfig_context->fg_color_button = gimp_color_button_new ("Foreground",
SEL_BUTTON_WIDTH,
......@@ -389,7 +399,7 @@ gfig_dialog (void)
FALSE, FALSE, 0);
gtk_widget_show (gfig_context->fg_color_button);
/* brush selector in Style frame */
/* brush selector in Stroke frame */
gfig_context->brush_select
= gimp_brush_select_widget_new ("Brush", gfig_context->current_style->brush_name,
-1, -1, -1,
......@@ -1720,6 +1730,8 @@ paint_layer_fill (void)
0.0, 0.0, /* (x1, y1) - ignored */
0.0, 0.0); /* (x2, y2) - ignored */
return;
default:
return;
}
gimp_edit_bucket_fill (gfig_context->drawable_id,
......
......@@ -82,120 +82,6 @@ d_draw_ellipse (GfigObject * obj)
gfig_draw_arc (center_pnt->pnt.x, center_pnt->pnt.y, bound_wx, bound_wy, 0, 360);
}
static void
d_paint_approx_ellipse (GfigObject *obj)
{
/* first point center */
/* Next point is radius */
gdouble *line_pnts;
gint seg_count = 0;
gint i = 0;
DobjPoints *center_pnt;
DobjPoints *radius_pnt;
gdouble a_axis;
gdouble b_axis;
gdouble ang_grid;
gdouble ang_loop;
gdouble radius;
gint loop;
GdkPoint first_pnt, last_pnt;
gboolean first = TRUE;
g_assert (obj != NULL);
/* count - add one to close polygon */
seg_count = 600;
center_pnt = obj->points;
if (!center_pnt || !seg_count)
return; /* no-line */
line_pnts = g_new0 (gdouble, 2 * seg_count + 1);
/* Go around all the points drawing a line from one to the next */
radius_pnt = center_pnt->next; /* this defines the vetices */
/* Have center and radius - get lines */
a_axis = ((gdouble) (radius_pnt->pnt.x - center_pnt->pnt.x));
b_axis = ((gdouble) (radius_pnt->pnt.y - center_pnt->pnt.y));
/* Lines */
ang_grid = 2 * G_PI / (gdouble) 600;
for (loop = 0; loop < 600; loop++)
{
gdouble lx, ly;
GdkPoint calc_pnt;
ang_loop = (gdouble)loop * ang_grid;
radius = (a_axis * b_axis /
(sqrt (cos (ang_loop) * cos (ang_loop) *
(b_axis * b_axis - a_axis * a_axis) + a_axis * a_axis)));
lx = radius * cos (ang_loop);
ly = radius * sin (ang_loop);
calc_pnt.x = RINT (lx + center_pnt->pnt.x);
calc_pnt.y = RINT (ly + center_pnt->pnt.y);
/* Miss out duped pnts */
if (!first)
{
if (calc_pnt.x == last_pnt.x && calc_pnt.y == last_pnt.y)
{
continue;
}
}
line_pnts[i++] = calc_pnt.x;
line_pnts[i++] = calc_pnt.y;
last_pnt = calc_pnt;
if (first)
{
first_pnt = calc_pnt;
first = FALSE;
}
}
line_pnts[i++] = first_pnt.x;
line_pnts[i++] = first_pnt.y;
/* Reverse line if approp */
if (selvals.reverselines)
reverse_pairs_list (&line_pnts[0], i / 2);
/* Scale before drawing */
if (selvals.scaletoimage)
scale_to_original_xy (&line_pnts[0], i / 2);
else
scale_to_xy (&line_pnts[0], i / 2);
/* One go */
if (selvals.painttype == PAINT_BRUSH_TYPE)
{
gfig_paint (selvals.brshtype,
gfig_context->drawable_id,
i, line_pnts);
}
else
{
gimp_free_select (gfig_context->image_id,
i, line_pnts,
selopt.type,
selopt.antia,
selopt.feather,
selopt.feather_radius);
}
g_free (line_pnts);
}
static void
d_paint_ellipse (GfigObject *obj)
{
......@@ -214,12 +100,6 @@ d_paint_ellipse (GfigObject *obj)
g_assert (obj != NULL);
if (selvals.approxcircles)
{
d_paint_approx_ellipse (obj);
return;
}
center_pnt = obj->points;
if (!center_pnt)
......@@ -266,7 +146,8 @@ d_paint_ellipse (GfigObject *obj)
paint_layer_fill ();
gimp_edit_stroke (gfig_context->drawable_id);
if (obj->style.paint_type == PAINT_BRUSH_TYPE)
gimp_edit_stroke (gfig_context->drawable_id);
}
static GfigObject *
......
......@@ -110,21 +110,12 @@ d_paint_line (GfigObject *obj)
scale_to_xy (&line_pnts[0], i/2);
/* One go */
if (selvals.painttype == PAINT_BRUSH_TYPE)
if (obj->style.paint_type == PAINT_BRUSH_TYPE)
{
gfig_paint (selvals.brshtype,
gfig_context->drawable_id,
seg_count * 2, line_pnts);
}
else
{
gimp_free_select (gfig_context->image_id,
seg_count * 2, line_pnts,
selopt.type,
selopt.antia,
selopt.feather,
selopt.feather_radius);
}
g_free (line_pnts);
}
......
......@@ -242,7 +242,8 @@ d_paint_poly (GfigObject *obj)
paint_layer_fill ();
gimp_edit_stroke (gfig_context->drawable_id);
if (obj->style.paint_type == PAINT_BRUSH_TYPE)
gimp_edit_stroke (gfig_context->drawable_id);
g_free (line_pnts);
}
......
......@@ -242,21 +242,12 @@ d_paint_spiral (GfigObject *obj)
scale_to_xy (&line_pnts[0], i / 2);
/* One go */
if (selvals.painttype == PAINT_BRUSH_TYPE)
if (obj->style.paint_type == PAINT_BRUSH_TYPE)
{
gfig_paint (selvals.brshtype,
gfig_context->drawable_id,
i, line_pnts);
}
else
{
gimp_free_select (gfig_context->image_id,
i, line_pnts,
selopt.type,
selopt.antia,
selopt.feather,
selopt.feather_radius);
}
g_free (line_pnts);
}
......
......@@ -299,7 +299,8 @@ d_paint_star (GfigObject *obj)
paint_layer_fill ();
gimp_edit_stroke (gfig_context->drawable_id);
if (obj->style.paint_type == PAINT_BRUSH_TYPE)
gimp_edit_stroke (gfig_context->drawable_id);
g_free (line_pnts);
}
......
......@@ -430,6 +430,18 @@ set_background_callback (GimpColorButton *button,
gfig_paint_callback ();
}
void
set_paint_type_callback (GtkToggleButton *toggle,
gpointer data)
{
gboolean paint_type;
paint_type = gtk_toggle_button_get_active (toggle);
gfig_context->default_style.paint_type = paint_type;
gfig_context->current_style->paint_type = paint_type;
gfig_paint_callback ();
}
/*
* gfig_brush_changed_callback() is the callback for the brush
* selector widget. It reads the brush name from the widget, and
......@@ -526,6 +538,7 @@ gfig_style_copy (Style *style1,
style1->pattern = g_strdup (style0->pattern);
style1->fill_type = style0->fill_type;
style1->fill_opacity = style0->fill_opacity;
style1->paint_type = style0->paint_type;
}
/*
......@@ -648,6 +661,8 @@ gfig_style_set_context_from_style (Style *style)
(gint) style->fill_type);
gfig_context->enable_repaint = enable_repaint;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gfig_context->paint_type_toggle),
style->paint_type);
}
/*
......@@ -685,6 +700,9 @@ gfig_style_set_style_from_context (Style *style)
/* FIXME when there is an opacity control widget to read */
style->fill_opacity = 100.;
style->paint_type =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gfig_context->paint_type_toggle));
}
void
......
......@@ -55,6 +55,8 @@ void set_foreground_callback (GimpColorButton *button,
void set_background_callback (GimpColorButton *button,
gpointer data);
void set_paint_type_callback (GtkToggleButton *toggle,
gpointer data);
void gfig_brush_changed_callback (const gchar *brush_name,
......
......@@ -73,9 +73,8 @@ typedef enum
typedef enum
{
PAINT_BRUSH_TYPE = 0,
PAINT_SELECTION_TYPE,
PAINT_SELECTION_FILL_TYPE
PAINT_NONE = 0,
PAINT_BRUSH_TYPE = 1
} PaintType;
typedef enum
......
......@@ -89,7 +89,6 @@ typedef struct
gboolean reverselines;
gboolean scaletoimage;
gdouble scaletoimagefp;
gboolean approxcircles;
BrushType brshtype;
DobjType otype;
} SelectItVals;
......@@ -144,6 +143,7 @@ typedef struct
GtkWidget *pattern_select;
GtkWidget *gradient_select;
GtkWidget *fillstyle_combo;
GtkWidget *paint_type_toggle;
GimpRGB *fg_color;
GimpRGB *bg_color;
gboolean enable_repaint;
......
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