new function gimp_color_button_double_new() which uses an array of gdouble

2000-02-18  Michael Natterer  <misch@gimp.org>

	* libgimp/gimpcolorbutton.[ch]: new function
	gimp_color_button_double_new() which uses an array of gdouble
	instead uf guchar to store the color.

	* libgimp/gimpwidgets.h: added macros for easier access of the
	scale_entries widgets.

	* plug-ins/common/film.c: use the scale_entry widget accessors.

	* plug-ins/libgck/gck/Makefile.am
	* plug-ins/libgck/gck/gckcolor.h
	* plug-ins/libgck/gck/gcktypes.h
	* plug-ins/libgck/gck/gckui.[ch]: removed.

	* plug-ins/libgck/gck/gck.h
	* plug-ins/libgck/gck/gckcolor.c: left only the color functions in
	libgck.

	* plug-ins/Lighting/lighting_pixmaps.h
	* plug-ins/MapObject/mapobject_pixmaps.h: removed (include the
	pixmaps directly).

	* po-plug-ins/POTFILES.in: added mapobject_ui.c.

	* plug-ins/Lighting/lighting_image.c
	* plug-ins/Lighting/lighting_main.[ch]
	* plug-ins/Lighting/lighting_preview.c
	* plug-ins/Lighting/lighting_ui.[ch]
	* plug-ins/MapObject/mapobject_image.[ch]
	* plug-ins/MapObject/mapobject_main.[ch]
	* plug-ins/MapObject/mapobject_preview.c
	* plug-ins/MapObject/mapobject_ui.[ch]: use gtk+ and libgimp
	functions instead of gck ones, cleanups, I18N. More stuff to
	come...
This commit is contained in:
Michael Natterer 2000-02-17 23:48:13 +00:00 committed by Michael Natterer
parent f769024aae
commit 52b8b75b6b
31 changed files with 4239 additions and 5190 deletions

View file

