Commit f6858e21 authored by Tor Lillqvist's avatar Tor Lillqvist

Actually use the enum types GimpImageType, GimpImageBaseType,

	* app/*.[ch]: Actually use the enum types GimpImageType,
	GimpImageBaseType, LayerModeEffects, PaintApplicationMode,
	BrushApplicationMode, GimpFillType and ConvertPaletteType, instead
	of just int or gint. Hopefully I catched most of the places
	where these should be used.

	Add an enum ConvolutionType, suffix the too general constants
	NORMAL, ABSOLUTE and NEGATIVE with _CONVOL. Use NORMAL_MODE
	instead of NORMAL in some places (this was what was intended). Fix
	some minor gccisms.

	* app/apptypes.h: New file. This file contains the above
	enumeration types, and some opaque struct typedefs. It was
	necessary to collect these in one header that doesn't include
	other headers, because when we started using the above mentioned
	types in the headers, all hell broke loose because of the
	spaghetti-like cross-inclusion mess between headers.

	(An example: Header A includes header B, which includes header C
	which includes A. B uses a type defined in A. This is not defined,
	because A hasn't defined it yet at the point where it includes B,
	and A included from B of course is skipped as we already are
	reading A.)
parent 088a9d71
......@@ -1240,7 +1240,7 @@ plug_in_repeat (int with_interface)
}
void
plug_in_set_menu_sensitivity (int base_type)
plug_in_set_menu_sensitivity (GimpImageType type)
{
PlugInProcDef *proc_def;
GSList *tmp;
......@@ -1254,7 +1254,7 @@ plug_in_set_menu_sensitivity (int base_type)
if (proc_def->image_types_val && proc_def->menu_path)
{
switch (base_type)
switch (type)
{
case -1:
sensitive = FALSE;
......
......@@ -86,7 +86,7 @@ static double non_gui_pressure;
static gboolean non_gui_incremental;
/* forward function declarations */
static void airbrush_motion (PaintCore *, GimpDrawable *, double, gboolean);
static void airbrush_motion (PaintCore *, GimpDrawable *, double, PaintApplicationMode);
static gint airbrush_time_out (gpointer);
......@@ -235,7 +235,8 @@ airbrush_paint_func (PaintCore *paint_core,
gtk_timeout_remove (timer);
timer_state = OFF;
airbrush_motion (paint_core, drawable, airbrush_options->pressure, airbrush_options->incremental);
airbrush_motion (paint_core, drawable, airbrush_options->pressure,
airbrush_options->incremental ? INCREMENTAL : CONSTANT);
if (airbrush_options->rate != 0.0)
{
......@@ -279,7 +280,7 @@ airbrush_time_out (gpointer client_data)
airbrush_motion (airbrush_timeout.paint_core,
airbrush_timeout.drawable,
airbrush_options->pressure,
airbrush_options->incremental);
airbrush_options->incremental ? INCREMENTAL : CONSTANT);
gdisplays_flush ();
/* restart the timer */
......@@ -291,10 +292,10 @@ airbrush_time_out (gpointer client_data)
static void
airbrush_motion (PaintCore *paint_core,
GimpDrawable *drawable,
double pressure,
gboolean mode)
airbrush_motion (PaintCore *paint_core,
GimpDrawable *drawable,
double pressure,
PaintApplicationMode mode)
{
gint opacity;
GImage *gimage;
......@@ -316,9 +317,9 @@ airbrush_motion (PaintCore *paint_core,
col[area->bytes - 1] = OPAQUE_OPACITY;
if(GIMP_IS_BRUSH_PIXMAP(paint_core->brush))
if (GIMP_IS_BRUSH_PIXMAP (paint_core->brush))
{
color_area_with_pixmap(gimage, drawable, area, paint_core->brush);
color_area_with_pixmap (gimage, drawable, area, paint_core->brush);
mode = INCREMENTAL;
}
else
......
/* The GIMP -- an 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __APPTYPES_H__
#define __APPTYPES_H__
/* To avoid problems with headers including each others like spaghetti
* (even recursively), and various types not being defined when they
* are needed depending on the order you happen to include headers,
* this file defines those enumeration and opaque struct types that
* don't depend on any other header. These problems began creeping up
* when we started to actually use these enums in function prototypes.
*/
/* Should we instead use the enums in libgimp/gimpenums.h? */
/* Base image types */
typedef enum
{
RGB,
GRAY,
INDEXED
} GimpImageBaseType;
/* Image types */
typedef enum
{
RGB_GIMAGE, /*< nick=RGB_IMAGE >*/
RGBA_GIMAGE, /*< nick=RGBA_IMAGE >*/
GRAY_GIMAGE, /*< nick=GRAY_IMAGE >*/
GRAYA_GIMAGE, /*< nick=GRAYA_IMAGE >*/
INDEXED_GIMAGE, /*< nick=INDEXED_IMAGE >*/
INDEXEDA_GIMAGE /*< nick=INDEXEDA_IMAGE >*/
} GimpImageType;
/* Fill types */
typedef enum
{
FOREGROUND_FILL, /*< nick=FG_IMAGE_FILL >*/
BACKGROUND_FILL, /*< nick=BG_IMAGE_FILL >*/
WHITE_FILL, /*< nick=WHITE_IMAGE_FILL >*/
TRANSPARENT_FILL, /*< nick=TRANS_IMAGE_FILL >*/
NO_FILL /*< nick=NO_IMAGE_FILL >*/
} GimpFillType;
/* Layer modes */
typedef enum
{
NORMAL_MODE,
DISSOLVE_MODE,
BEHIND_MODE,
MULTIPLY_MODE,
SCREEN_MODE,
OVERLAY_MODE,
DIFFERENCE_MODE,
ADDITION_MODE,
SUBTRACT_MODE,
DARKEN_ONLY_MODE,
LIGHTEN_ONLY_MODE,
HUE_MODE,
SATURATION_MODE,
COLOR_MODE,
VALUE_MODE,
DIVIDE_MODE,
ERASE_MODE, /*< skip >*/
REPLACE_MODE, /*< skip >*/
ANTI_ERASE_MODE, /*< skip >*/
} LayerModeEffects;
/* Types of convolutions */
typedef enum
{
NORMAL_CONVOL, /* Negative numbers truncated */
ABSOLUTE_CONVOL, /* Absolute value */
NEGATIVE_CONVOL /* add 127 to values */
} ConvolutionType;
/* Brush application types */
typedef enum
{
HARD, /* pencil */
SOFT, /* paintbrush */
PRESSURE /* paintbrush with variable pressure */
} BrushApplicationMode;
/* Paint application modes */
typedef enum
{
CONSTANT, /*< nick=CONTINUOUS >*/ /* pencil, paintbrush, airbrush, clone */
INCREMENTAL /* convolve, smudge */
} PaintApplicationMode;
typedef enum
{
APPLY,
DISCARD
} MaskApplyMode;
typedef enum /*< chop=ADD_ >*/
{
ADD_WHITE_MASK,
ADD_BLACK_MASK,
ADD_ALPHA_MASK
} AddMaskType;
typedef struct _GimpChannel GimpChannel;
typedef struct _GimpChannelClass GimpChannelClass;
typedef GimpChannel Channel; /* convenience */
typedef struct _GimpLayer GimpLayer;
typedef struct _GimpLayerClass GimpLayerClass;
typedef struct _GimpLayerMask GimpLayerMask;
typedef struct _GimpLayerMaskClass GimpLayerMaskClass;
typedef GimpLayer Layer; /* convenience */
typedef GimpLayerMask LayerMask; /* convenience */
typedef struct _layer_undo LayerUndo;
typedef struct _layer_mask_undo LayerMaskUndo;
typedef struct _fs_to_layer_undo FStoLayerUndo;
typedef struct _PlugIn PlugIn;
typedef struct _PlugInDef PlugInDef;
typedef struct _PlugInProcDef PlugInProcDef;
#endif /* __APPTYPES_H__ */
......@@ -901,7 +901,7 @@ display_brush (BrushSelectP bsp,
{
if (offset_y > 0 && offset_y < bsp->preview->allocation.height)
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview),
brush_scale_indicator_bits[i],
brush_scale_indicator_bits[i][0],
offset_x, offset_y,
brush_scale_indicator_width);
}
......
......@@ -18,8 +18,8 @@
#ifndef __CHANNEL_H__
#define __CHANNEL_H__
#include "apptypes.h"
#include "drawable.h"
#include "boundary.h"
#include "temp_buf.h"
#include "tile_manager.h"
......@@ -47,11 +47,6 @@ typedef enum
#define GIMP_IS_CHANNEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CHANNEL))
typedef struct _GimpChannel GimpChannel;
typedef struct _GimpChannelClass GimpChannelClass;
typedef GimpChannel Channel; /* convenience */
GtkType gimp_channel_get_type (void);
/* Special undo type */
......
......@@ -70,7 +70,7 @@ gint col_value[5] = { 0, 0, 0, 0, 0 };
/* the color picker dialog */
static gint update_type;
static gint sample_type;
static GimpImageType sample_type;
static InfoDialog * color_picker_info = NULL;
static gchar red_buf [MAX_INFO_BUF];
static gchar green_buf [MAX_INFO_BUF];
......
......@@ -736,18 +736,21 @@ indexed_dither_update (GtkWidget *w,
}
void
convert_image (GImage *gimage,
int new_type,
int num_cols, /* used only for new_type == INDEXED */
int dither, /* used only for new_type == INDEXED */
int palette_type) /* used only for new_type == INDEXED */
convert_image (GImage *gimage,
GimpImageBaseType new_type,
/* The following three params used only for
* new_type == INDEXED
*/
int num_cols,
int dither,
ConvertPaletteType palette_type)
{
QuantizeObj *quantobj;
Layer *layer;
Layer *floating_layer;
int old_type;
GimpImageBaseType old_type;
GSList *list;
int new_layer_type;
GimpImageType new_layer_type;
int new_layer_bytes;
int has_alpha;
TileManager *new_tiles;
......
......@@ -18,6 +18,7 @@
#ifndef __CONVERT_H__
#define __CONVERT_H__
#include "apptypes.h"
#include "procedural_db.h"
#include "gimpimageF.h"
#include "palette_entries.h"
......@@ -38,7 +39,10 @@ void convert_to_rgb (GimpImage *);
void convert_to_grayscale (GimpImage *);
void convert_to_indexed (GimpImage *);
void convert_image (GimpImage *, int, int, int, int);
void convert_image (GimpImage *,
GimpImageBaseType,
int, int,
ConvertPaletteType);
extern PaletteEntriesP theCustomPalette;
......
......@@ -337,7 +337,7 @@ convolve_motion (PaintCore *paint_core,
/* Convolve the region */
convolve_region (&tempPR, &destPR, matrix, matrix_size,
matrix_divisor, NORMAL);
matrix_divisor, NORMAL_CONVOL);
if (drawable_has_alpha (drawable))
separate_alpha_region (&destPR);
......
......@@ -285,7 +285,7 @@ edit_paste (GImage *gimage,
int cx, cy;
/* Make a new floating layer */
float_layer = layer_from_tiles (gimage, drawable, paste, _("Pasted Layer"), OPAQUE_OPACITY, NORMAL);
float_layer = layer_from_tiles (gimage, drawable, paste, _("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
if (float_layer)
{
......@@ -340,7 +340,7 @@ edit_paste_as_new (GImage *invoke,
layer = layer_new (gimage, gimage->width, gimage->height,
(invoke->base_type == RGB) ? RGBA_GIMAGE : GRAYA_GIMAGE,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL);
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* add the new layer to the image */
gimage_disable_undo (gimage);
......@@ -350,7 +350,7 @@ edit_paste_as_new (GImage *invoke,
/* make a new floating layer */
float_layer = layer_from_tiles (gimage, drawable, paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL);
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* add the new floating selection */
floating_sel_attach (float_layer, drawable);
......
......@@ -18,8 +18,8 @@
#ifndef __CHANNEL_H__
#define __CHANNEL_H__
#include "apptypes.h"
#include "drawable.h"
#include "boundary.h"
#include "temp_buf.h"
#include "tile_manager.h"
......@@ -47,11 +47,6 @@ typedef enum
#define GIMP_IS_CHANNEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CHANNEL))
typedef struct _GimpChannel GimpChannel;
typedef struct _GimpChannelClass GimpChannelClass;
typedef GimpChannel Channel; /* convenience */
GtkType gimp_channel_get_type (void);
/* Special undo type */
......
......@@ -18,8 +18,8 @@
#ifndef __CHANNEL_H__
#define __CHANNEL_H__
#include "apptypes.h"
#include "drawable.h"
#include "boundary.h"
#include "temp_buf.h"
#include "tile_manager.h"
......@@ -47,11 +47,6 @@ typedef enum
#define GIMP_IS_CHANNEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CHANNEL))
typedef struct _GimpChannel GimpChannel;
typedef struct _GimpChannelClass GimpChannelClass;
typedef GimpChannel Channel; /* convenience */
GtkType gimp_channel_get_type (void);
/* Special undo type */
......
......@@ -428,7 +428,7 @@ gimp_context_define_opacity (GimpContext *context,
/* paint mode */
gint
LayerModeEffects
gimp_context_get_paint_mode (GimpContext *context)
{
context_check_current (context);
......@@ -439,8 +439,8 @@ gimp_context_get_paint_mode (GimpContext *context)
}
void
gimp_context_set_paint_mode (GimpContext *context,
gint paint_mode)
gimp_context_set_paint_mode (GimpContext *context,
LayerModeEffects paint_mode)
{
context_check_current (context);
context_return_if_fail (context);
......
......@@ -51,26 +51,26 @@ typedef struct _GimpContextClass GimpContextClass;
struct _GimpContext
{
GimpObject object;
GimpObject object;
gchar *name;
GimpContext *parent;
gchar *name;
GimpContext *parent;
/* FIXME: the solution of having a boolean for each attribute and the
* name "defined" need some brainstorming
*/
gboolean opacity_defined;
gdouble opacity;
gboolean opacity_defined;
gdouble opacity;
gboolean paint_mode_defined;
gint paint_mode;
gboolean paint_mode_defined;
LayerModeEffects paint_mode;
gboolean image_defined;
GimpImage *image;
gboolean image_defined;
GimpImage *image;
gboolean display_defined;
GDisplay *display;
gboolean display_defined;
GDisplay *display;
};
struct _GimpContextClass
......@@ -136,9 +136,10 @@ gboolean gimp_context_opacity_defined (GimpContext *context);
void gimp_context_define_opacity (GimpContext *context,
gboolean defined);
gint gimp_context_get_paint_mode (GimpContext *context);
LayerModeEffects
gimp_context_get_paint_mode (GimpContext *context);
void gimp_context_set_paint_mode (GimpContext *context,
gint paint_mode);
LayerModeEffects paint_mode);
gboolean gimp_context_paint_mode_defined (GimpContext *context);
void gimp_context_define_paint_mode (GimpContext *context,
gboolean defined);
......
......@@ -274,7 +274,7 @@ gimp_drawable_set_gimage (GimpDrawable *drawable, GimpImage *gimage)
}
int
GimpImageType
gimp_drawable_type (GimpDrawable *drawable)
{
if (drawable)
......@@ -498,7 +498,7 @@ gimp_drawable_get_tattoo(const GimpDrawable *drawable)
int
gimp_drawable_type_with_alpha (GimpDrawable *drawable)
{
int type = gimp_drawable_type (drawable);
GimpImageType type = gimp_drawable_type (drawable);
int has_alpha = gimp_drawable_has_alpha (drawable);
if (has_alpha)
......@@ -692,7 +692,7 @@ gimp_drawable_destroy (GtkObject *object)
void
gimp_drawable_configure (GimpDrawable *drawable,
GimpImage* gimage, int width, int height,
int type, char *name)
GimpImageType type, char *name)
{
int bpp;
int alpha;
......@@ -743,4 +743,3 @@ gimp_drawable_configure (GimpDrawable *drawable,
drawable->preview_cache = NULL;
drawable->preview_valid = FALSE;
}
......@@ -18,6 +18,7 @@
#ifndef __GIMPDRAWABLE_H__
#define __GIMPDRAWABLE_H__
#include "apptypes.h"
#include "gimpobject.h"
#include "gimpdrawableF.h"
#include "tile_manager.h"
......@@ -31,16 +32,6 @@
GtkType gimp_drawable_get_type (void);
typedef enum
{
FOREGROUND_FILL, /*< nick=FG_IMAGE_FILL >*/
BACKGROUND_FILL, /*< nick=BG_IMAGE_FILL >*/
WHITE_FILL, /*< nick=WHITE_IMAGE_FILL >*/
TRANSPARENT_FILL, /*< nick=TRANS_IMAGE_FILL >*/
NO_FILL /*< nick=NO_IMAGE_FILL >*/
} GimpFillType;
/* drawable access functions */
void gimp_drawable_merge_shadow (GimpDrawable *, int);
void gimp_drawable_fill (GimpDrawable *drawable,
......@@ -54,7 +45,7 @@ int gimp_drawable_mask_bounds (GimpDrawable *,
void gimp_drawable_invalidate_preview (GimpDrawable *);
int gimp_drawable_dirty (GimpDrawable *);
int gimp_drawable_clean (GimpDrawable *);
int gimp_drawable_type (GimpDrawable *);
GimpImageType gimp_drawable_type (GimpDrawable *);
int gimp_drawable_has_alpha (GimpDrawable *);
int gimp_drawable_type_with_alpha (GimpDrawable *);
int gimp_drawable_color (GimpDrawable *);
......
......@@ -285,7 +285,7 @@ edit_paste (GImage *gimage,
int cx, cy;
/* Make a new floating layer */
float_layer = layer_from_tiles (gimage, drawable, paste, _("Pasted Layer"), OPAQUE_OPACITY, NORMAL);
float_layer = layer_from_tiles (gimage, drawable, paste, _("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
if (float_layer)
{
......@@ -340,7 +340,7 @@ edit_paste_as_new (GImage *invoke,
layer = layer_new (gimage, gimage->width, gimage->height,
(invoke->base_type == RGB) ? RGBA_GIMAGE : GRAYA_GIMAGE,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL);
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* add the new layer to the image */
gimage_disable_undo (gimage);
......@@ -350,7 +350,7 @@ edit_paste_as_new (GImage *invoke,
/* make a new floating layer */
float_layer = layer_from_tiles (gimage, drawable, paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL);
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* add the new floating selection */
floating_sel_attach (float_layer, drawable);
......
......@@ -736,18 +736,21 @@ indexed_dither_update (GtkWidget *w,
}
void
convert_image (GImage *gimage,
int new_type,
int num_cols, /* used only for new_type == INDEXED */
int dither, /* used only for new_type == INDEXED */
int palette_type) /* used only for new_type == INDEXED */
convert_image (GImage *gimage,
GimpImageBaseType new_type,
/* The following three params used only for
* new_type == INDEXED
*/
int num_cols,
int dither,
ConvertPaletteType palette_type)
{
QuantizeObj *quantobj;
Layer *layer;
Layer *floating_layer;
int old_type;
GimpImageBaseType old_type;
GSList *list;
int new_layer_type;
GimpImageType new_layer_type;
int new_layer_bytes;
int has_alpha;
TileManager *new_tiles;
......
......@@ -18,6 +18,7 @@
#ifndef __CONVERT_H__
#define __CONVERT_H__
#include "apptypes.h"
#include "procedural_db.h"
#include "gimpimageF.h"
#include "palette_entries.h"
......@@ -38,7 +39,10 @@ void convert_to_rgb (GimpImage *);
void convert_to_grayscale (GimpImage *);
void convert_to_indexed (GimpImage *);
void convert_image (GimpImage *, int, int, int, int);
void convert_image (GimpImage *,
GimpImageBaseType,
int, int,
ConvertPaletteType);
extern PaletteEntriesP theCustomPalette;
......
......@@ -250,7 +250,7 @@ gimp_image_allocate_shadow (GimpImage *gimage,
GimpImage *
gimp_image_new (int width,
int height,
int base_type)
GimpImageBaseType base_type)
{
GimpImage *gimage=GIMP_IMAGE(gtk_type_new(gimp_image_get_type ()));
int i;
......@@ -621,16 +621,16 @@ gimp_image_destroy (GtkObject *object)
}
void
gimp_image_apply_image (GimpImage *gimage,
GimpDrawable *drawable,
PixelRegion *src2PR,
int undo,
int opacity,
int mode,
gimp_image_apply_image (GimpImage *gimage,
GimpDrawable *drawable,
PixelRegion *src2PR,
int undo,
int opacity,
LayerModeEffects mode,
/* alternative to using drawable tiles as src1: */
TileManager *src1_tiles,
int x,
int y)
TileManager *src1_tiles,
int x,
int y)
{
Channel *mask;
int x1, y1, x2, y2;
......@@ -893,7 +893,7 @@ gimp_image_get_color_at (GimpImage *gimage,
void
gimp_image_get_color (GimpImage *gimage,
int d_type,
GimpImageType d_type,
unsigned char *rgb,
unsigned char *src)
{
......@@ -913,14 +913,14 @@ gimp_image_get_color (GimpImage *gimage,
void
gimp_image_transform_color (GimpImage *gimage,
GimpDrawable *drawable,
unsigned char *src,
unsigned char *dest,
int type)
gimp_image_transform_color (GimpImage *gimage,
GimpDrawable *drawable,
unsigned char *src,
unsigned char *dest,
GimpImageBaseType type)
{
#define INTENSITY(r,g,b) (r * 0.30 + g * 0.59 + b * 0.11 + 0.001)
int d_type;
GimpImageType d_type;
d_type = (drawable != NULL) ? drawable_type (drawable) :
gimp_image_base_type_with_alpha (gimage);
......@@ -1214,14 +1214,14 @@ project_channel (GimpImage *gimage,
type = (channel->show_masked) ?
INITIAL_CHANNEL_MASK : INITIAL_CHANNEL_SELECTION;
initial_region (src2, src, NULL, channel->col, channel->opacity,
NORMAL, NULL, type);
NORMAL_MODE, NULL, type);
}
else
{
type = (channel->show_masked) ?
COMBINE_INTEN_A_CHANNEL_MASK : COMBINE_INTEN_A_CHANNEL_SELECTION;
combine_regions (src, src2, src, NULL, channel->col, channel->opacity,
NORMAL, NULL, type);
NORMAL_MODE, NULL, type);
}
}
......@@ -2569,7 +2569,7 @@ gimp_image_merge_layers (GimpImage *gimage,
Layer *layer;
Layer *bottom;
unsigned char bg[4] = {0, 0, 0, 0};
int type;
GimpImageType type;
int count;
int x1, y1, x2, y2;
int x3, y3, x4, y4;
......@@ -2721,7 +