Bug 735895 - Precision Conversion "Dithering" dialog

Remember the convert precision dialog's dithering options in
GimpDialogConfig. Also addresses bug 599573.
This commit is contained in:
Michael Natterer 2016-09-26 17:38:26 +02:00
parent 1ddccf07a6
commit 98232c25a5
8 changed files with 141 additions and 40 deletions

View File

@ -51,6 +51,10 @@ enum
PROP_IMAGE_CONVERT_PROFILE_INTENT,
PROP_IMAGE_CONVERT_PROFILE_BPC,
PROP_IMAGE_CONVERT_PRECISION_LAYER_DITHER_METHOD,
PROP_IMAGE_CONVERT_PRECISION_TEXT_LAYER_DITHER_METHOD,
PROP_IMAGE_CONVERT_PRECISION_CHANNEL_DITHER_METHOD,
PROP_LAYER_NEW_NAME,
PROP_LAYER_NEW_FILL_TYPE,
@ -168,6 +172,33 @@ gimp_dialog_config_class_init (GimpDialogConfigClass *klass)
TRUE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_ENUM (object_class,
PROP_IMAGE_CONVERT_PRECISION_LAYER_DITHER_METHOD,
"image-convert-precision-layer-dither-method",
"Default layer dither type for precision conversion",
IMAGE_CONVERT_PRECISION_LAYER_DITHER_METHOD_BLURB,
GEGL_TYPE_DITHER_METHOD,
GEGL_DITHER_NONE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_ENUM (object_class,
PROP_IMAGE_CONVERT_PRECISION_TEXT_LAYER_DITHER_METHOD,
"image-convert-precision-text-layer-dither-method",
"Default text layer dither type for precision conversion",
IMAGE_CONVERT_PRECISION_TEXT_LAYER_DITHER_METHOD_BLURB,
GEGL_TYPE_DITHER_METHOD,
GEGL_DITHER_NONE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_ENUM (object_class,
PROP_IMAGE_CONVERT_PRECISION_CHANNEL_DITHER_METHOD,
"image-convert-precision-channel-dither-method",
"Default channel dither type for precision conversion",
IMAGE_CONVERT_PRECISION_CHANNEL_DITHER_METHOD_BLURB,
GEGL_TYPE_DITHER_METHOD,
GEGL_DITHER_NONE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_STRING (object_class, PROP_LAYER_NEW_NAME,
"layer-new-name",
"Default new layer name",
@ -447,6 +478,19 @@ gimp_dialog_config_set_property (GObject *object,
config->image_convert_profile_bpc = g_value_get_boolean (value);
break;
case PROP_IMAGE_CONVERT_PRECISION_LAYER_DITHER_METHOD:
config->image_convert_precision_layer_dither_method =
g_value_get_enum (value);
break;
case PROP_IMAGE_CONVERT_PRECISION_TEXT_LAYER_DITHER_METHOD:
config->image_convert_precision_text_layer_dither_method =
g_value_get_enum (value);
break;
case PROP_IMAGE_CONVERT_PRECISION_CHANNEL_DITHER_METHOD:
config->image_convert_precision_channel_dither_method =
g_value_get_enum (value);
break;
case PROP_LAYER_NEW_NAME:
if (config->layer_new_name)
g_free (config->layer_new_name);
@ -577,6 +621,19 @@ gimp_dialog_config_get_property (GObject *object,
g_value_set_boolean (value, config->image_convert_profile_bpc);
break;
case PROP_IMAGE_CONVERT_PRECISION_LAYER_DITHER_METHOD:
g_value_set_enum (value,
config->image_convert_precision_layer_dither_method);
break;
case PROP_IMAGE_CONVERT_PRECISION_TEXT_LAYER_DITHER_METHOD:
g_value_set_enum (value,
config->image_convert_precision_text_layer_dither_method);
break;
case PROP_IMAGE_CONVERT_PRECISION_CHANNEL_DITHER_METHOD:
g_value_set_enum (value,
config->image_convert_precision_channel_dither_method);
break;
case PROP_LAYER_NEW_NAME:
g_value_set_string (value, config->layer_new_name);
break;

View File

@ -49,6 +49,10 @@ struct _GimpDialogConfig
GimpColorRenderingIntent image_convert_profile_intent;
gboolean image_convert_profile_bpc;
GeglDitherMethod image_convert_precision_layer_dither_method;
GeglDitherMethod image_convert_precision_text_layer_dither_method;
GeglDitherMethod image_convert_precision_channel_dither_method;
gchar *layer_new_name;
GimpFillType layer_new_fill_type;

View File

@ -21,6 +21,7 @@
#include "config.h"
#include <gio/gio.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"

View File

@ -427,6 +427,15 @@ _("Sets the default rendering intent for the 'Convert to Color Profile' dialog."
_("Sets the default 'Black Point Compensation' state for the " \
"'Convert to Color Profile' dialog.")
#define IMAGE_CONVERT_PRECISION_LAYER_DITHER_METHOD_BLURB \
_("Sets the default layer dithering method for the 'Convert Precision' dialog.")
#define IMAGE_CONVERT_PRECISION_TEXT_LAYER_DITHER_METHOD_BLURB \
_("Sets the default text layer dithering method for the 'Convert Precision' dialog.")
#define IMAGE_CONVERT_PRECISION_CHANNEL_DITHER_METHOD_BLURB \
_("Sets the default channel dithering method for the 'Convert Precision' dialog.")
#define LAYER_NEW_NAME_BLURB \
_("Sets the default layer name for the 'New Layer' dialog.")

View File

@ -21,6 +21,7 @@
#include "config.h"
#include <gio/gio.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"

View File

@ -23,6 +23,7 @@
#include <string.h>
#include <gio/gio.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"

View File

@ -28,6 +28,8 @@
#include "gegl/gimp-babl.h"
#include "gegl/gimp-gegl-utils.h"
#include "config/gimpdialogconfig.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
@ -47,17 +49,17 @@
typedef struct
{
GtkWidget *dialog;
GtkWidget *dialog;
GimpImage *image;
GimpProgress *progress;
GimpImage *image;
GimpProgress *progress;
GimpComponentType component_type;
gboolean linear;
gint bits;
gint layer_dither_type;
gint text_layer_dither_type;
gint mask_dither_type;
GimpComponentType component_type;
gboolean linear;
gint bits;
GeglDitherMethod layer_dither_method;
GeglDitherMethod text_layer_dither_method;
GeglDitherMethod mask_dither_method;
} ConvertDialog;
@ -67,13 +69,6 @@ static void convert_precision_dialog_response (GtkWidget *widget,
static void convert_precision_dialog_free (ConvertDialog *dialog);
/* defaults */
static gint saved_layer_dither_type = 0;
static gint saved_text_layer_dither_type = 0;
static gint saved_mask_dither_type = 0;
/* public functions */
GtkWidget *
@ -94,7 +89,6 @@ convert_precision_dialog_new (GimpImage *image,
GtkSizeGroup *size_group;
const gchar *enum_desc;
gchar *blurb;
GType dither_type;
const Babl *format;
gint bits;
gboolean linear;
@ -107,8 +101,9 @@ convert_precision_dialog_new (GimpImage *image,
dialog = g_slice_new0 (ConvertDialog);
/* a random format with precision */
format = gimp_babl_format (GIMP_RGB, gimp_babl_precision (component_type,
FALSE), FALSE);
format = gimp_babl_format (GIMP_RGB,
gimp_babl_precision (component_type, FALSE),
FALSE);
bits = (babl_format_get_bytes_per_pixel (format) * 8 /
babl_format_get_n_components (format));
@ -124,9 +119,16 @@ convert_precision_dialog_new (GimpImage *image,
/* gegl:color-reduction only does 16 bits */
if (bits <= 16)
{
dialog->layer_dither_type = saved_layer_dither_type;
dialog->text_layer_dither_type = saved_text_layer_dither_type;
dialog->mask_dither_type = saved_mask_dither_type;
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
dialog->layer_dither_method =
config->image_convert_precision_layer_dither_method;
dialog->text_layer_dither_method =
config->image_convert_precision_text_layer_dither_method;
dialog->mask_dither_method =
config->image_convert_precision_channel_dither_method;
}
gimp_enum_get_value (GIMP_TYPE_COMPONENT_TYPE, component_type,
@ -179,9 +181,6 @@ convert_precision_dialog_new (GimpImage *image,
/* dithering */
dither_type = gimp_gegl_get_op_enum_type ("gegl:color-reduction",
"dither-strategy");
frame = gimp_frame_new (_("Dithering"));
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
@ -207,15 +206,15 @@ convert_precision_dialog_new (GimpImage *image,
gtk_size_group_add_widget (size_group, label);
gtk_widget_show (label);
combo = gimp_enum_combo_box_new (dither_type);
combo = gimp_enum_combo_box_new (GEGL_TYPE_DITHER_METHOD);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
gtk_widget_show (combo);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
dialog->layer_dither_type,
dialog->layer_dither_method,
G_CALLBACK (gimp_int_combo_box_get_active),
&dialog->layer_dither_type);
&dialog->layer_dither_method);
/* text layers */
@ -229,15 +228,15 @@ convert_precision_dialog_new (GimpImage *image,
gtk_size_group_add_widget (size_group, label);
gtk_widget_show (label);
combo = gimp_enum_combo_box_new (dither_type);
combo = gimp_enum_combo_box_new (GEGL_TYPE_DITHER_METHOD);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
gtk_widget_show (combo);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
dialog->text_layer_dither_type,
dialog->text_layer_dither_method,
G_CALLBACK (gimp_int_combo_box_get_active),
&dialog->text_layer_dither_type);
&dialog->text_layer_dither_method);
gimp_help_set_help_data (combo,
_("Dithering text layers will make them uneditable"),
@ -255,15 +254,15 @@ convert_precision_dialog_new (GimpImage *image,
gtk_size_group_add_widget (size_group, label);
gtk_widget_show (label);
combo = gimp_enum_combo_box_new (dither_type);
combo = gimp_enum_combo_box_new (GEGL_TYPE_DITHER_METHOD);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
gtk_widget_show (combo);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
dialog->mask_dither_type,
dialog->mask_dither_method,
G_CALLBACK (gimp_int_combo_box_get_active),
&dialog->mask_dither_type);
&dialog->mask_dither_method);
g_object_unref (size_group);
@ -318,9 +317,9 @@ convert_precision_dialog_response (GtkWidget *widget,
gimp_image_convert_precision (dialog->image,
precision,
dialog->layer_dither_type,
dialog->text_layer_dither_type,
dialog->mask_dither_type,
dialog->layer_dither_method,
dialog->text_layer_dither_method,
dialog->mask_dither_method,
progress);
if (progress)
@ -331,10 +330,18 @@ convert_precision_dialog_response (GtkWidget *widget,
/* gegl:color-reduction only does 16 bits */
if (dialog->bits <= 16)
{
GimpDialogConfig *config =
GIMP_DIALOG_CONFIG (dialog->image->gimp->config);
/* Save defaults for next time */
saved_layer_dither_type = dialog->layer_dither_type;
saved_text_layer_dither_type = dialog->text_layer_dither_type;
saved_mask_dither_type = dialog->mask_dither_type;
g_object_set (config,
"image-convert-precision-layer-dither-method",
dialog->layer_dither_method,
"image-convert-precision-text-layer-dither-method",
dialog->text_layer_dither_method,
"image-convert-precision-channel-dither-method",
dialog->mask_dither_method,
NULL);
}
}

View File

@ -1838,6 +1838,27 @@ prefs_dialog_new (Gimp *gimp,
_("Black point compensation"),
GTK_BOX (vbox2));
/* Convert Precision Dialog */
vbox2 = prefs_frame_new (_("Precision Conversion Dialog"),
GTK_CONTAINER (vbox), FALSE);
table = prefs_table_new (3, GTK_CONTAINER (vbox2));
prefs_enum_combo_box_add (object,
"image-convert-precision-layer-dither-method",
0, 0,
_("Dither layers:"),
GTK_TABLE (table), 0, size_group);
prefs_enum_combo_box_add (object,
"image-convert-precision-text-layer-dither-method",
0, 0,
_("Dither text layers:"),
GTK_TABLE (table), 1, size_group);
prefs_enum_combo_box_add (object,
"image-convert-precision-channel-dither-method",
0, 0,
_("Dither channels/masks:"),
GTK_TABLE (table), 2, size_group);
/* New Layer Dialog */
vbox2 = prefs_frame_new (_("New Layer Dialog"),
GTK_CONTAINER (vbox), FALSE);