app/tools/gimptransformtool.c app/tools/gimptransformoptions.[ch] take the

2008-03-06  Sven Neumann  <sven@gimp.org>

	* app/tools/gimptransformtool.c
	* app/tools/gimptransformoptions.[ch]
	* app/display/gimpdisplayshell-preview.c: take the preview opacity
	from the transform tool options. Based on a patch from Tom Lechner.
	Closes bug #520690.

svn path=/trunk/; revision=25049
This commit is contained in:
Sven Neumann 2008-03-06 11:54:44 +00:00 committed by Sven Neumann
parent da704ae158
commit b870738a86
5 changed files with 107 additions and 18 deletions

View File

@ -1,3 +1,11 @@
2008-03-06 Sven Neumann <sven@gimp.org>
* app/tools/gimptransformtool.c
* app/tools/gimptransformoptions.[ch]
* app/display/gimpdisplayshell-preview.c: take the preview opacity
from the transform tool options. Based on a patch from Tom Lechner.
Closes bug #520690.
2008-03-06 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-preview.c: don't do the blending

View File

@ -27,7 +27,6 @@
#include "core/gimpchannel.h"
#include "core/gimpdrawable.h"
#include "core/gimplayer.h"
#include "core/gimpimage.h"
#include "base/tile-manager.h"
@ -185,8 +184,16 @@ gimp_display_shell_preview_transform (GimpDisplayShell *shell)
if (! ((z1 * z2 > 0) && (z3 * z4 > 0)))
return;
if (GIMP_IS_LAYER (tool->drawable))
opacity = gimp_layer_get_opacity (GIMP_LAYER (tool->drawable)) * 255.999;
/* take opacity from the tool options */
{
gdouble value;
g_object_get (gimp_tool_get_options (tool),
"preview-opacity", &value,
NULL);
opacity = value * 255.999;
}
mask = NULL;
mask_offx = mask_offy = 0;

View File

