Commit 99f35577 authored by EDT 1999 Adrian Likins's avatar EDT 1999 Adrian Likins Committed by Adrian Likins

add a "Use Pressure" check button to the options so that pressure

Tue Aug 31 01:13:13 EDT 1999 Adrian Likins <alikins@redhat.com>

        * app/pencil.c: add a "Use Pressure" check button to the options
        so that pressure sensitivy can be disabled. Suggested by
        Tuomas Kuosmanen  <tigert@gimp.org>.
parent e3004838
Tue Aug 31 01:13:13 EDT 1999 Adrian Likins <alikins@redhat.com>
* app/pencil.c: add a "Use Pressure" check button to the options
so that pressure sensitivy can be disabled. Suggested by
Tuomas Kuosmanen <tigert@gimp.org>.
Mon Aug 30 18:56:19 PDT 1999 Manish Singh <yosh@gimp.org>
* app/apptypes.h
......
......@@ -28,19 +28,31 @@
#include "palette.h"
#include "pencil.h"
#include "selection.h"
#include "tool_options_ui.h"
#include "tools.h"
#include "libgimp/gimpintl.h"
/* the pencil tool options */
typedef struct _PencilOptions PencilOptions;
struct _PencilOptions
{
PaintOptions paint_options;
int use_pressure;
int use_pressure_d;
GtkWidget *use_pressure_w;
static PaintOptions *pencil_options = NULL;
};
static PencilOptions *pencil_options = NULL;
/* forward function declarations */
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean);
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean, gboolean);
static gboolean non_gui_incremental = FALSE;
static gboolean non_gui_pressure = TRUE;
static void pencil_options_reset (void);
#define PENCIL_INCREMENTAL_DEFAULT FALSE
......@@ -57,7 +69,8 @@ pencil_paint_func (PaintCore *paint_core,
break;
case MOTION_PAINT :
pencil_motion (paint_core, drawable, pencil_options->incremental);
pencil_motion (paint_core, drawable, pencil_options->paint_options.incremental,
pencil_options->use_pressure);
break;
case FINISH_PAINT :
......@@ -70,10 +83,51 @@ pencil_paint_func (PaintCore *paint_core,
return NULL;
}
void
static void
pencil_pressure_toggle_callback (GtkWidget *widget,
gpointer data)
{
tool_options_toggle_update (widget, data);
}
static PencilOptions *
pencil_options_new (void)
{
PencilOptions *options;
GtkWidget *vbox;
options = (PencilOptions *) g_malloc (sizeof (PencilOptions));
paint_options_init ((PaintOptions *) options,
PENCIL,
pencil_options_reset);
options->use_pressure =
options->use_pressure_d = TRUE;
vbox = ((ToolOptions *) options)->main_vbox;
options->use_pressure_w =
gtk_check_button_new_with_label (_("Use Pressure"));
gtk_box_pack_start (GTK_BOX (vbox), options->use_pressure_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->use_pressure_w), "toggled",
(GtkSignalFunc) pencil_pressure_toggle_callback,
&options->use_pressure);
gtk_widget_show (options->use_pressure_w);
return options;
}
static void
pencil_options_reset (void)
{
paint_options_reset (pencil_options);
PencilOptions *options = pencil_options;
paint_options_reset ((PaintOptions *) pencil_options);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->use_pressure_w),
options->use_pressure_d);
}
Tool *
......@@ -85,8 +139,9 @@ tools_new_pencil (void)
/* The tool options */
if (!pencil_options)
{
pencil_options = paint_options_new (PENCIL, pencil_options_reset);
pencil_options = pencil_options_new ();
tools_register (PENCIL, (ToolOptions *) pencil_options);
pencil_options_reset();
}
tool = paint_core_new (PENCIL);
......@@ -108,7 +163,8 @@ tools_free_pencil (Tool *tool)
static void
pencil_motion (PaintCore *paint_core,
GimpDrawable *drawable,
gboolean increment)
gboolean increment,
gboolean pressure)
{
GImage *gimage;
TempBuf * area;
......@@ -142,9 +198,18 @@ pencil_motion (PaintCore *paint_core,
This makes a more natural pencil since light pressure
on a graphite pen will give transparent line */
opacity = 255 * gimp_context_get_opacity (NULL) * (paint_core->curpressure / 0.5);
if (opacity > 255)
opacity = 255;
if(pressure)
{
opacity = 255 * gimp_context_get_opacity (NULL) * (paint_core->curpressure / 0.5);
if (opacity > 255)
opacity = 255;
}
else
{
opacity = 255 * gimp_context_get_opacity (NULL);
if (opacity > 255)
opacity = 255;
}
......@@ -160,7 +225,7 @@ pencil_non_gui_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
{
pencil_motion (paint_core, drawable, non_gui_incremental);
pencil_motion (paint_core, drawable, non_gui_incremental, non_gui_pressure);
return NULL;
}
......
......@@ -28,19 +28,31 @@
#include "palette.h"
#include "pencil.h"
#include "selection.h"
#include "tool_options_ui.h"
#include "tools.h"
#include "libgimp/gimpintl.h"
/* the pencil tool options */
typedef struct _PencilOptions PencilOptions;
struct _PencilOptions
{
PaintOptions paint_options;
int use_pressure;
int use_pressure_d;
GtkWidget *use_pressure_w;
static PaintOptions *pencil_options = NULL;
};
static PencilOptions *pencil_options = NULL;
/* forward function declarations */
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean);
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean, gboolean);
static gboolean non_gui_incremental = FALSE;
static gboolean non_gui_pressure = TRUE;
static void pencil_options_reset (void);
#define PENCIL_INCREMENTAL_DEFAULT FALSE
......@@ -57,7 +69,8 @@ pencil_paint_func (PaintCore *paint_core,
break;
case MOTION_PAINT :
pencil_motion (paint_core, drawable, pencil_options->incremental);
pencil_motion (paint_core, drawable, pencil_options->paint_options.incremental,
pencil_options->use_pressure);
break;
case FINISH_PAINT :
......@@ -70,10 +83,51 @@ pencil_paint_func (PaintCore *paint_core,
return NULL;
}
void
static void
pencil_pressure_toggle_callback (GtkWidget *widget,
gpointer data)
{
tool_options_toggle_update (widget, data);
}
static PencilOptions *
pencil_options_new (void)
{
PencilOptions *options;
GtkWidget *vbox;
options = (PencilOptions *) g_malloc (sizeof (PencilOptions));
paint_options_init ((PaintOptions *) options,
PENCIL,
pencil_options_reset);
options->use_pressure =
options->use_pressure_d = TRUE;
vbox = ((ToolOptions *) options)->main_vbox;
options->use_pressure_w =
gtk_check_button_new_with_label (_("Use Pressure"));
gtk_box_pack_start (GTK_BOX (vbox), options->use_pressure_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->use_pressure_w), "toggled",
(GtkSignalFunc) pencil_pressure_toggle_callback,
&options->use_pressure);
gtk_widget_show (options->use_pressure_w);
return options;
}
static void
pencil_options_reset (void)
{
paint_options_reset (pencil_options);
PencilOptions *options = pencil_options;
paint_options_reset ((PaintOptions *) pencil_options);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->use_pressure_w),
options->use_pressure_d);
}
Tool *
......@@ -85,8 +139,9 @@ tools_new_pencil (void)
/* The tool options */
if (!pencil_options)
{
pencil_options = paint_options_new (PENCIL, pencil_options_reset);
pencil_options = pencil_options_new ();
tools_register (PENCIL, (ToolOptions *) pencil_options);
pencil_options_reset();
}
tool = paint_core_new (PENCIL);
......@@ -108,7 +163,8 @@ tools_free_pencil (Tool *tool)
static void
pencil_motion (PaintCore *paint_core,
GimpDrawable *drawable,
gboolean increment)
gboolean increment,
gboolean pressure)
{
GImage *gimage;
TempBuf * area;
......@@ -142,9 +198,18 @@ pencil_motion (PaintCore *paint_core,
This makes a more natural pencil since light pressure
on a graphite pen will give transparent line */
opacity = 255 * gimp_context_get_opacity (NULL) * (paint_core->curpressure / 0.5);
if (opacity > 255)
opacity = 255;
if(pressure)
{
opacity = 255 * gimp_context_get_opacity (NULL) * (paint_core->curpressure / 0.5);
if (opacity > 255)
opacity = 255;
}
else
{
opacity = 255 * gimp_context_get_opacity (NULL);
if (opacity > 255)
opacity = 255;
}
......@@ -160,7 +225,7 @@ pencil_non_gui_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
{
pencil_motion (paint_core, drawable, non_gui_incremental);
pencil_motion (paint_core, drawable, non_gui_incremental, non_gui_pressure);
return NULL;
}
......
......@@ -28,19 +28,31 @@
#include "palette.h"
#include "pencil.h"
#include "selection.h"
#include "tool_options_ui.h"
#include "tools.h"
#include "libgimp/gimpintl.h"
/* the pencil tool options */
typedef struct _PencilOptions PencilOptions;
struct _PencilOptions
{
PaintOptions paint_options;
int use_pressure;
int use_pressure_d;
GtkWidget *use_pressure_w;
static PaintOptions *pencil_options = NULL;
};
static PencilOptions *pencil_options = NULL;
/* forward function declarations */
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean);
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean, gboolean);
static gboolean non_gui_incremental = FALSE;
static gboolean non_gui_pressure = TRUE;
static void pencil_options_reset (void);
#define PENCIL_INCREMENTAL_DEFAULT FALSE
......@@ -57,7 +69,8 @@ pencil_paint_func (PaintCore *paint_core,
break;
case MOTION_PAINT :
pencil_motion (paint_core, drawable, pencil_options->incremental);
pencil_motion (paint_core, drawable, pencil_options->paint_options.incremental,
pencil_options->use_pressure);
break;
case FINISH_PAINT :
......@@ -70,10 +83,51 @@ pencil_paint_func (PaintCore *paint_core,
return NULL;
}
void
static void
pencil_pressure_toggle_callback (GtkWidget *widget,
gpointer data)
{
tool_options_toggle_update (widget, data);
}
static PencilOptions *
pencil_options_new (void)
{
PencilOptions *options;
GtkWidget *vbox;
options = (PencilOptions *) g_malloc (sizeof (PencilOptions));
paint_options_init ((PaintOptions *) options,
PENCIL,
pencil_options_reset);
options->use_pressure =
options->use_pressure_d = TRUE;
vbox = ((ToolOptions *) options)->main_vbox;
options->use_pressure_w =
gtk_check_button_new_with_label (_("Use Pressure"));
gtk_box_pack_start (GTK_BOX (vbox), options->use_pressure_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->use_pressure_w), "toggled",
(GtkSignalFunc) pencil_pressure_toggle_callback,
&options->use_pressure);
gtk_widget_show (options->use_pressure_w);
return options;
}
static void
pencil_options_reset (void)
{
paint_options_reset (pencil_options);
PencilOptions *options = pencil_options;
paint_options_reset ((PaintOptions *) pencil_options);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->use_pressure_w),
options->use_pressure_d);
}
Tool *
......@@ -85,8 +139,9 @@ tools_new_pencil (void)
/* The tool options */
if (!pencil_options)
{
pencil_options = paint_options_new (PENCIL, pencil_options_reset);
pencil_options = pencil_options_new ();
tools_register (PENCIL, (ToolOptions *) pencil_options);
pencil_options_reset();
}
tool = paint_core_new (PENCIL);
......@@ -108,7 +163,8 @@ tools_free_pencil (Tool *tool)
static void
pencil_motion (PaintCore *paint_core,
GimpDrawable *drawable,
gboolean increment)
gboolean increment,
gboolean pressure)
{
GImage *gimage;
TempBuf * area;
......@@ -142,9 +198,18 @@ pencil_motion (PaintCore *paint_core,
This makes a more natural pencil since light pressure
on a graphite pen will give transparent line */
opacity = 255 * gimp_context_get_opacity (NULL) * (paint_core->curpressure / 0.5);
if (opacity > 255)
opacity = 255;
if(pressure)
{
opacity = 255 * gimp_context_get_opacity (NULL) * (paint_core->curpressure / 0.5);
if (opacity > 255)
opacity = 255;
}
else
{
opacity = 255 * gimp_context_get_opacity (NULL);
if (opacity > 255)
opacity = 255;
}
......@@ -160,7 +225,7 @@ pencil_non_gui_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
{
pencil_motion (paint_core, drawable, non_gui_incremental);
pencil_motion (paint_core, drawable, non_gui_incremental, non_gui_pressure);
return NULL;
}
......
......@@ -28,19 +28,31 @@
#include "palette.h"
#include "pencil.h"
#include "selection.h"
#include "tool_options_ui.h"
#include "tools.h"
#include "libgimp/gimpintl.h"
/* the pencil tool options */
typedef struct _PencilOptions PencilOptions;
struct _PencilOptions
{
PaintOptions paint_options;
int use_pressure;
int use_pressure_d;
GtkWidget *use_pressure_w;
static PaintOptions *pencil_options = NULL;
};
static PencilOptions *pencil_options = NULL;
/* forward function declarations */
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean);
static void pencil_motion (PaintCore *, GimpDrawable *, gboolean, gboolean);
static gboolean non_gui_incremental = FALSE;
static gboolean non_gui_pressure = TRUE;
static void pencil_options_reset (void);
#define PENCIL_INCREMENTAL_DEFAULT FALSE
......@@ -57,7 +69,8 @@ pencil_paint_func (PaintCore *paint_core,
break;
case MOTION_PAINT :
pencil_motion (paint_core, drawable, pencil_options->incremental);
pencil_motion (paint_core, drawable, pencil_options->paint_options.incremental,
pencil_options->use_pressure);
break;
case FINISH_PAINT :
......@@ -70,10 +83,51 @@ pencil_paint_func (PaintCore *paint_core,
return NULL;
}
void
static void
pencil_pressure_toggle_callback (GtkWidget *widget,
gpointer data)
{
tool_options_toggle_update (widget, data);
}
static PencilOptions *
pencil_options_new (void)
{
PencilOptions *options;
GtkWidget *vbox;
options = (PencilOptions *) g_malloc (sizeof (PencilOptions));
paint_options_init ((PaintOptions *) options,
PENCIL,
pencil_options_reset);
options->use_pressure =
options->use_pressure_d = TRUE;
vbox = ((ToolOptions *) options)->main_vbox;
options->use_pressure_w =
gtk_check_button_new_with_label (_("Use Pressure"));
gtk_box_pack_start (GTK_BOX (vbox), options->use_pressure_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->use_pressure_w), "toggled",
(GtkSignalFunc) pencil_pressure_toggle_callback,
&options->use_pressure);
gtk_widget_show (options->use_pressure_w);
return options;
}
static void
pencil_options_reset (void)
{
paint_options_reset (pencil_options);
PencilOptions *options = pencil_options;
paint_options_reset ((PaintOptions *) pencil_options);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->use_pressure_w),
options->use_pressure_d);
}
Tool *
......@@ -85,8 +139,9 @@ tools_new_pencil (void)
/* The tool options */
if (!pencil_options)
{
pencil_options = paint_options_new (PENCIL, pencil_options_reset);
pencil_options = pencil_options_new ();
tools_register (PENCIL, (ToolOptions *) pencil_options);
pencil_options_reset();
}
tool = paint_core_new (PENCIL);
......@@ -108,7 +163,8 @@ tools_free_pencil (Tool *tool)
static void
pencil_motion (PaintCore *paint_core,
GimpDrawable *drawable,
gboolean increment)
gboolean increment,
gboolean pressure)
{
GImage *gimage;
TempBuf * area;
......@@ -142,9 +198,18 @@ pencil_motion (PaintCore *paint_core,
This makes a more natural pencil since light pressure
on a graphite pen will give transparent line */
opacity = 255 * gimp_context_get_opacity (NULL) * (paint_core->curpressure / 0.5);
if (opacity > 255)
opacity = 255;
if(pressure)
{
opacity = 255 * gimp_context_get_opacity (NULL) * (paint_core->curpressure / 0.5);
if (opacity > 255)
opacity = 255;
}
else
{
opacity = 255 * gimp_context_get_opacity (NULL);
if (opacity > 255)
opacity = 255;
}
......@@ -160,7 +225,7 @@ pencil_non_gui_paint_func (PaintCore *paint_core,
GimpDrawable *drawable,
int state)
{
pencil_motion (paint_core, drawable, non_gui_incremental);
pencil_motion (paint_core, drawable, non_gui_incremental, non_gui_pressure);
return NULL;
}
......
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