Commit c6586ec6 authored by Michael Natterer's avatar Michael Natterer 😴

app: rename GimpMybrush to GimpMybrushCore

so GimpMybrush can be used for the actual brush object.
parent 812526f0
......@@ -52,8 +52,8 @@ libapppaint_a_sources = \
gimpinkoptions.h \
gimpinkundo.c \
gimpinkundo.h \
gimpmybrush.c \
gimpmybrush.h \
gimpmybrushcore.c \
gimpmybrushcore.h \
gimpmybrushoptions.c \
gimpmybrushoptions.h \
gimpmybrushsurface.c \
......
......@@ -34,7 +34,7 @@
#include "gimperaser.h"
#include "gimpheal.h"
#include "gimpink.h"
#include "gimpmybrush.h"
#include "gimpmybrushcore.h"
#include "gimppaintoptions.h"
#include "gimppaintbrush.h"
#include "gimppencil.h"
......@@ -66,7 +66,7 @@ gimp_paint_init (Gimp *gimp)
gimp_heal_register,
gimp_clone_register,
#ifdef HAVE_LIBMYPAINT
gimp_mybrush_register,
gimp_mybrush_core_register,
#endif
gimp_ink_register,
gimp_airbrush_register,
......
......@@ -47,14 +47,14 @@
#include "core/gimpimage-undo.h"
#include "core/gimptempbuf.h"
#include "gimpmybrushcore.h"
#include "gimpmybrushsurface.h"
#include "gimpmybrushoptions.h"
#include "gimpmybrush.h"
#include "gimp-intl.h"
struct _GimpMybrushPrivate
struct _GimpMybrushCorePrivate
{
#if 0
MyPaintGeglTiledSurface *surface;
......@@ -62,37 +62,37 @@ struct _GimpMybrushPrivate
GimpMybrushSurface *surface;
#endif
MyPaintBrush *brush;
gint64 lastTime;
gint64 last_time;
};
/* 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);
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 (GimpMybrush, gimp_mybrush, GIMP_TYPE_PAINT_CORE)
G_DEFINE_TYPE (GimpMybrushCore, gimp_mybrush_core, GIMP_TYPE_PAINT_CORE)
#define parent_class gimp_mybrush_parent_class
#define parent_class gimp_mybrush_core_parent_class
void
gimp_mybrush_register (Gimp *gimp,
GimpPaintRegisterCallback callback)
gimp_mybrush_core_register (Gimp *gimp,
GimpPaintRegisterCallback callback)
{
if (GIMP_GUI_CONFIG (gimp->config)->playground_mybrush_tool)
(* callback) (gimp,
GIMP_TYPE_MYBRUSH,
GIMP_TYPE_MYBRUSH_CORE,
GIMP_TYPE_MYBRUSH_OPTIONS,
"gimp-mybrush",
_("Mybrush"),
......@@ -100,33 +100,34 @@ gimp_mybrush_register (Gimp *gimp,
}
static void
gimp_mybrush_class_init (GimpMybrushClass *klass)
gimp_mybrush_core_class_init (GimpMybrushCoreClass *klass)
{
GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
paint_core_class->paint = gimp_mybrush_paint;
paint_core_class->paint = gimp_mybrush_core_paint;
g_type_class_add_private (klass, sizeof (GimpMybrushPrivate));
g_type_class_add_private (klass, sizeof (GimpMybrushCorePrivate));
}
static void
gimp_mybrush_init (GimpMybrush *mybrush)
gimp_mybrush_core_init (GimpMybrushCore *mybrush)
{
mybrush->private = G_TYPE_INSTANCE_GET_PRIVATE (mybrush,
GIMP_TYPE_MYBRUSH,
GimpMybrushPrivate);
GIMP_TYPE_MYBRUSH_CORE,
GimpMybrushCorePrivate);
}
static void
gimp_mybrush_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time)
gimp_mybrush_core_paint (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
const GimpCoords *coords,
GimpPaintState paint_state,
guint32 time)
{
GimpMybrush *mybrush = GIMP_MYBRUSH (paint_core);
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;
......@@ -138,77 +139,71 @@ gimp_mybrush_paint (GimpPaintCore *paint_core,
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);
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);
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));
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);
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);
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);
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;
}
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_motion (paint_core, drawable, paint_options, coords, time);
gimp_mybrush_core_motion (paint_core, drawable, paint_options,
coords, time);
break;
case GIMP_PAINT_STATE_FINISH:
......@@ -222,22 +217,21 @@ gimp_mybrush_paint (GimpPaintCore *paint_core,
}
static void
gimp_mybrush_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
const GimpCoords *coords,
guint32 time)
gimp_mybrush_core_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
const GimpCoords *coords,
guint32 time)
{
GimpMybrush *mybrush = GIMP_MYBRUSH (paint_core);
MyPaintRectangle rect;
GimpMybrushCore *mybrush = GIMP_MYBRUSH_CORE (paint_core);
MyPaintRectangle rect;
mypaint_surface_begin_atomic ((MyPaintSurface *) mybrush->private->surface);
if (mybrush->private->lastTime < 0)
if (mybrush->private->last_time < 0)
{
/* First motion, so we need a zero pressure event to start the stroke */
mybrush->private->lastTime = (gint64)time - 15;
mybrush->private->last_time = (gint64) time - 15;
mypaint_brush_stroke_to (mybrush->private->brush,
(MyPaintSurface *) mybrush->private->surface,
......@@ -256,8 +250,8 @@ gimp_mybrush_motion (GimpPaintCore *paint_core,
coords->pressure,
coords->xtilt,
coords->ytilt,
(time - mybrush->private->lastTime) * 0.001f);
mybrush->private->lastTime = time;
(time - mybrush->private->last_time) * 0.001f);
mybrush->private->last_time = time;
mypaint_surface_end_atomic ((MyPaintSurface *) mybrush->private->surface,
&rect);
......
......@@ -17,43 +17,43 @@
#ifdef HAVE_LIBMYPAINT
#ifndef __GIMP_MYBRUSH_H__
#define __GIMP_MYBRUSH_H__
#ifndef __GIMP_MYBRUSH_CORE_H__
#define __GIMP_MYBRUSH_CORE_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))
#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 _GimpMybrushPrivate GimpMybrushPrivate;
typedef struct _GimpMybrushClass GimpMybrushClass;
typedef struct _GimpMybrushCorePrivate GimpMybrushCorePrivate;
typedef struct _GimpMybrushCoreClass GimpMybrushCoreClass;
struct _GimpMybrush
struct _GimpMybrushCore
{
GimpPaintCore parent_instance;
GimpPaintCore parent_instance;
GimpMybrushPrivate *private;
GimpMybrushCorePrivate *private;
};
struct _GimpMybrushClass
struct _GimpMybrushCoreClass
{
GimpPaintCoreClass parent_class;
};
void gimp_mybrush_register (Gimp *gimp,
GimpPaintRegisterCallback callback);
void gimp_mybrush_core_register (Gimp *gimp,
GimpPaintRegisterCallback callback);
GType gimp_mybrush_get_type (void) G_GNUC_CONST;
GType gimp_mybrush_core_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_MYBRUSH_H__ */
#endif /* __GIMP_MYBRUSH_CORE_H__ */
#endif
......@@ -36,7 +36,7 @@ typedef struct _GimpDodgeBurn GimpDodgeBurn;
typedef struct _GimpEraser GimpEraser;
typedef struct _GimpHeal GimpHeal;
typedef struct _GimpInk GimpInk;
typedef struct _GimpMybrush GimpMybrush;
typedef struct _GimpMybrushCore GimpMybrushCore;
typedef struct _GimpPaintbrush GimpPaintbrush;
typedef struct _GimpPencil GimpPencil;
typedef struct _GimpPerspectiveClone GimpPerspectiveClone;
......
......@@ -274,7 +274,7 @@ app/paint/gimperaser.c
app/paint/gimpheal.c
app/paint/gimpink.c
app/paint/gimpinkoptions.c
app/paint/gimpmybrush.c
app/paint/gimpmybrushcore.c
app/paint/gimpmybrushoptions.c
app/paint/gimppaintbrush.c
app/paint/gimppaintcore-stroke.c
......
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