Commit b870738a authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

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
parent da704ae1
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> 2008-03-06 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-preview.c: don't do the blending * app/display/gimpdisplayshell-preview.c: don't do the blending
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "core/gimpchannel.h" #include "core/gimpchannel.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimplayer.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "base/tile-manager.h" #include "base/tile-manager.h"
...@@ -185,8 +184,16 @@ gimp_display_shell_preview_transform (GimpDisplayShell *shell) ...@@ -185,8 +184,16 @@ gimp_display_shell_preview_transform (GimpDisplayShell *shell)
if (! ((z1 * z2 > 0) && (z3 * z4 > 0))) if (! ((z1 * z2 > 0) && (z3 * z4 > 0)))
return; return;
if (GIMP_IS_LAYER (tool->drawable)) /* take opacity from the tool options */
opacity = gimp_layer_get_opacity (GIMP_LAYER (tool->drawable)) * 255.999; {
gdouble value;
g_object_get (gimp_tool_get_options (tool),
"preview-opacity", &value,
NULL);
opacity = value * 255.999;
}
mask = NULL; mask = NULL;
mask_offx = mask_offy = 0; mask_offx = mask_offy = 0;
......
...@@ -48,9 +48,10 @@ enum ...@@ -48,9 +48,10 @@ enum
PROP_INTERPOLATION, PROP_INTERPOLATION,
PROP_CLIP, PROP_CLIP,
PROP_PREVIEW_TYPE, PROP_PREVIEW_TYPE,
PROP_PREVIEW_OPACITY,
PROP_GRID_TYPE, PROP_GRID_TYPE,
PROP_GRID_SIZE, PROP_GRID_SIZE,
PROP_CONSTRAIN PROP_CONSTRAIN,
}; };
...@@ -67,7 +68,11 @@ static void gimp_transform_options_reset (GimpToolOptions *tool_optio ...@@ -67,7 +68,11 @@ static void gimp_transform_options_reset (GimpToolOptions *tool_optio
static void gimp_transform_options_preview_notify (GimpTransformOptions *options, static void gimp_transform_options_preview_notify (GimpTransformOptions *options,
GParamSpec *pspec, 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, G_DEFINE_TYPE (GimpTransformOptions, gimp_transform_options,
...@@ -112,6 +117,10 @@ gimp_transform_options_class_init (GimpTransformOptionsClass *klass) ...@@ -112,6 +117,10 @@ gimp_transform_options_class_init (GimpTransformOptionsClass *klass)
GIMP_TYPE_TRANSFORM_PREVIEW_TYPE, GIMP_TYPE_TRANSFORM_PREVIEW_TYPE,
GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE, GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE,
GIMP_PARAM_STATIC_STRINGS); 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, GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_GRID_TYPE,
"grid-type", NULL, "grid-type", NULL,
GIMP_TYPE_TRANSFORM_GRID_TYPE, GIMP_TYPE_TRANSFORM_GRID_TYPE,
...@@ -158,6 +167,9 @@ gimp_transform_options_set_property (GObject *object, ...@@ -158,6 +167,9 @@ gimp_transform_options_set_property (GObject *object,
case PROP_PREVIEW_TYPE: case PROP_PREVIEW_TYPE:
options->preview_type = g_value_get_enum (value); options->preview_type = g_value_get_enum (value);
break; break;
case PROP_PREVIEW_OPACITY:
options->preview_opacity = g_value_get_double (value);
break;
case PROP_GRID_TYPE: case PROP_GRID_TYPE:
options->grid_type = g_value_get_enum (value); options->grid_type = g_value_get_enum (value);
break; break;
...@@ -198,6 +210,9 @@ gimp_transform_options_get_property (GObject *object, ...@@ -198,6 +210,9 @@ gimp_transform_options_get_property (GObject *object,
case PROP_PREVIEW_TYPE: case PROP_PREVIEW_TYPE:
g_value_set_enum (value, options->preview_type); g_value_set_enum (value, options->preview_type);
break; break;
case PROP_PREVIEW_OPACITY:
g_value_set_double (value, options->preview_opacity);
break;
case PROP_GRID_TYPE: case PROP_GRID_TYPE:
g_value_set_enum (value, options->grid_type); g_value_set_enum (value, options->grid_type);
break; break;
...@@ -228,6 +243,14 @@ gimp_transform_options_reset (GimpToolOptions *tool_options) ...@@ -228,6 +243,14 @@ gimp_transform_options_reset (GimpToolOptions *tool_options)
GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (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 * GtkWidget *
gimp_transform_options_gui (GimpToolOptions *tool_options) gimp_transform_options_gui (GimpToolOptions *tool_options)
{ {
...@@ -239,7 +262,7 @@ gimp_transform_options_gui (GimpToolOptions *tool_options) ...@@ -239,7 +262,7 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
GtkWidget *frame; GtkWidget *frame;
GtkWidget *table; GtkWidget *table;
GtkWidget *combo; GtkWidget *combo;
GtkWidget *button; GtkWidget *preview_box;
const gchar *constrain = NULL; const gchar *constrain = NULL;
hbox = gimp_prop_enum_stock_box_new (config, "type", "gimp", 0, 0); hbox = gimp_prop_enum_stock_box_new (config, "type", "gimp", 0, 0);
...@@ -296,22 +319,42 @@ gimp_transform_options_gui (GimpToolOptions *tool_options) ...@@ -296,22 +319,42 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
gtk_widget_show (combo); gtk_widget_show (combo);
/* the grid type menu */ preview_box = gtk_vbox_new (FALSE, 6);
button = gtk_vbox_new (FALSE, 6); gtk_container_add (GTK_CONTAINER (frame), preview_box);
gtk_container_add (GTK_CONTAINER (frame), button); gtk_widget_show (preview_box);
gtk_widget_show (button);
/* 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); 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); gtk_widget_show (combo);
/* the grid density scale */ /* the grid density scale */
table = gtk_table_new (1, 3, FALSE); table = gtk_table_new (1, 3, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 1, 2); 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_show (table);
gtk_widget_set_sensitive (button, gtk_widget_set_sensitive (combo,
options->preview_type == options->preview_type ==
GIMP_TRANSFORM_PREVIEW_TYPE_GRID || GIMP_TRANSFORM_PREVIEW_TYPE_GRID ||
options->preview_type == options->preview_type ==
...@@ -319,7 +362,17 @@ gimp_transform_options_gui (GimpToolOptions *tool_options) ...@@ -319,7 +362,17 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
g_signal_connect (config, "notify::preview-type", g_signal_connect (config, "notify::preview-type",
G_CALLBACK (gimp_transform_options_preview_notify), 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", gimp_prop_scale_entry_new (config, "grid-size",
GTK_TABLE (table), 0, 0, GTK_TABLE (table), 0, 0,
...@@ -338,7 +391,10 @@ gimp_transform_options_gui (GimpToolOptions *tool_options) ...@@ -338,7 +391,10 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
if (constrain) if (constrain)
{ {
gchar *label = g_strdup_printf (constrain, GtkWidget *button;
gchar *label;
label = g_strdup_printf (constrain,
gimp_get_mod_string (GDK_CONTROL_MASK)); gimp_get_mod_string (GDK_CONTROL_MASK));
button = gimp_prop_check_button_new (config, "constrain", label); button = gimp_prop_check_button_new (config, "constrain", label);
...@@ -357,11 +413,24 @@ gimp_transform_options_gui (GimpToolOptions *tool_options) ...@@ -357,11 +413,24 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
static void static void
gimp_transform_options_preview_notify (GimpTransformOptions *options, gimp_transform_options_preview_notify (GimpTransformOptions *options,
GParamSpec *pspec, GParamSpec *pspec,
GtkWidget *density_box) GtkWidget *box)
{ {
gtk_widget_set_sensitive (density_box, gtk_widget_set_sensitive (box,
options->preview_type == options->preview_type ==
GIMP_TRANSFORM_PREVIEW_TYPE_GRID || GIMP_TRANSFORM_PREVIEW_TYPE_GRID ||
options->preview_type == options->preview_type ==
GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE_GRID); 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);
}
...@@ -44,6 +44,7 @@ struct _GimpTransformOptions ...@@ -44,6 +44,7 @@ struct _GimpTransformOptions
gint recursion_level; gint recursion_level;
gboolean clip; gboolean clip;
GimpTransformPreviewType preview_type; GimpTransformPreviewType preview_type;
gdouble preview_opacity;
GimpTransformGridType grid_type; GimpTransformGridType grid_type;
gint grid_size; gint grid_size;
gboolean constrain; gboolean constrain;
......
...@@ -280,6 +280,10 @@ gimp_transform_tool_constructor (GType type, ...@@ -280,6 +280,10 @@ gimp_transform_tool_constructor (GType type,
g_signal_connect_object (options, "notify::grid-size", g_signal_connect_object (options, "notify::grid-size",
G_CALLBACK (gimp_transform_tool_notify_preview), G_CALLBACK (gimp_transform_tool_notify_preview),
tr_tool, 0); 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", g_signal_connect_object (options, "notify::constrain",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment