Made these widgets show a preview of the vectors object. Does not work

2003-09-29  Simon Budig  <simon@gimp.org>

	* app/widgets/gimppreviewrenderervectors.c: Made these widgets
	show a preview of the vectors object. Does not work everywhere
	right now, also most probably has scaling issues for non-square
	images.

	* app/tools/gimpdrawtool.c: Fixed Svens fix.
This commit is contained in:
Simon Budig 2003-09-29 11:48:15 +00:00 committed by Simon Budig
parent 55a0c4c960
commit eb489c44c4
4 changed files with 86 additions and 17 deletions

View File

@ -1,3 +1,12 @@
2003-09-29 Simon Budig <simon@gimp.org>
* app/widgets/gimppreviewrenderervectors.c: Made these widgets
show a preview of the vectors object. Does not work everywhere
right now, also most probably has scaling issues for non-square
images.
* app/tools/gimpdrawtool.c: Fixed Svens fix.
2003-09-29 Sven Neumann <sven@gimp.org>
* app/core/gimpstrokeoptions.[ch]: removed "dash-unit" property and

View File

@ -1012,7 +1012,7 @@ gimp_draw_tool_on_vectors_curve (GimpDrawTool *draw_tool,
&segment_end,
&cur_pos);
if (cur_dist < min_dist)
if (cur_dist >= 0 && (min_dist < 0 || cur_dist < min_dist))
{
min_dist = cur_dist;
min_coords = cur_coords;

View File

@ -29,6 +29,7 @@
#include "widgets-types.h"
#include "vectors/gimpvectors.h"
#include "vectors/gimpstroke.h"
#include "gimppreviewrenderervectors.h"
@ -86,15 +87,44 @@ static void
gimp_preview_renderer_vectors_render (GimpPreviewRenderer *renderer,
GtkWidget *widget)
{
const gchar *stock_id = NULL;
GimpVectors *vectors;
GimpStroke *stroke;
GArray *coordinates;
GimpCoords *coords;
GdkPoint *points;
gboolean closed;
gint i;
gdouble xscale, yscale;
vectors = GIMP_VECTORS (renderer->viewable);
if (GIMP_IS_VECTORS (renderer->viewable))
gdk_draw_rectangle (widget->window, widget->style->white_gc, TRUE,
widget->allocation.x, widget->allocation.y,
widget->allocation.width, widget->allocation.height);
xscale = ((float) GIMP_ITEM (vectors)->width) /
((float) widget->allocation.width);
yscale = ((float) GIMP_ITEM (vectors)->height) /
((float) widget->allocation.height);
for (stroke = gimp_vectors_stroke_get_next (vectors, NULL);
stroke != NULL;
stroke = gimp_vectors_stroke_get_next (vectors, stroke))
{
stock_id = gimp_viewable_get_stock_id (renderer->viewable);
}
coordinates = gimp_stroke_interpolate (stroke, MIN (xscale, yscale),
&closed);
points = g_new (GdkPoint, coordinates->len);
if (stock_id)
gimp_preview_renderer_default_render_stock (renderer, widget, stock_id);
else
GIMP_PREVIEW_RENDERER_CLASS (parent_class)->render (renderer, widget);
for (i=0; i < coordinates->len; i++)
{
coords = &(g_array_index (coordinates, GimpCoords, i));
points[i].x = ROUND (coords->x / xscale) + widget->allocation.x;
points[i].y = ROUND (coords->y / yscale) + widget->allocation.y;
}
gdk_draw_lines (widget->window, widget->style->black_gc,
points, coordinates->len);
g_array_free (coordinates, TRUE);
g_free (points);
}
}

View File

@ -29,6 +29,7 @@
#include "widgets-types.h"
#include "vectors/gimpvectors.h"
#include "vectors/gimpstroke.h"
#include "gimppreviewrenderervectors.h"
@ -86,15 +87,44 @@ static void
gimp_preview_renderer_vectors_render (GimpPreviewRenderer *renderer,
GtkWidget *widget)
{
const gchar *stock_id = NULL;
GimpVectors *vectors;
GimpStroke *stroke;
GArray *coordinates;
GimpCoords *coords;
GdkPoint *points;
gboolean closed;
gint i;
gdouble xscale, yscale;
vectors = GIMP_VECTORS (renderer->viewable);
if (GIMP_IS_VECTORS (renderer->viewable))
gdk_draw_rectangle (widget->window, widget->style->white_gc, TRUE,
widget->allocation.x, widget->allocation.y,
widget->allocation.width, widget->allocation.height);
xscale = ((float) GIMP_ITEM (vectors)->width) /
((float) widget->allocation.width);
yscale = ((float) GIMP_ITEM (vectors)->height) /
((float) widget->allocation.height);
for (stroke = gimp_vectors_stroke_get_next (vectors, NULL);
stroke != NULL;
stroke = gimp_vectors_stroke_get_next (vectors, stroke))
{
stock_id = gimp_viewable_get_stock_id (renderer->viewable);
}
coordinates = gimp_stroke_interpolate (stroke, MIN (xscale, yscale),
&closed);
points = g_new (GdkPoint, coordinates->len);
if (stock_id)
gimp_preview_renderer_default_render_stock (renderer, widget, stock_id);
else
GIMP_PREVIEW_RENDERER_CLASS (parent_class)->render (renderer, widget);
for (i=0; i < coordinates->len; i++)
{
coords = &(g_array_index (coordinates, GimpCoords, i));
points[i].x = ROUND (coords->x / xscale) + widget->allocation.x;
points[i].y = ROUND (coords->y / yscale) + widget->allocation.y;
}
gdk_draw_lines (widget->window, widget->style->black_gc,
points, coordinates->len);
g_array_free (coordinates, TRUE);
g_free (points);
}
}