mirror of https://github.com/GNOME/gimp.git
app: rename GimpMybrush to GimpMybrushCore
so GimpMybrush can be used for the actual brush object.
This commit is contained in:
parent
812526f0f0
commit
c6586ec6e4
|
@ -52,8 +52,8 @@ libapppaint_a_sources = \
|
||||||
gimpinkoptions.h \
|
gimpinkoptions.h \
|
||||||
gimpinkundo.c \
|
gimpinkundo.c \
|
||||||
gimpinkundo.h \
|
gimpinkundo.h \
|
||||||
gimpmybrush.c \
|
gimpmybrushcore.c \
|
||||||
gimpmybrush.h \
|
gimpmybrushcore.h \
|
||||||
gimpmybrushoptions.c \
|
gimpmybrushoptions.c \
|
||||||
gimpmybrushoptions.h \
|
gimpmybrushoptions.h \
|
||||||
gimpmybrushsurface.c \
|
gimpmybrushsurface.c \
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#include "gimperaser.h"
|
#include "gimperaser.h"
|
||||||
#include "gimpheal.h"
|
#include "gimpheal.h"
|
||||||
#include "gimpink.h"
|
#include "gimpink.h"
|
||||||
#include "gimpmybrush.h"
|
#include "gimpmybrushcore.h"
|
||||||
#include "gimppaintoptions.h"
|
#include "gimppaintoptions.h"
|
||||||
#include "gimppaintbrush.h"
|
#include "gimppaintbrush.h"
|
||||||
#include "gimppencil.h"
|
#include "gimppencil.h"
|
||||||
|
@ -66,7 +66,7 @@ gimp_paint_init (Gimp *gimp)
|
||||||
gimp_heal_register,
|
gimp_heal_register,
|
||||||
gimp_clone_register,
|
gimp_clone_register,
|
||||||
#ifdef HAVE_LIBMYPAINT
|
#ifdef HAVE_LIBMYPAINT
|
||||||
gimp_mybrush_register,
|
gimp_mybrush_core_register,
|
||||||
#endif
|
#endif
|
||||||
gimp_ink_register,
|
gimp_ink_register,
|
||||||
gimp_airbrush_register,
|
gimp_airbrush_register,
|
||||||
|
|
|
@ -1,287 +0,0 @@
|
||||||
/* GIMP - The GNU Image Manipulation Program
|
|
||||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBMYPAINT
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <cairo.h>
|
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
|
||||||
#include <gegl.h>
|
|
||||||
|
|
||||||
#include <mypaint-brush.h>
|
|
||||||
#if 0
|
|
||||||
#include <mypaint-tiled-surface.h>
|
|
||||||
#include <mypaint-gegl-surface.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "libgimpmath/gimpmath.h"
|
|
||||||
#include "libgimpcolor/gimpcolor.h"
|
|
||||||
|
|
||||||
#include "paint-types.h"
|
|
||||||
|
|
||||||
#include "gegl/gimp-gegl-utils.h"
|
|
||||||
|
|
||||||
#include "config/gimpguiconfig.h" /* playground */
|
|
||||||
|
|
||||||
#include "core/gimp.h"
|
|
||||||
#include "core/gimp-palettes.h"
|
|
||||||
#include "core/gimpdrawable.h"
|
|
||||||
#include "core/gimpimage.h"
|
|
||||||
#include "core/gimpimage-undo.h"
|
|
||||||
#include "core/gimptempbuf.h"
|
|
||||||
|
|
||||||
#include "gimpmybrushsurface.h"
|
|
||||||
#include "gimpmybrushoptions.h"
|
|
||||||
#include "gimpmybrush.h"
|
|
||||||
|
|
||||||
#include "gimp-intl.h"
|
|
||||||
|
|
||||||
|
|
||||||
struct _GimpMybrushPrivate
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
MyPaintGeglTiledSurface *surface;
|
|
||||||
#else
|
|
||||||
GimpMybrushSurface *surface;
|
|
||||||
#endif
|
|
||||||
MyPaintBrush *brush;
|
|
||||||
gint64 lastTime;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* local function prototypes */
|
|
||||||
|
|
||||||
static void gimp_mybrush_paint (GimpPaintCore *paint_core,
|
|
||||||
GimpDrawable *drawable,
|
|
||||||
GimpPaintOptions *paint_options,
|
|
||||||
const GimpCoords *coords,
|
|
||||||
GimpPaintState paint_state,
|
|
||||||
guint32 time);
|
|
||||||
static void gimp_mybrush_motion (GimpPaintCore *paint_core,
|
|
||||||
GimpDrawable *drawable,
|
|
||||||
GimpPaintOptions *paint_options,
|
|
||||||
const GimpCoords *coords,
|
|
||||||
guint32 time);
|
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GimpMybrush, gimp_mybrush, GIMP_TYPE_PAINT_CORE)
|
|
||||||
|
|
||||||
#define parent_class gimp_mybrush_parent_class
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
gimp_mybrush_register (Gimp *gimp,
|
|
||||||
GimpPaintRegisterCallback callback)
|
|
||||||
{
|
|
||||||
if (GIMP_GUI_CONFIG (gimp->config)->playground_mybrush_tool)
|
|
||||||
(* callback) (gimp,
|
|
||||||
GIMP_TYPE_MYBRUSH,
|
|
||||||
GIMP_TYPE_MYBRUSH_OPTIONS,
|
|
||||||
"gimp-mybrush",
|
|
||||||
_("Mybrush"),
|
|
||||||
"gimp-tool-mybrush");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_mybrush_class_init (GimpMybrushClass *klass)
|
|
||||||
{
|
|
||||||
GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
|
|
||||||
|
|
||||||
paint_core_class->paint = gimp_mybrush_paint;
|
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (GimpMybrushPrivate));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_mybrush_init (GimpMybrush *mybrush)
|
|
||||||
{
|
|
||||||
mybrush->private = G_TYPE_INSTANCE_GET_PRIVATE (mybrush,
|
|
||||||
GIMP_TYPE_MYBRUSH,
|
|
||||||
GimpMybrushPrivate);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_mybrush_paint (GimpPaintCore *paint_core,
|
|
||||||
GimpDrawable *drawable,
|
|
||||||
GimpPaintOptions *paint_options,
|
|
||||||
const GimpCoords *coords,
|
|
||||||
GimpPaintState paint_state,
|
|
||||||
guint32 time)
|
|
||||||
{
|
|
||||||
GimpMybrush *mybrush = GIMP_MYBRUSH (paint_core);
|
|
||||||
GimpMybrushOptions *options = GIMP_MYBRUSH_OPTIONS (paint_options);
|
|
||||||
const gchar *brush_data;
|
|
||||||
#if 0
|
|
||||||
GeglBuffer *buffer;
|
|
||||||
GimpComponentMask active_mask;
|
|
||||||
#endif
|
|
||||||
GimpRGB fg;
|
|
||||||
GimpHSV hsv;
|
|
||||||
|
|
||||||
switch (paint_state)
|
|
||||||
{
|
|
||||||
case GIMP_PAINT_STATE_INIT:
|
|
||||||
{
|
|
||||||
GimpContext *context = GIMP_CONTEXT (paint_options);
|
|
||||||
GimpRGB foreground;
|
|
||||||
|
|
||||||
gimp_context_get_foreground (context, &foreground);
|
|
||||||
gimp_palettes_add_color_history (context->gimp,
|
|
||||||
&foreground);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
mybrush->private->surface = mypaint_gegl_tiled_surface_new ();
|
|
||||||
|
|
||||||
buffer = mypaint_gegl_tiled_surface_get_buffer (mybrush->private->surface);
|
|
||||||
buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
|
||||||
gimp_item_get_width (GIMP_ITEM (drawable)),
|
|
||||||
gimp_item_get_height (GIMP_ITEM (drawable))),
|
|
||||||
gegl_buffer_get_format (buffer));
|
|
||||||
gegl_buffer_copy (gimp_drawable_get_buffer (drawable), NULL,
|
|
||||||
GEGL_ABYSS_NONE,
|
|
||||||
buffer, NULL);
|
|
||||||
mypaint_gegl_tiled_surface_set_buffer (mybrush->private->surface, buffer);
|
|
||||||
g_object_unref (buffer);
|
|
||||||
#else
|
|
||||||
mybrush->private->surface = gimp_mypaint_surface_new (gimp_drawable_get_buffer (drawable),
|
|
||||||
gimp_drawable_get_active_mask (drawable));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mybrush->private->brush = mypaint_brush_new ();
|
|
||||||
mypaint_brush_from_defaults (mybrush->private->brush);
|
|
||||||
brush_data = gimp_mybrush_options_get_brush_data (options);
|
|
||||||
if (brush_data)
|
|
||||||
mypaint_brush_from_string (mybrush->private->brush, brush_data);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
active_mask = gimp_drawable_get_active_mask (drawable);
|
|
||||||
|
|
||||||
mypaint_brush_set_base_value (mybrush->private->brush,
|
|
||||||
MYPAINT_BRUSH_SETTING_LOCK_ALPHA,
|
|
||||||
(active_mask & GIMP_COMPONENT_MASK_ALPHA) ?
|
|
||||||
FALSE : TRUE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gimp_context_get_foreground (context, &fg);
|
|
||||||
gimp_rgb_to_hsv (&fg, &hsv);
|
|
||||||
|
|
||||||
mypaint_brush_set_base_value (mybrush->private->brush,
|
|
||||||
MYPAINT_BRUSH_SETTING_COLOR_H,
|
|
||||||
hsv.h);
|
|
||||||
mypaint_brush_set_base_value (mybrush->private->brush,
|
|
||||||
MYPAINT_BRUSH_SETTING_COLOR_S,
|
|
||||||
hsv.s);
|
|
||||||
mypaint_brush_set_base_value (mybrush->private->brush,
|
|
||||||
MYPAINT_BRUSH_SETTING_COLOR_V,
|
|
||||||
hsv.v);
|
|
||||||
|
|
||||||
mypaint_brush_set_base_value (mybrush->private->brush,
|
|
||||||
MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC,
|
|
||||||
options->radius);
|
|
||||||
mypaint_brush_set_base_value (mybrush->private->brush,
|
|
||||||
MYPAINT_BRUSH_SETTING_OPAQUE,
|
|
||||||
options->opaque * gimp_context_get_opacity (context));
|
|
||||||
mypaint_brush_set_base_value (mybrush->private->brush,
|
|
||||||
MYPAINT_BRUSH_SETTING_HARDNESS,
|
|
||||||
options->hardness);
|
|
||||||
|
|
||||||
mypaint_brush_new_stroke (mybrush->private->brush);
|
|
||||||
mybrush->private->lastTime = -1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GIMP_PAINT_STATE_MOTION:
|
|
||||||
gimp_mybrush_motion (paint_core, drawable, paint_options, coords, time);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GIMP_PAINT_STATE_FINISH:
|
|
||||||
mypaint_surface_unref ((MyPaintSurface *) mybrush->private->surface);
|
|
||||||
mybrush->private->surface = NULL;
|
|
||||||
|
|
||||||
mypaint_brush_unref (mybrush->private->brush);
|
|
||||||
mybrush->private->brush = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_mybrush_motion (GimpPaintCore *paint_core,
|
|
||||||
GimpDrawable *drawable,
|
|
||||||
GimpPaintOptions *paint_options,
|
|
||||||
const GimpCoords *coords,
|
|
||||||
guint32 time)
|
|
||||||
{
|
|
||||||
GimpMybrush *mybrush = GIMP_MYBRUSH (paint_core);
|
|
||||||
MyPaintRectangle rect;
|
|
||||||
|
|
||||||
mypaint_surface_begin_atomic ((MyPaintSurface *) mybrush->private->surface);
|
|
||||||
|
|
||||||
|
|
||||||
if (mybrush->private->lastTime < 0)
|
|
||||||
{
|
|
||||||
/* First motion, so we need a zero pressure event to start the stroke */
|
|
||||||
mybrush->private->lastTime = (gint64)time - 15;
|
|
||||||
|
|
||||||
mypaint_brush_stroke_to (mybrush->private->brush,
|
|
||||||
(MyPaintSurface *) mybrush->private->surface,
|
|
||||||
coords->x,
|
|
||||||
coords->y,
|
|
||||||
0.0f,
|
|
||||||
coords->xtilt,
|
|
||||||
coords->ytilt,
|
|
||||||
1.0f /* Pretend the cursor hasn't moved in a while */);
|
|
||||||
}
|
|
||||||
|
|
||||||
mypaint_brush_stroke_to (mybrush->private->brush,
|
|
||||||
(MyPaintSurface *) mybrush->private->surface,
|
|
||||||
coords->x,
|
|
||||||
coords->y,
|
|
||||||
coords->pressure,
|
|
||||||
coords->xtilt,
|
|
||||||
coords->ytilt,
|
|
||||||
(time - mybrush->private->lastTime) * 0.001f);
|
|
||||||
mybrush->private->lastTime = time;
|
|
||||||
|
|
||||||
mypaint_surface_end_atomic ((MyPaintSurface *) mybrush->private->surface,
|
|
||||||
&rect);
|
|
||||||
|
|
||||||
if (rect.width > 0 && rect.height > 0)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
GeglBuffer *src;
|
|
||||||
|
|
||||||
src = mypaint_gegl_tiled_surface_get_buffer (mybrush->private->surface);
|
|
||||||
|
|
||||||
gegl_buffer_copy (src,
|
|
||||||
(GeglRectangle *) &rect,
|
|
||||||
GEGL_ABYSS_NONE,
|
|
||||||
gimp_drawable_get_buffer (drawable),
|
|
||||||
NULL);
|
|
||||||
#endif
|
|
||||||
paint_core->x1 = MIN (paint_core->x1, rect.x);
|
|
||||||
paint_core->y1 = MIN (paint_core->y1, rect.y);
|
|
||||||
paint_core->x2 = MAX (paint_core->x2, rect.x + rect.width);
|
|
||||||
paint_core->y2 = MAX (paint_core->y2, rect.y + rect.height);
|
|
||||||
|
|
||||||
gimp_drawable_update (drawable, rect.x, rect.y, rect.width, rect.height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,59 +0,0 @@
|
||||||
/* GIMP - The GNU Image Manipulation Program
|
|
||||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBMYPAINT
|
|
||||||
|
|
||||||
#ifndef __GIMP_MYBRUSH_H__
|
|
||||||
#define __GIMP_MYBRUSH_H__
|
|
||||||
|
|
||||||
|
|
||||||
#include "gimppaintcore.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_TYPE_MYBRUSH (gimp_mybrush_get_type ())
|
|
||||||
#define GIMP_MYBRUSH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_MYBRUSH, GimpMybrush))
|
|
||||||
#define GIMP_MYBRUSH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_MYBRUSH, GimpMybrushClass))
|
|
||||||
#define GIMP_IS_MYBRUSH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_MYBRUSH))
|
|
||||||
#define GIMP_IS_MYBRUSH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_MYBRUSH))
|
|
||||||
#define GIMP_MYBRUSH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_MYBRUSH, GimpMybrushClass))
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _GimpMybrushPrivate GimpMybrushPrivate;
|
|
||||||
typedef struct _GimpMybrushClass GimpMybrushClass;
|
|
||||||
|
|
||||||
struct _GimpMybrush
|
|
||||||
{
|
|
||||||
GimpPaintCore parent_instance;
|
|
||||||
|
|
||||||
GimpMybrushPrivate *private;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GimpMybrushClass
|
|
||||||
{
|
|
||||||
GimpPaintCoreClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void gimp_mybrush_register (Gimp *gimp,
|
|
||||||
GimpPaintRegisterCallback callback);
|
|
||||||
|
|
||||||
GType gimp_mybrush_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_MYBRUSH_H__ */
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -0,0 +1,281 @@
|
||||||
|
/* GIMP - The GNU Image Manipulation Program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBMYPAINT
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <cairo.h>
|
||||||
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
#include <gegl.h>
|
||||||
|
|
||||||
|
#include <mypaint-brush.h>
|
||||||
|
#if 0
|
||||||
|
#include <mypaint-tiled-surface.h>
|
||||||
|
#include <mypaint-gegl-surface.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "libgimpmath/gimpmath.h"
|
||||||
|
#include "libgimpcolor/gimpcolor.h"
|
||||||
|
|
||||||
|
#include "paint-types.h"
|
||||||
|
|
||||||
|
#include "gegl/gimp-gegl-utils.h"
|
||||||
|
|
||||||
|
#include "config/gimpguiconfig.h" /* playground */
|
||||||
|
|
||||||
|
#include "core/gimp.h"
|
||||||
|
#include "core/gimp-palettes.h"
|
||||||
|
#include "core/gimpdrawable.h"
|
||||||
|
#include "core/gimpimage.h"
|
||||||
|
#include "core/gimpimage-undo.h"
|
||||||
|
#include "core/gimptempbuf.h"
|
||||||
|
|
||||||
|
#include "gimpmybrushcore.h"
|
||||||
|
#include "gimpmybrushsurface.h"
|
||||||
|
#include "gimpmybrushoptions.h"
|
||||||
|
|
||||||
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct _GimpMybrushCorePrivate
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
MyPaintGeglTiledSurface *surface;
|
||||||
|
#else
|
||||||
|
GimpMybrushSurface *surface;
|
||||||
|
#endif
|
||||||
|
MyPaintBrush *brush;
|
||||||
|
gint64 last_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* local function prototypes */
|
||||||
|
|
||||||
|
static void gimp_mybrush_core_paint (GimpPaintCore *paint_core,
|
||||||
|
GimpDrawable *drawable,
|
||||||
|
GimpPaintOptions *paint_options,
|
||||||
|
const GimpCoords *coords,
|
||||||
|
GimpPaintState paint_state,
|
||||||
|
guint32 time);
|
||||||
|
static void gimp_mybrush_core_motion (GimpPaintCore *paint_core,
|
||||||
|
GimpDrawable *drawable,
|
||||||
|
GimpPaintOptions *paint_options,
|
||||||
|
const GimpCoords *coords,
|
||||||
|
guint32 time);
|
||||||
|
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GimpMybrushCore, gimp_mybrush_core, GIMP_TYPE_PAINT_CORE)
|
||||||
|
|
||||||
|
#define parent_class gimp_mybrush_core_parent_class
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_mybrush_core_register (Gimp *gimp,
|
||||||
|
GimpPaintRegisterCallback callback)
|
||||||
|
{
|
||||||
|
if (GIMP_GUI_CONFIG (gimp->config)->playground_mybrush_tool)
|
||||||
|
(* callback) (gimp,
|
||||||
|
GIMP_TYPE_MYBRUSH_CORE,
|
||||||
|
GIMP_TYPE_MYBRUSH_OPTIONS,
|
||||||
|
"gimp-mybrush",
|
||||||
|
_("Mybrush"),
|
||||||
|
"gimp-tool-mybrush");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_mybrush_core_class_init (GimpMybrushCoreClass *klass)
|
||||||
|
{
|
||||||
|
GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
|
||||||
|
|
||||||
|
paint_core_class->paint = gimp_mybrush_core_paint;
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GimpMybrushCorePrivate));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_mybrush_core_init (GimpMybrushCore *mybrush)
|
||||||
|
{
|
||||||
|
mybrush->private = G_TYPE_INSTANCE_GET_PRIVATE (mybrush,
|
||||||
|
GIMP_TYPE_MYBRUSH_CORE,
|
||||||
|
GimpMybrushCorePrivate);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_mybrush_core_paint (GimpPaintCore *paint_core,
|
||||||
|
GimpDrawable *drawable,
|
||||||
|
GimpPaintOptions *paint_options,
|
||||||
|
const GimpCoords *coords,
|
||||||
|
GimpPaintState paint_state,
|
||||||
|
guint32 time)
|
||||||
|
{
|
||||||
|
GimpMybrushCore *mybrush = GIMP_MYBRUSH_CORE (paint_core);
|
||||||
|
GimpMybrushOptions *options = GIMP_MYBRUSH_OPTIONS (paint_options);
|
||||||
|
GimpContext *context = GIMP_CONTEXT (paint_options);
|
||||||
|
const gchar *brush_data;
|
||||||
|
#if 0
|
||||||
|
GeglBuffer *buffer;
|
||||||
|
GimpComponentMask active_mask;
|
||||||
|
#endif
|
||||||
|
GimpRGB fg;
|
||||||
|
GimpHSV hsv;
|
||||||
|
|
||||||
|
switch (paint_state)
|
||||||
|
{
|
||||||
|
case GIMP_PAINT_STATE_INIT:
|
||||||
|
gimp_context_get_foreground (context, &fg);
|
||||||
|
gimp_palettes_add_color_history (context->gimp, &fg);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
mybrush->private->surface = mypaint_gegl_tiled_surface_new ();
|
||||||
|
|
||||||
|
buffer = mypaint_gegl_tiled_surface_get_buffer (mybrush->private->surface);
|
||||||
|
buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
||||||
|
gimp_item_get_width (GIMP_ITEM (drawable)),
|
||||||
|
gimp_item_get_height (GIMP_ITEM (drawable))),
|
||||||
|
gegl_buffer_get_format (buffer));
|
||||||
|
gegl_buffer_copy (gimp_drawable_get_buffer (drawable), NULL,
|
||||||
|
GEGL_ABYSS_NONE,
|
||||||
|
buffer, NULL);
|
||||||
|
mypaint_gegl_tiled_surface_set_buffer (mybrush->private->surface, buffer);
|
||||||
|
g_object_unref (buffer);
|
||||||
|
#else
|
||||||
|
mybrush->private->surface = gimp_mypaint_surface_new (gimp_drawable_get_buffer (drawable),
|
||||||
|
gimp_drawable_get_active_mask (drawable));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mybrush->private->brush = mypaint_brush_new ();
|
||||||
|
mypaint_brush_from_defaults (mybrush->private->brush);
|
||||||
|
brush_data = gimp_mybrush_options_get_brush_data (options);
|
||||||
|
if (brush_data)
|
||||||
|
mypaint_brush_from_string (mybrush->private->brush, brush_data);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
active_mask = gimp_drawable_get_active_mask (drawable);
|
||||||
|
|
||||||
|
mypaint_brush_set_base_value (mybrush->private->brush,
|
||||||
|
MYPAINT_BRUSH_SETTING_LOCK_ALPHA,
|
||||||
|
(active_mask & GIMP_COMPONENT_MASK_ALPHA) ?
|
||||||
|
FALSE : TRUE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gimp_rgb_to_hsv (&fg, &hsv);
|
||||||
|
|
||||||
|
mypaint_brush_set_base_value (mybrush->private->brush,
|
||||||
|
MYPAINT_BRUSH_SETTING_COLOR_H,
|
||||||
|
hsv.h);
|
||||||
|
mypaint_brush_set_base_value (mybrush->private->brush,
|
||||||
|
MYPAINT_BRUSH_SETTING_COLOR_S,
|
||||||
|
hsv.s);
|
||||||
|
mypaint_brush_set_base_value (mybrush->private->brush,
|
||||||
|
MYPAINT_BRUSH_SETTING_COLOR_V,
|
||||||
|
hsv.v);
|
||||||
|
|
||||||
|
mypaint_brush_set_base_value (mybrush->private->brush,
|
||||||
|
MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC,
|
||||||
|
options->radius);
|
||||||
|
mypaint_brush_set_base_value (mybrush->private->brush,
|
||||||
|
MYPAINT_BRUSH_SETTING_OPAQUE,
|
||||||
|
options->opaque * gimp_context_get_opacity (context));
|
||||||
|
mypaint_brush_set_base_value (mybrush->private->brush,
|
||||||
|
MYPAINT_BRUSH_SETTING_HARDNESS,
|
||||||
|
options->hardness);
|
||||||
|
|
||||||
|
mypaint_brush_new_stroke (mybrush->private->brush);
|
||||||
|
mybrush->private->last_time = -1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GIMP_PAINT_STATE_MOTION:
|
||||||
|
gimp_mybrush_core_motion (paint_core, drawable, paint_options,
|
||||||
|
coords, time);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GIMP_PAINT_STATE_FINISH:
|
||||||
|
mypaint_surface_unref ((MyPaintSurface *) mybrush->private->surface);
|
||||||
|
mybrush->private->surface = NULL;
|
||||||
|
|
||||||
|
mypaint_brush_unref (mybrush->private->brush);
|
||||||
|
mybrush->private->brush = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_mybrush_core_motion (GimpPaintCore *paint_core,
|
||||||
|
GimpDrawable *drawable,
|
||||||
|
GimpPaintOptions *paint_options,
|
||||||
|
const GimpCoords *coords,
|
||||||
|
guint32 time)
|
||||||
|
{
|
||||||
|
GimpMybrushCore *mybrush = GIMP_MYBRUSH_CORE (paint_core);
|
||||||
|
MyPaintRectangle rect;
|
||||||
|
|
||||||
|
mypaint_surface_begin_atomic ((MyPaintSurface *) mybrush->private->surface);
|
||||||
|
|
||||||
|
if (mybrush->private->last_time < 0)
|
||||||
|
{
|
||||||
|
/* First motion, so we need a zero pressure event to start the stroke */
|
||||||
|
mybrush->private->last_time = (gint64) time - 15;
|
||||||
|
|
||||||
|
mypaint_brush_stroke_to (mybrush->private->brush,
|
||||||
|
(MyPaintSurface *) mybrush->private->surface,
|
||||||
|
coords->x,
|
||||||
|
coords->y,
|
||||||
|
0.0f,
|
||||||
|
coords->xtilt,
|
||||||
|
coords->ytilt,
|
||||||
|
1.0f /* Pretend the cursor hasn't moved in a while */);
|
||||||
|
}
|
||||||
|
|
||||||
|
mypaint_brush_stroke_to (mybrush->private->brush,
|
||||||
|
(MyPaintSurface *) mybrush->private->surface,
|
||||||
|
coords->x,
|
||||||
|
coords->y,
|
||||||
|
coords->pressure,
|
||||||
|
coords->xtilt,
|
||||||
|
coords->ytilt,
|
||||||
|
(time - mybrush->private->last_time) * 0.001f);
|
||||||
|
mybrush->private->last_time = time;
|
||||||
|
|
||||||
|
mypaint_surface_end_atomic ((MyPaintSurface *) mybrush->private->surface,
|
||||||
|
&rect);
|
||||||
|
|
||||||
|
if (rect.width > 0 && rect.height > 0)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
GeglBuffer *src;
|
||||||
|
|
||||||
|
src = mypaint_gegl_tiled_surface_get_buffer (mybrush->private->surface);
|
||||||
|
|
||||||
|
gegl_buffer_copy (src,
|
||||||
|
(GeglRectangle *) &rect,
|
||||||
|
GEGL_ABYSS_NONE,
|
||||||
|
gimp_drawable_get_buffer (drawable),
|
||||||
|
NULL);
|
||||||
|
#endif
|
||||||
|
paint_core->x1 = MIN (paint_core->x1, rect.x);
|
||||||
|
paint_core->y1 = MIN (paint_core->y1, rect.y);
|
||||||
|
paint_core->x2 = MAX (paint_core->x2, rect.x + rect.width);
|
||||||
|
paint_core->y2 = MAX (paint_core->y2, rect.y + rect.height);
|
||||||
|
|
||||||
|
gimp_drawable_update (drawable, rect.x, rect.y, rect.width, rect.height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,59 @@
|
||||||
|
/* GIMP - The GNU Image Manipulation Program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBMYPAINT
|
||||||
|
|
||||||
|
#ifndef __GIMP_MYBRUSH_CORE_H__
|
||||||
|
#define __GIMP_MYBRUSH_CORE_H__
|
||||||
|
|
||||||
|
|
||||||
|
#include "gimppaintcore.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define GIMP_TYPE_MYBRUSH_CORE (gimp_mybrush_core_get_type ())
|
||||||
|
#define GIMP_MYBRUSH_CORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_MYBRUSH_CORE, GimpMybrushCore))
|
||||||
|
#define GIMP_MYBRUSH_CORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_MYBRUSH_CORE, GimpMybrushCoreClass))
|
||||||
|
#define GIMP_IS_MYBRUSH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_MYBRUSH_CORE))
|
||||||
|
#define GIMP_IS_MYBRUSH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_MYBRUSH_CORE))
|
||||||
|
#define GIMP_MYBRUSH_CORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_MYBRUSH_CORE, GimpMybrushCoreClass))
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _GimpMybrushCorePrivate GimpMybrushCorePrivate;
|
||||||
|
typedef struct _GimpMybrushCoreClass GimpMybrushCoreClass;
|
||||||
|
|
||||||
|
struct _GimpMybrushCore
|
||||||
|
{
|
||||||
|
GimpPaintCore parent_instance;
|
||||||
|
|
||||||
|
GimpMybrushCorePrivate *private;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpMybrushCoreClass
|
||||||
|
{
|
||||||
|
GimpPaintCoreClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void gimp_mybrush_core_register (Gimp *gimp,
|
||||||
|
GimpPaintRegisterCallback callback);
|
||||||
|
|
||||||
|
GType gimp_mybrush_core_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __GIMP_MYBRUSH_CORE_H__ */
|
||||||
|
|
||||||
|
#endif
|
|
@ -36,7 +36,7 @@ typedef struct _GimpDodgeBurn GimpDodgeBurn;
|
||||||
typedef struct _GimpEraser GimpEraser;
|
typedef struct _GimpEraser GimpEraser;
|
||||||
typedef struct _GimpHeal GimpHeal;
|
typedef struct _GimpHeal GimpHeal;
|
||||||
typedef struct _GimpInk GimpInk;
|
typedef struct _GimpInk GimpInk;
|
||||||
typedef struct _GimpMybrush GimpMybrush;
|
typedef struct _GimpMybrushCore GimpMybrushCore;
|
||||||
typedef struct _GimpPaintbrush GimpPaintbrush;
|
typedef struct _GimpPaintbrush GimpPaintbrush;
|
||||||
typedef struct _GimpPencil GimpPencil;
|
typedef struct _GimpPencil GimpPencil;
|
||||||
typedef struct _GimpPerspectiveClone GimpPerspectiveClone;
|
typedef struct _GimpPerspectiveClone GimpPerspectiveClone;
|
||||||
|
|
|
@ -274,7 +274,7 @@ app/paint/gimperaser.c
|
||||||
app/paint/gimpheal.c
|
app/paint/gimpheal.c
|
||||||
app/paint/gimpink.c
|
app/paint/gimpink.c
|
||||||
app/paint/gimpinkoptions.c
|
app/paint/gimpinkoptions.c
|
||||||
app/paint/gimpmybrush.c
|
app/paint/gimpmybrushcore.c
|
||||||
app/paint/gimpmybrushoptions.c
|
app/paint/gimpmybrushoptions.c
|
||||||
app/paint/gimppaintbrush.c
|
app/paint/gimppaintbrush.c
|
||||||
app/paint/gimppaintcore-stroke.c
|
app/paint/gimppaintcore-stroke.c
|
||||||
|
|
Loading…
Reference in New Issue