Add a new method, gboolean want_null_motion(), that tells if the brush

1999-08-30  Tor Lillqvist  <tml@iki.fi>

* app/gimpbrush.h (GimpBrushClass): Add a new method, gboolean
want_null_motion(), that tells if the brush wants to be painted
when we don't know the direction yet. This is needed (so far) by
brush pipes that select the brush based on direction.

* app/gimpbrush.c: Implement above method returning always TRUE.

* app/gimpbrushpipe.c: Here, implement it returning FALSE or TRUE
on whether the brush pipe has any angular (direction) dependent
dimension or not.

* app/paint_core.c (paint_core_button_press): Call the method
if current point == last point.
This commit is contained in:
Tor Lillqvist 1999-08-30 21:24:13 +00:00 committed by Tor Lillqvist
parent c2ef7d787a
commit 26b70edddf
11 changed files with 138 additions and 10 deletions

View File

@ -8,6 +8,20 @@
* app/gimpbrushlist.c (brushes_free): Portability fixes. Use
g_strconcat. Free allocated strings.
* app/gimpbrush.h (GimpBrushClass): Add a new method, gboolean
want_null_motion(), that tells if the brush wants to be painted
when we don't know the direction yet. This is needed (so far) by
brush pipes that select the brush based on direction.
* app/gimpbrush.c: Implement above method returning always TRUE.
* app/gimpbrushpipe.c: Here, implement it returning FALSE or TRUE
on whether the brush pipe has any angular (direction) dependent
dimension or not.
* app/paint_core.c (paint_core_button_press): Call the method
if current point == last point.
Mon Aug 30 22:15:29 MEST 1999 Sven Neumann <sven@gimp.org>
* app/devices.c: use the new [gimp|pattern]_preview_widgets.

View File

