Commit d0e1c1c6 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

cleanup.

2003-09-30  Michael Natterer  <mitch@gimp.org>

	* app/paint/gimppaintcore-stroke.c: cleanup.

	(gimp_paint_core_stroke_boundary): don't push a separate undo
	for each part of the boundary.

	* app/core/gimpdrawable-stroke.[ch]: added empty stub
	gimp_drawable_stroke_boundary(). Changed
	gimp_drawable_stroke_vectors() to take the GimpStrokeOptions as
	second parameter.

	* app/core/gimpchannel.c (gimp_channel_stroke): use it. No need
	to push an undo group around gimp_paint_core_stroke_boundary().

	* app/vectors/gimpvectors.c: changed accordingly.

	* app/widgets/gimpselectioneditor.[ch]: added a GimpStrokeItemFunc
	pointer and use it for stroking.

	* app/gui/edit-commands.[ch] (edit_stroke_selection): a
	GimpStrokeItemFunc which strokes the selection using the
	stroke-dialog.

	* app/gui/dialogs-constructors.c: use it for the selection editor.
parent fba6a1a7
2003-09-30 Michael Natterer <mitch@gimp.org>
* app/paint/gimppaintcore-stroke.c: cleanup.
(gimp_paint_core_stroke_boundary): don't push a separate undo
for each part of the boundary.
* app/core/gimpdrawable-stroke.[ch]: added empty stub
gimp_drawable_stroke_boundary(). Changed
gimp_drawable_stroke_vectors() to take the GimpStrokeOptions as
second parameter.
* app/core/gimpchannel.c (gimp_channel_stroke): use it. No need
to push an undo group around gimp_paint_core_stroke_boundary().
* app/vectors/gimpvectors.c: changed accordingly.
* app/widgets/gimpselectioneditor.[ch]: added a GimpStrokeItemFunc
pointer and use it for stroking.
* app/gui/edit-commands.[ch] (edit_stroke_selection): a
GimpStrokeItemFunc which strokes the selection using the
stroke-dialog.
* app/gui/dialogs-constructors.c: use it for the selection editor.
2003-09-30 Simon Budig <simon@gimp.org>
 
