app/tools/Makefile.am app/tools/gimpiscissorsoptions.[ch] new options

2008-03-09  Michael Natterer  <mitch@gimp.org>

	* app/tools/Makefile.am
	* app/tools/gimpiscissorsoptions.[ch]
	* app/tools/gimpregionselectoptions.[ch]: new options classes.

	* app/tools/gimpselectionoptions.[ch]: remove the options here.
	Also remove some leftover rectangle options cruft that is in its
	own files since long ago.

	* app/tools/gimpbycolorselecttool.c
	* app/tools/gimpfuzzyselecttool.c
	* app/tools/gimpiscissorstool.[ch]
	* app/tools/gimpregionselecttool.[ch]
	* app/widgets/gimpselectioneditor.c: changed accordingly.


svn path=/trunk/; revision=25071
This commit is contained in:
Michael Natterer 2008-03-09 15:05:54 +00:00 committed by Michael Natterer
parent e87c938808
commit 32a1de9167
15 changed files with 585 additions and 219 deletions

View file

@ -1,3 +1,19 @@
2008-03-09 Michael Natterer <mitch@gimp.org>
* app/tools/Makefile.am
* app/tools/gimpiscissorsoptions.[ch]
* app/tools/gimpregionselectoptions.[ch]: new options classes.
* app/tools/gimpselectionoptions.[ch]: remove the options here.
Also remove some leftover rectangle options cruft that is in its
own files since long ago.
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimpiscissorstool.[ch]
* app/tools/gimpregionselecttool.[ch]
* app/widgets/gimpselectioneditor.c: changed accordingly.
2008-03-09 Martin Nordholts <martinn@svn.gnome.org>
* app/tools/gimprectangletool.c

View file

@ -94,6 +94,8 @@ libapptools_a_sources = \
gimpinkoptions-gui.h \
gimpinktool.c \
gimpinktool.h \
gimpiscissorsoptions.c \
gimpiscissorsoptions.h \
gimpiscissorstool.c \
gimpiscissorstool.h \
gimplevelstool.c \
@ -134,6 +136,8 @@ libapptools_a_sources = \
gimprectangletool.h \
gimprectangleoptions.c \
gimprectangleoptions.h \
gimpregionselectoptions.c \
gimpregionselectoptions.h \
gimpregionselecttool.c \
gimpregionselecttool.h \
gimprotatetool.c \

View file