@ -48,9 +48,10 @@ enum
PROP_INTERPOLATION,
PROP_CLIP,
PROP_PREVIEW_TYPE,
PROP_PREVIEW_OPACITY,
PROP_GRID_TYPE,
PROP_GRID_SIZE,
PROP_CONSTRAIN
PROP_CONSTRAIN,
};
@ -67,7 +68,11 @@ static void gimp_transform_options_reset (GimpToolOptions *tool_optio
static void gimp_transform_options_preview_notify (GimpTransformOptions *options,
GParamSpec *pspec,
GtkWidget *density_box);
GtkWidget *box);
static void gimp_transform_options_preview_opacity_notify (GimpTransformOptions *options,
GParamSpec *pspec,
GtkWidget *table);
G_DEFINE_TYPE (GimpTransformOptions, gimp_transform_options,
@ -112,6 +117,10 @@ gimp_transform_options_class_init (GimpTransformOptionsClass *klass)
GIMP_TYPE_TRANSFORM_PREVIEW_TYPE,
GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_PREVIEW_OPACITY,
"preview-opacity", NULL,
0.0, 1.0, 1.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_GRID_TYPE,
"grid-type", NULL,
GIMP_TYPE_TRANSFORM_GRID_TYPE,
@ -158,6 +167,9 @@ gimp_transform_options_set_property (GObject *object,
case PROP_PREVIEW_TYPE:
options->preview_type = g_value_get_enum (value);
break;
case PROP_PREVIEW_OPACITY:
options->preview_opacity = g_value_get_double (value);
break;
case PROP_GRID_TYPE:
options->grid_type = g_value_get_enum (value);
break;
@ -198,6 +210,9 @@ gimp_transform_options_get_property (GObject *object,
case PROP_PREVIEW_TYPE:
g_value_set_enum (value, options->preview_type);
break;
case PROP_PREVIEW_OPACITY:
g_value_set_double (value, options->preview_opacity);
break;
case PROP_GRID_TYPE:
g_value_set_enum (value, options->grid_type);
break;
@ -228,6 +243,14 @@ gimp_transform_options_reset (GimpToolOptions *tool_options)
GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options);
}
/**
* gimp_transform_options_gui:
* @tool_options: a #GimpToolOptions
*
* Build the Transform Tool Options.
*
* Return value: a container holding the transform tool options
**/
GtkWidget *
gimp_transform_options_gui (GimpToolOptions *tool_options)
{
@ -239,7 +262,7 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
GtkWidget *frame;
GtkWidget *table;
GtkWidget *combo;
GtkWidget *button;
GtkWidget *preview_box;
const gchar *constrain = NULL;
hbox = gimp_prop_enum_stock_box_new (config, "type", "gimp", 0, 0);
@ -296,22 +319,42 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
gtk_widget_show (combo);
/* the grid type menu */
button = gtk_vbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (frame), button);
gtk_widget_show (button);
preview_box = gtk_vbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (frame), preview_box);
gtk_widget_show (preview_box);
/* the preview opacity scale */
table = gtk_table_new (1, 3, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 1, 2);
gtk_box_pack_start (GTK_BOX (preview_box), table, FALSE, FALSE, 0);
gtk_widget_show (table);
gtk_widget_set_sensitive (table,
options->preview_type ==
GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE ||
options->preview_type ==
GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE_GRID);
g_signal_connect (config, "notify::preview-type",
G_CALLBACK (gimp_transform_options_preview_opacity_notify),
table);
gimp_prop_opacity_entry_new (config, "preview-opacity",
GTK_TABLE (table), 0, 0,
_("Opacity:"));
/* the grid type menu */
combo = gimp_prop_enum_combo_box_new (config, "grid-type", 0, 0);
gtk_box_pack_start (GTK_BOX (button), combo, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (preview_box), combo, FALSE, FALSE, 0);
gtk_widget_show (combo);
/* the grid density scale */
table = gtk_table_new (1, 3, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 1, 2);
gtk_box_pack_start (GTK_BOX (button), table, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (preview_box), table, FALSE, FALSE, 0);
gtk_widget_show (table);
gtk_widget_set_sensitive (button,
gtk_widget_set_sensitive (combo,
options->preview_type ==
GIMP_TRANSFORM_PREVIEW_TYPE_GRID ||
options->preview_type ==
@ -319,7 +362,17 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
g_signal_connect (config, "notify::preview-type",
G_CALLBACK (gimp_transform_options_preview_notify),
button);
combo);
gtk_widget_set_sensitive (table,
options->preview_type ==
GIMP_TRANSFORM_PREVIEW_TYPE_GRID ||
options->preview_type ==
GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE_GRID);
g_signal_connect (config, "notify::preview-type",
G_CALLBACK (gimp_transform_options_preview_notify),
table);
gimp_prop_scale_entry_new (config, "grid-size",
GTK_TABLE (table), 0, 0,
@ -338,8 +391,11 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
if (constrain)
{
gchar *label = g_strdup_printf (constrain,
gimp_get_mod_string (GDK_CONTROL_MASK));
GtkWidget *button;
gchar *label;
label = g_strdup_printf (constrain,
gimp_get_mod_string (GDK_CONTROL_MASK));
button = gimp_prop_check_button_new (config, "constrain", label);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
@ -357,11 +413,24 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
static void
gimp_transform_options_preview_notify (GimpTransformOptions *options,
GParamSpec *pspec,
GtkWidget *density_box)
GtkWidget *box)
{
gtk_widget_set_sensitive (density_box,
gtk_widget_set_sensitive (box,
options->preview_type ==
GIMP_TRANSFORM_PREVIEW_TYPE_GRID ||
options->preview_type ==
GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE_GRID);
}
static void
gimp_transform_options_preview_opacity_notify (GimpTransformOptions *options,
GParamSpec *pspec,
GtkWidget *table)
{
gtk_widget_set_sensitive (table,
options->preview_type ==
GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE ||
options->preview_type ==
GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE_GRID);
}

View File

@ -44,6 +44,7 @@ struct _GimpTransformOptions
gint recursion_level;
gboolean clip;
GimpTransformPreviewType preview_type;
gdouble preview_opacity;
GimpTransformGridType grid_type;
gint grid_size;
gboolean constrain;

View File

@ -280,6 +280,10 @@ gimp_transform_tool_constructor (GType type,
g_signal_connect_object (options, "notify::grid-size",
G_CALLBACK (gimp_transform_tool_notify_preview),
tr_tool, 0);
g_signal_connect_object (tool->tool_info->tool_options,
"notify::preview-opacity",
G_CALLBACK (gimp_transform_tool_notify_preview),
tr_tool, 0);
}
g_signal_connect_object (options, "notify::constrain",