@ -34,6 +34,7 @@ enum{
};
static GimpBrush *gimp_brush_select_brush (PaintCore *paint_core);
static gboolean gimp_brush_want_null_motion (PaintCore *paint_core);
static guint gimp_brush_signals[LAST_SIGNAL];
static GimpObjectClass* parent_class;
@ -67,6 +68,7 @@ gimp_brush_class_init (GimpBrushClass *klass)
object_class->destroy = gimp_brush_destroy;
klass->select_brush = gimp_brush_select_brush;
klass->want_null_motion = gimp_brush_want_null_motion;
gimp_brush_signals[DIRTY] =
gimp_signal_new ("dirty", GTK_RUN_FIRST, type, 0, gimp_sigtype_void);
@ -126,6 +128,12 @@ gimp_brush_select_brush (PaintCore *paint_core)
return paint_core->brush;
}
static gboolean
gimp_brush_want_null_motion (PaintCore *paint_core)
{
return TRUE;
}
TempBuf *
gimp_brush_get_mask (GimpBrush *brush)
{

View File

@ -34,6 +34,7 @@ enum{
};
static GimpBrush *gimp_brush_select_brush (PaintCore *paint_core);
static gboolean gimp_brush_want_null_motion (PaintCore *paint_core);
static guint gimp_brush_signals[LAST_SIGNAL];
static GimpObjectClass* parent_class;
@ -67,6 +68,7 @@ gimp_brush_class_init (GimpBrushClass *klass)
object_class->destroy = gimp_brush_destroy;
klass->select_brush = gimp_brush_select_brush;
klass->want_null_motion = gimp_brush_want_null_motion;
gimp_brush_signals[DIRTY] =
gimp_signal_new ("dirty", GTK_RUN_FIRST, type, 0, gimp_sigtype_void);
@ -126,6 +128,12 @@ gimp_brush_select_brush (PaintCore *paint_core)
return paint_core->brush;
}
static gboolean
gimp_brush_want_null_motion (PaintCore *paint_core)
{
return TRUE;
}
TempBuf *
gimp_brush_get_mask (GimpBrush *brush)
{

View File

@ -42,6 +42,7 @@ struct _GimpBrushClass
{
GimpObjectClass parent_class;
GimpBrush *(* select_brush) (PaintCore *);
gboolean (* want_null_motion) (PaintCore *);
};
#define GIMP_BRUSH_CLASS(klass) \

View File

@ -60,6 +60,7 @@ static GimpBrushClass* gimp_brush_class;
static GtkObjectClass* gimp_object_class;
static GimpBrush *gimp_brush_pixmap_select_brush (PaintCore *paint_core);
static gboolean gimp_brush_pixmap_want_null_motion (PaintCore *paint_core);
static void paint_line_pixmap_mask(GImage *dest,
GimpDrawable *drawable,
@ -97,6 +98,7 @@ gimp_brush_pixmap_class_init (GimpBrushPixmapClass *klass)
object_class->destroy = gimp_brush_pixmap_destroy;
brush_class->select_brush = gimp_brush_pixmap_select_brush;
brush_class->want_null_motion = gimp_brush_pixmap_want_null_motion;
}
void
@ -189,6 +191,26 @@ gimp_brush_pixmap_select_brush (PaintCore *paint_core)
return GIMP_BRUSH (pipe->current);
}
static gboolean
gimp_brush_pixmap_want_null_motion (PaintCore *paint_core)
{
GimpBrushPipe *pipe;
int i;
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP (paint_core->brush), TRUE);
pipe = GIMP_BRUSH_PIXMAP (paint_core->brush)->pipe;
if (pipe->nbrushes == 1)
return TRUE;
for (i = 0; i < pipe->dimension; i++)
if (pipe->select[i] == PIPE_SELECT_ANGULAR)
return FALSE;
return TRUE;
}
static void
gimp_brush_pipe_destroy(GtkObject *object)
{

View File

@ -60,6 +60,7 @@ static GimpBrushClass* gimp_brush_class;
static GtkObjectClass* gimp_object_class;
static GimpBrush *gimp_brush_pixmap_select_brush (PaintCore *paint_core);
static gboolean gimp_brush_pixmap_want_null_motion (PaintCore *paint_core);
static void paint_line_pixmap_mask(GImage *dest,
GimpDrawable *drawable,
@ -97,6 +98,7 @@ gimp_brush_pixmap_class_init (GimpBrushPixmapClass *klass)
object_class->destroy = gimp_brush_pixmap_destroy;
brush_class->select_brush = gimp_brush_pixmap_select_brush;
brush_class->want_null_motion = gimp_brush_pixmap_want_null_motion;
}
void
@ -189,6 +191,26 @@ gimp_brush_pixmap_select_brush (PaintCore *paint_core)
return GIMP_BRUSH (pipe->current);
}
static gboolean
gimp_brush_pixmap_want_null_motion (PaintCore *paint_core)
{
GimpBrushPipe *pipe;
int i;
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP (paint_core->brush), TRUE);
pipe = GIMP_BRUSH_PIXMAP (paint_core->brush)->pipe;
if (pipe->nbrushes == 1)
return TRUE;
for (i = 0; i < pipe->dimension; i++)
if (pipe->select[i] == PIPE_SELECT_ANGULAR)
return FALSE;
return TRUE;
}
static void
gimp_brush_pipe_destroy(GtkObject *object)
{

View File

@ -34,6 +34,7 @@ enum{
};
static GimpBrush *gimp_brush_select_brush (PaintCore *paint_core);
static gboolean gimp_brush_want_null_motion (PaintCore *paint_core);
static guint gimp_brush_signals[LAST_SIGNAL];
static GimpObjectClass* parent_class;
@ -67,6 +68,7 @@ gimp_brush_class_init (GimpBrushClass *klass)
object_class->destroy = gimp_brush_destroy;
klass->select_brush = gimp_brush_select_brush;
klass->want_null_motion = gimp_brush_want_null_motion;
gimp_brush_signals[DIRTY] =
gimp_signal_new ("dirty", GTK_RUN_FIRST, type, 0, gimp_sigtype_void);
@ -126,6 +128,12 @@ gimp_brush_select_brush (PaintCore *paint_core)
return paint_core->brush;
}
static gboolean
gimp_brush_want_null_motion (PaintCore *paint_core)
{
return TRUE;
}
TempBuf *
gimp_brush_get_mask (GimpBrush *brush)
{

View File

@ -42,6 +42,7 @@ struct _GimpBrushClass
{
GimpObjectClass parent_class;
GimpBrush *(* select_brush) (PaintCore *);
gboolean (* want_null_motion) (PaintCore *);
};
#define GIMP_BRUSH_CLASS(klass) \

View File

@ -60,6 +60,7 @@ static GimpBrushClass* gimp_brush_class;
static GtkObjectClass* gimp_object_class;
static GimpBrush *gimp_brush_pixmap_select_brush (PaintCore *paint_core);
static gboolean gimp_brush_pixmap_want_null_motion (PaintCore *paint_core);
static void paint_line_pixmap_mask(GImage *dest,
GimpDrawable *drawable,
@ -97,6 +98,7 @@ gimp_brush_pixmap_class_init (GimpBrushPixmapClass *klass)
object_class->destroy = gimp_brush_pixmap_destroy;
brush_class->select_brush = gimp_brush_pixmap_select_brush;
brush_class->want_null_motion = gimp_brush_pixmap_want_null_motion;
}
void
@ -189,6 +191,26 @@ gimp_brush_pixmap_select_brush (PaintCore *paint_core)
return GIMP_BRUSH (pipe->current);
}
static gboolean
gimp_brush_pixmap_want_null_motion (PaintCore *paint_core)
{
GimpBrushPipe *pipe;
int i;
g_return_val_if_fail (GIMP_IS_BRUSH_PIXMAP (paint_core->brush), TRUE);
pipe = GIMP_BRUSH_PIXMAP (paint_core->brush)->pipe;
if (pipe->nbrushes == 1)
return TRUE;
for (i = 0; i < pipe->dimension; i++)
if (pipe->select[i] == PIPE_SELECT_ANGULAR)
return FALSE;
return TRUE;
}
static void
gimp_brush_pipe_destroy(GtkObject *object)
{

View File

@ -273,11 +273,22 @@ paint_core_button_press (Tool *tool,
}
else
{
if (paint_core->flags & TOOL_CAN_HANDLE_CHANGING_BRUSH)
paint_core->brush =
(* GIMP_BRUSH_CLASS (GTK_OBJECT (paint_core->brush)
->klass)->select_brush) (paint_core);
(* paint_core->paint_func) (paint_core, drawable, MOTION_PAINT);
/* If we current point == last point, check if the brush
* wants to be painted in that case. (Direction dependent
* pixmap brush pipes don't, as they don't know which
* pixmap to select.)
*/
if (paint_core->lastx != paint_core->curx
|| paint_core->lasty != paint_core->cury
|| (* GIMP_BRUSH_CLASS (GTK_OBJECT (paint_core->brush)
->klass)->want_null_motion) (paint_core))
{
if (paint_core->flags & TOOL_CAN_HANDLE_CHANGING_BRUSH)
paint_core->brush =
(* GIMP_BRUSH_CLASS (GTK_OBJECT (paint_core->brush)
->klass)->select_brush) (paint_core);
(* paint_core->paint_func) (paint_core, drawable, MOTION_PAINT);
}
}
gdisplay_flush_now (gdisp);

View File

@ -273,11 +273,22 @@ paint_core_button_press (Tool *tool,
}
else
{
if (paint_core->flags & TOOL_CAN_HANDLE_CHANGING_BRUSH)
paint_core->brush =
(* GIMP_BRUSH_CLASS (GTK_OBJECT (paint_core->brush)
->klass)->select_brush) (paint_core);
(* paint_core->paint_func) (paint_core, drawable, MOTION_PAINT);
/* If we current point == last point, check if the brush
* wants to be painted in that case. (Direction dependent
* pixmap brush pipes don't, as they don't know which
* pixmap to select.)
*/
if (paint_core->lastx != paint_core->curx
|| paint_core->lasty != paint_core->cury
|| (* GIMP_BRUSH_CLASS (GTK_OBJECT (paint_core->brush)
->klass)->want_null_motion) (paint_core))
{
if (paint_core->flags & TOOL_CAN_HANDLE_CHANGING_BRUSH)
paint_core->brush =
(* GIMP_BRUSH_CLASS (GTK_OBJECT (paint_core->brush)
->klass)->select_brush) (paint_core);
(* paint_core->paint_func) (paint_core, drawable, MOTION_PAINT);
}
}
gdisplay_flush_now (gdisp);