Commit 09a51f21 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

GType is a pointer now, not a guint.

2001-11-27  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpcontainer.c: GType is a pointer now, not a guint.

	* app/widgets/gimpdock.c: chain up in widget_class->style_set().

	Gradient Editor chopping plus merging of bex' proofreading:
	(fixes #62278).

	* app/core/core-types.h: moved the gradient related enums here.

	* app/core/gimpgradient.[ch]: removed the enums, added gradient
	segment utility functions from the gradient_editor.

	* app/gui/gui-types.h: added the GradientEditor typedef here.

	* app/gui/Makefile.am
	* app/gui/gradient-editor-commands.[ch]: new files implementing
	callbacks and menu_update stuff for the new gradient_editor
	item factory.

	* app/gui/gradient-editor.[ch]: removed tons of code, namespace
	cleanup, stuff...

	* app/gui/menus.[ch]: added the gradient_editor menu stuff here.
	Added menus_set_color() which creates & updates a color menu item
	(will soon be used in other places too). Renamed menus_set_state()
	to menus_set_active().

	The editor's menu code is ugly as before, only different and evil
	the same way as the rest of the menu stuff, so it's at least
	consistent :)

	* app/display/gimpdisplayshell.c: changed accordingly.

	* app/gui/test-commands.c: don't include "gradient-editor.h".