@ -37,7 +37,7 @@
#include "display/gimpdisplay.h"
#include "gimpbycolorselecttool.h"
#include "gimpselectionoptions.h"
#include "gimpregionselectoptions.h"
#include "gimptoolcontrol.h"
#include "gimp-intl.h"
@ -58,8 +58,8 @@ gimp_by_color_select_tool_register (GimpToolRegisterCallback callback,
gpointer data)
{
(* callback) (GIMP_TYPE_BY_COLOR_SELECT_TOOL,
GIMP_TYPE_SELECTION_OPTIONS,
gimp_selection_options_gui,
GIMP_TYPE_REGION_SELECT_OPTIONS,
gimp_region_select_options_gui,
0,
"gimp-by-color-select-tool",
_("Select by Color"),
@ -93,12 +93,13 @@ static GimpChannel *
gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
GimpDisplay *display)
{
GimpTool *tool = GIMP_TOOL (region_select);
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GimpDrawable *drawable;
GimpPickable *pickable;
GimpRGB color;
gint x, y;
GimpTool *tool = GIMP_TOOL (region_select);
GimpSelectionOptions *sel_options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GimpRegionSelectOptions *options = GIMP_REGION_SELECT_TOOL_GET_OPTIONS (tool);
GimpDrawable *drawable;
GimpPickable *pickable;
GimpRGB color;
gint x, y;
drawable = gimp_image_get_active_drawable (display->image);
@ -126,7 +127,7 @@ gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
if (gimp_pickable_get_color_at (pickable, x, y, &color))
return gimp_image_contiguous_region_by_color (display->image, drawable,
options->sample_merged,
options->antialias,
sel_options->antialias,
options->threshold,
options->select_transparent,
options->select_criterion,

View file

@ -35,7 +35,7 @@
#include "display/gimpdisplay.h"
#include "gimpfuzzyselecttool.h"
#include "gimpselectionoptions.h"
#include "gimpregionselectoptions.h"
#include "gimptoolcontrol.h"
#include "gimp-intl.h"
@ -56,8 +56,8 @@ gimp_fuzzy_select_tool_register (GimpToolRegisterCallback callback,
gpointer data)
{
(* callback) (GIMP_TYPE_FUZZY_SELECT_TOOL,
GIMP_TYPE_SELECTION_OPTIONS,
gimp_selection_options_gui,
GIMP_TYPE_REGION_SELECT_OPTIONS,
gimp_region_select_options_gui,
0,
"gimp-fuzzy-select-tool",
_("Fuzzy Select"),
@ -92,10 +92,11 @@ static GimpChannel *
gimp_fuzzy_select_tool_get_mask (GimpRegionSelectTool *region_select,
GimpDisplay *display)
{
GimpTool *tool = GIMP_TOOL (region_select);
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GimpDrawable *drawable;
gint x, y;
GimpTool *tool = GIMP_TOOL (region_select);
GimpSelectionOptions *sel_options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GimpRegionSelectOptions *options = GIMP_REGION_SELECT_TOOL_GET_OPTIONS (tool);
GimpDrawable *drawable;
gint x, y;
drawable = gimp_image_get_active_drawable (display->image);
@ -114,7 +115,7 @@ gimp_fuzzy_select_tool_get_mask (GimpRegionSelectTool *region_select,
return gimp_image_contiguous_region_by_seed (display->image, drawable,
options->sample_merged,
options->antialias,
sel_options->antialias,
options->threshold,
options->select_transparent,
options->select_criterion,

View file

@ -0,0 +1,131 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995-1999 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.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "widgets/gimppropwidgets.h"
#include "gimpiscissorstool.h"
#include "gimpiscissorsoptions.h"
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_INTERACTIVE
};
static void gimp_iscissors_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_iscissors_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE (GimpIscissorsOptions, gimp_iscissors_options,
GIMP_TYPE_SELECTION_OPTIONS)
#define parent_class gimp_iscissors_options_parent_class
static void
gimp_iscissors_options_class_init (GimpIscissorsOptionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_iscissors_options_set_property;
object_class->get_property = gimp_iscissors_options_get_property;
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_INTERACTIVE,
"interactive", NULL,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
}
static void
gimp_iscissors_options_init (GimpIscissorsOptions *options)
{
}
static void
gimp_iscissors_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpIscissorsOptions *options = GIMP_ISCISSORS_OPTIONS (object);
switch (property_id)
{
case PROP_INTERACTIVE:
options->interactive = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_iscissors_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpIscissorsOptions *options = GIMP_ISCISSORS_OPTIONS (object);
switch (property_id)
{
case PROP_INTERACTIVE:
g_value_set_boolean (value, options->interactive);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
GtkWidget *
gimp_iscissors_options_gui (GimpToolOptions *tool_options)
{
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_selection_options_gui (tool_options);
GtkWidget *button;
button = gimp_prop_check_button_new (config, "interactive",
_("Interactive boundary"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
return vbox;
}

View file

@ -0,0 +1,50 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995-1999 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 __GIMP_ISCISSORS_OPTIONS_H__
#define __GIMP_ISCISSORS_OPTIONS_H__
#include "gimpselectionoptions.h"
#define GIMP_TYPE_ISCISSORS_OPTIONS (gimp_iscissors_options_get_type ())
#define GIMP_ISCISSORS_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_ISCISSORS_OPTIONS, GimpIscissorsOptions))
#define GIMP_ISCISSORS_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_ISCISSORS_OPTIONS, GimpIscissorsOptionsClass))
#define GIMP_IS_ISCISSORS_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_ISCISSORS_OPTIONS))
#define GIMP_IS_ISCISSORS_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_ISCISSORS_OPTIONS))
#define GIMP_ISCISSORS_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_ISCISSORS_OPTIONS, GimpIscissorsOptionsClass))
typedef struct _GimpIscissorsOptions GimpIscissorsOptions;
typedef struct _GimpToolOptionsClass GimpIscissorsOptionsClass;
struct _GimpIscissorsOptions
{
GimpSelectionOptions parent_instance;
gboolean interactive;
};
GType gimp_iscissors_options_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_iscissors_options_gui (GimpToolOptions *tool_options);
#endif /* __GIMP_ISCISSORS_OPTIONS_H__ */

View file

@ -75,8 +75,8 @@
#include "display/gimpdisplay.h"
#include "gimpiscissorsoptions.h"
#include "gimpiscissorstool.h"
#include "gimpselectionoptions.h"
#include "gimptoolcontrol.h"
#include "gimp-intl.h"
@ -271,8 +271,8 @@ gimp_iscissors_tool_register (GimpToolRegisterCallback callback,
gpointer data)
{
(* callback) (GIMP_TYPE_ISCISSORS_TOOL,
GIMP_TYPE_SELECTION_OPTIONS,
gimp_selection_options_gui,
GIMP_TYPE_ISCISSORS_OPTIONS,
gimp_iscissors_options_gui,
0,
"gimp-iscissors-tool",
_("Scissors"),
@ -405,7 +405,7 @@ gimp_iscissors_tool_button_press (GimpTool *tool,
GimpDisplay *display)
{
GimpIscissorsTool *iscissors = GIMP_ISCISSORS_TOOL (tool);
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GimpIscissorsOptions *options = GIMP_ISCISSORS_TOOL_GET_OPTIONS (tool);
iscissors->x = RINT (coords->x);
iscissors->y = RINT (coords->y);
@ -549,7 +549,7 @@ gimp_iscissors_tool_button_release (GimpTool *tool,
GimpDisplay *display)
{
GimpIscissorsTool *iscissors = GIMP_ISCISSORS_TOOL (tool);
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GimpIscissorsOptions *options = GIMP_ISCISSORS_TOOL_GET_OPTIONS (tool);
/* Make sure X didn't skip the button release event -- as it's known
* to do
@ -665,7 +665,7 @@ gimp_iscissors_tool_motion (GimpTool *tool,
GimpDisplay *display)
{
GimpIscissorsTool *iscissors = GIMP_ISCISSORS_TOOL (tool);
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GimpIscissorsOptions *options = GIMP_ISCISSORS_TOOL_GET_OPTIONS (tool);
if (iscissors->state == NO_ACTION)
return;

View file

@ -63,6 +63,8 @@ typedef struct _ICurve ICurve;
#define GIMP_IS_ISCISSORS_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_ISCISSORS_TOOL))
#define GIMP_ISCISSORS_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_ISCISSORS_TOOL, GimpIscissorsToolClass))
#define GIMP_ISCISSORS_TOOL_GET_OPTIONS(t) (GIMP_ISCISSORS_OPTIONS (gimp_tool_get_options (GIMP_TOOL (t))))
typedef struct _GimpIscissorsTool GimpIscissorsTool;
typedef struct _GimpIscissorsToolClass GimpIscissorsToolClass;

View file

@ -0,0 +1,231 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995-1999 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.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpwidgets-utils.h"
#include "gimpregionselectoptions.h"
#include "gimpregionselecttool.h"
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_SELECT_TRANSPARENT,
PROP_SAMPLE_MERGED,
PROP_THRESHOLD,
PROP_SELECT_CRITERION
};
static void gimp_region_select_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_region_select_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_region_select_options_reset (GimpToolOptions *tool_options);
G_DEFINE_TYPE (GimpRegionSelectOptions, gimp_region_select_options,
GIMP_TYPE_SELECTION_OPTIONS)
#define parent_class gimp_region_select_options_parent_class
static void
gimp_region_select_options_class_init (GimpRegionSelectOptionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolOptionsClass *options_class = GIMP_TOOL_OPTIONS_CLASS (klass);
object_class->set_property = gimp_region_select_options_set_property;
object_class->get_property = gimp_region_select_options_get_property;
options_class->reset = gimp_region_select_options_reset;
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SELECT_TRANSPARENT,
"select-transparent",
N_("Allow completely transparent regions "
"to be selected"),
TRUE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAMPLE_MERGED,
"sample-merged",
N_("Base region_select on all visible layers"),
FALSE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_THRESHOLD,
"threshold",
N_("Maximum color difference"),
0.0, 255.0, 15.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_SELECT_CRITERION,
"select-criterion", NULL,
GIMP_TYPE_SELECT_CRITERION,
GIMP_SELECT_CRITERION_COMPOSITE,
GIMP_PARAM_STATIC_STRINGS);
}
static void
gimp_region_select_options_init (GimpRegionSelectOptions *options)
{
}
static void
gimp_region_select_options_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpRegionSelectOptions *options = GIMP_REGION_SELECT_OPTIONS (object);
switch (property_id)
{
case PROP_SELECT_TRANSPARENT:
options->select_transparent = g_value_get_boolean (value);
break;
case PROP_SAMPLE_MERGED:
options->sample_merged = g_value_get_boolean (value);
break;
case PROP_THRESHOLD:
options->threshold = g_value_get_double (value);
break;
case PROP_SELECT_CRITERION:
options->select_criterion = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_region_select_options_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpRegionSelectOptions *options = GIMP_REGION_SELECT_OPTIONS (object);
switch (property_id)
{
case PROP_SELECT_TRANSPARENT:
g_value_set_boolean (value, options->select_transparent);
break;
case PROP_SAMPLE_MERGED:
g_value_set_boolean (value, options->sample_merged);
break;
case PROP_THRESHOLD:
g_value_set_double (value, options->threshold);
break;
case PROP_SELECT_CRITERION:
g_value_set_enum (value, options->select_criterion);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_region_select_options_reset (GimpToolOptions *tool_options)
{
GParamSpec *pspec;
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (tool_options),
"threshold");
if (pspec)
G_PARAM_SPEC_DOUBLE (pspec)->default_value =
GIMP_GUI_CONFIG (tool_options->tool_info->gimp->config)->default_threshold;
GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options);
}
GtkWidget *
gimp_region_select_options_gui (GimpToolOptions *tool_options)
{
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_selection_options_gui (tool_options);
GtkWidget *button;
GtkWidget *table;
GtkWidget *combo;
/* the select transparent areas toggle */
button = gimp_prop_check_button_new (config, "select-transparent",
_("Select transparent areas"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* the sample merged toggle */
button = gimp_prop_check_button_new (config, "sample-merged",
_("Sample merged"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* the threshold scale */
table = gtk_table_new (2, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
gimp_prop_scale_entry_new (config, "threshold",
GTK_TABLE (table), 0, 0,
_("Threshold:"),
1.0, 16.0, 1,
FALSE, 0.0, 0.0);
/* the select criterion combo */
combo = gimp_prop_enum_combo_box_new (config, "select-criterion", 0, 0);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Select by:"), 0.0, 0.5,
combo, 2, FALSE);
return vbox;
}

View file

@ -0,0 +1,53 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995-1999 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 __GIMP_REGION_SELECT_OPTIONS_H__
#define __GIMP_REGION_SELECT_OPTIONS_H__
#include "gimpselectionoptions.h"
#define GIMP_TYPE_REGION_SELECT_OPTIONS (gimp_region_select_options_get_type ())
#define GIMP_REGION_SELECT_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_REGION_SELECT_OPTIONS, GimpRegionSelectOptions))
#define GIMP_REGION_SELECT_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_REGION_SELECT_OPTIONS, GimpRegionSelectOptionsClass))
#define GIMP_IS_REGION_SELECT_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_REGION_SELECT_OPTIONS))
#define GIMP_IS_REGION_SELECT_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_REGION_SELECT_OPTIONS))
#define GIMP_REGION_SELECT_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_REGION_SELECT_OPTIONS, GimpRegionSelectOptionsClass))
typedef struct _GimpRegionSelectOptions GimpRegionSelectOptions;
typedef struct _GimpToolOptionsClass GimpRegionSelectOptionsClass;
struct _GimpRegionSelectOptions
{
GimpSelectionOptions parent_instance;
gboolean select_transparent;
gboolean sample_merged;
gdouble threshold;
GimpSelectCriterion select_criterion;
};
GType gimp_region_select_options_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_region_select_options_gui (GimpToolOptions *tool_options);
#endif /* __GIMP_REGION_SELECT_OPTIONS_H__ */

View file

@ -40,8 +40,8 @@
#include "display/gimpdisplayshell-cursor.h"
#include "display/gimpdisplayshell-transform.h"
#include "gimpregionselectoptions.h"
#include "gimpregionselecttool.h"
#include "gimpselectionoptions.h"
#include "gimptoolcontrol.h"
#include "gimp-intl.h"
@ -145,8 +145,8 @@ gimp_region_select_tool_button_press (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpRegionSelectTool *region_sel = GIMP_REGION_SELECT_TOOL (tool);
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GimpRegionSelectTool *region_sel = GIMP_REGION_SELECT_TOOL (tool);
GimpRegionSelectOptions *options = GIMP_REGION_SELECT_TOOL_GET_OPTIONS (tool);
region_sel->x = coords->x;
region_sel->y = coords->y;
@ -176,8 +176,9 @@ gimp_region_select_tool_button_release (GimpTool *tool,
GimpButtonReleaseType release_type,
GimpDisplay *display)
{
GimpRegionSelectTool *region_sel = GIMP_REGION_SELECT_TOOL (tool);
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GimpRegionSelectTool *region_sel = GIMP_REGION_SELECT_TOOL (tool);
GimpSelectionOptions *sel_options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GimpRegionSelectOptions *options = GIMP_REGION_SELECT_TOOL_GET_OPTIONS (tool);
gimp_tool_pop_status (tool, display);
@ -226,10 +227,10 @@ gimp_region_select_tool_button_release (GimpTool *tool,
region_sel->region_mask,
off_x,
off_y,
options->operation,
options->feather,
options->feather_radius,
options->feather_radius);
sel_options->operation,
sel_options->feather,
sel_options->feather_radius,
sel_options->feather_radius);
gimp_image_flush (display->image);
@ -262,12 +263,12 @@ gimp_region_select_tool_motion (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpRegionSelectTool *region_sel = GIMP_REGION_SELECT_TOOL (tool);
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GdkSegment *new_segs;
gint num_new_segs;
gint diff_x, diff_y;
gdouble diff;
GimpRegionSelectTool *region_sel = GIMP_REGION_SELECT_TOOL (tool);
GimpRegionSelectOptions *options = GIMP_REGION_SELECT_TOOL_GET_OPTIONS (tool);
GdkSegment *new_segs;
gint num_new_segs;
gint diff_x, diff_y;
gdouble diff;
static guint32 last_time = 0;
@ -308,8 +309,8 @@ gimp_region_select_tool_cursor_update (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
GimpRegionSelectOptions *options = GIMP_REGION_SELECT_TOOL_GET_OPTIONS (tool);
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
if (! gimp_image_coords_in_active_pickable (display->image, coords,
options->sample_merged, FALSE))
@ -342,13 +343,13 @@ gimp_region_select_tool_calculate (GimpRegionSelectTool *region_sel,
GimpDisplay *display,
gint *num_segs)
{
GimpTool *tool = GIMP_TOOL (region_sel);
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
GimpDrawable *drawable;
GdkSegment *segs;
BoundSeg *bsegs;
PixelRegion maskPR;
GimpTool *tool = GIMP_TOOL (region_sel);
GimpRegionSelectOptions *options = GIMP_REGION_SELECT_TOOL_GET_OPTIONS (tool);
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
GimpDrawable *drawable;
GdkSegment *segs;
BoundSeg *bsegs;
PixelRegion maskPR;
drawable = gimp_image_get_active_drawable (display->image);

View file

@ -32,6 +32,8 @@
#define GIMP_IS_REGION_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_REGION_SELECT_TOOL))
#define GIMP_REGION_SELECT_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_REGION_SELECT_TOOL, GimpRegionSelectToolClass))
#define GIMP_REGION_SELECT_TOOL_GET_OPTIONS(t) (GIMP_REGION_SELECT_OPTIONS (gimp_tool_get_options (GIMP_TOOL (t))))
typedef struct _GimpRegionSelectTool GimpRegionSelectTool;
typedef struct _GimpRegionSelectToolClass GimpRegionSelectToolClass;

View file

@ -34,11 +34,7 @@
#include "widgets/gimpwidgets-utils.h"
#include "gimpforegroundselecttool.h"
#include "gimprectangleselecttool.h"
#include "gimpregionselecttool.h"
#include "gimpiscissorstool.h"
#include "gimpselectionoptions.h"
#include "gimprectangleselectoptions.h"
#include "gimptooloptions-gui.h"
#include "gimp-intl.h"
@ -50,12 +46,7 @@ enum
PROP_OPERATION,
PROP_ANTIALIAS,
PROP_FEATHER,
PROP_FEATHER_RADIUS,
PROP_SELECT_TRANSPARENT,
PROP_SAMPLE_MERGED,
PROP_THRESHOLD,
PROP_SELECT_CRITERION,
PROP_INTERACTIVE
PROP_FEATHER_RADIUS
};
@ -93,46 +84,22 @@ gimp_selection_options_class_init (GimpSelectionOptionsClass *klass)
GIMP_TYPE_CHANNEL_OPS,
GIMP_CHANNEL_OP_REPLACE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_ANTIALIAS,
"antialias",
N_("Smooth edges"),
TRUE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_FEATHER,
"feather", NULL,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_FEATHER_RADIUS,
"feather-radius", NULL,
0.0, 100.0, 10.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SELECT_TRANSPARENT,
"select-transparent",
N_("Allow completely transparent regions "
"to be selected"),
TRUE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAMPLE_MERGED,
"sample-merged",
N_("Base selection on all visible layers"),
FALSE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_THRESHOLD,
"threshold",
N_("Maximum color difference"),
0.0, 255.0, 15.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_SELECT_CRITERION,
"select-criterion", NULL,
GIMP_TYPE_SELECT_CRITERION,
GIMP_SELECT_CRITERION_COMPOSITE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_INTERACTIVE,
"interactive", NULL,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
}
static void
@ -153,33 +120,19 @@ gimp_selection_options_set_property (GObject *object,
case PROP_OPERATION:
options->operation = g_value_get_enum (value);
break;
case PROP_ANTIALIAS:
options->antialias = g_value_get_boolean (value);
break;
case PROP_FEATHER:
options->feather = g_value_get_boolean (value);
break;
case PROP_FEATHER_RADIUS:
options->feather_radius = g_value_get_double (value);
break;
case PROP_SELECT_TRANSPARENT:
options->select_transparent = g_value_get_boolean (value);
break;
case PROP_SAMPLE_MERGED:
options->sample_merged = g_value_get_boolean (value);
break;
case PROP_THRESHOLD:
options->threshold = g_value_get_double (value);
break;
case PROP_SELECT_CRITERION:
options->select_criterion = g_value_get_enum (value);
break;
case PROP_INTERACTIVE:
options->interactive = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -199,33 +152,19 @@ gimp_selection_options_get_property (GObject *object,
case PROP_OPERATION:
g_value_set_enum (value, options->operation);
break;
case PROP_ANTIALIAS:
g_value_set_boolean (value, options->antialias);
break;
case PROP_FEATHER:
g_value_set_boolean (value, options->feather);
break;
case PROP_FEATHER_RADIUS:
g_value_set_double (value, options->feather_radius);
break;
case PROP_SELECT_TRANSPARENT:
g_value_set_boolean (value, options->select_transparent);
break;
case PROP_SAMPLE_MERGED:
g_value_set_boolean (value, options->sample_merged);
break;
case PROP_THRESHOLD:
g_value_set_double (value, options->threshold);
break;
case PROP_SELECT_CRITERION:
g_value_set_enum (value, options->select_criterion);
break;
case PROP_INTERACTIVE:
g_value_set_boolean (value, options->interactive);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -244,13 +183,6 @@ gimp_selection_options_reset (GimpToolOptions *tool_options)
G_PARAM_SPEC_BOOLEAN (pspec)->default_value =
(tool_options->tool_info->tool_type != GIMP_TYPE_FOREGROUND_SELECT_TOOL);
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (tool_options),
"threshold");
if (pspec)
G_PARAM_SPEC_DOUBLE (pspec)->default_value =
GIMP_GUI_CONFIG (tool_options->tool_info->gimp->config)->default_threshold;
GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options);
}
@ -380,53 +312,5 @@ gimp_selection_options_gui (GimpToolOptions *tool_options)
FALSE, 0.0, 0.0);
}
/* selection tool with an interactive boundary that can be toggled */
if (tool_options->tool_info->tool_type == GIMP_TYPE_ISCISSORS_TOOL)
{
button = gimp_prop_check_button_new (config, "interactive",
_("Interactive boundary"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
}
/* selection tools which operate on colors or contiguous regions */
if (g_type_is_a (tool_options->tool_info->tool_type,
GIMP_TYPE_REGION_SELECT_TOOL))
{
GtkWidget *table;
GtkWidget *combo;
/* the select transparent areas toggle */
button = gimp_prop_check_button_new (config, "select-transparent",
_("Select transparent areas"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* the sample merged toggle */
button = gimp_prop_check_button_new (config, "sample-merged",
_("Sample merged"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* the threshold scale */
table = gtk_table_new (2, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
gimp_prop_scale_entry_new (config, "threshold",
GTK_TABLE (table), 0, 0,
_("Threshold:"),
1.0, 16.0, 1,
FALSE, 0.0, 0.0);
/* the select criterion combo */
combo = gimp_prop_enum_combo_box_new (config, "select-criterion", 0, 0);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Select by:"), 0.0, 0.5,
combo, 2, FALSE);
}
return vbox;
}

View file

@ -36,29 +36,15 @@ typedef struct _GimpToolOptionsClass GimpSelectionOptionsClass;
struct _GimpSelectionOptions
{
GimpToolOptions parent_instance;
GimpToolOptions parent_instance;
/* options used by all selection tools */
GimpChannelOps operation;
gboolean antialias;
gboolean feather;
gdouble feather_radius;
/* used by fuzzy, by-color selection */
gboolean select_transparent;
gboolean sample_merged;
gdouble threshold;
GimpSelectCriterion select_criterion;
/* used by rect., ellipse selection */
gboolean auto_shrink;
gboolean shrink_merged;
/* used by iscissors */
gboolean interactive;
GimpChannelOps operation;
gboolean antialias;
gboolean feather;
gdouble feather_radius;
/* options gui */
GtkWidget *antialias_toggle;
GtkWidget *antialias_toggle;
};
@ -67,4 +53,4 @@ GType gimp_selection_options_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_selection_options_gui (GimpToolOptions *tool_options);
#endif /* __GIMP_SELCTION_OPTIONS_H__ */
#endif /* __GIMP_SELECTION_OPTIONS_H__ */

View file

@ -40,7 +40,7 @@
#warning #include "tools/tools-types.h"
#endif
#include "tools/tools-types.h"
#include "tools/gimpselectionoptions.h"
#include "tools/gimpregionselectoptions.h"
#include "gimpselectioneditor.h"
#include "gimpdnd.h"
@ -251,14 +251,15 @@ gimp_selection_view_button_press (GtkWidget *widget,
GdkEventButton *bevent,
GimpSelectionEditor *editor)
{
GimpImageEditor *image_editor = GIMP_IMAGE_EDITOR (editor);
GimpViewRenderer *renderer;
GimpToolInfo *tool_info;
GimpSelectionOptions *options;
GimpDrawable *drawable;
GimpChannelOps operation = GIMP_CHANNEL_OP_REPLACE;
gint x, y;
GimpRGB color;
GimpImageEditor *image_editor = GIMP_IMAGE_EDITOR (editor);
GimpViewRenderer *renderer;
GimpToolInfo *tool_info;
GimpSelectionOptions *sel_options;
GimpRegionSelectOptions *options;
GimpDrawable *drawable;
GimpChannelOps operation = GIMP_CHANNEL_OP_REPLACE;
gint x, y;
GimpRGB color;
if (! image_editor->image)
return TRUE;
@ -271,7 +272,8 @@ gimp_selection_view_button_press (GtkWidget *widget,
if (! tool_info)
return TRUE;
options = GIMP_SELECTION_OPTIONS (tool_info->tool_options);
sel_options = GIMP_SELECTION_OPTIONS (tool_info->tool_options);
options = GIMP_REGION_SELECT_OPTIONS (tool_info->tool_options);
drawable = gimp_image_get_active_drawable (image_editor->image);
@ -311,10 +313,10 @@ gimp_selection_view_button_press (GtkWidget *widget,
options->select_transparent,
options->select_criterion,
operation,
options->antialias,
options->feather,
options->feather_radius,
options->feather_radius);
sel_options->antialias,
sel_options->feather,
sel_options->feather_radius,
sel_options->feather_radius);
gimp_image_flush (image_editor->image);
}
@ -328,10 +330,11 @@ gimp_selection_editor_drop_color (GtkWidget *widget,
const GimpRGB *color,
gpointer data)
{
GimpImageEditor *editor = GIMP_IMAGE_EDITOR (data);
GimpToolInfo *tool_info;
GimpSelectionOptions *options;
GimpDrawable *drawable;
GimpImageEditor *editor = GIMP_IMAGE_EDITOR (data);
GimpToolInfo *tool_info;
GimpSelectionOptions *sel_options;
GimpRegionSelectOptions *options;
GimpDrawable *drawable;
if (! editor->image)
return;
@ -341,7 +344,8 @@ gimp_selection_editor_drop_color (GtkWidget *widget,
if (! tool_info)
return;
options = GIMP_SELECTION_OPTIONS (tool_info->tool_options);
sel_options = GIMP_SELECTION_OPTIONS (tool_info->tool_options);
options = GIMP_REGION_SELECT_OPTIONS (tool_info->tool_options);
drawable = gimp_image_get_active_drawable (editor->image);
@ -355,11 +359,11 @@ gimp_selection_editor_drop_color (GtkWidget *widget,
options->threshold,
options->select_transparent,
options->select_criterion,
options->operation,
options->antialias,
options->feather,
options->feather_radius,
options->feather_radius);
sel_options->operation,
sel_options->antialias,
sel_options->feather,
sel_options->feather_radius,
sel_options->feather_radius);
gimp_image_flush (editor->image);
}