* app/core/gimpscanconvert.[ch]: replaced
......@@ -44,6 +44,7 @@
#include "dialogs.h"
#include "edit-commands.h"
#include "stroke-dialog.h"
#include "gimp-intl.h"
......@@ -259,25 +260,35 @@ edit_fill_cmd_callback (GtkWidget *widget,
void
edit_stroke_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
edit_stroke_selection (GIMP_ITEM (gimp_image_get_mask (gimage)));
}
void
edit_stroke_selection (GimpItem *item)
{
GimpImage *gimage;
GimpDrawable *active_drawable;
GimpToolInfo *tool_info;
return_if_no_image (gimage, data);
GtkWidget *dialog;
g_return_if_fail (GIMP_IS_ITEM (item));
gimage = gimp_item_get_image (item);
active_drawable = gimp_image_active_drawable (gimage);
if (! active_drawable)
{
g_message (_("There is no active layer or channel to stroke to."));
g_message (_("There is no active layer or channel to stroke to"));
return;
}
tool_info = gimp_context_get_tool (gimp_get_current_context (gimage->gimp));
gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
active_drawable, GIMP_OBJECT (tool_info->paint_info));
gimp_image_flush (gimage);
dialog = stroke_dialog_new (item, GIMP_STOCK_SELECTION_STROKE,
GIMP_HELP_SELECTION_STROKE);
gtk_widget_show (dialog);
}
......
......@@ -48,5 +48,7 @@ void edit_fill_cmd_callback (GtkWidget *widget,
void edit_stroke_cmd_callback (GtkWidget *widget,
gpointer data);
void edit_stroke_selection (GimpItem *item);
#endif /* __EDIT_COMMANDS_H__ */
......@@ -25,7 +25,6 @@
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "stroke-dialog.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
......@@ -54,6 +53,7 @@
#include "tools/gimpvectortool.h"
#include "tools/tool_manager.h"
#include "stroke-dialog.h"
#include "vectors-commands.h"
#include "gimp-intl.h"
......
......@@ -46,9 +46,11 @@
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
#include "gimpchannel.h"
#include "gimpdrawable-stroke.h"
#include "gimplayer.h"
#include "gimppaintinfo.h"
#include "gimpparasitelist.h"
#include "gimpstrokeoptions.h"
#include "gimp-intl.h"
......@@ -577,20 +579,18 @@ gimp_channel_transform (GimpItem *item,
}
static gboolean
gimp_channel_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpObject *stroke_desc)
gimp_channel_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpObject *stroke_desc)
{
GimpChannel *channel;
GimpImage *gimage;
const BoundSeg *bs_in;
const BoundSeg *bs_out;
gint num_segs_in;
gint num_segs_out;
GimpPaintCore *core;
GimpPaintInfo *paint_info;
gboolean retval;
const BoundSeg *segs_in;
const BoundSeg *segs_out;
gint n_segs_in;
gint n_segs_out;
gboolean retval = FALSE;
channel = GIMP_CHANNEL (item);
......@@ -598,29 +598,37 @@ gimp_channel_stroke (GimpItem *item,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
paint_info = GIMP_PAINT_INFO (stroke_desc);
if (! gimp_channel_boundary (channel, &bs_in, &bs_out,
&num_segs_in, &num_segs_out,
if (! gimp_channel_boundary (channel, &segs_in, &segs_out,
&n_segs_in, &n_segs_out,
0, 0, 0, 0))
{
g_message (_("Cannot stroke empty channel."));
return FALSE;
}
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_PAINT,
_("Stroke Channel"));
if (GIMP_IS_STROKE_OPTIONS (stroke_desc))
{
gimp_drawable_stroke_boundary (drawable,
GIMP_STROKE_OPTIONS (stroke_desc),
segs_in, n_segs_in);
retval = TRUE;
}
else if (GIMP_IS_PAINT_INFO (stroke_desc))
{
GimpPaintInfo *paint_info;
GimpPaintCore *core;
core = g_object_new (paint_info->paint_type, NULL);
paint_info = GIMP_PAINT_INFO (stroke_desc);
retval = gimp_paint_core_stroke_boundary (core, drawable,
paint_info->paint_options,
bs_in, num_segs_in,
0, 0);
core = g_object_new (paint_info->paint_type, NULL);
g_object_unref (core);
retval = gimp_paint_core_stroke_boundary (core, drawable,
paint_info->paint_options,
segs_in, n_segs_in,
0, 0);
gimp_image_undo_group_end (gimage);
g_object_unref (core);
}
return retval;
}
......
......@@ -49,12 +49,26 @@
#include "gimp-intl.h"
/* local function prototypes */
/* public functions */
void
gimp_drawable_stroke_boundary (GimpDrawable *drawable,
GimpStrokeOptions *options,
const BoundSeg *bound_segs,
gint n_bound_segs)
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
g_return_if_fail (bound_segs != NULL);
g_return_if_fail (n_bound_segs > 0);
g_message ("gimp_drawable_stroke_boundary() is unimplemented");
}
void
gimp_drawable_stroke_vectors (GimpDrawable *drawable,
GimpVectors *vectors,
GimpStrokeOptions *options)
GimpStrokeOptions *options,
GimpVectors *vectors)
{
/* Stroke options */
gdouble width;
......@@ -73,8 +87,8 @@ gimp_drawable_stroke_vectors (GimpDrawable *drawable,
PixelRegion maskPR, basePR;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_VECTORS (vectors));
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
g_return_if_fail (GIMP_IS_VECTORS (vectors));
context = GIMP_CONTEXT (options);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
......
......@@ -23,8 +23,13 @@
#define __GIMP_DRAWABLE_STROKE_H__
void gimp_drawable_stroke_vectors (GimpDrawable *drawable,
GimpVectors *vectors,
GimpStrokeOptions *options);
void gimp_drawable_stroke_boundary (GimpDrawable *drawable,
GimpStrokeOptions *options,
const BoundSeg *bound_segs,
gint n_bound_segs);
void gimp_drawable_stroke_vectors (GimpDrawable *drawable,
GimpStrokeOptions *options,
GimpVectors *vectors);
#endif /* __GIMP_DRAWABLE_STROKE_H__ */
......@@ -79,6 +79,7 @@
#include "channels-commands.h"
#include "dialogs.h"
#include "dialogs-constructors.h"
#include "edit-commands.h"
#include "file-commands.h"
#include "file-new-dialog.h"
#include "layers-commands.h"
......@@ -914,6 +915,7 @@ dialogs_selection_editor_new (GimpDialogFactory *factory,
selection_editor = GIMP_SELECTION_EDITOR (view);
selection_editor->stroke_item_func = edit_stroke_selection;
selection_editor->selection_to_vectors_func = vectors_selection_to_vectors;
dockable = dialogs_dockable_new (view,
......
......@@ -79,6 +79,7 @@
#include "channels-commands.h"
#include "dialogs.h"
#include "dialogs-constructors.h"
#include "edit-commands.h"
#include "file-commands.h"
#include "file-new-dialog.h"
#include "layers-commands.h"
......@@ -914,6 +915,7 @@ dialogs_selection_editor_new (GimpDialogFactory *factory,
selection_editor = GIMP_SELECTION_EDITOR (view);
selection_editor->stroke_item_func = edit_stroke_selection;
selection_editor->selection_to_vectors_func = vectors_selection_to_vectors;
dockable = dialogs_dockable_new (view,
......
......@@ -44,6 +44,7 @@
#include "dialogs.h"
#include "edit-commands.h"
#include "stroke-dialog.h"
#include "gimp-intl.h"
......@@ -259,25 +260,35 @@ edit_fill_cmd_callback (GtkWidget *widget,
void
edit_stroke_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
return_if_no_image (gimage, data);
edit_stroke_selection (GIMP_ITEM (gimp_image_get_mask (gimage)));
}
void
edit_stroke_selection (GimpItem *item)
{
GimpImage *gimage;
GimpDrawable *active_drawable;
GimpToolInfo *tool_info;
return_if_no_image (gimage, data);
GtkWidget *dialog;
g_return_if_fail (GIMP_IS_ITEM (item));
gimage = gimp_item_get_image (item);
active_drawable = gimp_image_active_drawable (gimage);
if (! active_drawable)
{
g_message (_("There is no active layer or channel to stroke to."));
g_message (_("There is no active layer or channel to stroke to"));
return;
}
tool_info = gimp_context_get_tool (gimp_get_current_context (gimage->gimp));
gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
active_drawable, GIMP_OBJECT (tool_info->paint_info));
gimp_image_flush (gimage);
dialog = stroke_dialog_new (item, GIMP_STOCK_SELECTION_STROKE,
GIMP_HELP_SELECTION_STROKE);
gtk_widget_show (dialog);
}
......
......@@ -48,5 +48,7 @@ void edit_fill_cmd_callback (GtkWidget *widget,
void edit_stroke_cmd_callback (GtkWidget *widget,
gpointer data);
void edit_stroke_selection (GimpItem *item);
#endif /* __EDIT_COMMANDS_H__ */
......@@ -25,7 +25,6 @@
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "stroke-dialog.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
......@@ -54,6 +53,7 @@
#include "tools/gimpvectortool.h"
#include "tools/tool_manager.h"
#include "stroke-dialog.h"
#include "vectors-commands.h"
#include "gimp-intl.h"
......
......@@ -50,7 +50,7 @@ gimp_paint_core_stroke (GimpPaintCore *core,
if (gimp_paint_core_start (core, drawable, paint_options, &strokes[0]))
{
GimpBrush *current_brush;
gint i;
gint i;
core->start_coords = strokes[0];
core->last_coords = strokes[0];
......@@ -95,6 +95,7 @@ gimp_paint_core_stroke_boundary (GimpPaintCore *core,
gint off_x;
gint off_y;
GimpCoords *coords;
gboolean initialized = FALSE;
gint n_coords;
gint seg;
gint i;
......@@ -134,6 +135,9 @@ gimp_paint_core_stroke_boundary (GimpPaintCore *core,
for (i = 0; i < n_stroke_segs; i++)
{
GimpBrush *current_brush;
gint i;
while (stroke_segs[seg].x1 != -1 ||
stroke_segs[seg].x2 != -1 ||
stroke_segs[seg].y1 != -1 ||
......@@ -157,8 +161,30 @@ gimp_paint_core_stroke_boundary (GimpPaintCore *core,
n_coords++;
gimp_paint_core_stroke (core, drawable, paint_options,
coords, n_coords);
if (initialized ||
gimp_paint_core_start (core, drawable, paint_options,
&coords[0]))
{
initialized = TRUE;
core->start_coords = coords[0];
core->last_coords = coords[0];
gimp_paint_core_paint (core, drawable, paint_options, INIT_PAINT);
current_brush = core->brush;
gimp_paint_core_paint (core, drawable, paint_options, MOTION_PAINT);
core->brush = current_brush;
for (i = 1; i < n_coords; i++)
{
core->cur_coords = coords[i];
gimp_paint_core_interpolate (core, drawable, paint_options);
}
gimp_paint_core_paint (core, drawable, paint_options, FINISH_PAINT);
}
n_coords = 0;
seg++;
......@@ -173,6 +199,13 @@ gimp_paint_core_stroke_boundary (GimpPaintCore *core,
n_coords++;
}
if (initialized)
{
gimp_paint_core_finish (core, drawable);
gimp_paint_core_cleanup (core);
}
g_free (coords);
g_free (stroke_segs);
......@@ -205,14 +238,13 @@ gimp_paint_core_stroke_vectors (GimpPaintCore *core,
for (stroke = vectors->strokes; stroke; stroke = stroke->next)
{
gint i;
coords = gimp_stroke_interpolate (GIMP_STROKE (stroke->data),
1.0, &closed);
if (coords && coords->len)
{
GimpBrush *current_brush;
gint i;
for (i = 0; i < coords->len; i++)
{
......@@ -220,43 +252,40 @@ gimp_paint_core_stroke_vectors (GimpPaintCore *core,
g_array_index (coords, GimpCoords, i).y -= off_y;
}
if (! initialized)
if (initialized ||
gimp_paint_core_start (core, drawable, paint_options,
&g_array_index (coords,
GimpCoords, 0)))
{
if (! gimp_paint_core_start (core, drawable, paint_options,
&g_array_index (coords,
GimpCoords, 0)))
{
g_array_free (coords, TRUE);
return FALSE;
}
initialized = TRUE;
}
gimp_paint_core_paint (core, drawable, paint_options, INIT_PAINT);
core->start_coords = g_array_index (coords, GimpCoords, 0);
core->last_coords = g_array_index (coords, GimpCoords, 0);
core->start_coords = g_array_index (coords, GimpCoords, 0);
core->last_coords = g_array_index (coords, GimpCoords, 0);
gimp_paint_core_paint (core, drawable, paint_options, INIT_PAINT);
current_brush = core->brush;
gimp_paint_core_paint (core, drawable, paint_options, MOTION_PAINT);
core->brush = current_brush;
current_brush = core->brush;
gimp_paint_core_paint (core, drawable, paint_options,
MOTION_PAINT);
core->brush = current_brush;
for (i = 1; i < coords->len; i++)
{
core->cur_coords = g_array_index (coords, GimpCoords, i);
for (i = 1; i < coords->len; i++)
{
core->cur_coords = g_array_index (coords, GimpCoords, i);
gimp_paint_core_interpolate (core, drawable, paint_options);
}
gimp_paint_core_interpolate (core, drawable, paint_options);
}
if (closed)
{
core->cur_coords = g_array_index (coords, GimpCoords, 0);
if (closed)
{
core->cur_coords = g_array_index (coords, GimpCoords, 0);
gimp_paint_core_interpolate (core, drawable, paint_options);
}
gimp_paint_core_interpolate (core, drawable, paint_options);
}
gimp_paint_core_paint (core, drawable, paint_options, FINISH_PAINT);
gimp_paint_core_paint (core, drawable, paint_options,
FINISH_PAINT);
}
}
if (coords)
......
......@@ -538,13 +538,12 @@ gimp_vectors_transform (GimpItem *item,
}
static gboolean
gimp_vectors_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpObject *stroke_desc)
gimp_vectors_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpObject *stroke_desc)
{
GimpVectors *vectors;
GimpPaintInfo *paint_info;
gboolean retval;
GimpVectors *vectors;
gboolean retval = FALSE;
g_return_val_if_fail (GIMP_IS_PAINT_INFO (stroke_desc) ||
GIMP_IS_STROKE_OPTIONS (stroke_desc), FALSE);
......@@ -559,15 +558,18 @@ gimp_vectors_stroke (GimpItem *item,
if (GIMP_IS_STROKE_OPTIONS (stroke_desc))
{
gimp_drawable_stroke_vectors (drawable, vectors,
GIMP_STROKE_OPTIONS (stroke_desc));
gimp_drawable_stroke_vectors (drawable,
GIMP_STROKE_OPTIONS (stroke_desc),
vectors);
retval = TRUE;
}
else
else if (GIMP_IS_PAINT_INFO (stroke_desc))
{
GimpPaintInfo *paint_info;
GimpPaintCore *core;
paint_info = GIMP_PAINT_INFO (stroke_desc);
core = g_object_new (paint_info->paint_type, NULL);
retval = gimp_paint_core_stroke_vectors (core, drawable,
......
......@@ -349,17 +349,12 @@ static void
gimp_selection_editor_stroke_clicked (GtkWidget *widget,
GimpImageEditor *editor)
{
GimpImage *gimage = editor->gimage;
if (gimage)
if (editor->gimage)
{
GimpToolInfo *tool_info =
gimp_context_get_tool (gimp_get_current_context (gimage->gimp));
GimpSelectionEditor *sel_editor = GIMP_SELECTION_EDITOR (editor);
gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
gimp_image_active_drawable (gimage),
GIMP_OBJECT (tool_info->paint_info));
gimp_image_flush (gimage);
if (sel_editor->stroke_item_func)
sel_editor->stroke_item_func (GIMP_ITEM (gimp_image_get_mask (editor->gimage)));
}
}
......
......@@ -37,6 +37,7 @@ struct _GimpSelectionEditor
{
GimpImageEditor parent_instance;
GimpStrokeItemFunc stroke_item_func;
GimpSelectionToVectorsFunc selection_to_vectors_func;
GtkWidget *preview;
......
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