Commit 5153abaf authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

return the corrent value in g_retuen_val_if_fail().

2002-02-21  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimpdrawtool.c: return the corrent value in
	g_retuen_val_if_fail().

	* app/tools/gimppainttool.c: removed some more painting logic...

	* app/paint/gimppaintcore.[ch]: ...and added it here so the PDB
	wrappers can use it too. Added "gboolean use_pressure" which needs
	to be set by GimpPaintTool so we don't need access to GdkDevices.
parent 6537ee98
2002-02-21 Michael Natterer <mitch@gimp.org>
* app/tools/gimpdrawtool.c: return the corrent value in
g_retuen_val_if_fail().
* app/tools/gimppainttool.c: removed some more painting logic...
* app/paint/gimppaintcore.[ch]: ...and added it here so the PDB
wrappers can use it too. Added "gboolean use_pressure" which needs
to be set by GimpPaintTool so we don't need access to GdkDevices.
2002-02-20 Sven Neumann <sven@gimp.org>
* plug-ins/common/colortoalpha.c: optimization and cleanup based
......
......@@ -66,7 +66,8 @@ static void gimp_paint_core_init (GimpPaintCore *core);
static void gimp_paint_core_finalize (GObject *object);
static void gimp_paint_core_calc_brush_size (MaskBuf *mask,
static void gimp_paint_core_calc_brush_size (GimpPaintCore *core,
MaskBuf *mask,
gdouble scale,
gint *width,
gint *height);
......@@ -205,6 +206,7 @@ gimp_paint_core_init (GimpPaintCore *core)
core->brush = NULL;
core->flags = 0;
core->use_pressure = FALSE;
core->undo_tiles = NULL;
core->canvas_tiles = NULL;
......@@ -303,12 +305,28 @@ gimp_paint_core_paint (GimpPaintCore *core,
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (paint_options != NULL);
if (paint_state == MOTION_PAINT &&
(core->flags & CORE_HANDLES_CHANGING_BRUSH))
if (paint_state == MOTION_PAINT)
{
core->brush = gimp_brush_select_brush (core->brush,
&core->last_coords,
&core->cur_coords);
/* 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 (core->last_coords.x == core->cur_coords.x &&
core->last_coords.y == core->cur_coords.y &&
! gimp_brush_want_null_motion (core->brush,
&core->last_coords,
&core->cur_coords))
{
return;
}
if (core->flags & CORE_HANDLES_CHANGING_BRUSH)
{
core->brush = gimp_brush_select_brush (core->brush,
&core->last_coords,
&core->cur_coords);
}
}
GIMP_PAINT_CORE_GET_CLASS (core)->paint (core,
......@@ -652,7 +670,8 @@ gimp_paint_core_get_paint_area (GimpPaintCore *core,
bytes = (gimp_drawable_has_alpha (drawable) ?
gimp_drawable_bytes (drawable) : gimp_drawable_bytes (drawable) + 1);
gimp_paint_core_calc_brush_size (core->brush->mask,
gimp_paint_core_calc_brush_size (core,
core->brush->mask,
scale,
&bwidth, &bheight);
......@@ -832,14 +851,15 @@ gimp_paint_core_invalidate_cache (GimpBrush *brush,
************************************************************/
static void
gimp_paint_core_calc_brush_size (MaskBuf *mask,
gdouble scale,
gint *width,
gint *height)
gimp_paint_core_calc_brush_size (GimpPaintCore *core,
MaskBuf *mask,
gdouble scale,
gint *width,
gint *height)
{
scale = CLAMP (scale, 0.0, 1.0);
if (gimp_devices_get_current (the_gimp) == gdk_device_get_core_pointer ())
if (! core->use_pressure)
{
*width = mask->width;
*height = mask->height;
......@@ -1099,7 +1119,9 @@ gimp_paint_core_scale_mask (GimpPaintCore *core,
if (scale == 1.0)
return brush_mask;
gimp_paint_core_calc_brush_size (brush_mask, scale,
gimp_paint_core_calc_brush_size (core,
brush_mask,
scale,
&dest_width, &dest_height);
if (brush_mask == core->last_scale_brush &&
......@@ -1141,7 +1163,9 @@ gimp_paint_core_scale_pixmap (GimpPaintCore *core,
if (scale == 1.0)
return brush_mask;
gimp_paint_core_calc_brush_size (brush_mask, scale,
gimp_paint_core_calc_brush_size (core,
brush_mask,
scale,
&dest_width, &dest_height);
if (brush_mask == core->last_scale_pixmap &&
......@@ -1174,7 +1198,7 @@ gimp_paint_core_get_brush_mask (GimpPaintCore *core,
{
MaskBuf *mask;
if (gimp_devices_get_current (the_gimp) == gdk_device_get_core_pointer ())
if (! core->use_pressure)
{
mask = core->brush->mask;
}
......
......@@ -49,11 +49,11 @@ typedef enum /*< pdb-skip >*/
*/
CORE_HANDLES_CHANGING_BRUSH = 0x1 << 0,
/* Set for tools that perform
* temporary rendering directly to the
* window. These require sequencing with
* gdisplay_flush() routines.
* See gimpclone.c for example.
/* Set for tools that perform
* temporary rendering directly to the
* window. These require sequencing with
* gdisplay_flush() routines.
* See gimpclone.c for example.
*/
CORE_TRACES_ON_WINDOW = 0x1 << 1
} GimpPaintCoreFlags;
......@@ -87,9 +87,10 @@ struct _GimpPaintCore
gint x1, y1; /* undo extents in image coords */
gint x2, y2; /* undo extents in image coords */
GimpBrush *brush; /* current brush */
GimpBrush *brush; /* current brush */
GimpPaintCoreFlags flags; /* tool flags, see ToolFlags above */
GimpPaintCoreFlags flags; /* tool flags, see ToolFlags above */
gboolean use_pressure; /* look at coords->pressure */
/* undo blocks variables */
TileManager *undo_tiles;
......
......@@ -29,7 +29,6 @@
#include "tools-types.h"
#include "core/gimp.h"
#include "core/gimpbrush.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
......@@ -291,6 +290,16 @@ gimp_paint_tool_button_press (GimpTool *tool,
tool->gdisp = gdisp;
}
if (gimp_devices_get_current (gdisp->gimage->gimp) ==
gdk_device_get_core_pointer ())
{
core->use_pressure = FALSE;
}
else
{
core->use_pressure = TRUE;
}
if (! gimp_paint_core_start (core, drawable, &curr_coords))
return;
......@@ -363,19 +372,7 @@ gimp_paint_tool_button_press (GimpTool *tool,
}
else
{
/* 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 (core->last_coords.x != core->cur_coords.x ||
core->last_coords.y != core->cur_coords.y ||
gimp_brush_want_null_motion (core->brush,
&core->last_coords,
&core->cur_coords))
{
gimp_paint_core_paint (core, drawable, paint_options, MOTION_PAINT);
}
gimp_paint_core_paint (core, drawable, paint_options, MOTION_PAINT);
}
gimp_display_flush_now (gdisp);
......
......@@ -635,8 +635,8 @@ gimp_draw_tool_on_handle (GimpDrawTool *draw_tool,
gdouble tx, ty;
gdouble handle_tx, handle_ty;
g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), 0.0);
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), 0.0);
g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), FALSE);
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), FALSE);
gdisplay_transform_coords_f (gdisp, x, y, &tx, &ty, use_offsets);
gdisplay_transform_coords_f (gdisp,
......
......@@ -29,7 +29,6 @@
#include "tools-types.h"
#include "core/gimp.h"
#include "core/gimpbrush.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
......@@ -291,6 +290,16 @@ gimp_paint_tool_button_press (GimpTool *tool,
tool->gdisp = gdisp;
}
if (gimp_devices_get_current (gdisp->gimage->gimp) ==
gdk_device_get_core_pointer ())
{
core->use_pressure = FALSE;
}
else
{
core->use_pressure = TRUE;
}
if (! gimp_paint_core_start (core, drawable, &curr_coords))
return;
......@@ -363,19 +372,7 @@ gimp_paint_tool_button_press (GimpTool *tool,
}
else
{
/* 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 (core->last_coords.x != core->cur_coords.x ||
core->last_coords.y != core->cur_coords.y ||
gimp_brush_want_null_motion (core->brush,
&core->last_coords,
&core->cur_coords))
{
gimp_paint_core_paint (core, drawable, paint_options, MOTION_PAINT);
}
gimp_paint_core_paint (core, drawable, paint_options, MOTION_PAINT);
}
gimp_display_flush_now (gdisp);
......
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