Commit 8dbd5f9b authored by Michael Natterer's avatar Michael Natterer Committed by Michael Natterer

app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c

1999-04-12  Michael Natterer  <mitschel@cs.tu-berlin.de>

        * app/airbrush.c
        * app/bezier_select.c
        * app/blend.c
        * app/brightness_contrast.c
        * app/bucket_fill.c
        * app/by_color_select.c
        * app/clone.c
        * app/color_balance.c
        * app/color_picker.c
        * app/convolve.c
        * app/crop.c
        * app/curves.c
        * app/ellipse_select.c
        * app/eraser.c
        * app/flip_tool.c
        * app/free_select.c
        * app/fuzzy_select.c
        * app/histogram_tool.c
        * app/hue_saturation.c
        * app/ink.c
        * app/iscissors.c
        * app/levels.c
        * app/magnify.c
        * app/move.c
        * app/paintbrush.c
        * app/pencil.c
        * app/posterize.c
        * app/rect_select.[ch]
        * app/text_tool.c
        * app/threshold.c
        * app/transform_tool.c

        * app/tools.[ch]
        * app/toolsF.h: again: all tools :(

        * app/Makefile.am
        * app/tool_options.[ch]
        * app/selection_options.h
        * app/tool_options_ui.h: new files.

        Ok, this time it's general enough for future extensions:

        - The tool options structures are organized like the gtk object
          system to allow derived tool options.
        - Renamed all create and reset functions to *_options_new() and
          *_options_reset() to reflect this.
        - Changed tools_register() again. Now it takes just a pointer to a
          ToolOptions structure.
        - Moved almost the entire tool options gui code to tool_options.c.
        - Visually separated the common selection options from the
          tool-specific ones. I'd like to do the same with opacity/paint
          mode in all paint tool options but I think this needs some more
          discussion.

        * app/histogram_tool.c: changed packing boxes, label alignments.

        * app/paintbrush.c: some more sensitive settings. The gradient
        feature can now be toggled with a button. Hopefully didn't break
        anything.
parent add9089f
1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/airbrush.c
* app/bezier_select.c
* app/blend.c
* app/brightness_contrast.c
* app/bucket_fill.c
* app/by_color_select.c
* app/clone.c
* app/color_balance.c
* app/color_picker.c
* app/convolve.c
* app/crop.c
* app/curves.c
* app/ellipse_select.c
* app/eraser.c
* app/flip_tool.c
* app/free_select.c
* app/fuzzy_select.c
* app/histogram_tool.c
* app/hue_saturation.c
* app/ink.c
* app/iscissors.c
* app/levels.c
* app/magnify.c
* app/move.c
* app/paintbrush.c
* app/pencil.c
* app/posterize.c
* app/rect_select.[ch]
* app/text_tool.c
* app/threshold.c
* app/transform_tool.c
* app/tools.[ch]
* app/toolsF.h: again: all tools :(
* app/Makefile.am
* app/tool_options.[ch]
* app/selection_options.h
* app/tool_options_ui.h: new files.
Ok, this time it's general enough for future extensions:
- The tool options structures are organized like the gtk object
system to allow derived tool options.
- Renamed all create and reset functions to *_options_new() and
*_options_reset() to reflect this.
- Changed tools_register() again. Now it takes just a pointer to a
ToolOptions structure.
- Moved almost the entire tool options gui code to tool_options.c.
- Visually separated the common selection options from the
tool-specific ones. I'd like to do the same with opacity/paint
mode in all paint tool options but I think this needs some more
discussion.
* app/histogram_tool.c: changed packing boxes, label alignments.
* app/paintbrush.c: some more sensitive settings. The gradient
feature can now be toggled with a button. Hopefully didn't break
anything.
Sun Apr 11 23:35:31 CEST 1999 Marc Lehmann <pcg@goof.com>
* app/general.c: save string token length into "token_int".
......
......@@ -323,6 +323,7 @@ gimp_SOURCES = \
scroll.h \
selection.c \
selection.h \
selection_options.h \
session.h \
session.c \
shear_tool.c \
......@@ -346,6 +347,9 @@ gimp_SOURCES = \
tile_swap.h \
tips_dialog.c \
tips_dialog.h \
tool_options.c \
tool_options.h \
tool_options_ui.h \
tools.c \
tools.h \
toolsF.h \
......
......@@ -26,6 +26,7 @@
#include "palette.h"
#include "airbrush.h"
#include "selection.h"
#include "tool_options_ui.h"
#include "tools.h"
#include "gimage.h"
......@@ -49,16 +50,19 @@ struct _AirbrushTimeout
typedef struct _AirbrushOptions AirbrushOptions;
struct _AirbrushOptions
{
double rate;
double rate_d;
GtkObject *rate_w;
ToolOptions tool_options;
double pressure;
double pressure_d;
GtkObject *pressure_w;
double rate;
double rate_d;
GtkObject *rate_w;
double pressure;
double pressure_d;
GtkObject *pressure_w;
};
/* airbrush tool options */
/* the airbrush tool options */
static AirbrushOptions *airbrush_options = NULL;
/* local variables */
......@@ -78,14 +82,7 @@ static Argument * airbrush_invoker (Argument *);
/* functions */
static void
airbrush_scale_update (GtkAdjustment *adjustment,
double *scale_val)
{
*scale_val = adjustment->value;
}
static void
reset_airbrush_options (void)
airbrush_options_reset (void)
{
AirbrushOptions *options = airbrush_options;
......@@ -96,21 +93,25 @@ reset_airbrush_options (void)
}
static AirbrushOptions *
create_airbrush_options (void)
airbrush_options_new (void)
{
AirbrushOptions *options;
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *label;
GtkWidget *scale;
/* the new options structure */
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *label;
GtkWidget *scale;
/* the new airbrush tool options structure */
options = (AirbrushOptions *) g_malloc (sizeof (AirbrushOptions));
tool_options_init ((ToolOptions *) options,
_("Airbrush Options"),
airbrush_options_reset);
options->rate = options->rate_d = 80.0;
options->pressure = options->pressure_d = 10.0;
/* the main vbox */
vbox = gtk_vbox_new (FALSE, 2);
vbox = options->tool_options.main_vbox;
/* the rate scale */
table = gtk_table_new (2, 2, FALSE);
......@@ -131,7 +132,8 @@ create_airbrush_options (void)
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP);
gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (options->rate_w), "value_changed",
(GtkSignalFunc) airbrush_scale_update, &options->rate);
(GtkSignalFunc) tool_options_double_adjustment_update,
&options->rate);
gtk_widget_show (scale);
/* the pressure scale */
......@@ -148,18 +150,36 @@ create_airbrush_options (void)
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP);
gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (options->pressure_w), "value_changed",
(GtkSignalFunc) airbrush_scale_update, &options->pressure);
(GtkSignalFunc) tool_options_double_adjustment_update,
&options->pressure);
gtk_widget_show (scale);
gtk_widget_show (table);
/* Register this selection options widget with the main tools options dialog
*/
tools_register (AIRBRUSH, vbox, _("Airbrush Options"), reset_airbrush_options);
return options;
}
Tool *
tools_new_airbrush ()
{
Tool * tool;
PaintCore * private;
/* The tool options */
if (! airbrush_options)
{
airbrush_options = airbrush_options_new ();
tools_register (AIRBRUSH, (ToolOptions *) airbrush_options);
}
tool = paint_core_new (AIRBRUSH);
private = (PaintCore *) tool->private;
private->paint_func = airbrush_paint_func;
return tool;
}
void *
airbrush_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
......@@ -214,24 +234,6 @@ airbrush_paint_func (PaintCore *paint_core,
}
Tool *
tools_new_airbrush ()
{
Tool * tool;
PaintCore * private;
if (! airbrush_options)
airbrush_options = create_airbrush_options ();
tool = paint_core_new (AIRBRUSH);
private = (PaintCore *) tool->private;
private->paint_func = airbrush_paint_func;
return tool;
}
void
tools_free_airbrush (Tool *tool)
{
......
......@@ -80,8 +80,9 @@ struct _ColorBalanceDialog
gint application_mode;
};
/* the color balance tool options */
static void *color_balance_options = NULL; /* dummy */
static ToolOptions *color_balance_options = NULL;
/* the color balance dialog */
static ColorBalanceDialog *color_balance_dialog = NULL;
......@@ -115,6 +116,7 @@ static void color_balance_yb_text_update (GtkWidget *, gpo
static void color_balance (PixelRegion *, PixelRegion *, void *);
static Argument * color_balance_invoker (Argument *);
/* color balance machinery */
static void
......@@ -252,8 +254,8 @@ tools_new_color_balance ()
/* The tool options */
if (!color_balance_options)
{
tools_register (COLOR_BALANCE, NULL, _("Color Balance Options"), NULL);
color_balance_options = (void *) 1;
color_balance_options = tool_options_new (_("Color Balance Options"));
tools_register (COLOR_BALANCE, color_balance_options);
}
tool = (Tool *) g_malloc (sizeof (Tool));
......
......@@ -104,11 +104,12 @@ struct _CurvesDialog
typedef double CRMatrix[4][4];
/* the curves tool options */
static void *curves_options = NULL; /* dummy */
static ToolOptions * curves_options = NULL;
/* the curves dialog */
static CurvesDialog *curves_dialog = NULL;
static CurvesDialog * curves_dialog = NULL;
static CRMatrix CR_basis =
{
......@@ -359,8 +360,8 @@ tools_new_curves ()
/* The tool options */
if (!curves_options)
{
tools_register (CURVES, NULL, _("Curves Options"), NULL);
curves_options = (void *) 1;
curves_options = tool_options_new (_("Curves Options"));
tools_register (CURVES, curves_options);
}
tool = (Tool *) g_malloc (sizeof (Tool));
......
......@@ -82,8 +82,9 @@ struct _HueSaturationDialog
gint preview;
};
/* the hue-saturation tool options */
static void *hue_saturation_options = NULL; /* dummy */
static ToolOptions *hue_saturation_options = NULL;
/* the hue-saturation tool dialog */
static HueSaturationDialog *hue_saturation_dialog = NULL;
......@@ -326,8 +327,8 @@ tools_new_hue_saturation ()
/* The tool options */
if (!hue_saturation_options)
{
tools_register (HUE_SATURATION, NULL, _("Hue-Saturation Options"), NULL);
hue_saturation_options = (void *) 1;
hue_saturation_options = tool_options_new (_("Hue-Saturation Options"));
tools_register (HUE_SATURATION, hue_saturation_options);
}
tool = (Tool *) g_malloc (sizeof (Tool));
......@@ -416,13 +417,6 @@ hue_saturation_free ()
/* Select by Color dialog */
/****************************/
/* the action area structure */
static ActionAreaItem action_items[] =
{
{ N_("OK"), hue_saturation_ok_callback, NULL, NULL },
{ N_("Cancel"), hue_saturation_cancel_callback, NULL, NULL }
};
static HueSaturationDialog *
hue_saturation_new_dialog ()
{
......@@ -440,6 +434,12 @@ hue_saturation_new_dialog ()
GtkObject *data;
GSList *group = NULL;
int i;
static ActionAreaItem action_items[] =
{
{ N_("OK"), hue_saturation_ok_callback, NULL, NULL },
{ N_("Cancel"), hue_saturation_cancel_callback, NULL, NULL }
};
char *hue_partition_names[7] =
{
N_("Master"),
......@@ -541,7 +541,7 @@ hue_saturation_new_dialog ()
/* Create the hue scale widget */
label = gtk_label_new (_("Hue"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 2, 2);
......@@ -575,7 +575,7 @@ hue_saturation_new_dialog ()
/* Create the lightness scale widget */
label = gtk_label_new (_("Lightness"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 2, 2);
......@@ -609,7 +609,7 @@ hue_saturation_new_dialog ()
/* Create the saturation scale widget */
label = gtk_label_new (_("Saturation"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 2, 2);
......
......@@ -60,8 +60,9 @@ struct _ThresholdDialog
gint preview;
};
/* the threshold tool options */
static void *threshold_options = NULL; /* dummy */
static ToolOptions *threshold_options = NULL;
/* the threshold tool dialog */
static ThresholdDialog *threshold_dialog = NULL;
......@@ -249,14 +250,14 @@ tools_new_threshold ()
Threshold * private;
/* The tool options */
if (!threshold_options)
if (! threshold_options)
{
tools_register (THRESHOLD, NULL, _("Threshold Options"), NULL);
threshold_options = (void *) 1;
threshold_options = tool_options_new (_("Threshold Options"));
tools_register (THRESHOLD, threshold_options);
}
/* The threshold dialog */
if (!threshold_dialog)
if (! threshold_dialog)
threshold_dialog = threshold_new_dialog ();
else
if (!GTK_WIDGET_VISIBLE (threshold_dialog->shell))
......
......@@ -31,6 +31,7 @@
#include "bezier_select.h"
#include "bezier_selectP.h"
#include "paths_dialog.h"
#include "selection_options.h"
#include "libgimp/gimpintl.h"
......@@ -64,13 +65,12 @@
#define ROUND(x) ((int) ((x) + 0.5))
/* bezier select type definitions */
/* the bezier select structures */
typedef double BezierMatrix[4][4];
/* The named paste dialog */
/* The named paste dialog */
typedef struct _PasteNamedDlg PasteNamedDlg;
struct _PasteNamedDlg
{
GtkWidget *shell;
......@@ -78,9 +78,8 @@ struct _PasteNamedDlg
GDisplay *gdisp;
};
/* The named buffer structure... */
/* The named buffer structure... */
typedef struct _named_buffer BezierNamedBuffer;
struct _named_buffer
{
BezierSelect *sel;
......@@ -105,33 +104,11 @@ typedef struct {
gboolean found;
} BezierDistance;
static void bezier_select_button_press (Tool *, GdkEventButton *, gpointer);
static void bezier_select_button_release (Tool *, GdkEventButton *, gpointer);
static void bezier_select_motion (Tool *, GdkEventMotion *, gpointer);
static void bezier_select_control (Tool *, int, gpointer);
static void bezier_select_draw (Tool *);
static void bezier_offset_point (BezierPoint *, int, int);
static int bezier_check_point (BezierPoint *, int, int, int);
static void bezier_draw_handles (BezierSelect *);
static void bezier_draw_current (BezierSelect *);
static void bezier_draw_point (BezierSelect *, BezierPoint *, int);
static void bezier_draw_line (BezierSelect *, BezierPoint *, BezierPoint *);
static void bezier_draw_segment (BezierSelect *, BezierPoint *, int, int, BezierPointsFunc,gpointer);
static void bezier_draw_segment_points (BezierSelect *, GdkPoint *, int, gpointer);
static void bezier_compose (BezierMatrix, BezierMatrix, BezierMatrix);
static void bezier_convert (BezierSelect *, GDisplay *, int, int);
static void bezier_convert_points (BezierSelect *, GdkPoint *, int, gpointer);
static void bezier_convert_line (GSList **, int, int, int, int);
static GSList * bezier_insert_in_list (GSList *, int);
static int test_add_point_on_segment (BezierSelect *, BezierPoint *, int, int, int, int, int);
static void bezier_to_sel_internal (BezierSelect *, Tool *, GDisplay *, gint, gint);
static void bezier_stack_points (BezierSelect *, GdkPoint *, int, gpointer);
static gboolean stroke_interpolatable (int, int, int, int, gdouble);
static void bezier_stack_points_aux (GdkPoint *, int, int, gdouble, BezierRenderPnts *);
/* the bezier selection tool options */
static SelectionOptions *bezier_options = NULL;
/* local variables */
static BezierMatrix basis =
{
{ -1, 3, -3, 1 },
......@@ -152,10 +129,8 @@ static BezierMatrix basis =
/* The named buffer list */
GSList *bezier_named_buffers = NULL;
static SelectionOptions *bezier_options = NULL;
/* Global Static Variable to maintain informations about rhe "contexte" */
/* Global Static Variable to maintain informations about the "contexte" */
static BezierSelect * curSel;
static Tool * curTool;
static GDisplay * curGdisp;
......@@ -163,10 +138,42 @@ static DrawCore * curCore;
static int ModeEdit = EXTEND_NEW;
/* local function prototypes */
static void bezier_select_button_press (Tool *, GdkEventButton *, gpointer);
static void bezier_select_button_release (Tool *, GdkEventButton *, gpointer);
static void bezier_select_motion (Tool *, GdkEventMotion *, gpointer);
static void bezier_select_control (Tool *, int, gpointer);
static void bezier_select_draw (Tool *);
static void bezier_offset_point (BezierPoint *, int, int);
static int bezier_check_point (BezierPoint *, int, int, int);
static void bezier_draw_handles (BezierSelect *);
static void bezier_draw_current (BezierSelect *);
static void bezier_draw_point (BezierSelect *, BezierPoint *, int);
static void bezier_draw_line (BezierSelect *, BezierPoint *, BezierPoint *);
static void bezier_draw_segment (BezierSelect *, BezierPoint *, int, int, BezierPointsFunc,gpointer);
static void bezier_draw_segment_points (BezierSelect *, GdkPoint *, int, gpointer);
static void bezier_compose (BezierMatrix, BezierMatrix, BezierMatrix);
static void bezier_convert (BezierSelect *, GDisplay *, int, int);
static void bezier_convert_points (BezierSelect *, GdkPoint *, int, gpointer);
static void bezier_convert_line (GSList **, int, int, int, int);
static GSList * bezier_insert_in_list (GSList *, int);
static int test_add_point_on_segment (BezierSelect *, BezierPoint *, int, int, int, int, int);
static void bezier_to_sel_internal (BezierSelect *, Tool *, GDisplay *, gint, gint);
static void bezier_stack_points (BezierSelect *, GdkPoint *, int, gpointer);
static gboolean stroke_interpolatable (int, int, int, int, gdouble);
static void bezier_stack_points_aux (GdkPoint *, int, int, gdouble, BezierRenderPnts *);
/* functions */
static void
bezier_select_reset_options ()
bezier_select_options_reset ()
{
reset_selection_options (bezier_options);
selection_options_reset (bezier_options);
}
Tool*
......@@ -176,9 +183,12 @@ tools_new_bezier_select ()
BezierSelect * bezier_sel;
/* The tool options */
if (!bezier_options)
bezier_options = create_selection_options (BEZIER_SELECT,
bezier_select_reset_options);
if (! bezier_options)
{
bezier_options =
selection_options_new (BEZIER_SELECT, bezier_select_options_reset);
tools_register (BEZIER_SELECT, (ToolOptions *) bezier_options);
}
tool = g_malloc (sizeof (Tool));
......
This diff is collapsed.
......@@ -43,15 +43,15 @@
#define CONTRAST_TEXT 0x8
#define ALL 0xF
typedef struct _BrightnessContrast BrightnessContrast;
/* the brightness-contrast structures */
typedef struct _BrightnessContrast BrightnessContrast;
struct _BrightnessContrast
{
int x, y; /* coords for last mouse click */
};
typedef struct _BrightnessContrastDialog BrightnessContrastDialog;
struct _BrightnessContrastDialog
{
GtkWidget *shell;
......@@ -72,6 +72,14 @@ struct _BrightnessContrastDialog
GimpLut *lut;
};
/* the brightness-contrast tool options */
static ToolOptions *brightness_contrast_options = NULL;
/* the brightness-contrast dialog */
static BrightnessContrastDialog *brightness_contrast_dialog = NULL;
/* brightness contrast action functions */
static void brightness_contrast_button_press (Tool *, GdkEventButton *, gpointer);
......@@ -92,10 +100,6 @@ static void brightness_contrast_contrast_scale_update (GtkAdjustment *, gpoi
static void brightness_contrast_brightness_text_update (GtkWidget *, gpointer);
static void brightness_contrast_contrast_text_update (GtkWidget *, gpointer);
static void *brightness_contrast_options = NULL;
static BrightnessContrastDialog *brightness_contrast_dialog = NULL;
/* by_color select action functions */
......@@ -168,10 +172,10 @@ tools_new_brightness_contrast ()
/* The tool options */
if (!brightness_contrast_options)
{
tools_register (BRIGHTNESS_CONTRAST, NULL,
_("Brightness-Contrast Options"), NULL);
brightness_contrast_options = (void *) 1;
}
brightness_contrast_options =
tool_options_new (_("Brightness-Contrast Options"));
tools_register (BRIGHTNESS_CONTRAST, brightness_contrast_options);
}
tool = (Tool *) g_malloc (sizeof (Tool));
private = (BrightnessContrast *) g_malloc (sizeof (BrightnessContrast));
......@@ -286,7 +290,7 @@ brightness_contrast_new_dialog ()
/* Create the brightness scale widget */
label = gtk_label_new (_("Brightness"));