@ -1,3 +1,40 @@
2000-02-18 Michael Natterer <misch@gimp.org>
* libgimp/gimpcolorbutton.[ch]: new function
gimp_color_button_double_new() which uses an array of gdouble
instead uf guchar to store the color.
* libgimp/gimpwidgets.h: added macros for easier access of the
scale_entries widgets.
* plug-ins/common/film.c: use the scale_entry widget accessors.
* plug-ins/libgck/gck/Makefile.am
* plug-ins/libgck/gck/gckcolor.h
* plug-ins/libgck/gck/gcktypes.h
* plug-ins/libgck/gck/gckui.[ch]: removed.
* plug-ins/libgck/gck/gck.h
* plug-ins/libgck/gck/gckcolor.c: left only the color functions in
libgck.
* plug-ins/Lighting/lighting_pixmaps.h
* plug-ins/MapObject/mapobject_pixmaps.h: removed (include the
pixmaps directly).
* po-plug-ins/POTFILES.in: added mapobject_ui.c.
* plug-ins/Lighting/lighting_image.c
* plug-ins/Lighting/lighting_main.[ch]
* plug-ins/Lighting/lighting_preview.c
* plug-ins/Lighting/lighting_ui.[ch]
* plug-ins/MapObject/mapobject_image.[ch]
* plug-ins/MapObject/mapobject_main.[ch]
* plug-ins/MapObject/mapobject_preview.c
* plug-ins/MapObject/mapobject_ui.[ch]: use gtk+ and libgimp
functions instead of gck ones, cleanups, I18N. More stuff to
come...
Thu Feb 17 03:30:40 PST 2000 Manish Singh <yosh@gimp.org>
* tools/pdbgen/*.pl: added 2000 to the copyrights

View file

@ -67,9 +67,11 @@ static const GtkTargetEntry targets[] = { { "application/x-color", 0 } };
struct _GimpColorButton
{
GtkButton button;
gboolean double_color;
gchar *title;
guchar *color;
gpointer color;
gint bpp;
gint width;
gint height;
@ -87,18 +89,26 @@ struct _GimpColorButton
static void gimp_color_button_destroy (GtkObject *object);
static void gimp_color_button_clicked (GtkButton *button);
static void gimp_color_button_paint (GimpColorButton *gcb);
static void gimp_color_button_state_changed (GtkWidget *widget, GtkStateType previous_state);
static void gimp_color_button_state_changed (GtkWidget *widget,
GtkStateType previous_state);
static void gimp_color_button_dialog_ok (GtkWidget *widget, gpointer data);
static void gimp_color_button_dialog_cancel (GtkWidget *widget, gpointer data);
static void gimp_color_button_dialog_ok (GtkWidget *widget,
gpointer data);
static void gimp_color_button_dialog_cancel (GtkWidget *widget,
gpointer data);
static void gimp_color_button_use_fg (gpointer callback_data, guint callback_action,
static void gimp_color_button_use_fg (gpointer callback_data,
guint callback_action,
GtkWidget *widget);
static void gimp_color_button_use_bg (gpointer callback_data, guint callback_action,
static void gimp_color_button_use_bg (gpointer callback_data,
guint callback_action,
GtkWidget *widget);
static gint gimp_color_button_menu_popup (GtkWidget *widget, GdkEvent *event, gpointer data);
static gchar* gimp_color_button_menu_translate (const gchar *path, gpointer func_data);
static gint gimp_color_button_menu_popup (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static gchar* gimp_color_button_menu_translate (const gchar *path,
gpointer func_data);
static GtkItemFactoryEntry menu_items[] = {
@ -172,16 +182,18 @@ gimp_color_button_class_init (GimpColorButtonClass *class)
static void
gimp_color_button_init (GimpColorButton *gcb)
{
gcb->title = NULL;
gcb->bpp = 0;
gcb->color = NULL;
gcb->double_color = FALSE;
gcb->dcolor = NULL;
gcb->preview = NULL;
gcb->dialog = NULL;
gcb->title = NULL;
gcb->bpp = 0;
gcb->color = NULL;
gcb->even = NULL;
gcb->odd = NULL;
gcb->dcolor = NULL;
gcb->preview = NULL;
gcb->dialog = NULL;
gcb->even = NULL;
gcb->odd = NULL;
}
GtkType
@ -208,6 +220,7 @@ gimp_color_button_get_type (void)
return gcb_type;
}
/**
* gimp_color_button_new:
* @title: String that wil be used as title for the color_selector.
@ -224,13 +237,13 @@ gimp_color_button_get_type (void)
*
* Returns: Pointer to the new GimpColorButton widget.
*/
GtkWidget*
gimp_color_button_new (gchar *title,
gint width,
gint height,
guchar *color,
gint bpp)
static GtkWidget *
_gimp_color_button_new (gboolean double_color,
gchar *title,
gint width,
gint height,
gpointer color,
gint bpp)
{
GimpColorButton *gcb;
gint i;
@ -240,18 +253,28 @@ gimp_color_button_new (gchar *title,
gcb = gtk_type_new (gimp_color_button_get_type ());
gcb->double_color = double_color;
gcb->title = g_strdup (title);
gcb->width = width;
gcb->height = height;
gcb->color = color;
gcb->bpp = bpp;
gcb->dcolor = g_new (gdouble, 4);
gcb->even = g_new (guchar, 3 * width);
gcb->odd = g_new (guchar, 3 * width);
for (i = 0; i < bpp; i++)
gcb->dcolor[i] = (gdouble)color[i] / 255.0;
if (double_color)
{
for (i = 0; i < bpp; i++)
gcb->dcolor[i] = ((gdouble *) color)[i];
}
else
{
for (i = 0; i < bpp; i++)
gcb->dcolor[i] = (gdouble) ((guchar *) color)[i] / 255.0;
}
if (bpp == 3)
gcb->dcolor[3] = 1.0;
@ -267,11 +290,11 @@ gimp_color_button_new (gchar *title,
/* right-click opens a popup */
gcb->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL);
gtk_item_factory_set_translate_func (gcb->item_factory, gimp_color_button_menu_translate,
gtk_item_factory_set_translate_func (gcb->item_factory,
gimp_color_button_menu_translate,
NULL, NULL);
gtk_item_factory_create_items (gcb->item_factory, nmenu_items, menu_items, gcb);
gtk_signal_connect (GTK_OBJECT (gcb),
"button_press_event",
gtk_signal_connect (GTK_OBJECT (gcb), "button_press_event",
GTK_SIGNAL_FUNC (gimp_color_button_menu_popup),
gcb);
@ -308,6 +331,60 @@ gimp_color_button_new (gchar *title,
return (GTK_WIDGET (gcb));
}
/**
* gimp_color_button_new:
* @title: String that wil be used as title for the color_selector.
* @width: Width of the colorpreview in pixels.
* @height: Height of the colorpreview in pixels.
* @color: An array of guchar holding the color (RGB or RGBA)
* @bpp: May be 3 for RGB or 4 for RGBA.
*
* Creates a new GimpColorbutton widget. This returns a button with
* a preview showing the color. When the button is clicked a
* GtkColorSelectionDialog is opened. If the user changes the color
* the new color is written into the array that was used to pass
* the initial color and the "color_changed" signal is emitted.
*
* Returns: Pointer to the new GimpColorButton widget.
*/
GtkWidget *
gimp_color_button_new (gchar *title,
gint width,
gint height,
guchar *color,
gint bpp)
{
return _gimp_color_button_new (FALSE, title, width, height,
(gpointer) color, bpp);
}
/**
* gimp_color_button_double_new:
* @title: String that wil be used as title for the color_selector.
* @width: Width of the colorpreview in pixels.
* @height: Height of the colorpreview in pixels.
* @color: An array of gdouble holding the color (RGB or RGBA)
* @bpp: May be 3 for RGB or 4 for RGBA.
*
* Creates a new GimpColorbutton widget. This returns a button with
* a preview showing the color. When the button is clicked a
* GtkColorSelectionDialog is opened. If the user changes the color
* the new color is written into the array that was used to pass
* the initial color and the "color_changed" signal is emitted.
*
* Returns: Pointer to the new GimpColorButton widget.
*/
GtkWidget *
gimp_color_button_double_new (gchar *title,
gint width,
gint height,
gdouble *color,
gint bpp)
{
return _gimp_color_button_new (TRUE, title, width, height,
(gpointer) color, bpp);
}
/**
* gimp_color_button_update:
* @gcb: Pointer to a #GimpColorButton.
@ -323,8 +400,16 @@ gimp_color_button_update (GimpColorButton *gcb)
g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb));
for (i = 0; i < gcb->bpp; i++)
gcb->dcolor[i] = (gdouble)gcb->color[i] / 255.0;
if (gcb->double_color)
{
for (i = 0; i < gcb->bpp; i++)
gcb->dcolor[i] = ((gdouble *) gcb->color)[i];
}
else
{
for (i = 0; i < gcb->bpp; i++)
gcb->dcolor[i] = (gdouble) ((guchar *) gcb->color)[i] / 255.0;
}
gimp_color_button_paint (gcb);
@ -465,7 +550,6 @@ gimp_color_button_dialog_ok (GtkWidget *widget,
gpointer data)
{
GimpColorButton *gcb;
guchar new_color[4];
gboolean color_changed = FALSE;
gint i;
@ -474,12 +558,26 @@ gimp_color_button_dialog_ok (GtkWidget *widget,
gtk_color_selection_get_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), gcb->dcolor);
for (i = 0; i < gcb->bpp; i++)
if (gcb->double_color)
{
new_color[i] = gcb->dcolor[i] * 255.999;
if (new_color[i] != gcb->color[i])
color_changed = TRUE;
gcb->color[i] = new_color[i];
for (i = 0; i < gcb->bpp; i++)
{
if (gcb->dcolor[i] != ((gdouble *) gcb->color)[i])
color_changed = TRUE;
((gdouble *) gcb->color)[i] = gcb->dcolor[i];
}
}
else
{
guchar new_color[4];
for (i = 0; i < gcb->bpp; i++)
{
new_color[i] = gcb->dcolor[i] * 255.999;
if (new_color[i] != ((guchar *) gcb->color)[i])
color_changed = TRUE;
((guchar *) gcb->color)[i] = new_color[i];
}
}
gtk_widget_hide (gcb->dialog);
@ -511,11 +609,24 @@ gimp_color_button_use_fg (gpointer callback_data,
GtkWidget *widget)
{
GimpColorButton *gcb;
guchar fg_color[3];
gint i;
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
gcb = GIMP_COLOR_BUTTON (callback_data);
gimp_palette_get_foreground (gcb->color, gcb->color+1, gcb->color+2);
gimp_palette_get_foreground (fg_color, &fg_color[1], &fg_color[2]);
if (gcb->double_color)
{
for (i = 0; i < 3; i++)
((gdouble *) gcb->color)[i] = fg_color[i] / 255.0;
}
else
{
for (i = 0; i < 3; i ++)
((guchar *) gcb->color)[i] = fg_color[i];
}
gimp_color_button_update (gcb);
@ -530,11 +641,24 @@ gimp_color_button_use_bg (gpointer callback_data,
GtkWidget *widget)
{
GimpColorButton *gcb;
guchar bg_color[3];
gint i;
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
gcb = GIMP_COLOR_BUTTON (callback_data);
gimp_palette_get_background (gcb->color, gcb->color+1, gcb->color+2);
gimp_palette_get_background (bg_color, &bg_color[1], &bg_color[2]);
if (gcb->double_color)
{
for (i = 0; i < 3; i++)
((gdouble *) gcb->color)[i] = bg_color[i] / 255.0;
}
else
{
for (i = 0; i < 3; i ++)
((guchar *) gcb->color)[i] = bg_color[i];
}
gimp_color_button_update (gcb);
@ -542,7 +666,7 @@ gimp_color_button_use_bg (gpointer callback_data,
gimp_color_button_signals[COLOR_CHANGED]);
}
static gchar*
static gchar *
gimp_color_button_menu_translate (const gchar *path,
gpointer func_data)
{
@ -584,7 +708,8 @@ gimp_color_button_drag_end (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
{
gtk_object_set_data (GTK_OBJECT (widget), "gimp-color-button-drag-window", NULL);
gtk_object_set_data (GTK_OBJECT (widget),
"gimp-color-button-drag-window", NULL);
}
static void
@ -599,7 +724,6 @@ gimp_color_button_drop_handle (GtkWidget *widget,
{
GimpColorButton *gcb = data;
guint16 *vals;
guchar new_color[4];
gboolean color_changed = FALSE;
gint i;
@ -615,15 +739,30 @@ gimp_color_button_drop_handle (GtkWidget *widget,
vals = (guint16 *)selection_data->data;
for (i = 0; i < gcb->bpp; i++)
if (gcb->double_color)
{
gcb->dcolor[i] = (gdouble)vals[i] / 0xffff;
new_color[i] = gcb->dcolor[i] * 255.999;
if (new_color[i] != gcb->color[i])
color_changed = TRUE;
gcb->color[i] = new_color[i];
for (i = 0; i < gcb->bpp; i++)
{
gcb->dcolor[i] = (gdouble) vals[i] / 0xffff;
if (gcb->dcolor[i] != ((gdouble *) gcb->color)[i])
color_changed = TRUE;
((gdouble *) gcb->color)[i] = gcb->dcolor[i];
}
}
else
{
guchar new_color[4];
for (i = 0; i < gcb->bpp; i++)
{
gcb->dcolor[i] = (gdouble) vals[i] / 0xffff;
new_color[i] = gcb->dcolor[i] * 255.999;
if (new_color[i] != ((guchar *) gcb->color)[i])
color_changed = TRUE;
((guchar *) gcb->color)[i] = new_color[i];
}
}
if (color_changed)
{
gimp_color_button_paint (gcb);

View file

@ -59,6 +59,11 @@ GtkWidget* gimp_color_button_new (gchar *title,
gint height,
guchar *color,
gint bpp);
GtkWidget* gimp_color_button_double_new (gchar *title,
gint width,
gint height,
gdouble *color,
gint bpp);
void gimp_color_button_update (GimpColorButton *gcb);
#ifdef __cplusplus

View file

@ -103,6 +103,21 @@ GtkWidget * gimp_spin_button_new (/* return value: */
gfloat climb_rate,
guint digits);
#define GIMP_SCALE_ENTRY_LABEL(adj) \
GTK_LABEL (gtk_object_get_data (GTK_OBJECT(adj), "label"))
#define GIMP_SCALE_ENTRY_SCALE(adj) \
GTK_HSCALE (gtk_object_get_data (GTK_OBJECT(adj), "scale"))
#define GIMP_SCALE_ENTRY_SCALE_ADJ(adj) \
gtk_range_get_adjustment \
(GTK_RANGE (gtk_object_get_data (GTK_OBJECT(adj), "scale")))
#define GIMP_SCALE_ENTRY_SPINBUTTON(adj) \
GTK_SPIN_BUTTON (gtk_object_get_data (GTK_OBJECT(adj), "spinbutton"))
#define GIMP_SCALE_ENTRY_SPINBUTTON_ADJ(adj) \
gtk_spin_button_get_adjustment \
(GTK_SPIN_BUTTON (gtk_object_get_data (GTK_OBJECT(adj), "spinbutton")))
GtkObject * gimp_scale_entry_new (GtkTable *table,
gint column,
gint row,

View file

@ -67,9 +67,11 @@ static const GtkTargetEntry targets[] = { { "application/x-color", 0 } };
struct _GimpColorButton
{
GtkButton button;
gboolean double_color;
gchar *title;
guchar *color;
gpointer color;
gint bpp;
gint width;
gint height;
@ -87,18 +89,26 @@ struct _GimpColorButton
static void gimp_color_button_destroy (GtkObject *object);
static void gimp_color_button_clicked (GtkButton *button);
static void gimp_color_button_paint (GimpColorButton *gcb);
static void gimp_color_button_state_changed (GtkWidget *widget, GtkStateType previous_state);
static void gimp_color_button_state_changed (GtkWidget *widget,
GtkStateType previous_state);
static void gimp_color_button_dialog_ok (GtkWidget *widget, gpointer data);
static void gimp_color_button_dialog_cancel (GtkWidget *widget, gpointer data);
static void gimp_color_button_dialog_ok (GtkWidget *widget,
gpointer data);
static void gimp_color_button_dialog_cancel (GtkWidget *widget,
gpointer data);
static void gimp_color_button_use_fg (gpointer callback_data, guint callback_action,
static void gimp_color_button_use_fg (gpointer callback_data,
guint callback_action,
GtkWidget *widget);
static void gimp_color_button_use_bg (gpointer callback_data, guint callback_action,
static void gimp_color_button_use_bg (gpointer callback_data,
guint callback_action,
GtkWidget *widget);
static gint gimp_color_button_menu_popup (GtkWidget *widget, GdkEvent *event, gpointer data);
static gchar* gimp_color_button_menu_translate (const gchar *path, gpointer func_data);
static gint gimp_color_button_menu_popup (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static gchar* gimp_color_button_menu_translate (const gchar *path,
gpointer func_data);
static GtkItemFactoryEntry menu_items[] = {
@ -172,16 +182,18 @@ gimp_color_button_class_init (GimpColorButtonClass *class)
static void
gimp_color_button_init (GimpColorButton *gcb)
{
gcb->title = NULL;
gcb->bpp = 0;
gcb->color = NULL;
gcb->double_color = FALSE;
gcb->dcolor = NULL;
gcb->preview = NULL;
gcb->dialog = NULL;
gcb->title = NULL;
gcb->bpp = 0;
gcb->color = NULL;
gcb->even = NULL;
gcb->odd = NULL;
gcb->dcolor = NULL;
gcb->preview = NULL;
gcb->dialog = NULL;
gcb->even = NULL;
gcb->odd = NULL;
}
GtkType
@ -208,6 +220,7 @@ gimp_color_button_get_type (void)
return gcb_type;
}
/**
* gimp_color_button_new:
* @title: String that wil be used as title for the color_selector.
@ -224,13 +237,13 @@ gimp_color_button_get_type (void)
*
* Returns: Pointer to the new GimpColorButton widget.
*/
GtkWidget*
gimp_color_button_new (gchar *title,
gint width,
gint height,
guchar *color,
gint bpp)
static GtkWidget *
_gimp_color_button_new (gboolean double_color,
gchar *title,
gint width,
gint height,
gpointer color,
gint bpp)
{
GimpColorButton *gcb;
gint i;
@ -240,18 +253,28 @@ gimp_color_button_new (gchar *title,
gcb = gtk_type_new (gimp_color_button_get_type ());
gcb->double_color = double_color;
gcb->title = g_strdup (title);
gcb->width = width;
gcb->height = height;
gcb->color = color;
gcb->bpp = bpp;
gcb->dcolor = g_new (gdouble, 4);
gcb->even = g_new (guchar, 3 * width);
gcb->odd = g_new (guchar, 3 * width);
for (i = 0; i < bpp; i++)
gcb->dcolor[i] = (gdouble)color[i] / 255.0;
if (double_color)
{
for (i = 0; i < bpp; i++)
gcb->dcolor[i] = ((gdouble *) color)[i];
}
else
{
for (i = 0; i < bpp; i++)
gcb->dcolor[i] = (gdouble) ((guchar *) color)[i] / 255.0;
}
if (bpp == 3)
gcb->dcolor[3] = 1.0;
@ -267,11 +290,11 @@ gimp_color_button_new (gchar *title,
/* right-click opens a popup */
gcb->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL);
gtk_item_factory_set_translate_func (gcb->item_factory, gimp_color_button_menu_translate,
gtk_item_factory_set_translate_func (gcb->item_factory,
gimp_color_button_menu_translate,
NULL, NULL);
gtk_item_factory_create_items (gcb->item_factory, nmenu_items, menu_items, gcb);
gtk_signal_connect (GTK_OBJECT (gcb),
"button_press_event",
gtk_signal_connect (GTK_OBJECT (gcb), "button_press_event",
GTK_SIGNAL_FUNC (gimp_color_button_menu_popup),
gcb);
@ -308,6 +331,60 @@ gimp_color_button_new (gchar *title,
return (GTK_WIDGET (gcb));
}
/**
* gimp_color_button_new:
* @title: String that wil be used as title for the color_selector.
* @width: Width of the colorpreview in pixels.
* @height: Height of the colorpreview in pixels.
* @color: An array of guchar holding the color (RGB or RGBA)
* @bpp: May be 3 for RGB or 4 for RGBA.
*
* Creates a new GimpColorbutton widget. This returns a button with
* a preview showing the color. When the button is clicked a
* GtkColorSelectionDialog is opened. If the user changes the color
* the new color is written into the array that was used to pass
* the initial color and the "color_changed" signal is emitted.
*
* Returns: Pointer to the new GimpColorButton widget.
*/
GtkWidget *
gimp_color_button_new (gchar *title,
gint width,
gint height,
guchar *color,
gint bpp)
{
return _gimp_color_button_new (FALSE, title, width, height,
(gpointer) color, bpp);
}
/**
* gimp_color_button_double_new:
* @title: String that wil be used as title for the color_selector.
* @width: Width of the colorpreview in pixels.
* @height: Height of the colorpreview in pixels.
* @color: An array of gdouble holding the color (RGB or RGBA)
* @bpp: May be 3 for RGB or 4 for RGBA.
*
* Creates a new GimpColorbutton widget. This returns a button with
* a preview showing the color. When the button is clicked a
* GtkColorSelectionDialog is opened. If the user changes the color
* the new color is written into the array that was used to pass
* the initial color and the "color_changed" signal is emitted.
*
* Returns: Pointer to the new GimpColorButton widget.
*/
GtkWidget *
gimp_color_button_double_new (gchar *title,
gint width,
gint height,
gdouble *color,
gint bpp)
{
return _gimp_color_button_new (TRUE, title, width, height,
(gpointer) color, bpp);
}
/**
* gimp_color_button_update:
* @gcb: Pointer to a #GimpColorButton.
@ -323,8 +400,16 @@ gimp_color_button_update (GimpColorButton *gcb)
g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb));
for (i = 0; i < gcb->bpp; i++)
gcb->dcolor[i] = (gdouble)gcb->color[i] / 255.0;
if (gcb->double_color)
{
for (i = 0; i < gcb->bpp; i++)
gcb->dcolor[i] = ((gdouble *) gcb->color)[i];
}
else
{
for (i = 0; i < gcb->bpp; i++)
gcb->dcolor[i] = (gdouble) ((guchar *) gcb->color)[i] / 255.0;
}
gimp_color_button_paint (gcb);
@ -465,7 +550,6 @@ gimp_color_button_dialog_ok (GtkWidget *widget,
gpointer data)
{
GimpColorButton *gcb;
guchar new_color[4];
gboolean color_changed = FALSE;
gint i;
@ -474,12 +558,26 @@ gimp_color_button_dialog_ok (GtkWidget *widget,
gtk_color_selection_get_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), gcb->dcolor);
for (i = 0; i < gcb->bpp; i++)
if (gcb->double_color)
{
new_color[i] = gcb->dcolor[i] * 255.999;
if (new_color[i] != gcb->color[i])
color_changed = TRUE;
gcb->color[i] = new_color[i];
for (i = 0; i < gcb->bpp; i++)
{
if (gcb->dcolor[i] != ((gdouble *) gcb->color)[i])
color_changed = TRUE;
((gdouble *) gcb->color)[i] = gcb->dcolor[i];
}
}
else
{
guchar new_color[4];
for (i = 0; i < gcb->bpp; i++)
{
new_color[i] = gcb->dcolor[i] * 255.999;
if (new_color[i] != ((guchar *) gcb->color)[i])
color_changed = TRUE;
((guchar *) gcb->color)[i] = new_color[i];
}
}
gtk_widget_hide (gcb->dialog);
@ -511,11 +609,24 @@ gimp_color_button_use_fg (gpointer callback_data,
GtkWidget *widget)
{
GimpColorButton *gcb;
guchar fg_color[3];
gint i;
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
gcb = GIMP_COLOR_BUTTON (callback_data);
gimp_palette_get_foreground (gcb->color, gcb->color+1, gcb->color+2);
gimp_palette_get_foreground (fg_color, &fg_color[1], &fg_color[2]);
if (gcb->double_color)
{
for (i = 0; i < 3; i++)
((gdouble *) gcb->color)[i] = fg_color[i] / 255.0;
}
else
{
for (i = 0; i < 3; i ++)
((guchar *) gcb->color)[i] = fg_color[i];
}
gimp_color_button_update (gcb);
@ -530,11 +641,24 @@ gimp_color_button_use_bg (gpointer callback_data,
GtkWidget *widget)
{
GimpColorButton *gcb;
guchar bg_color[3];
gint i;
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
gcb = GIMP_COLOR_BUTTON (callback_data);
gimp_palette_get_background (gcb->color, gcb->color+1, gcb->color+2);
gimp_palette_get_background (bg_color, &bg_color[1], &bg_color[2]);
if (gcb->double_color)
{
for (i = 0; i < 3; i++)
((gdouble *) gcb->color)[i] = bg_color[i] / 255.0;
}
else
{
for (i = 0; i < 3; i ++)
((guchar *) gcb->color)[i] = bg_color[i];
}
gimp_color_button_update (gcb);
@ -542,7 +666,7 @@ gimp_color_button_use_bg (gpointer callback_data,
gimp_color_button_signals[COLOR_CHANGED]);
}
static gchar*
static gchar *
gimp_color_button_menu_translate (const gchar *path,
gpointer func_data)
{
@ -584,7 +708,8 @@ gimp_color_button_drag_end (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
{
gtk_object_set_data (GTK_OBJECT (widget), "gimp-color-button-drag-window", NULL);
gtk_object_set_data (GTK_OBJECT (widget),
"gimp-color-button-drag-window", NULL);
}
static void
@ -599,7 +724,6 @@ gimp_color_button_drop_handle (GtkWidget *widget,
{
GimpColorButton *gcb = data;
guint16 *vals;
guchar new_color[4];
gboolean color_changed = FALSE;
gint i;
@ -615,15 +739,30 @@ gimp_color_button_drop_handle (GtkWidget *widget,
vals = (guint16 *)selection_data->data;
for (i = 0; i < gcb->bpp; i++)
if (gcb->double_color)
{
gcb->dcolor[i] = (gdouble)vals[i] / 0xffff;
new_color[i] = gcb->dcolor[i] * 255.999;
if (new_color[i] != gcb->color[i])
color_changed = TRUE;
gcb->color[i] = new_color[i];
for (i = 0; i < gcb->bpp; i++)
{
gcb->dcolor[i] = (gdouble) vals[i] / 0xffff;
if (gcb->dcolor[i] != ((gdouble *) gcb->color)[i])
color_changed = TRUE;
((gdouble *) gcb->color)[i] = gcb->dcolor[i];
}
}
else
{
guchar new_color[4];
for (i = 0; i < gcb->bpp; i++)
{
gcb->dcolor[i] = (gdouble) vals[i] / 0xffff;
new_color[i] = gcb->dcolor[i] * 255.999;
if (new_color[i] != ((guchar *) gcb->color)[i])
color_changed = TRUE;
((guchar *) gcb->color)[i] = new_color[i];
}
}
if (color_changed)
{
gimp_color_button_paint (gcb);

View file

@ -59,6 +59,11 @@ GtkWidget* gimp_color_button_new (gchar *title,
gint height,
guchar *color,
gint bpp);
GtkWidget* gimp_color_button_double_new (gchar *title,
gint width,
gint height,
gdouble *color,
gint bpp);
void gimp_color_button_update (GimpColorButton *gcb);
#ifdef __cplusplus

View file

@ -103,6 +103,21 @@ GtkWidget * gimp_spin_button_new (/* return value: */
gfloat climb_rate,
guint digits);
#define GIMP_SCALE_ENTRY_LABEL(adj) \
GTK_LABEL (gtk_object_get_data (GTK_OBJECT(adj), "label"))
#define GIMP_SCALE_ENTRY_SCALE(adj) \
GTK_HSCALE (gtk_object_get_data (GTK_OBJECT(adj), "scale"))
#define GIMP_SCALE_ENTRY_SCALE_ADJ(adj) \
gtk_range_get_adjustment \
(GTK_RANGE (gtk_object_get_data (GTK_OBJECT(adj), "scale")))
#define GIMP_SCALE_ENTRY_SPINBUTTON(adj) \
GTK_SPIN_BUTTON (gtk_object_get_data (GTK_OBJECT(adj), "spinbutton"))
#define GIMP_SCALE_ENTRY_SPINBUTTON_ADJ(adj) \
gtk_spin_button_get_adjustment \
(GTK_SPIN_BUTTON (gtk_object_get_data (GTK_OBJECT(adj), "spinbutton")))
GtkObject * gimp_scale_entry_new (GtkTable *table,
gint column,
gint row,

View file

@ -3,194 +3,221 @@
/*************************************/
#include "lighting_image.h"
#include "lighting_preview.h"
#include "lighting_ui.h"
GDrawable *input_drawable,*output_drawable;
GPixelRgn source_region, dest_region;
GPixelRgn source_region, dest_region;
GDrawable *bump_drawable = NULL;
GPixelRgn bump_region;
GPixelRgn bump_region;
GDrawable *env_drawable = NULL;
GPixelRgn env_region;
GPixelRgn env_region;
guchar *preview_rgb_data = NULL;
guchar *preview_rgb_data = NULL;
GdkImage *image = NULL;
glong maxcounter;
gint imgtype,width,height,env_width,env_height,in_channels,out_channels;
glong maxcounter;
gint imgtype, width, height, env_width, env_height, in_channels, out_channels;
GckRGB background;
gint border_x1,border_y1,border_x2,border_y2;
gint border_x1, border_y1, border_x2, border_y2;
guchar sinemap[256],spheremap[256],logmap[256];
guchar sinemap[256], spheremap[256], logmap[256];
/******************/
/* Implementation */
/******************/
guchar peek_map(GPixelRgn *region,gint x,gint y)
guchar
peek_map (GPixelRgn *region,
gint x,
gint y)
{
guchar data;
gimp_pixel_rgn_get_pixel(region,&data,x,y);
return(data);
gimp_pixel_rgn_get_pixel (region, &data, x, y);
return data;
}
GckRGB peek(gint x,gint y)
GckRGB
peek (gint x,
gint y)
{
guchar data[4];
GckRGB color;
gimp_pixel_rgn_get_pixel(&source_region,data,x,y);
gimp_pixel_rgn_get_pixel (&source_region,data, x, y);
color.r=(gdouble)(data[0])/255.0;
color.g=(gdouble)(data[1])/255.0;
color.b=(gdouble)(data[2])/255.0;
color.r = (gdouble) (data[0]) / 255.0;
color.g = (gdouble) (data[1]) / 255.0;
color.b = (gdouble) (data[2]) / 255.0;
if (input_drawable->bpp==4)
if (input_drawable->bpp == 4)
{
if (in_channels==4)
color.a=(gdouble)(data[3])/255.0;
if (in_channels == 4)
color.a = (gdouble) (data[3]) / 255.0;
else
color.a=1.0;
color.a = 1.0;
}
else
color.a=1.0;
color.a = 1.0;
return(color);
return color;
}
GckRGB peek_env_map(gint x,gint y)
GckRGB
peek_env_map (gint x,
gint y)
{
guchar data[4];
GckRGB color;
if (x<0)
x=0;
else if (x>=env_width)
x=env_width-1;
if (y<0)
y=0;
else if (y>=env_height)
y=env_height-1;
if (x < 0)
x = 0;
else if (x >= env_width)
x = env_width - 1;
if (y < 0)
y = 0;
else if (y >= env_height)
y = env_height - 1;
gimp_pixel_rgn_get_pixel(&env_region,data,x,y);
gimp_pixel_rgn_get_pixel (&env_region, data, x, y);
color.r=(gdouble)(data[0])/255.0;
color.g=(gdouble)(data[1])/255.0;
color.b=(gdouble)(data[2])/255.0;
color.a=1.0;
color.r = (gdouble) (data[0]) / 255.0;
color.g = (gdouble) (data[1]) / 255.0;
color.b = (gdouble) (data[2]) / 255.0;
color.a = 1.0;
return(color);
return color;
}
void poke(gint x,gint y,GckRGB *color)
void
poke (gint x,
gint y,
GckRGB *color)
{
static guchar data[4];
if (x<0)
x=0;
else if (x>=width)
x=width-1;
if (y<0)
y=0;
else if (y>=height)
y=height-1;
if (x < 0)
x = 0;
else if (x >= width)
x = width - 1;
if (y < 0)
y = 0;
else if (y >= height)
y = height - 1;
data[0]=(guchar)(color->r*255.0);
data[1]=(guchar)(color->g*255.0);
data[2]=(guchar)(color->b*255.0);
data[3]=(guchar)(color->a*255.0);
gimp_pixel_rgn_set_pixel(&dest_region,data,x,y);
data[0] = (guchar) (color->r * 255.0);
data[1] = (guchar) (color->g * 255.0);
data[2] = (guchar) (color->b * 255.0);
data[3] = (guchar) (color->a * 255.0);
gimp_pixel_rgn_set_pixel (&dest_region, data, x, y);
}
gint check_bounds(gint x,gint y)
gint
check_bounds (gint x,
gint y)
{
if (x<border_x1 || y<border_y1 || x>=border_x2 || y>=border_y2)
return(FALSE);
if (x < border_x1 || y < border_y1 || x >= border_x2 || y >= border_y2)
return FALSE;
else
return(TRUE);
return TRUE;
}
GimpVector3 int_to_pos(gint x,gint y)
GimpVector3
int_to_pos (gint x,
gint y)
{
GimpVector3 pos;
if (width>=height)
if (width >= height)
{
pos.x=(gdouble)x/(gdouble)width;
pos.y=(gdouble)y/(gdouble)width;
pos.x = (gdouble) x / (gdouble) width;
pos.y = (gdouble) y / (gdouble) width;
pos.y+=0.5*(1.0-(gdouble)height/(gdouble)width);
pos.y += 0.5 * (1.0 - (gdouble) height / (gdouble) width);
}
else
{
pos.x=(gdouble)x/(gdouble)height;
pos.y=(gdouble)y/(gdouble)height;
pos.x = (gdouble) x / (gdouble) height;
pos.y = (gdouble) y / (gdouble) height;
pos.x+=0.5*(1.0-(gdouble)width/(gdouble)height);
pos.x += 0.5 * (1.0 - (gdouble) width / (gdouble) height);
}
pos.z=0.0;
return(pos);
pos.z = 0.0;
return pos;
}
GimpVector3 int_to_posf(gdouble x,gdouble y)
GimpVector3
int_to_posf (gdouble x,
gdouble y)
{
GimpVector3 pos;
if (width>=height)
if (width >= height)
{
pos.x=x/(gdouble)width;
pos.y=y/(gdouble)width;
pos.x = x / (gdouble) width;
pos.y = y / (gdouble) width;
pos.y+=0.5*(1.0-(gdouble)height/(gdouble)width);
pos.y += 0.5 * (1.0 - (gdouble) height / (gdouble) width);
}
else
{
pos.x=x/(gdouble)height;
pos.y=y/(gdouble)height;
pos.x = x / (gdouble) height;
pos.y = y / (gdouble) height;
pos.x+=0.5*(1.0-(gdouble)width/(gdouble)height);
pos.x += 0.5 * (1.0 - (gdouble) width / (gdouble) height);
}
pos.z=0.0;
return(pos);
pos.z = 0.0;
return pos;
}
void pos_to_int(gdouble x,gdouble y,gint *scr_x,gint *scr_y)
void
pos_to_int (gdouble x,
gdouble y,
gint *scr_x,
gint *scr_y)
{
if (width>=height)
if (width >= height)
{
y-=0.5*(1.0-(gdouble)height/(gdouble)width);
*scr_x=(gint)((x*(gdouble)width)+0.5);
*scr_y=(gint)((y*(gdouble)width)+0.5);
y -= 0.5 * (1.0 - (gdouble) height / (gdouble) width);
*scr_x = (gint) ((x * (gdouble) width) + 0.5);
*scr_y = (gint) ((y * (gdouble) width) + 0.5);
}
else
{
x-=0.5*(1.0-(gdouble)width/(gdouble)height);
x -= 0.5 * (1.0 - (gdouble) width / (gdouble) height);
*scr_x=(gint)((x*(gdouble)height)+0.5);
*scr_y=(gint)((y*(gdouble)height)+0.5);
*scr_x = (gint) ((x * (gdouble) height) + 0.5);
*scr_y = (gint) ((y *(gdouble) height) + 0.5);
}
}
void pos_to_float(gdouble x,gdouble y,gdouble *xf,gdouble *yf)
void
pos_to_float (gdouble x,
gdouble y,
gdouble *xf,
gdouble *yf)
{
if (width>=height)
if (width >= height)
{
y-=0.5*(1.0-(gdouble)height/(gdouble)width);
*xf=x*(gdouble)width;
*yf=y*(gdouble)width;
y -= 0.5 * (1.0 - (gdouble) height / (gdouble) width);
*xf = x * (gdouble) width;
*yf = y * (gdouble) width;
}
else
{
x-=0.5*(1.0-(gdouble)width/(gdouble)height);
x -= 0.5 * (1.0 - (gdouble) width / (gdouble) height);
*xf=x*(gdouble)height;
*yf=y*(gdouble)height;
*xf = x * (gdouble) height;
*yf = y * (gdouble) height;
}
}
@ -199,144 +226,159 @@ void pos_to_float(gdouble x,gdouble y,gdouble *xf,gdouble *yf)
/* Quartics bilinear interpolation stuff. */
/**********************************************/
GckRGB get_image_color(gdouble u,gdouble v,gint *inside)
GckRGB
get_image_color (gdouble u,
gdouble v,
gint *inside)
{
gint x1, y1, x2, y2;
gint x1, y1, x2, y2;
GckRGB p[4];
x1=(gint)(u+0.5);
y1=(gint)(v+0.5);
x1 = (gint) (u + 0.5);
y1 = (gint) (v + 0.5);
if (check_bounds(x1,y1)==FALSE)
if (check_bounds (x1, y1) == FALSE)
{
*inside=FALSE;
return(background);
*inside = FALSE;
return background;
}
x2 = (x1 + 1);
y2 = (y1 + 1);
if (check_bounds(x2,y2)==FALSE)
{
*inside=TRUE;
return(peek(x1,y1));
}
if (check_bounds (x2, y2) == FALSE)
{
*inside = TRUE;
return peek (x1, y1);
}
*inside=TRUE;
p[0] = peek(x1, y1);
p[1] = peek(x2, y1);
p[2] = peek(x1, y2);
p[3] = peek(x2, y2);
*inside = TRUE;
p[0] = peek (x1, y1);
p[1] = peek (x2, y1);
p[2] = peek (x1, y2);
p[3] = peek (x2, y2);
return(gck_bilinear_rgba(u, v, p));
return gck_bilinear_rgba (u, v, p);
}
gdouble get_map_value(GPixelRgn *region, gdouble u,gdouble v, gint *inside)
gdouble
get_map_value (GPixelRgn *region,
gdouble u,
gdouble v,
gint *inside)
{
gint x1, y1, x2, y2;
gdouble p[4];
x1=(gint)(u+0.5);
y1=(gint)(v+0.5);
x1 = (gint) (u + 0.5);
y1 = (gint) (v + 0.5);
x2 = (x1 + 1);
y2 = (y1 + 1);
if (check_bounds(x2,y2)==FALSE)
{
*inside=TRUE;
return((gdouble)peek_map(region, x1,y1));
}
if (check_bounds (x2, y2) == FALSE)
{
*inside = TRUE;
return (gdouble) peek_map (region, x1, y1);
}
*inside=TRUE;
p[0] = (gdouble)peek_map(region, x1, y1);
p[1] = (gdouble)peek_map(region, x2, y1);
p[2] = (gdouble)peek_map(region, x1, y2);
p[3] = (gdouble)peek_map(region, x2, y2);
*inside = TRUE;
p[0] = (gdouble) peek_map (region, x1, y1);
p[1] = (gdouble) peek_map (region, x2, y1);
p[2] = (gdouble) peek_map (region, x1, y2);
p[3] = (gdouble) peek_map (region, x2, y2);
return(gck_bilinear(u, v, p));
return gck_bilinear (u, v, p);
}
void compute_maps(void)
void
compute_maps (void)
{
gint x;
gdouble val,c,d;
gint x;
gdouble val, c, d;
/* Compute Sine, Log ans Spherical transfer function maps */
/* ====================================================== */
c=1.0/255.0;
d=1.15*255.0;
for (x=0;x<256;x++)
{
sinemap[x]=(guchar)(255.0*(0.5*(sin((G_PI*c*(gdouble)x)-0.5*G_PI)+1.0)));
spheremap[x]=(guchar)(255.0*(sqrt(sin(G_PI*(gdouble)x/512.0))));
val=(d*exp(-1.0/(8.0*c*((gdouble)x+5.0))));
if (val>255.0)
val=255.0;
logmap[x]=(guchar)val;
}
c = 1.0 / 255.0;
d = 1.15 * 255.0;
for (x = 0; x < 256; x++)
{
sinemap[x] = (guchar) (255.0 * (0.5 * (sin ((G_PI * c * (gdouble) x) -
0.5 * G_PI) +
1.0)));
spheremap[x] = (guchar) (255.0 * (sqrt (sin (G_PI * (gdouble) x /
512.0))));
val = (d * exp (-1.0 / (8.0 * c * ((gdouble) x + 5.0))));
if (val > 255.0)
val = 255.0;
logmap[x] = (guchar) val;
}
}
/****************************************/
/* Allocate memory for temporary images */
/****************************************/
gint image_setup(GDrawable *drawable,gint interactive)
gint
image_setup (GDrawable *drawable,
gint interactive)
{
glong numbytes;
compute_maps();
compute_maps ();
/* Get some useful info on the input drawable */
/* ========================================== */
input_drawable=drawable;
output_drawable=drawable;
input_drawable = drawable;
output_drawable = drawable;
gimp_drawable_mask_bounds (drawable->id, &border_x1, &border_y1, &border_x2, &border_y2);
gimp_drawable_mask_bounds (drawable->id,
&border_x1, &border_y1, &border_x2, &border_y2);
width=input_drawable->width;
height=input_drawable->height;
width = input_drawable->width;
height = input_drawable->height;
gimp_pixel_rgn_init (&source_region, input_drawable, 0, 0, width, height, FALSE, FALSE);
gimp_pixel_rgn_init (&source_region, input_drawable,
0, 0, width, height, FALSE, FALSE);
maxcounter=(glong)width*(glong)height;
maxcounter = (glong) width * (glong) height;
/* Assume at least RGB */
/* =================== */
in_channels=3;
if (gimp_drawable_has_alpha(input_drawable->id)==TRUE)
in_channels = 3;
if (gimp_drawable_has_alpha (input_drawable->id) == TRUE)
in_channels++;
if (interactive==TRUE)
if (interactive == TRUE)
{
/* Allocate memory for temp. images */
/* ================================ */
image=gdk_image_new(GDK_IMAGE_FASTEST,appwin->visinfo->visual,PREVIEW_WIDTH,PREVIEW_HEIGHT);
image = gdk_image_new (GDK_IMAGE_FASTEST, visinfo->visual,
PREVIEW_WIDTH, PREVIEW_HEIGHT);
if (image==NULL)
return(FALSE);
if (image == NULL)
return FALSE;
numbytes=(glong)PREVIEW_WIDTH*(glong)PREVIEW_HEIGHT*3;
preview_rgb_data=(guchar *)malloc((size_t)numbytes);
numbytes = (glong) PREVIEW_WIDTH * (glong) PREVIEW_HEIGHT * 3;
preview_rgb_data = (guchar *) malloc ((size_t) numbytes);
if (preview_rgb_data==NULL)
return(FALSE);
if (preview_rgb_data == NULL)
return FALSE;
memset (preview_rgb_data, 0, numbytes);
memset(preview_rgb_data,0,numbytes);
/* Convert from raw RGB to GdkImage */
/* ================================ */
gck_rgb_to_gdkimage(appwin->visinfo,preview_rgb_data,image,PREVIEW_WIDTH,PREVIEW_HEIGHT);
gck_rgb_to_gdkimage (visinfo, preview_rgb_data, image,
PREVIEW_WIDTH, PREVIEW_HEIGHT);
}
return(TRUE);
return TRUE;
}

View file

@ -1,31 +1,34 @@
/*********************************************************************************/
/* Lighting Effects 0.2.2 -- image filter plug-in for The Gimp program */
/* Copyright (C) 1996-98 Tom Bech */
/* Copyright (C) 1996-98 Federico Mena Quintero */
/*===============================================================================*/
/* E-mail: tomb@gimp.org (Tom) or quartic@gimp.org (Federico) */
/* You can contact the original The Gimp authors at gimp@xcf.berkeley.edu */
/*===============================================================================*/
/* 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 (read the "COPYING" file); if not, write to the Free Software */
/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/*===============================================================================*/
/* In other words, you can't sue us for whatever happens while using this ;) */
/*********************************************************************************/
/* Lighting Effects 0.2.2 -- image filter plug-in for The Gimp program
*
* Copyright (C) 1996-98 Tom Bech
* Copyright (C) 1996-98 Federico Mena Quintero
*
* E-mail: tomb@gimp.org (Tom) or quartic@gimp.org (Federico)
*
* 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.
*/
#include "lighting_apply.h"
#include "lighting_image.h"
#include "lighting_main.h"
#include "lighting_preview.h"
#include "lighting_shade.h"
#include "lighting_ui.h"
/* Global variables */
/* ================ */
#include "config.h"
#include "libgimp/stdplugins-intl.h"
LightingValues mapvals;
@ -33,138 +36,122 @@ LightingValues mapvals;
/* Implementation */
/******************/
void lighting_interactive (GDrawable *drawable);
void lighting_noninteractive (GDrawable *drawable);
/*************************************/
/* Set parameters to standard values */
/*************************************/
void set_default_settings(void)
static void
set_default_settings (void)
{
gimp_vector3_set(&mapvals.viewpoint, 0.5, 0.5, 0.25);
gimp_vector3_set(&mapvals.planenormal, 0.0, 0.0, 1.0);
gimp_vector3_set (&mapvals.viewpoint, 0.5, 0.5, 0.25);
gimp_vector3_set (&mapvals.planenormal, 0.0, 0.0, 1.0);
gimp_vector3_set(&mapvals.lightsource.position, 1.0, 0.0, 1.0);
gimp_vector3_set(&mapvals.lightsource.direction, -1.0, -1.0, 1.0);
gimp_vector3_set (&mapvals.lightsource.position, 1.0, 0.0, 1.0);
gimp_vector3_set (&mapvals.lightsource.direction, -1.0, -1.0, 1.0);
gck_rgb_set(&mapvals.lightsource.color, 1.0, 1.0, 1.0);
gck_rgb_set (&mapvals.lightsource.color, 1.0, 1.0, 1.0);
mapvals.lightsource.intensity = 1.0;
mapvals.lightsource.type = POINT_LIGHT;
mapvals.lightsource.type = POINT_LIGHT;
mapvals.material.ambient_int = 0.3;
mapvals.material.diffuse_int = 1.0;
mapvals.material.diffuse_ref = 0.4;
mapvals.material.specular_ref = 0.6;
mapvals.material.highlight = 27.0;
mapvals.material.ambient_int = 0.3;
mapvals.material.diffuse_int = 1.0;
mapvals.material.diffuse_ref = 0.4;
mapvals.material.specular_ref = 0.6;
mapvals.material.highlight = 27.0;
mapvals.pixel_treshold = 0.25;
mapvals.max_depth = 3.0;
mapvals.preview_zoom_factor = 1.0;
/* mapvals.bumptype=0; */
mapvals.bumpmaptype=0;
mapvals.bumpmin=0.0;
mapvals.bumpmax=0.1;
mapvals.pixel_treshold = 0.25;
mapvals.max_depth = 3.0;
mapvals.preview_zoom_factor = 1.0;
mapvals.antialiasing = FALSE;
mapvals.create_new_image = FALSE;
mapvals.bumpmaptype = 0;
mapvals.bumpmin = 0.0;
mapvals.bumpmax = 0.1;
mapvals.antialiasing = FALSE;
mapvals.create_new_image = FALSE;
mapvals.transparent_background = FALSE;
mapvals.tooltips_enabled = FALSE;
mapvals.bump_mapped=FALSE;
mapvals.env_mapped=FALSE;
mapvals.ref_mapped=FALSE;
mapvals.previewquality=FALSE;
mapvals.bumpmap_id=-1;
mapvals.envmap_id=-1;
mapvals.tooltips_enabled = FALSE;
mapvals.bump_mapped = FALSE;
mapvals.env_mapped = FALSE;
mapvals.ref_mapped = FALSE;
mapvals.previewquality = FALSE;
mapvals.bumpmap_id = -1;
mapvals.envmap_id = -1;
}
void check_drawables(void)
static void
check_drawables (void)
{
/* Check that envmap_id and bumpmap_id references legal images (are valid drawables) */
/* ================================================================================= */
if (mapvals.bumpmap_id!=-1 && gimp_drawable_image_id(mapvals.bumpmap_id)==-1)
if (mapvals.bumpmap_id != -1 &&
gimp_drawable_image_id (mapvals.bumpmap_id) == -1)
{
mapvals.bump_mapped=FALSE;
mapvals.bumpmap_id=-1;
mapvals.bump_mapped = FALSE;
mapvals.bumpmap_id = -1;
}
if (mapvals.envmap_id!=-1 && gimp_drawable_image_id(mapvals.envmap_id)==-1)
if (mapvals.envmap_id != -1 &&
gimp_drawable_image_id (mapvals.envmap_id) == -1)
{
mapvals.env_mapped=FALSE;
mapvals.envmap_id=-1;
mapvals.env_mapped = FALSE;
mapvals.envmap_id = -1;
}
if (mapvals.bump_mapped)
{
/* Check if bump-map is grayscale and of the same size as the input drawable */
/* ========================================================================= */
if (!gimp_drawable_is_gray(mapvals.bumpmap_id) ||
gimp_drawable_width(mapvals.drawable_id)!=gimp_drawable_width(mapvals.bumpmap_id) ||
gimp_drawable_height(mapvals.drawable_id)!=gimp_drawable_height(mapvals.bumpmap_id))
if (!gimp_drawable_is_gray (mapvals.bumpmap_id) ||
(gimp_drawable_width (mapvals.drawable_id) !=
gimp_drawable_width(mapvals.bumpmap_id)) ||
(gimp_drawable_height (mapvals.drawable_id) !=
gimp_drawable_height(mapvals.bumpmap_id)))
{
/* If not then we silently disable bump mapping */
/* ============================================ */
mapvals.bump_mapped=FALSE;
mapvals.bumpmap_id=-1;
mapvals.bump_mapped = FALSE;
mapvals.bumpmap_id = -1;
}
}
if (mapvals.env_mapped)
{
/* Check if env-map is grayscale or has alpha */
/* ========================================== */
if (gimp_drawable_is_gray(mapvals.envmap_id) ||
gimp_drawable_has_alpha(mapvals.envmap_id))
if (gimp_drawable_is_gray (mapvals.envmap_id) ||
gimp_drawable_has_alpha (mapvals.envmap_id))
{
/* If it has then we silently disable env mapping */
/* ============================================== */
mapvals.bump_mapped=FALSE;
mapvals.bumpmap_id=-1;
mapvals.bump_mapped = FALSE;
mapvals.bumpmap_id = -1;
}
}
}
static void query(void)
static void
query (void)
{
static GParamDef args[] =
{
{ PARAM_INT32, "run_mode", "Interactive (0), non-interactive (1)" },
{ PARAM_IMAGE, "image", "Input image" },
{ PARAM_DRAWABLE, "drawable", "Input drawable" },
{ PARAM_DRAWABLE, "bumpdrawable", "Bumpmap drawable (set to 0 if disabled)" },
{ PARAM_DRAWABLE, "envdrawable", "Environmentmap drawable (set to 0 if disabled)" },
{ PARAM_INT32, "dobumpmap", "Enable bumpmapping (TRUE/FALSE)" },
{ PARAM_INT32, "doenvmap", "Enable envmapping (TRUE/FALSE)" },
{ PARAM_INT32, "bumpmaptype", "Type of mapping (0=linear,1=log, 2=sinusoidal, 3=spherical)" },
{ PARAM_INT32, "lighttype", "Type of lightsource (0=point,1=directional,3=spot,4=none)" },
{ PARAM_COLOR, "lightcolor", "Lightsource color (r,g,b)" },
{ PARAM_FLOAT, "lightposition_x", "Lightsource position (x,y,z)" },
{ PARAM_FLOAT, "lightposition_y", "Lightsource position (x,y,z)" },
{ PARAM_FLOAT, "lightposition_z", "Lightsource position (x,y,z)" },
{ PARAM_FLOAT, "lightdirection_x", "Lightsource direction [x,y,z]" },
{ PARAM_FLOAT, "lightdirection_y", "Lightsource direction [x,y,z]" },
{ PARAM_FLOAT, "lightdirection_z", "Lightsource direction [x,y,z]" },
{ PARAM_FLOAT, "ambient_intensity", "Material ambient intensity (0..1)" },
{ PARAM_FLOAT, "diffuse_intensity", "Material diffuse intensity (0..1)" },
{ PARAM_FLOAT, "diffuse_reflectivity", "Material diffuse reflectivity (0..1)" },
{ PARAM_FLOAT, "specular_reflectivity", "Material specular reflectivity (0..1)" },
{ PARAM_FLOAT, "highlight", "Material highlight (0..->), note: it's expotential" },
{ PARAM_INT32, "antialiasing", "Apply antialiasing (TRUE/FALSE)" },
{ PARAM_INT32, "newimage", "Create a new image (TRUE/FALSE)" },
{ PARAM_INT32, "transparentbackground", "Make background transparent (TRUE/FALSE)" }
};
static GParamDef *return_vals = NULL;
{
{ PARAM_INT32, "run_mode", "Interactive (0), non-interactive (1)" },
{ PARAM_IMAGE, "image", "Input image" },
{ PARAM_DRAWABLE, "drawable", "Input drawable" },
{ PARAM_DRAWABLE, "bumpdrawable", "Bumpmap drawable (set to 0 if disabled)" },
{ PARAM_DRAWABLE, "envdrawable", "Environmentmap drawable (set to 0 if disabled)" },
{ PARAM_INT32, "dobumpmap", "Enable bumpmapping (TRUE/FALSE)" },
{ PARAM_INT32, "doenvmap", "Enable envmapping (TRUE/FALSE)" },
{ PARAM_INT32, "bumpmaptype", "Type of mapping (0=linear,1=log, 2=sinusoidal, 3=spherical)" },
{ PARAM_INT32, "lighttype", "Type of lightsource (0=point,1=directional,3=spot,4=none)" },
{ PARAM_COLOR, "lightcolor", "Lightsource color (r,g,b)" },
{ PARAM_FLOAT, "lightposition_x", "Lightsource position (x,y,z)" },
{ PARAM_FLOAT, "lightposition_y", "Lightsource position (x,y,z)" },
{ PARAM_FLOAT, "lightposition_z", "Lightsource position (x,y,z)" },
{ PARAM_FLOAT, "lightdirection_x", "Lightsource direction [x,y,z]" },
{ PARAM_FLOAT, "lightdirection_y", "Lightsource direction [x,y,z]" },
{ PARAM_FLOAT, "lightdirection_z", "Lightsource direction [x,y,z]" },
{ PARAM_FLOAT, "ambient_intensity", "Material ambient intensity (0..1)" },
{ PARAM_FLOAT, "diffuse_intensity", "Material diffuse intensity (0..1)" },
{ PARAM_FLOAT, "diffuse_reflectivity", "Material diffuse reflectivity (0..1)" },
{ PARAM_FLOAT, "specular_reflectivity", "Material specular reflectivity (0..1)" },
{ PARAM_FLOAT, "highlight", "Material highlight (0..->), note: it's expotential" },
{ PARAM_INT32, "antialiasing", "Apply antialiasing (TRUE/FALSE)" },
{ PARAM_INT32, "newimage", "Create a new image (TRUE/FALSE)" },
{ PARAM_INT32, "transparentbackground", "Make background transparent (TRUE/FALSE)" }
};
static gint nargs = sizeof (args) / sizeof (args[0]);
static gint nreturn_vals = 0;
INIT_I18N();
@ -177,15 +164,16 @@ static void query(void)
N_("<Image>/Filters/Light Effects/Lighting Effects..."),
"RGB*",
PROC_PLUG_IN,
nargs, nreturn_vals,
args, return_vals);
nargs, 0,
args, NULL);
}
static void run(gchar *name,
gint nparams,
GParam *param,
gint *nreturn_vals,
GParam **return_vals)
static void
run (gchar *name,
gint nparams,
GParam *param,
gint *nreturn_vals,
GParam **return_vals)
{
static GParam values[1];
GDrawable *drawable;
@ -194,11 +182,14 @@ static void run(gchar *name,
run_mode = param[0].data.d_int32;
if (run_mode == RUN_INTERACTIVE) {
INIT_I18N_UI();
} else {
INIT_I18N();
}
if (run_mode == RUN_INTERACTIVE)
{
INIT_I18N_UI();
}
else
{
INIT_I18N();
}
*nreturn_vals = 1;
*return_vals = values;
@ -209,7 +200,7 @@ static void run(gchar *name,
/* Set default values */
/* ================== */
set_default_settings();
set_default_settings ();
/* Possibly retrieve data */
/* ====================== */
@ -221,36 +212,45 @@ static void run(gchar *name,
drawable = gimp_drawable_get (param[2].data.d_drawable);
mapvals.drawable_id=drawable->id;
mapvals.drawable_id = drawable->id;
check_drawables();
check_drawables ();
if (status == STATUS_SUCCESS)
{
/* Make sure that the drawable is RGBA or RGB color */
/* ================================================ */
if (gimp_drawable_is_rgb(drawable->id))
if (gimp_drawable_is_rgb (drawable->id))
{
/* Set the tile cache size */
/* ======================= */
gimp_tile_cache_ntiles(TILE_CACHE_SIZE);
gimp_tile_cache_ntiles (TILE_CACHE_SIZE);
switch (run_mode)
{
case RUN_INTERACTIVE:
lighting_interactive(drawable);
gimp_set_data("plug_in_lighting", &mapvals, sizeof(LightingValues));
if (main_dialog (drawable))
{
compute_image ();
gimp_set_data ("plug_in_lighting",
&mapvals, sizeof (LightingValues));
}
break;
case RUN_WITH_LAST_VALS:
image_setup(drawable,FALSE);
compute_image();
image_setup (drawable, FALSE);
compute_image ();
break;
case RUN_NONINTERACTIVE:
if (nparams != 24)
status = STATUS_CALLING_ERROR;
else if (status == STATUS_SUCCESS)
{
status = STATUS_CALLING_ERROR;
}
else
{
mapvals.bumpmap_id = param[3].data.d_drawable;
mapvals.envmap_id = param[4].data.d_drawable;
@ -276,9 +276,9 @@ static void run(gchar *name,
mapvals.create_new_image = (gint)param[22].data.d_int32;
mapvals.transparent_background = (gint)param[23].data.d_int32;
check_drawables();
image_setup(drawable, FALSE);
compute_image();
check_drawables ();
image_setup (drawable, FALSE);
compute_image ();
}
default:
break;
@ -289,61 +289,23 @@ static void run(gchar *name,
}
if (run_mode != RUN_NONINTERACTIVE)
gimp_displays_flush();
gimp_displays_flush ();
values[0].data.d_status = status;
gimp_drawable_detach (drawable);
if (xpostab)
g_free(xpostab);
g_free (xpostab);
if (ypostab)
g_free(ypostab);
g_free (ypostab);
}
GPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
};
void lighting_interactive(GDrawable *drawable)
{
gchar **argv;
gint argc;
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("lighting");
gdk_set_show_events(0);
gdk_set_use_xshm(gimp_use_xshm());
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc());
/* Create application window */
/* ========================= */
create_main_dialog();
/* Prepare images */
/* ============== */
image_setup(drawable,TRUE);
/* Gtk main event loop */
/* =================== */
gtk_main();
gdk_flush();
}
void lighting_noninteractive(GDrawable *drawable)
{
fprintf(stderr, "Noninteractive not yet implemented! Sorry.\n");
}
MAIN ()

View file

@ -1,23 +1,11 @@
#ifndef LIGHTINGMAINH
#define LIGHTINGMAINH
#ifndef __LIGHTING_MAIN_H__
#define __LIGHTING_MAIN_H__
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gck/gck.h>
#include <libgimp/gimp.h>
#include "lighting_ui.h"
#include "lighting_image.h"
#include "lighting_apply.h"
#include "lighting_preview.h"
#include "config.h"
#include "libgimp/stdplugins-intl.h"
/* Defines and stuff */
/* ================= */
@ -26,14 +14,24 @@
/* Typedefs */
/* ======== */
typedef enum {
typedef enum
{
POINT_LIGHT,
DIRECTIONAL_LIGHT,
SPOT_LIGHT,
NO_LIGHT
} LightType;
enum {
enum
{
LINEAR_MAP,
LOGARITHMIC_MAP,
SINUSOIDAL_MAP,
SPHERICAL_MAP
};
enum
{
IMAGE_BUMP,
WAVES_BUMP
};
@ -50,15 +48,15 @@ typedef struct
typedef struct
{
LightType type;
LightType type;
GimpVector3 position;
GimpVector3 direction;
GckRGB color;
gdouble intensity;
GckRGB color;
gdouble intensity;
} LightSettings;
typedef struct {
typedef struct
{
gint32 drawable_id;
gint32 bumpmap_id;
gint32 envmap_id;
@ -66,8 +64,8 @@ typedef struct {
/* Render variables */
/* ================ */
GimpVector3 viewpoint;
GimpVector3 planenormal;
GimpVector3 viewpoint;
GimpVector3 planenormal;
LightSettings lightsource;
MaterialSettings material;
MaterialSettings ref_material;
@ -83,7 +81,7 @@ typedef struct {
/* Flags */
/* ===== */
gint antialiasing;
gint create_new_image;
gint transparent_background;
@ -98,7 +96,6 @@ typedef struct {
/* ==== */
gdouble preview_zoom_factor;
} LightingValues;
/* Externally visible variables */

View file

@ -1,26 +0,0 @@
#ifndef LIGHTINGPIXMAPSH
#define LIGHTINGPIXMAPSH
#include "amb1.xpm"
#include "amb2.xpm"
#include "diffint1.xpm"
#include "diffint2.xpm"
#include "diffref1.xpm"
#include "diffref2.xpm"
#include "specref1.xpm"
#include "specref2.xpm"
#include "high1.xpm"
#include "high2.xpm"
extern char *amb1_xpm[];
extern char *amb2_xpm[];
extern char *diffint1_xpm[];
extern char *diffint2_xpm[];
extern char *diffref1_xpm[];
extern char *diffref2_xpm[];
extern char *specref1_xpm[];
extern char *specref2_xpm[];
extern char *high1_xpm[];
extern char *high2_xpm[];
#endif

View file

@ -16,12 +16,11 @@ gint ypostab_size = -1;
/* Protos */
/* ====== */
void draw_preview_image (gint recompute);
void update_light (gint xpos,gint ypos);
void draw_light_marker (gint xpos,gint ypos);
void clear_light_marker (void);
void compute_preview (gint startx,gint starty,gint w,gint h)
void
compute_preview (gint startx,
gint starty,
gint w,
gint h)
{
gint xcnt,ycnt,f1,f2;
gdouble imagex,imagey;
@ -160,10 +159,11 @@ void compute_preview (gint startx,gint starty,gint w,gint h)
}
}
gck_rgb_to_gdkimage(appwin->visinfo, preview_rgb_data, image, PREVIEW_WIDTH, PREVIEW_HEIGHT);
gck_rgb_to_gdkimage(visinfo, preview_rgb_data, image, PREVIEW_WIDTH, PREVIEW_HEIGHT);
}
void blah()
void
blah (void)
{
/* First, compute the linear mapping (x,y,x+w,y+h) to (0,0,pw,ph) */
/* ============================================================== */
@ -249,7 +249,7 @@ void blah()
/* Convert to visual type */
/* ====================== */
/* gck_rgb_to_gdkimage(appwin->visinfo,preview_rgb_data,image,pw,ph); */
/* gck_rgb_to_gdkimage(visinfo,preview_rgb_data,image,pw,ph); */
}
@ -258,7 +258,9 @@ void blah()
/* light marker. Return TRUE if so, FALSE if not */
/*************************************************/
gint check_light_hit(gint xpos,gint ypos)
gint
check_light_hit (gint xpos,
gint ypos)
{
/* gdouble dx,dy,r;
@ -274,17 +276,19 @@ gint check_light_hit(gint xpos,gint ypos)
return(TRUE);
}
*/
return(FALSE);
return FALSE;
}
/****************************************/
/* Draw a marker to show light position */
/****************************************/
void draw_light_marker(gint xpos,gint ypos)
void
draw_light_marker (gint xpos,
gint ypos)
{
/* gck_gc_set_foreground(appwin->visinfo,gc,0,50,255);
gck_gc_set_background(appwin->visinfo,gc,0,0,0);
/* gck_gc_set_foreground(visinfo,gc,0,50,255);
gck_gc_set_background(visinfo,gc,0,0,0);
gdk_gc_set_function(gc,GDK_COPY);
@ -320,15 +324,16 @@ void draw_light_marker(gint xpos,gint ypos)
} */
}
void clear_light_marker(void)
void
clear_light_marker (void)
{
/* Restore background if it has been saved */
/* ======================================= */
/* if (backbuf.image!=NULL)
{
gck_gc_set_foreground(appwin->visinfo,gc,255,255,255);
gck_gc_set_background(appwin->visinfo,gc,0,0,0);
gck_gc_set_foreground(visinfo,gc,255,255,255);
gck_gc_set_background(visinfo,gc,0,0,0);
gdk_gc_set_function(gc,GDK_COPY);
gdk_draw_image(previewarea->window,gc,backbuf.image,0,0,backbuf.x,backbuf.y,
@ -338,7 +343,8 @@ void clear_light_marker(void)
} */
}
void draw_lights(void)
void
draw_lights (void)
{
/* gdouble dxpos,dypos;
gint xpos,ypos;
@ -359,7 +365,9 @@ void draw_lights(void)
/* Update light position given new screen coords */
/*************************************************/
void update_light(gint xpos,gint ypos)
void
update_light (gint xpos,
gint ypos)
{
/* gint startx,starty,pw,ph;
@ -374,9 +382,13 @@ void update_light(gint xpos,gint ypos)
draw_lights(startx,starty,pw,ph); */
}
void compute_preview_rectangle(gint *xp,gint *yp,gint *wid,gint *heig)
void
compute_preview_rectangle (gint *xp,
gint *yp,
gint *wid,
gint *heig)
{
gdouble x,y,w,h;
gdouble x, y, w, h;
if (width>=height)
{
@ -405,30 +417,38 @@ void compute_preview_rectangle(gint *xp,gint *yp,gint *wid,gint *heig)
/* Draw preview image. if DoCompute is TRUE then recompute image. */
/******************************************************************/
void draw_preview_image(gint recompute)
void
draw_preview_image (gint recompute)
{
gint startx,starty,pw,ph;
gint startx, starty, pw, ph;
gck_gc_set_foreground(appwin->visinfo,gc,255,255,255);
gck_gc_set_background(appwin->visinfo,gc,0,0,0);
gck_gc_set_foreground (visinfo, gc, 255, 255, 255);
gck_gc_set_background (visinfo, gc, 0, 0, 0);
gdk_gc_set_function(gc,GDK_COPY);
gdk_gc_set_function (gc, GDK_COPY);
compute_preview_rectangle(&startx,&starty,&pw,&ph);
compute_preview_rectangle (&startx, &starty, &pw, &ph);
if (recompute==TRUE)
if (recompute == TRUE)
{
gck_cursor_set(previewarea->window,GDK_WATCH);
compute_preview(startx,starty,pw,ph);
gck_cursor_set(previewarea->window,GDK_HAND2);
clear_light_marker();
GdkCursor *newcursor;
newcursor = gdk_cursor_new (GDK_WATCH);
gdk_window_set_cursor (previewarea->window, newcursor);
gdk_cursor_destroy (newcursor);
gdk_flush();
compute_preview (startx, starty, pw, ph);
newcursor = gdk_cursor_new (GDK_HAND2);
gdk_window_set_cursor (previewarea->window, newcursor);
gdk_cursor_destroy (newcursor);
gdk_flush();
clear_light_marker ();
}
/* if (pw!=PREVIEW_WIDTH)
gdk_window_clear(previewarea->window); */
gdk_draw_image(previewarea->window,gc,image,0,0,0,0,PREVIEW_WIDTH,PREVIEW_HEIGHT);
/* draw_lights(); */
gdk_draw_image (previewarea->window, gc, image,
0, 0, 0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT);
}

File diff suppressed because it is too large Load diff

View file

@ -1,31 +1,23 @@
#ifndef LIGHTINGUIH
#define LIGHTINGUIH
#ifndef __LIGHTING_UI_H__
#define __LIGHTING_UI_H__
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gck/gck.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpmenu.h>
#include "lighting_main.h"
#include "lighting_image.h"
#include "lighting_apply.h"
#include "lighting_preview.h"
#include <libgimp/gimp.h>
#include <gck/gck.h>
/* Externally visible variables */
/* ============================ */
extern GckApplicationWindow *appwin;
extern GckVisualInfo *visinfo;
extern GdkGC *gc;
extern GdkGC *gc;
extern GtkWidget *previewarea;
/* Externally visible functions */
/* ============================ */
extern void create_main_dialog (void);
gboolean main_dialog (GDrawable *drawable);
#endif

View file

@ -318,7 +318,7 @@ gint image_setup(GDrawable *drawable,gint interactive)
numbytes=PREVIEW_HEIGHT*PREVIEW_WIDTH*3;
image=gdk_image_new(GDK_IMAGE_FASTEST,appwin->visinfo->visual,PREVIEW_WIDTH,PREVIEW_HEIGHT);
image=gdk_image_new(GDK_IMAGE_FASTEST,visinfo->visual,PREVIEW_WIDTH,PREVIEW_HEIGHT);
if (image==NULL)
return(FALSE);
@ -330,7 +330,7 @@ gint image_setup(GDrawable *drawable,gint interactive)
/* Convert from raw RGB to GdkImage */
/* ================================ */
gck_rgb_to_gdkimage(appwin->visinfo,preview_rgb_data,image,PREVIEW_WIDTH,PREVIEW_HEIGHT);
gck_rgb_to_gdkimage(visinfo,preview_rgb_data,image,PREVIEW_WIDTH,PREVIEW_HEIGHT);
}
return(TRUE);

View file

@ -1,12 +1,12 @@
#ifndef MAPOBJECTIMAGEH
#define MAPOBJECTIMAGEH
#ifndef __MAPOBJECT_IMAGE_H__
#define __MAPOBJECT_IMAGE_H__
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gck/gck.h>
#include <libgimp/gimp.h>
#include "mapobject_main.h"
@ -21,37 +21,54 @@ extern GDrawable *input_drawable,*output_drawable;
extern GPixelRgn source_region,dest_region;
extern GDrawable *box_drawables[6];
extern GPixelRgn box_regions[6];
extern GPixelRgn box_regions[6];
extern GDrawable *cylinder_drawables[2];
extern GPixelRgn cylinder_regions[2];
extern GPixelRgn cylinder_regions[2];
extern guchar *preview_rgb_data;
extern GdkImage *image;
extern glong maxcounter,old_depth,max_depth;
extern gint imgtype,width,height,in_channels,out_channels;
extern glong maxcounter, old_depth, max_depth;
extern gint imgtype, width,height, in_channels, out_channels;
extern GckRGB background;
extern gdouble oldtreshold;
extern gint border_x1,border_y1,border_x2,border_y2;
extern gint border_x1, border_y1, border_x2, border_y2;
extern GTile *current_in_tile, *current_out_tile;
/* Externally visible functions */
/* ============================ */
extern gint image_setup (GDrawable *drawable,gint interactive);
extern glong in_xy_to_index (gint x,gint y);
extern glong out_xy_to_index (gint x,gint y);
extern gint checkbounds (gint x,gint y);
extern GckRGB peek (gint x,gint y);
extern void poke (gint x,gint y,GckRGB *color);
extern GimpVector3 int_to_pos (gint x,gint y);
extern void pos_to_int (gdouble x,gdouble y,gint *scr_x,gint *scr_y);
extern gint image_setup (GDrawable *drawable,
gint interactive);
extern glong in_xy_to_index (gint x,
gint y);
extern glong out_xy_to_index (gint x,
gint y);
extern gint checkbounds (gint x,
gint y);
extern GckRGB peek (gint x,
gint y);
extern void poke (gint x,
gint y,
GckRGB *color);
extern GimpVector3 int_to_pos (gint x,
gint y);
extern void pos_to_int (gdouble x,
gdouble y,
gint *scr_x,
gint *scr_y);
extern GckRGB get_image_color (gdouble u,gdouble v,gint *inside);
extern GckRGB get_box_image_color (gint image, gdouble u,gdouble v);
extern GckRGB get_cylinder_image_color (gint image, gdouble u,gdouble v);
extern GckRGB get_image_color (gdouble u,
gdouble v,
gint *inside);
extern GckRGB get_box_image_color (gint image,
gdouble u,
gdouble v);
extern GckRGB get_cylinder_image_color (gint image,
gdouble u,
gdouble v);
#endif
#endif /* __MAPOBJECT_IMAGE_H__ */

View file

@ -33,152 +33,152 @@ MapObjectValues mapvals;
/* Implementation */
/******************/
void mapobject_interactive (GDrawable *drawable);
void mapobject_noninteractive (GDrawable *drawable);
/*************************************/
/* Set parameters to standard values */
/*************************************/
void set_default_settings(void)
static void
set_default_settings (void)
{
gint i;
gimp_vector3_set(&mapvals.viewpoint, 0.5,0.5,2.0);
gimp_vector3_set(&mapvals.firstaxis, 1.0,0.0,0.0);
gimp_vector3_set(&mapvals.secondaxis, 0.0,1.0,0.0);
gimp_vector3_set(&mapvals.normal, 0.0,0.0,1.0);
gimp_vector3_set(&mapvals.position, 0.5,0.5,0.0);
gimp_vector3_set(&mapvals.lightsource.position, -0.5,-0.5,2.0);
gimp_vector3_set(&mapvals.lightsource.direction, -1.0,-1.0,1.0);
gimp_vector3_set(&mapvals.scale, 0.5,0.5,0.5);
gimp_vector3_set (&mapvals.viewpoint, 0.5, 0.5, 2.0);
gimp_vector3_set (&mapvals.firstaxis, 1.0, 0.0, 0.0);
gimp_vector3_set (&mapvals.secondaxis, 0.0, 1.0, 0.0);
gimp_vector3_set (&mapvals.normal, 0.0, 0.0, 1.0);
gimp_vector3_set (&mapvals.position, 0.5, 0.5, 0.0);
gimp_vector3_set (&mapvals.lightsource.position, -0.5, -0.5, 2.0);
gimp_vector3_set (&mapvals.lightsource.direction, -1.0, -1.0, 1.0);
gimp_vector3_set (&mapvals.scale, 0.5, 0.5, 0.5);
mapvals.maptype=MAP_PLANE;
mapvals.maptype = MAP_PLANE;
mapvals.pixeltreshold=0.25;
mapvals.alpha=mapvals.beta=mapvals.gamma=0.0;
mapvals.maxdepth=3.0;
mapvals.radius=0.25;
mapvals.cylinder_radius=0.25;
mapvals.cylinder_length=1.0;
mapvals.pixeltreshold = 0.25;
mapvals.alpha = 0.0;
mapvals.beta = 0.0;
mapvals.gamma = 0.0;
mapvals.maxdepth = 3.0;
mapvals.radius = 0.25;
mapvals.cylinder_radius = 0.25;
mapvals.cylinder_length = 1.0;
mapvals.preview_zoom_factor=0;
mapvals.preview_zoom_factor = 0;
mapvals.lightsource.type=POINT_LIGHT;
mapvals.lightsource.type = POINT_LIGHT;
mapvals.antialiasing=TRUE;
mapvals.create_new_image=FALSE;
mapvals.transparent_background=FALSE;
mapvals.tiled=FALSE;
mapvals.showgrid=FALSE;
mapvals.tooltips_enabled=TRUE;
mapvals.antialiasing = TRUE;
mapvals.create_new_image = FALSE;
mapvals.transparent_background = FALSE;
mapvals.tiled = FALSE;
mapvals.showgrid = FALSE;
mapvals.tooltips_enabled = TRUE;
mapvals.lightsource.intensity = 1.0;
gck_rgb_set(&mapvals.lightsource.color,1.0,1.0,1.0);
gck_rgb_set (&mapvals.lightsource.color, 1.0, 1.0, 1.0);
mapvals.material.ambient_int = 0.3;
mapvals.material.diffuse_int = 1.0;
mapvals.material.diffuse_ref = 0.5;
mapvals.material.ambient_int = 0.3;
mapvals.material.diffuse_int = 1.0;
mapvals.material.diffuse_ref = 0.5;
mapvals.material.specular_ref = 0.5;
mapvals.material.highlight = 27.0;
mapvals.material.highlight = 27.0;
for (i=0;i<6;i++)
for (i = 0; i < 6; i++)
mapvals.boxmap_id[i] = -1;
for (i=0;i<2;i++)
for (i = 0; i < 2; i++)
mapvals.cylindermap_id[i] = -1;
}
void check_drawables(GDrawable *drawable)
static void
check_drawables (GDrawable *drawable)
{
gint i;
/* Check that boxmap images are valid */
/* ================================== */
for (i=0;i<6;i++)
for (i = 0; i < 6; i++)
{
if (mapvals.boxmap_id[i]==-1)
if (mapvals.boxmap_id[i] == -1)
mapvals.boxmap_id[i] = drawable->id;
else if (mapvals.boxmap_id[i]!=-1 && gimp_drawable_image_id(mapvals.boxmap_id[i])==-1)
else if (mapvals.boxmap_id[i] != -1 &&
gimp_drawable_image_id (mapvals.boxmap_id[i]) == -1)
mapvals.boxmap_id[i] = drawable->id;
else if (gimp_drawable_is_gray(mapvals.boxmap_id[i]))
else if (gimp_drawable_is_gray (mapvals.boxmap_id[i]))
mapvals.boxmap_id[i] = drawable->id;
}
/* Check that cylindermap images are valid */
/* ======================================= */
for (i=0;i<2;i++)
for (i = 0; i < 2; i++)
{
if (mapvals.cylindermap_id[i]==-1)
if (mapvals.cylindermap_id[i] == -1)
mapvals.cylindermap_id[i] = drawable->id;
else if (mapvals.cylindermap_id[i]!=-1 &&
gimp_drawable_image_id(mapvals.cylindermap_id[i])==-1)
gimp_drawable_image_id (mapvals.cylindermap_id[i]) == -1)
mapvals.cylindermap_id[i] = drawable->id;
else if (gimp_drawable_is_gray(mapvals.cylindermap_id[i]))
else if (gimp_drawable_is_gray (mapvals.cylindermap_id[i]))
mapvals.cylindermap_id[i] = drawable->id;
}
}
static void query(void)
static void
query (void)
{
static GParamDef args[] =
{
{ PARAM_INT32, "run_mode", "Interactive (0), non-interactive (1)" },
{ PARAM_IMAGE, "image", "Input image" },
{ PARAM_DRAWABLE, "drawable", "Input drawable" },
{ PARAM_INT32, "maptype", "Type of mapping (0=plane,1=sphere,2=box,3=cylinder)" },
{ PARAM_FLOAT, "viewpoint_x", "Position of viewpoint (x,y,z)" },
{ PARAM_FLOAT, "viewpoint_y", "Position of viewpoint (x,y,z)" },
{ PARAM_FLOAT, "viewpoint_z", "Position of viewpoint (x,y,z)" },
{ PARAM_FLOAT, "position_x", "Object position (x,y,z)" },
{ PARAM_FLOAT, "position_y", "Object position (x,y,z)" },
{ PARAM_FLOAT, "position_z", "Object position (x,y,z)" },
{ PARAM_FLOAT, "firstaxis_x", "First axis of object [x,y,z]" },
{ PARAM_FLOAT, "firstaxis_y", "First axis of object [x,y,z]" },
{ PARAM_FLOAT, "firstaxis_z", "First axis of object [x,y,z]" },
{ PARAM_FLOAT, "secondaxis_x", "Second axis of object [x,y,z]" },
{ PARAM_FLOAT, "secondaxis_y", "Second axis of object [x,y,z]" },
{ PARAM_FLOAT, "secondaxis_z", "Second axis of object [x,y,z]" },
{ PARAM_FLOAT, "rotationangle_x", "Rotation about X axis in degrees" },
{ PARAM_FLOAT, "rotationangle_y", "Rotation about Y axis in degrees" },
{ PARAM_FLOAT, "rotationangle_z", "Rotation about Z axis in degrees" },
{ PARAM_INT32, "lighttype", "Type of lightsource (0=point,1=directional,3=none)" },
{ PARAM_COLOR, "lightcolor", "Lightsource color (r,g,b)" },
{ PARAM_FLOAT, "lightposition_x", "Lightsource position (x,y,z)" },
{ PARAM_FLOAT, "lightposition_y", "Lightsource position (x,y,z)" },
{ PARAM_FLOAT, "lightposition_z", "Lightsource position (x,y,z)" },
{ PARAM_FLOAT, "lightdirection_x", "Lightsource direction [x,y,z]" },
{ PARAM_FLOAT, "lightdirection_y", "Lightsource direction [x,y,z]" },
{ PARAM_FLOAT, "lightdirection_z", "Lightsource direction [x,y,z]" },
{ PARAM_FLOAT, "ambient_intensity", "Material ambient intensity (0..1)" },
{ PARAM_FLOAT, "diffuse_intensity", "Material diffuse intensity (0..1)" },
{ PARAM_FLOAT, "diffuse_reflectivity", "Material diffuse reflectivity (0..1)" },
{ PARAM_FLOAT, "specular_reflectivity", "Material specular reflectivity (0..1)" },
{ PARAM_FLOAT, "highlight", "Material highlight (0..->), note: it's expotential" },
{ PARAM_INT32, "antialiasing", "Apply antialiasing (TRUE/FALSE)" },
{ PARAM_INT32, "tiled", "Tile source image (TRUE/FALSE)" },
{ PARAM_INT32, "newimage", "Create a new image (TRUE/FALSE)" },
{ PARAM_INT32, "transparentbackground", "Make background transparent (TRUE/FALSE)" },
{ PARAM_FLOAT, "radius", "Sphere/cylinder radius (only used when maptype=1 or 3)" },
{ PARAM_FLOAT, "x_scale", "Box x size (0..->)" },
{ PARAM_FLOAT, "y_scale", "Box y size (0..->)" },
{ PARAM_FLOAT, "z_scale", "Box z size (0..->)"},
{ PARAM_FLOAT, "cylinder_length", "Cylinder length (0..->)"},
{ PARAM_DRAWABLE, "box_front_drawable", "Box front face (set these to -1 if not used)" },
{ PARAM_DRAWABLE, "box_back_drawable", "Box back face" },
{ PARAM_DRAWABLE, "box_top_drawable", "Box top face" },
{ PARAM_DRAWABLE, "box_bottom_drawable", "Box bottom face" },
{ PARAM_DRAWABLE, "box_left_drawable", "Box left face" },
{ PARAM_DRAWABLE, "box_right_drawable", "Box right face" },
{ PARAM_DRAWABLE, "cyl_top_drawable", "Cylinder top face (set these to -1 if not used)" },
{ PARAM_DRAWABLE, "cyl_bottom_drawable", "Cylinder bottom face" }
};
static GParamDef *return_vals = NULL;
{
{ PARAM_INT32, "run_mode", "Interactive (0), non-interactive (1)" },
{ PARAM_IMAGE, "image", "Input image" },
{ PARAM_DRAWABLE, "drawable", "Input drawable" },
{ PARAM_INT32, "maptype", "Type of mapping (0=plane,1=sphere,2=box,3=cylinder)" },
{ PARAM_FLOAT, "viewpoint_x", "Position of viewpoint (x,y,z)" },
{ PARAM_FLOAT, "viewpoint_y", "Position of viewpoint (x,y,z)" },
{ PARAM_FLOAT, "viewpoint_z", "Position of viewpoint (x,y,z)" },
{ PARAM_FLOAT, "position_x", "Object position (x,y,z)" },
{ PARAM_FLOAT, "position_y", "Object position (x,y,z)" },
{ PARAM_FLOAT, "position_z", "Object position (x,y,z)" },
{ PARAM_FLOAT, "firstaxis_x", "First axis of object [x,y,z]" },
{ PARAM_FLOAT, "firstaxis_y", "First axis of object [x,y,z]" },
{ PARAM_FLOAT, "firstaxis_z", "First axis of object [x,y,z]" },
{ PARAM_FLOAT, "secondaxis_x", "Second axis of object [x,y,z]" },
{ PARAM_FLOAT, "secondaxis_y", "Second axis of object [x,y,z]" },
{ PARAM_FLOAT, "secondaxis_z", "Second axis of object [x,y,z]" },
{ PARAM_FLOAT, "rotationangle_x", "Rotation about X axis in degrees" },
{ PARAM_FLOAT, "rotationangle_y", "Rotation about Y axis in degrees" },
{ PARAM_FLOAT, "rotationangle_z", "Rotation about Z axis in degrees" },
{ PARAM_INT32, "lighttype", "Type of lightsource (0=point,1=directional,3=none)" },
{ PARAM_COLOR, "lightcolor", "Lightsource color (r,g,b)" },
{ PARAM_FLOAT, "lightposition_x", "Lightsource position (x,y,z)" },
{ PARAM_FLOAT, "lightposition_y", "Lightsource position (x,y,z)" },
{ PARAM_FLOAT, "lightposition_z", "Lightsource position (x,y,z)" },
{ PARAM_FLOAT, "lightdirection_x", "Lightsource direction [x,y,z]" },
{ PARAM_FLOAT, "lightdirection_y", "Lightsource direction [x,y,z]" },
{ PARAM_FLOAT, "lightdirection_z", "Lightsource direction [x,y,z]" },
{ PARAM_FLOAT, "ambient_intensity", "Material ambient intensity (0..1)" },
{ PARAM_FLOAT, "diffuse_intensity", "Material diffuse intensity (0..1)" },
{ PARAM_FLOAT, "diffuse_reflectivity", "Material diffuse reflectivity (0..1)" },
{ PARAM_FLOAT, "specular_reflectivity", "Material specular reflectivity (0..1)" },
{ PARAM_FLOAT, "highlight", "Material highlight (0..->), note: it's expotential" },
{ PARAM_INT32, "antialiasing", "Apply antialiasing (TRUE/FALSE)" },
{ PARAM_INT32, "tiled", "Tile source image (TRUE/FALSE)" },
{ PARAM_INT32, "newimage", "Create a new image (TRUE/FALSE)" },
{ PARAM_INT32, "transparentbackground", "Make background transparent (TRUE/FALSE)" },
{ PARAM_FLOAT, "radius", "Sphere/cylinder radius (only used when maptype=1 or 3)" },
{ PARAM_FLOAT, "x_scale", "Box x size (0..->)" },
{ PARAM_FLOAT, "y_scale", "Box y size (0..->)" },
{ PARAM_FLOAT, "z_scale", "Box z size (0..->)"},
{ PARAM_FLOAT, "cylinder_length", "Cylinder length (0..->)"},
{ PARAM_DRAWABLE, "box_front_drawable", "Box front face (set these to -1 if not used)" },
{ PARAM_DRAWABLE, "box_back_drawable", "Box back face" },
{ PARAM_DRAWABLE, "box_top_drawable", "Box top face" },
{ PARAM_DRAWABLE, "box_bottom_drawable", "Box bottom face" },
{ PARAM_DRAWABLE, "box_left_drawable", "Box left face" },
{ PARAM_DRAWABLE, "box_right_drawable", "Box right face" },
{ PARAM_DRAWABLE, "cyl_top_drawable", "Cylinder top face (set these to -1 if not used)" },
{ PARAM_DRAWABLE, "cyl_bottom_drawable", "Cylinder bottom face" }
};
static gint nargs = sizeof (args) / sizeof (args[0]);
static gint nreturn_vals = 0;
gimp_install_procedure ("plug_in_map_object",
"Maps a picture to a object (plane, sphere, box or cylinder)",
@ -189,15 +189,16 @@ static void query(void)
N_("<Image>/Filters/Map/Map Object..."),
"RGB*",
PROC_PLUG_IN,
nargs, nreturn_vals,
args, return_vals);
nargs, 0,
args, NULL);
}
static void run(gchar *name,
gint nparams,
GParam *param,
gint *nreturn_vals,
GParam **return_vals)
static void
run (gchar *name,
gint nparams,
GParam *param,
gint *nreturn_vals,
GParam **return_vals)
{
static GParam values[1];
GDrawable *drawable;
@ -207,6 +208,15 @@ static void run(gchar *name,
run_mode = param[0].data.d_int32;
if (run_mode == RUN_INTERACTIVE)
{
INIT_I18N_UI();
}
else
{
INIT_I18N();
}
values[0].type = PARAM_STATUS;
values[0].data.d_status = status;
@ -216,11 +226,11 @@ static void run(gchar *name,
/* Set default values */
/* ================== */
set_default_settings();
set_default_settings ();
/* Get the specified drawable */
/* ========================== */
drawable = gimp_drawable_get (param[2].data.d_drawable);
switch (run_mode)
@ -231,20 +241,29 @@ static void run(gchar *name,
/* ====================== */
gimp_get_data ("plug_in_map_object", &mapvals);
check_drawables(drawable);
mapobject_interactive(drawable);
gimp_set_data("plug_in_map_object", &mapvals, sizeof(MapObjectValues));
check_drawables (drawable);
if (main_dialog (drawable))
{
compute_image ();
gimp_set_data ("plug_in_map_object",
&mapvals, sizeof (MapObjectValues));
}
break;
case RUN_WITH_LAST_VALS:
gimp_get_data ("plug_in_map_object", &mapvals);
check_drawables(drawable);
image_setup(drawable,FALSE);
compute_image();
check_drawables (drawable);
image_setup (drawable, FALSE);
compute_image ();
break;
case RUN_NONINTERACTIVE:
if (nparams != 49)
status = STATUS_CALLING_ERROR;
else if (status == STATUS_SUCCESS)
{
status = STATUS_CALLING_ERROR;
}
else
{
mapvals.maptype = (MapType)param[3].data.d_int32;
mapvals.viewpoint.x = param[4].data.d_float;
@ -288,15 +307,17 @@ static void run(gchar *name,
mapvals.scale.z = param[39].data.d_float;
mapvals.cylinder_length = param[40].data.d_float;
for (i=0;i<6;i++)
mapvals.boxmap_id[i] = gimp_drawable_get(param[41+i].data.d_drawable)->id;
for (i = 0; i < 6; i++)
mapvals.boxmap_id[i] =
gimp_drawable_get (param[41+i].data.d_drawable)->id;
for (i=0;i<2;i++)
mapvals.cylindermap_id[i] = gimp_drawable_get(param[47+i].data.d_drawable)->id;
for (i = 0; i < 2; i++)
mapvals.cylindermap_id[i] =
gimp_drawable_get (param[47+i].data.d_drawable)->id;
check_drawables(drawable);
image_setup(drawable, FALSE);
compute_image();
check_drawables (drawable);
image_setup (drawable, FALSE);
compute_image ();
}
break;
}
@ -304,54 +325,17 @@ static void run(gchar *name,
values[0].data.d_status = status;
if (run_mode != RUN_NONINTERACTIVE)
gimp_displays_flush();
gimp_drawable_detach(drawable);
gimp_displays_flush ();
gimp_drawable_detach (drawable);
}
GPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
};
void mapobject_interactive(GDrawable *drawable)
{
gchar **argv;
gint argc;
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("map_object");
gdk_set_use_xshm(gimp_use_xshm());
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
/* Set up ArcBall stuff */
/* ==================== */
/*ArcBall_Init(); */
/* Create application window */
/* ========================= */
create_main_dialog();
/* Prepare images */
/* ============== */
image_setup(drawable,TRUE);
/* Gtk main event loop */
/* =================== */
gtk_main();
gdk_flush();
}
MAIN ()

View file

@ -1,14 +1,15 @@
#ifndef MAPOBJECTMAINH
#define MAPOBJECTMAINH
#ifndef __MAPOBJECT_MAIN_H__
#define __MAPOBJECT_MAIN_H__
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gck/gck.h>
#include <libgimp/gimp.h>
#include "libgimp/stdplugins-intl.h"
#include <libgimp/gimpui.h>
#include "arcball.h"
#include "mapobject_ui.h"
@ -16,6 +17,9 @@
#include "mapobject_apply.h"
#include "mapobject_preview.h"
#include "config.h"
#include "libgimp/stdplugins-intl.h"
/* Defines and stuff */
/* ================= */
@ -24,13 +28,15 @@
/* Typedefs */
/* ======== */
typedef enum {
typedef enum
{
POINT_LIGHT,
DIRECTIONAL_LIGHT,
NO_LIGHT
} LightType;
typedef enum {
typedef enum
{
MAP_PLANE,
MAP_SPHERE,
MAP_BOX,
@ -52,15 +58,16 @@ typedef struct
typedef struct
{
LightType type;
LightType type;
GimpVector3 position;
GimpVector3 direction;
GckRGB color;
gdouble intensity;
GckRGB color;
gdouble intensity;
} LightSettings;
typedef struct {
GimpVector3 viewpoint,firstaxis,secondaxis,normal,position,scale;
typedef struct
{
GimpVector3 viewpoint,firstaxis,secondaxis,normal,position,scale;
LightSettings lightsource;
MaterialSettings material;
@ -75,9 +82,9 @@ typedef struct {
gint showgrid;
gint tooltips_enabled;
gint showcaps;
glong preview_zoom_factor;
gdouble alpha,beta,gamma;
gdouble maxdepth;
gdouble pixeltreshold;
@ -96,4 +103,4 @@ typedef struct {
extern MapObjectValues mapvals;
extern GckRGB background;
#endif
#endif /* __MAPOBJECT_MAIN_H__ */

View file

@ -1,26 +0,0 @@
#ifndef MAPOBJECTPIXMAPSH
#define MAPOBJECTPIXMAPSH
#include "amb1.xpm"
#include "amb2.xpm"
#include "diffint1.xpm"
#include "diffint2.xpm"
#include "diffref1.xpm"
#include "diffref2.xpm"
#include "specref1.xpm"
#include "specref2.xpm"
#include "high1.xpm"
#include "high2.xpm"
extern char *amb1_xpm[];
extern char *amb2_xpm[];
extern char *diffint1_xpm[];
extern char *diffint2_xpm[];
extern char *diffref1_xpm[];
extern char *diffref2_xpm[];
extern char *specref1_xpm[];
extern char *specref2_xpm[];
extern char *high1_xpm[];
extern char *high2_xpm[];
#endif

View file

@ -213,7 +213,7 @@ void compute_preview(gint x,gint y,gint w,gint h,gint pw,gint ph)
/* Convert to visual type */
/* ====================== */
gck_rgb_to_gdkimage(appwin->visinfo,preview_rgb_data,image,pw,ph);
gck_rgb_to_gdkimage(visinfo,preview_rgb_data,image,pw,ph);
}
/*************************************************/
@ -245,8 +245,8 @@ gint check_light_hit(gint xpos,gint ypos)
void draw_light_marker(gint xpos,gint ypos)
{
gck_gc_set_foreground(appwin->visinfo,gc,0,50,255);
gck_gc_set_background(appwin->visinfo,gc,0,0,0);
gck_gc_set_foreground(visinfo,gc,0,50,255);
gck_gc_set_background(visinfo,gc,0,0,0);
gdk_gc_set_function(gc,GDK_COPY);
@ -288,8 +288,8 @@ void clear_light_marker()
if (backbuf.image!=NULL)
{
gck_gc_set_foreground(appwin->visinfo,gc,255,255,255);
gck_gc_set_background(appwin->visinfo,gc,0,0,0);
gck_gc_set_foreground(visinfo,gc,255,255,255);
gck_gc_set_background(visinfo,gc,0,0,0);
gdk_gc_set_function(gc,GDK_COPY);
gdk_draw_image(previewarea->window,gc,backbuf.image,0,0,backbuf.x,backbuf.y,
@ -336,34 +336,46 @@ void update_light(gint xpos,gint ypos)
/* Draw preview image. if DoCompute is TRUE then recompute image. */
/******************************************************************/
void draw_preview_image(gint docompute)
void
draw_preview_image (gint docompute)
{
gint startx,starty,pw,ph;
gck_gc_set_foreground(appwin->visinfo,gc,255,255,255);
gck_gc_set_background(appwin->visinfo,gc,0,0,0);
gint startx, starty, pw, ph;
gdk_gc_set_function(gc,GDK_COPY);
linetab[0].x1=-1;
gck_gc_set_foreground (visinfo, gc, 255, 255, 255);
gck_gc_set_background (visinfo, gc, 0, 0, 0);
pw=PREVIEW_WIDTH >> mapvals.preview_zoom_factor;
ph=PREVIEW_HEIGHT >> mapvals.preview_zoom_factor;
startx=(PREVIEW_WIDTH-pw)>>1;
starty=(PREVIEW_HEIGHT-ph)>>1;
gdk_gc_set_function (gc, GDK_COPY);
linetab[0].x1 = -1;
if (docompute==TRUE)
pw = PREVIEW_WIDTH >> mapvals.preview_zoom_factor;
ph = PREVIEW_HEIGHT >> mapvals.preview_zoom_factor;
startx = (PREVIEW_WIDTH - pw) >> 1;
starty = (PREVIEW_HEIGHT - ph) >> 1;
if (docompute == TRUE)
{
gck_cursor_set(previewarea->window,GDK_WATCH);
compute_preview(0,0,width-1,height-1,pw,ph);
gck_cursor_set(previewarea->window,GDK_HAND2);
clear_light_marker();
GdkCursor *newcursor;
newcursor = gdk_cursor_new (GDK_WATCH);
gdk_window_set_cursor(previewarea->window, newcursor);
gdk_cursor_destroy (newcursor);
gdk_flush();
compute_preview (0, 0, width - 1, height - 1, pw, ph);
newcursor = gdk_cursor_new (GDK_HAND2);
gdk_window_set_cursor(previewarea->window, newcursor);
gdk_cursor_destroy (newcursor);
gdk_flush();
clear_light_marker ();
}
if (pw!=PREVIEW_WIDTH)
gdk_window_clear(previewarea->window);
gdk_draw_image(previewarea->window,gc,image,0,0,startx,starty,pw,ph);
draw_lights(startx,starty,pw,ph);
if (pw != PREVIEW_WIDTH)
gdk_window_clear (previewarea->window);
gdk_draw_image (previewarea->window, gc, image, 0, 0, startx, starty, pw, ph);
draw_lights (startx, starty, pw, ph);
}
/**************************/
@ -374,8 +386,8 @@ void draw_preview_wireframe(void)
{
gint startx,starty,pw,ph;
gck_gc_set_foreground(appwin->visinfo,gc,255,255,255);
gck_gc_set_background(appwin->visinfo,gc,0,0,0);
gck_gc_set_foreground(visinfo,gc,255,255,255);
gck_gc_set_background(visinfo,gc,0,0,0);
gdk_gc_set_function(gc,GDK_INVERT);

File diff suppressed because it is too large Load diff

View file

@ -1,31 +1,23 @@
#ifndef MAPOBJECTUIH
#define MAPOBJECTUIH
#ifndef __MAPOBJECT_UI_H__
#define __MAPOBJECT_UI_H__
#include <stdlib.h>
#include <stdio.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gck/gck.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "arcball.h"
#include "mapobject_main.h"
#include "mapobject_image.h"
#include "mapobject_apply.h"
#include "mapobject_preview.h"
#include <libgimp/gimp.h>
#include <gck/gck.h>
/* Externally visible variables */
/* ============================ */
extern GckApplicationWindow *appwin;
extern GckVisualInfo *visinfo;
extern GdkGC *gc;
extern GdkGC *gc;
extern GtkWidget *previewarea;
/* Externally visible functions */
/* ============================ */
extern void create_main_dialog(void);
gboolean main_dialog (GDrawable *drawable);
#endif
#endif /* __MAPOBJECT_UI_H__ */

View file

@ -1383,11 +1383,8 @@ film_dialog (gint32 image_ID)
GTK_SIGNAL_FUNC (gimp_double_adjustment_update),
&filmvals.picture_height);
spinbutton = gtk_object_get_data (GTK_OBJECT (adj), "spinbutton");
gtk_spin_button_configure
(GTK_SPIN_BUTTON (spinbutton),
gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)),
0.01, 3);
gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj),
GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 3);
filmint.advanced_adj[1] = adj =
gimp_scale_entry_new (GTK_TABLE (table), 0, row++,
@ -1400,11 +1397,8 @@ film_dialog (gint32 image_ID)
GTK_SIGNAL_FUNC (gimp_double_adjustment_update),
&filmvals.picture_space);
spinbutton = gtk_object_get_data (GTK_OBJECT (adj), "spinbutton");
gtk_spin_button_configure
(GTK_SPIN_BUTTON (spinbutton),
gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)),
0.01, 3);
gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj),
GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 3);
sep = gtk_hseparator_new ();
gtk_table_attach (GTK_TABLE (table), sep, 0, 3, row, row + 1,
@ -1424,11 +1418,8 @@ film_dialog (gint32 image_ID)
GTK_SIGNAL_FUNC (gimp_double_adjustment_update),
&filmvals.hole_offset);
spinbutton = gtk_object_get_data (GTK_OBJECT (adj), "spinbutton");
gtk_spin_button_configure
(GTK_SPIN_BUTTON (spinbutton),
gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)),
0.01, 3);
gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj),
GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 3);
filmint.advanced_adj[3] = adj =
gimp_scale_entry_new (GTK_TABLE (table), 0, row++,
@ -1441,11 +1432,8 @@ film_dialog (gint32 image_ID)
GTK_SIGNAL_FUNC (gimp_double_adjustment_update),
&filmvals.hole_width);
spinbutton = gtk_object_get_data (GTK_OBJECT (adj), "spinbutton");
gtk_spin_button_configure
(GTK_SPIN_BUTTON (spinbutton),
gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)),
0.01, 3);
gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj),
GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 3);
filmint.advanced_adj[4] = adj =
gimp_scale_entry_new (GTK_TABLE (table), 0, row++,
@ -1458,11 +1446,8 @@ film_dialog (gint32 image_ID)
GTK_SIGNAL_FUNC (gimp_double_adjustment_update),
&filmvals.hole_height);
spinbutton = gtk_object_get_data (GTK_OBJECT (adj), "spinbutton");
gtk_spin_button_configure
(GTK_SPIN_BUTTON (spinbutton),
gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)),
0.01, 3);
gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj),
GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 3);
filmint.advanced_adj[5] = adj =
gimp_scale_entry_new (GTK_TABLE (table), 0, row++,
@ -1475,11 +1460,8 @@ film_dialog (gint32 image_ID)
GTK_SIGNAL_FUNC (gimp_double_adjustment_update),
&filmvals.hole_space);
spinbutton = gtk_object_get_data (GTK_OBJECT (adj), "spinbutton");
gtk_spin_button_configure
(GTK_SPIN_BUTTON (spinbutton),
gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)),
0.01, 3);
gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj),
GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 3);
sep = gtk_hseparator_new ();
gtk_table_attach (GTK_TABLE (table), sep, 0, 3, row, row + 1,
@ -1499,11 +1481,8 @@ film_dialog (gint32 image_ID)
GTK_SIGNAL_FUNC (gimp_double_adjustment_update),
&filmvals.number_height);
spinbutton = gtk_object_get_data (GTK_OBJECT (adj), "spinbutton");
gtk_spin_button_configure
(GTK_SPIN_BUTTON (spinbutton),
gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)),
0.01, 3);
gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj),
GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 3);
sep = gtk_hseparator_new ();
gtk_table_attach (GTK_TABLE (table), sep, 0, 3, row, row + 1,

View file

@ -5,14 +5,10 @@ gckincludedir = $(includedir)/gck
lib_LTLIBRARIES = libgck.la
libgck_la_SOURCES = \
gckcolor.c \
gckui.c
gckcolor.c
gckinclude_HEADERS = \
gck.h \
gckcolor.h \
gcktypes.h \
gckui.h
gck.h
libgck_la_LDFLAGS = \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -release $(LT_RELEASE)

View file

@ -24,11 +24,152 @@
#include <gtk/gtk.h>
#define g_function_enter(fname)
#define g_function_leave(fname)
#ifdef __cplusplus
extern "C" {
#endif
#include <gck/gcktypes.h>
#include <gck/gckcolor.h>
#include <gck/gckui.h>
#define GCK_CONSTRAIN_RGB 1<<0
#define GCK_CONSTRAIN_RGBA 1<<1
#define GCK_CONSTRAIN_GRAY 1<<2
#define GCK_CONSTRAIN_GRAYA 1<<3
#define GCK_CONSTRAIN_INDEXED 1<<4
#define GCK_CONSTRAIN_INDEXEDA 1<<5
#define GCK_CONSTRAIN_ALL 0xff
#define GCK_HSV_UNDEFINED -1.0
#define GCK_HSL_UNDEFINED -1.0
typedef enum
{
DITHER_NONE,
DITHER_FLOYD_STEINBERG,
DITHER_ORDERED
} GckDitherType;
typedef struct
{
gdouble r, g, b, a;
} GckRGB;
typedef struct
{
guchar r, g, b;
const gchar *name;
} GckNamedRGB;
typedef struct
{
GdkVisual *visual;
GdkColormap *colormap;
gulong allocedpixels[256];
guint32 colorcube[256];
GdkColor rgbpalette[256];
guchar map_r[256], map_g[256], map_b[256];
guchar indextab[7][7][7];
guchar invmap_r[256], invmap_g[256], invmap_b[256];
gint shades_r, shades_g, shades_b, numcolors;
GckDitherType dithermethod;
} GckVisualInfo;
typedef void (* GckRenderFunction) (gdouble, gdouble, GckRGB *);
typedef void (* GckPutPixelFunction) (gint, gint, GckRGB *);
typedef void (* GckProgressFunction) (gint, gint, gint);
typedef void (* GckColorUpdateFunction) (GckRGB *);
typedef gint (* GckEventFunction) (GtkWidget *, GdkEvent *, gpointer);
typedef struct
{
GtkWidget *widget;
GckVisualInfo *visinfo;
} GckApplicationWindow;
typedef struct
{
gint x, y, w, h;
GdkImage *buffer;
} _GckBackBuffer;
GckVisualInfo *gck_visualinfo_new (void);
void gck_visualinfo_destroy (GckVisualInfo *visinfo);
GckDitherType gck_visualinfo_get_dither (GckVisualInfo *visinfo);
void gck_visualinfo_set_dither (GckVisualInfo *visinfo,
GckDitherType dithermethod);
/* RGB to Gdk routines */
/* =================== */
void gck_rgb_to_gdkimage (GckVisualInfo *visinfo,
guchar *RGB_data,
GdkImage *image,
int width,int height);
/* returns a static storage */
GdkColor *gck_rgb_to_gdkcolor (GckVisualInfo *visinfo,guchar r,guchar g,guchar b);
/* returns a malloc'ed area */
GdkColor *gck_rgb_to_gdkcolor_r (GckVisualInfo *visinfo,guchar r,guchar g,guchar b);
void gck_gc_set_foreground (GckVisualInfo *visinfo,GdkGC *gc,
guchar r, guchar g, guchar b);
void gck_gc_set_background (GckVisualInfo *visinfo,GdkGC *gc,
guchar r, guchar g, guchar b);
/********************/
/* Color operations */
/********************/
double gck_bilinear (double x,double y, double *values);
guchar gck_bilinear_8 (double x,double y, guchar *values);
guint16 gck_bilinear_16 (double x,double y, guint16 *values);
guint32 gck_bilinear_32 (double x,double y, guint32 *values);
GckRGB gck_bilinear_rgb (double x,double y, GckRGB *values);
GckRGB gck_bilinear_rgba (double x,double y, GckRGB *values);
/* RGB pixel operations */
/* ==================== */
void gck_rgb_add (GckRGB *p,GckRGB *q);
void gck_rgb_sub (GckRGB *p,GckRGB *q);
void gck_rgb_mul (GckRGB *p,double b);
void gck_rgb_clamp (GckRGB *p);
void gck_rgb_set (GckRGB *p,double r,double g,double b);
void gck_rgb_gamma (GckRGB *p,double gamma);
void gck_rgba_add (GckRGB *p,GckRGB *q);
void gck_rgba_sub (GckRGB *p,GckRGB *q);
void gck_rgba_mul (GckRGB *p,double b);
void gck_rgba_clamp (GckRGB *p);
void gck_rgba_set (GckRGB *p,double r,double g,double b,double a);
void gck_rgba_gamma (GckRGB *p,double gamma);
/* Colorspace conversions */
/* ====================== */
void gck_rgb_to_hsv (GckRGB *p, double *h,double *s,double *v);
void gck_rgb_to_hsl (GckRGB *p, double *h,double *s,double *l);
void gck_hsv_to_rgb (double h,double s,double v, GckRGB *p);
void gck_hsl_to_rgb (double h,double s,double l, GckRGB *p);
void gck_rgb_to_hwb (GckRGB *rgb, gdouble *hue,gdouble *whiteness,gdouble *blackness);
void gck_hwb_to_rgb (gdouble H,gdouble W, gdouble B, GckRGB *rgb);
/* Supersampling */
/* ============= */
gulong gck_adaptive_supersample_area (int x1,int y1,int x2,int y2,
int max_depth,
double threshold,
GckRenderFunction render_func,
GckPutPixelFunction put_pixel_func,
GckProgressFunction progress_func);
extern GckNamedRGB gck_named_colors[];
#ifdef __cplusplus
}
#endif
#endif /* __GCK_H__ */

File diff suppressed because it is too large Load diff

View file

@ -1,114 +0,0 @@
/***************************************************************************/
/* GCK - The General Convenience Kit. Generally useful conveniece routines */
/* for GIMP plug-in writers and users of the GDK/GTK libraries. */
/* Copyright (C) 1996 Tom Bech */
/* */
/* 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,i */
/* USA. */
/***************************************************************************/
#ifndef __GCKCOLOR_H__
#define __GCKCOLOR_H__
#include <gdk/gdk.h>
#include <gck/gck.h>
#include <gck/gcktypes.h>
#ifdef __cplusplus
extern "C" {
#endif
GckVisualInfo *gck_visualinfo_new (void);
void gck_visualinfo_destroy (GckVisualInfo *visinfo);
GckDitherType gck_visualinfo_get_dither (GckVisualInfo *visinfo);
void gck_visualinfo_set_dither (GckVisualInfo *visinfo,
GckDitherType dithermethod);
/* RGB to Gdk routines */
/* =================== */
void gck_rgb_to_gdkimage (GckVisualInfo *visinfo,
guchar *RGB_data,
GdkImage *image,
int width,int height);
/* returns a static storage */
GdkColor *gck_rgb_to_gdkcolor (GckVisualInfo *visinfo,guchar r,guchar g,guchar b);
/* returns a malloc'ed area */
GdkColor *gck_rgb_to_gdkcolor_r (GckVisualInfo *visinfo,guchar r,guchar g,guchar b);
void gck_gc_set_foreground (GckVisualInfo *visinfo,GdkGC *gc,
guchar r, guchar g, guchar b);
void gck_gc_set_background (GckVisualInfo *visinfo,GdkGC *gc,
guchar r, guchar g, guchar b);
/********************/
/* Color operations */
/********************/
double gck_bilinear (double x,double y, double *values);
guchar gck_bilinear_8 (double x,double y, guchar *values);
guint16 gck_bilinear_16 (double x,double y, guint16 *values);
guint32 gck_bilinear_32 (double x,double y, guint32 *values);
GckRGB gck_bilinear_rgb (double x,double y, GckRGB *values);
GckRGB gck_bilinear_rgba (double x,double y, GckRGB *values);
/* RGB pixel operations */
/* ==================== */
void gck_rgb_add (GckRGB *p,GckRGB *q);
void gck_rgb_sub (GckRGB *p,GckRGB *q);
void gck_rgb_mul (GckRGB *p,double b);
void gck_rgb_clamp (GckRGB *p);
void gck_rgb_set (GckRGB *p,double r,double g,double b);
void gck_rgb_gamma (GckRGB *p,double gamma);
void gck_rgba_add (GckRGB *p,GckRGB *q);
void gck_rgba_sub (GckRGB *p,GckRGB *q);
void gck_rgba_mul (GckRGB *p,double b);
void gck_rgba_clamp (GckRGB *p);
void gck_rgba_set (GckRGB *p,double r,double g,double b,double a);
void gck_rgba_gamma (GckRGB *p,double gamma);
/* Colorspace conversions */
/* ====================== */
void gck_rgb_to_hsv (GckRGB *p, double *h,double *s,double *v);
void gck_rgb_to_hsl (GckRGB *p, double *h,double *s,double *l);
void gck_hsv_to_rgb (double h,double s,double v, GckRGB *p);
void gck_hsl_to_rgb (double h,double s,double l, GckRGB *p);
void gck_rgb_to_hwb (GckRGB *rgb, gdouble *hue,gdouble *whiteness,gdouble *blackness);
void gck_hwb_to_rgb (gdouble H,gdouble W, gdouble B, GckRGB *rgb);
/* Supersampling */
/* ============= */
gulong gck_adaptive_supersample_area (int x1,int y1,int x2,int y2,
int max_depth,
double threshold,
GckRenderFunction render_func,
GckPutPixelFunction put_pixel_func,
GckProgressFunction progress_func);
extern GckNamedRGB gck_named_colors[];
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,201 +0,0 @@
/***************************************************************************/
/* GCK - The General Convenience Kit. Generally useful conveniece routines */
/* for GIMP plug-in writers and users of the GDK/GTK libraries. */
/* Copyright (C) 1996 Tom Bech */
/* */
/* 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 __GCKTYPES_H__
#define __GCKTYPES_H__
#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#ifdef __cplusplus
extern "C" {
#endif
#define GCK_CONSTRAIN_RGB 1<<0
#define GCK_CONSTRAIN_RGBA 1<<1
#define GCK_CONSTRAIN_GRAY 1<<2
#define GCK_CONSTRAIN_GRAYA 1<<3
#define GCK_CONSTRAIN_INDEXED 1<<4
#define GCK_CONSTRAIN_INDEXEDA 1<<5
#define GCK_CONSTRAIN_ALL 0xff
#define GCK_ALIGN_CENTERED 0.5
#define GCK_ALIGN_RIGHT 1.0
#define GCK_ALIGN_LEFT 0.0
#define GCK_ALIGN_TOP 0.0
#define GCK_ALIGN_BOTTOM 1.0
#define GCK_HSV_UNDEFINED -1.0
#define GCK_HSL_UNDEFINED -1.0
typedef enum
{
DITHER_NONE,
DITHER_FLOYD_STEINBERG,
DITHER_ORDERED
} GckDitherType;
typedef struct
{
double r,g,b,a;
} GckRGB;
typedef struct
{
guchar r,g,b;
const char *name;
} GckNamedRGB;
typedef struct
{
GdkVisual *visual;
GdkColormap *colormap;
gulong allocedpixels[256];
guint32 colorcube[256];
GdkColor rgbpalette[256];
guchar map_r[256],map_g[256],map_b[256];
guchar indextab[7][7][7];
guchar invmap_r[256],invmap_g[256],invmap_b[256];
int shades_r,shades_g,shades_b,numcolors;
GckDitherType dithermethod;
} GckVisualInfo;
typedef void (*GckRenderFunction) (double, double, GckRGB *);
typedef void (*GckPutPixelFunction) (int, int, GckRGB *);
typedef void (*GckProgressFunction) (int, int, int);
typedef void (*GckColorUpdateFunction) (GckRGB *);
typedef gint (*GckEventFunction) (GtkWidget *, GdkEvent *, gpointer);
typedef struct
{
double size;
double value;
double lower;
double upper;
double step_inc;
double page_inc;
double page_size;
GtkUpdateType update_type;
gint draw_value_flag;
} GckScaleValues;
typedef enum
{
GCK_RIGHT,
GCK_LEFT,
GCK_TOP,
GCK_BOTTOM
} GckPosition;
typedef struct
{
GtkWidget *widget;
GtkWidget *actionbox,*workbox;
GtkWidget *okbutton;
GtkWidget *cancelbutton;
GtkWidget *helpbutton;
} GckDialogWindow;
typedef struct
{
GtkWidget *widget;
GtkStyle *style;
GtkAccelGroup *accel_group;
GckVisualInfo *visinfo;
} GckApplicationWindow;
typedef struct _GckMenuItem
{
char *label;
char accelerator_key;
gint accelerator_mods;
GtkSignalFunc item_selected_func;
gpointer user_data;
struct _GckMenuItem *subitems;
GtkWidget *widget;
} GckMenuItem;
typedef struct
{
GtkWidget *widget;
GtkWidget *list;
GckEventFunction event_handler;
GdkEvent last_event;
GList *itemlist;
GList *current_selection;
gint *selected_items,num_selected_items;
gint width,height;
gint num_items;
gint disable_signals;
} GckListBox;
typedef struct
{
char *label;
GtkWidget *widget;
gpointer user_data;
GckListBox *listbox;
} GckListBoxItem;
typedef struct
{
GtkWidget *widget;
GtkWidget *tab_box;
GtkWidget *workbox;
GList *page_list;
GtkPositionType tab_position;
gint width;
gint height;
gint current_page;
gint num_pages;
gint button_down;
} GckNoteBook;
typedef struct
{
char *label;
GdkImage *image;
GdkPixmap *pixmap;
GdkRectangle area;
} GckNoteBookTab;
typedef struct
{
gchar *label;
gint position;
gint active;
GtkWidget *widget;
GckNoteBookTab *tab;
GtkWidget *labelwidget;
GckNoteBook *notebook;
} GckNoteBookPage;
typedef struct {
int x,y,w,h;
GdkImage *buffer;
} _GckBackBuffer;
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,151 +0,0 @@
/***************************************************************************/
/* GCK - The General Convenience Kit. Generally useful conveniece routines */
/* for GIMP plug-in writers and users of the GDK/GTK libraries. */
/* Copyright (C) 1996 Tom Bech */
/* */
/* 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 __GCKUI_H__
#define __GCKUI_H__
#include "gck.h"
#ifdef __cplusplus
extern "C" {
#endif
void gck_cursor_set (GdkWindow *window,
GdkCursorType cursortype);
void gck_auto_show (gint flag);
GckApplicationWindow *gck_application_window_new (char *name);
void gck_application_window_destroy (GckApplicationWindow *appwin);
GckDialogWindow *gck_dialog_window_new (char *name,
GckPosition ActionPos,
GtkSignalFunc ok_pressed_func,
GtkSignalFunc cancel_pressed_func,
GtkSignalFunc help_pressed_func);
void gck_dialog_window_destroy (GckDialogWindow *dialog);
GtkWidget *gck_vseparator_new (GtkWidget *container);
GtkWidget *gck_hseparator_new (GtkWidget *container);
GtkWidget *gck_frame_new (char *name,GtkWidget *container,
GtkShadowType shadowtype,
gint expand,gint fill,gint padding,
gint borderwidth);
GtkWidget *gck_label_new (char *name,GtkWidget *container);
GtkWidget *gck_label_aligned_new (char *name,GtkWidget *container,
gdouble xalign,gdouble yalign);
GtkWidget *gck_drawing_area_new (GtkWidget *container,
gint width,gint height,
gint event_mask,
GtkSignalFunc event_handler);
GtkWidget *gck_hscale_new (char *name,GtkWidget *container,
GckScaleValues *svals,
GtkSignalFunc value_changed_func);
GtkWidget *gck_vscale_new (char *name,GtkWidget *container,
GckScaleValues *svals,
GtkSignalFunc value_changed_func);
GtkWidget *gck_entryfield_new (char *name,GtkWidget *container,
double initial_value,
GtkSignalFunc valuechangedfunc);
GtkWidget *gck_entryfield_text_new (char *name,GtkWidget *container,
char *initial_text,
GtkSignalFunc textchangedfunc);
GtkWidget *gck_pushbutton_new (char *name,GtkWidget *container,
gint expand,gint fill,gint padding,
GtkSignalFunc button_clicked_func);
GtkWidget *gck_pushbutton_pixmap_new (char *name,
GdkPixmap *pixm,
GdkBitmap *mask,
GtkWidget *container,
gint expand,gint fill,gint padding,
GtkSignalFunc button_clicked_func);
GtkWidget *gck_togglebutton_pixmap_new (char *name,
GdkPixmap *pixm,
GdkBitmap *mask,
GtkWidget *container,
gint expand,gint fill,gint padding,
GtkSignalFunc button_toggled_func);
GtkWidget *gck_checkbutton_new (char *name,GtkWidget *container,
gint value,
GtkSignalFunc status_changed_func);
GtkWidget *gck_radiobutton_new (char *name,GtkWidget *container,
GtkWidget *previous,
GtkSignalFunc status_changed_func);
GtkWidget *gck_radiobutton_pixmap_new (char *name,
GdkPixmap *pixm,
GdkBitmap *mask,
GtkWidget *container,
GtkWidget *previous,
GtkSignalFunc status_changed_func);
GtkWidget *gck_pixmap_new (GdkPixmap *pixm,
GdkBitmap *mask,
GtkWidget *container);
GtkWidget *gck_vbox_new (GtkWidget *Container,
gint homogenous,gint expand,gint fill,
gint spacing,gint padding,
gint borderwidth);
GtkWidget *gck_hbox_new (GtkWidget *container,
gint homogenous,gint expand,gint fill,
gint spacing,gint padding,
gint borderwidth);
GtkWidget *gck_menu_bar_new (GtkWidget *container,
GckMenuItem menu_items[],
GtkAccelGroup *acc_group);
GtkWidget *gck_menu_new (GckMenuItem *menu_items,
GtkAccelGroup *acc_group);
GtkWidget *gck_option_menu_new (char *name,GtkWidget *container,
gint expand,gint fill,
gint padding,
char *item_labels[],
GtkSignalFunc item_selected_func,
gpointer data);
GtkWidget *gck_image_menu_new (char *name,GtkWidget *container,
gint expand,gint fill,
gint padding,
gint constrain,
GtkSignalFunc item_selected_func);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -10,6 +10,7 @@ plug-ins/Lighting/lighting_main.c
plug-ins/Lighting/lighting_ui.c
plug-ins/MapObject/arcball.c
plug-ins/MapObject/mapobject_main.c
plug-ins/MapObject/mapobject_ui.c
plug-ins/bmp/bmpread.c
plug-ins/bmp/bmpwrite.c
plug-ins/borderaverage/borderaverage.c