parent 19e1acbc
2001-11-27 Michael Natterer <mitch@gimp.org>
* app/core/gimpcontainer.c: GType is a pointer now, not a guint.
* app/widgets/gimpdock.c: chain up in widget_class->style_set().
Gradient Editor chopping plus merging of bex' proofreading:
(fixes #62278).
* app/core/core-types.h: moved the gradient related enums here.
* app/core/gimpgradient.[ch]: removed the enums, added gradient
segment utility functions from the gradient_editor.
* app/gui/gui-types.h: added the GradientEditor typedef here.
* app/gui/Makefile.am
* app/gui/gradient-editor-commands.[ch]: new files implementing
callbacks and menu_update stuff for the new gradient_editor
item factory.
* app/gui/gradient-editor.[ch]: removed tons of code, namespace
cleanup, stuff...
* app/gui/menus.[ch]: added the gradient_editor menu stuff here.
Added menus_set_color() which creates & updates a color menu item
(will soon be used in other places too). Renamed menus_set_state()
to menus_set_active().
The editor's menu code is ugly as before, only different and evil
the same way as the rest of the menu stuff, so it's at least
consistent :)
* app/display/gimpdisplayshell.c: changed accordingly.
* app/gui/test-commands.c: don't include "gradient-editor.h".
2001-11-27 Sven Neumann <sven@gimp.org>
* configure.in
......@@ -64,7 +101,6 @@
* app/gui/file-save-dialog.c: More of my extensive proofing.
Someone needs to check bex comments and do some hacking.
2001-11-26 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage.c: gimp_image_construct_layers/channels():
......
This diff is collapsed.
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GRADIENT_EDITOR_COMMANDS_H__
#define __GRADIENT_EDITOR_COMMANDS_H__
void gradient_editor_left_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_load_left_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_save_left_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_right_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_load_right_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_save_right_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_blending_func_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_coloring_type_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_flip_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_replicate_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_split_midpoint_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_split_uniformly_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_delete_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_recenter_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_redistribute_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_blend_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_blend_opacity_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void gradient_editor_show_context_menu (GradientEditor *editor);
#endif /* __GRADIENT_EDITOR_COMMANDS_H__ */
......@@ -176,6 +176,22 @@ typedef enum
SPIRAL_ANTICLOCKWISE
} GradientType;
typedef enum /*< skip >*/
{
GRAD_LINEAR = 0,
GRAD_CURVED,
GRAD_SINE,
GRAD_SPHERE_INCREASING,
GRAD_SPHERE_DECREASING
} GimpGradientSegmentType;
typedef enum /*< skip >*/
{
GRAD_RGB = 0, /* normal RGB */
GRAD_HSV_CCW, /* counterclockwise hue */
GRAD_HSV_CW /* clockwise hue */
} GimpGradientSegmentColor;
typedef enum /*< chop=_MODE >*/
{
FG_BG_RGB_MODE,
......
......@@ -205,22 +205,11 @@ gimp_container_class_init (GimpContainerClass *klass)
klass->get_child_by_index = NULL;
klass->get_child_index = NULL;
/* spit out a warning once GType becomes a gpointer */
{
guint32 *foo = NULL;
GType *bar;
bar = foo;
}
g_object_class_install_property (object_class,
PROP_CHILDREN_TYPE,
g_param_spec_uint ("children_type",
NULL, NULL,
GIMP_TYPE_OBJECT,
G_MAXINT,
GIMP_TYPE_OBJECT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_param_spec_pointer ("children_type",
NULL, NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_POLICY,
......@@ -278,7 +267,7 @@ gimp_container_set_property (GObject *object,
switch (property_id)
{
case PROP_CHILDREN_TYPE:
container->children_type = (GType) g_value_get_uint (value);
container->children_type = (GType) g_value_get_pointer (value);
g_type_class_ref (container->children_type);
break;
case PROP_POLICY:
......@@ -303,7 +292,7 @@ gimp_container_get_property (GObject *object,
switch (property_id)
{
case PROP_CHILDREN_TYPE:
g_value_set_uint (value, (guint) container->children_type);
g_value_set_pointer (value, (gpointer) container->children_type);
break;
case PROP_POLICY:
g_value_set_enum (value, container->policy);
......
......@@ -811,3 +811,242 @@ gimp_gradient_segment_get_last (GimpGradientSegment *seg)
return seg;
}
GimpGradientSegment *
gimp_gradient_segment_get_first (GimpGradientSegment *seg)
{
if (!seg)
return NULL;
while (seg->prev)
seg = seg->prev;
return seg;
}
void
gimp_gradient_segment_split_midpoint (GimpGradient *gradient,
GimpGradientSegment *lseg,
GimpGradientSegment **newl,
GimpGradientSegment **newr)
{
GimpRGB color;
GimpGradientSegment *newseg;
g_return_if_fail (GIMP_IS_GRADIENT (gradient));
g_return_if_fail (lseg != NULL);
g_return_if_fail (newl != NULL);
g_return_if_fail (newr != NULL);
/* Get color at original segment's midpoint */
gimp_gradient_get_color_at (gradient, lseg->middle, &color);
/* Create a new segment and insert it in the list */
newseg = gimp_gradient_segment_new ();
newseg->prev = lseg;
newseg->next = lseg->next;
lseg->next = newseg;
if (newseg->next)
newseg->next->prev = newseg;
/* Set coordinates of new segment */
newseg->left = lseg->middle;
newseg->right = lseg->right;
newseg->middle = (newseg->left + newseg->right) / 2.0;
/* Set coordinates of original segment */
lseg->right = newseg->left;
lseg->middle = (lseg->left + lseg->right) / 2.0;
/* Set colors of both segments */
newseg->right_color = lseg->right_color;
lseg->right_color.r = newseg->left_color.r = color.r;
lseg->right_color.g = newseg->left_color.g = color.g;
lseg->right_color.b = newseg->left_color.b = color.b;
lseg->right_color.a = newseg->left_color.a = color.a;
/* Set parameters of new segment */
newseg->type = lseg->type;
newseg->color = lseg->color;
/* Done */
*newl = lseg;
*newr = newseg;
}
void
gimp_gradient_segment_split_uniform (GimpGradient *gradient,
GimpGradientSegment *lseg,
gint parts,
GimpGradientSegment **newl,
GimpGradientSegment **newr)
{
GimpGradientSegment *seg, *prev, *tmp;
gdouble seg_len;
gint i;
g_return_if_fail (GIMP_IS_GRADIENT (gradient));
g_return_if_fail (lseg != NULL);
g_return_if_fail (newl != NULL);
g_return_if_fail (newr != NULL);
seg_len = (lseg->right - lseg->left) / parts; /* Length of divisions */
seg = NULL;
prev = NULL;
tmp = NULL;
for (i = 0; i < parts; i++)
{
seg = gimp_gradient_segment_new ();
if (i == 0)
tmp = seg; /* Remember first segment */
seg->left = lseg->left + i * seg_len;
seg->right = lseg->left + (i + 1) * seg_len;
seg->middle = (seg->left + seg->right) / 2.0;
gimp_gradient_get_color_at (gradient, seg->left, &seg->left_color);
gimp_gradient_get_color_at (gradient, seg->right, &seg->right_color);
seg->type = lseg->type;
seg->color = lseg->color;
seg->prev = prev;
seg->next = NULL;
if (prev)
prev->next = seg;
prev = seg;
}
/* Fix edges */
tmp->left_color = lseg->left_color;
seg->right_color = lseg->right_color;
tmp->left = lseg->left;
seg->right = lseg->right; /* To squish accumulative error */
/* Link in list */
tmp->prev = lseg->prev;
seg->next = lseg->next;
if (lseg->prev)
lseg->prev->next = tmp;
else
gradient->segments = tmp; /* We are on leftmost segment */
if (lseg->next)
lseg->next->prev = seg;
gradient->last_visited = NULL; /* Force re-search */
/* Done */
*newl = tmp;
*newr = seg;
/* Delete old segment */
gimp_gradient_segment_free (lseg);
}
void
gimp_gradient_segments_compress_range (GimpGradientSegment *range_l,
GimpGradientSegment *range_r,
gdouble new_l,
gdouble new_r)
{
gdouble orig_l, orig_r;
gdouble scale;
GimpGradientSegment *seg, *aseg;
g_return_if_fail (range_l != NULL);
g_return_if_fail (range_r != NULL);
orig_l = range_l->left;
orig_r = range_r->right;
scale = (new_r - new_l) / (orig_r - orig_l);
seg = range_l;
do
{
seg->left = new_l + (seg->left - orig_l) * scale;
seg->middle = new_l + (seg->middle - orig_l) * scale;
seg->right = new_l + (seg->right - orig_l) * scale;
/* Next */
aseg = seg;
seg = seg->next;
}
while (aseg != range_r);
}
void
gimp_gradient_segments_blend_endpoints (GimpGradientSegment *lseg,
GimpGradientSegment *rseg,
GimpRGB *rgb1,
GimpRGB *rgb2,
gboolean blend_colors,
gboolean blend_opacity)
{
GimpRGB d;
gdouble left, len;
GimpGradientSegment *seg;
GimpGradientSegment *aseg;
g_return_if_fail (lseg != NULL);
g_return_if_fail (rseg != NULL);
d.r = rgb2->r - rgb1->r;
d.g = rgb2->g - rgb1->g;
d.b = rgb2->b - rgb1->b;
d.a = rgb2->a - rgb1->a;
left = lseg->left;
len = rseg->right - left;
seg = lseg;
do
{
if (blend_colors)
{
seg->left_color.r = rgb1->r + (seg->left - left) / len * d.r;
seg->left_color.g = rgb1->g + (seg->left - left) / len * d.g;
seg->left_color.b = rgb1->b + (seg->left - left) / len * d.b;
seg->right_color.r = rgb1->r + (seg->right - left) / len * d.r;
seg->right_color.g = rgb1->g + (seg->right - left) / len * d.g;
seg->right_color.b = rgb1->b + (seg->right - left) / len * d.b;
}
if (blend_opacity)
{
seg->left_color.a = rgb1->a + (seg->left - left) / len * d.a;
seg->right_color.a = rgb1->a + (seg->right - left) / len * d.a;
}
aseg = seg;
seg = seg->next;
}
while (aseg != rseg);
}
......@@ -28,23 +28,6 @@
#define GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE 40
typedef enum
{
GRAD_LINEAR = 0,
GRAD_CURVED,
GRAD_SINE,
GRAD_SPHERE_INCREASING,
GRAD_SPHERE_DECREASING
} GimpGradientSegmentType;
typedef enum
{
GRAD_RGB = 0, /* normal RGB */
GRAD_HSV_CCW, /* counterclockwise hue */
GRAD_HSV_CW /* clockwise hue */
} GimpGradientSegmentColor;
typedef struct _GimpGradientSegment GimpGradientSegment;
struct _GimpGradientSegment
......@@ -101,11 +84,32 @@ GimpGradientSegment * gimp_gradient_get_segment_at (GimpGradient *grad,
/* gradient segment functions */
GimpGradientSegment * gimp_gradient_segment_new (void);
GimpGradientSegment * gimp_gradient_segment_get_last (GimpGradientSegment *seg);
GimpGradientSegment * gimp_gradient_segment_new (void);
GimpGradientSegment * gimp_gradient_segment_get_last (GimpGradientSegment *seg);
GimpGradientSegment * gimp_gradient_segment_get_first (GimpGradientSegment *seg);
void gimp_gradient_segment_free (GimpGradientSegment *seg);
void gimp_gradient_segments_free (GimpGradientSegment *seg);
void gimp_gradient_segment_split_midpoint (GimpGradient *gradient,
GimpGradientSegment *lseg,
GimpGradientSegment **newl,
GimpGradientSegment **newr);
void gimp_gradient_segment_split_uniform (GimpGradient *gradient,
GimpGradientSegment *lseg,
gint parts,
GimpGradientSegment **newl,
GimpGradientSegment **newr);
void gimp_gradient_segments_compress_range (GimpGradientSegment *range_l,
GimpGradientSegment *range_r,
gdouble new_l,
gdouble new_r);
void gimp_gradient_segments_blend_endpoints (GimpGradientSegment *lseg,
GimpGradientSegment *rseg,
GimpRGB *rgb1,
GimpRGB *rgb2,
gboolean blend_colors,
gboolean blend_opacity);
#endif /* __GIMP_GRADIENT_H__ */
......@@ -953,8 +953,8 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
#define SET_SENSITIVE(menu,condition) \
menus_set_sensitive ("<Image>/" menu, (condition) != 0)
#define SET_STATE(menu,condition) \
menus_set_state ("<Image>/" menu, (condition) != 0)
#define SET_ACTIVE(menu,condition) \
menus_set_active ("<Image>/" menu, (condition) != 0)
SET_SENSITIVE ("File/Save", gdisp && drawable);
SET_SENSITIVE ("File/Save as...", gdisp && drawable);
......@@ -998,15 +998,15 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("View/Zoom", gdisp);
if (gdisp)
{
SET_STATE ("View/Toggle Selection", ! shell->select->hidden);
SET_STATE ("View/Toggle Layer Boundary", ! shell->select->layer_hidden);
SET_STATE ("View/Toggle Rulers",
GTK_WIDGET_VISIBLE (shell->origin) ? 1 : 0);
SET_STATE ("View/Toggle Guides", gdisp->draw_guides);
SET_STATE ("View/Snap to Guides", gdisp->snap_to_guides);
SET_STATE ("View/Toggle Statusbar",
GTK_WIDGET_VISIBLE (shell->statusarea) ? 1 : 0);
SET_STATE ("View/Dot for Dot", gdisp->dot_for_dot);
SET_ACTIVE ("View/Toggle Selection", ! shell->select->hidden);
SET_ACTIVE ("View/Toggle Layer Boundary", ! shell->select->layer_hidden);
SET_ACTIVE ("View/Toggle Rulers",
GTK_WIDGET_VISIBLE (shell->origin) ? 1 : 0);
SET_ACTIVE ("View/Toggle Guides", gdisp->draw_guides);
SET_ACTIVE ("View/Snap to Guides", gdisp->snap_to_guides);
SET_ACTIVE ("View/Toggle Statusbar",
GTK_WIDGET_VISIBLE (shell->statusarea) ? 1 : 0);
SET_ACTIVE ("View/Dot for Dot", gdisp->dot_for_dot);
}
SET_SENSITIVE ("Image", gdisp);
......@@ -1073,7 +1073,7 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("Script-Fu", gdisp && lp);
#undef SET_STATE
#undef SET_ACTIVE
#undef SET_SENSITIVE
plug_in_set_menu_sensitivity (type);
......
......@@ -953,8 +953,8 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
#define SET_SENSITIVE(menu,condition) \
menus_set_sensitive ("<Image>/" menu, (condition) != 0)
#define SET_STATE(menu,condition) \
menus_set_state ("<Image>/" menu, (condition) != 0)
#define SET_ACTIVE(menu,condition) \
menus_set_active ("<Image>/" menu, (condition) != 0)
SET_SENSITIVE ("File/Save", gdisp && drawable);
SET_SENSITIVE ("File/Save as...", gdisp && drawable);
......@@ -998,15 +998,15 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("View/Zoom", gdisp);
if (gdisp)
{
SET_STATE ("View/Toggle Selection", ! shell->select->hidden);
SET_STATE ("View/Toggle Layer Boundary", ! shell->select->layer_hidden);
SET_STATE ("View/Toggle Rulers",
GTK_WIDGET_VISIBLE (shell->origin) ? 1 : 0);
SET_STATE ("View/Toggle Guides", gdisp->draw_guides);
SET_STATE ("View/Snap to Guides", gdisp->snap_to_guides);
SET_STATE ("View/Toggle Statusbar",
GTK_WIDGET_VISIBLE (shell->statusarea) ? 1 : 0);
SET_STATE ("View/Dot for Dot", gdisp->dot_for_dot);
SET_ACTIVE ("View/Toggle Selection", ! shell->select->hidden);
SET_ACTIVE ("View/Toggle Layer Boundary", ! shell->select->layer_hidden);
SET_ACTIVE ("View/Toggle Rulers",
GTK_WIDGET_VISIBLE (shell->origin) ? 1 : 0);
SET_ACTIVE ("View/Toggle Guides", gdisp->draw_guides);
SET_ACTIVE ("View/Snap to Guides", gdisp->snap_to_guides);
SET_ACTIVE ("View/Toggle Statusbar",
GTK_WIDGET_VISIBLE (shell->statusarea) ? 1 : 0);
SET_ACTIVE ("View/Dot for Dot", gdisp->dot_for_dot);
}
SET_SENSITIVE ("Image", gdisp);
......@@ -1073,7 +1073,7 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_SENSITIVE ("Script-Fu", gdisp && lp);
#undef SET_STATE
#undef SET_ACTIVE
#undef SET_SENSITIVE
plug_in_set_menu_sensitivity (type);
......
......@@ -54,6 +54,8 @@ libappgui_a_SOURCES = @STRIP_BEGIN@ \
file-save-dialog.h \
gradient-editor.c \
gradient-editor.h \
gradient-editor-commands.c \
gradient-editor-commands.h \
gradient-select.h \
gradient-select.c \
gradients-commands.c \
......
This diff is collapsed.
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify