2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2004-10-23 06:28:45 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2004-10-23 06:28:45 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2004-10-23 06:28:45 +08:00
|
|
|
* (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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2004-10-23 06:28:45 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2004-10-23 06:28:45 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
2016-09-25 03:10:07 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2004-10-23 06:28:45 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "dialogs-types.h"
|
|
|
|
|
2017-02-14 05:12:39 +08:00
|
|
|
#include "operations/layer-modes/gimp-layer-modes.h"
|
|
|
|
|
2004-10-23 06:28:45 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2016-05-12 07:49:53 +08:00
|
|
|
#include "core/gimpdrawable-filters.h"
|
2004-10-23 06:28:45 +08:00
|
|
|
#include "core/gimpimage.h"
|
|
|
|
#include "core/gimplayer.h"
|
|
|
|
|
|
|
|
#include "text/gimptext.h"
|
|
|
|
#include "text/gimptextlayer.h"
|
|
|
|
|
2013-04-17 02:29:18 +08:00
|
|
|
#include "widgets/gimpcontainertreeview.h"
|
2017-01-30 20:24:35 +08:00
|
|
|
#include "widgets/gimplayermodebox.h"
|
2016-10-22 04:54:10 +08:00
|
|
|
#include "widgets/gimpspinscale.h"
|
2004-10-23 06:28:45 +08:00
|
|
|
#include "widgets/gimpviewabledialog.h"
|
|
|
|
|
2016-10-26 22:51:56 +08:00
|
|
|
#include "item-options-dialog.h"
|
2004-10-23 06:28:45 +08:00
|
|
|
#include "layer-options-dialog.h"
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2016-09-25 03:10:07 +08:00
|
|
|
typedef struct _LayerOptionsDialog LayerOptionsDialog;
|
|
|
|
|
|
|
|
struct _LayerOptionsDialog
|
|
|
|
{
|
|
|
|
GimpLayer *layer;
|
2017-01-09 06:00:19 +08:00
|
|
|
GimpLayerMode mode;
|
2017-02-13 06:49:26 +08:00
|
|
|
GimpLayerColorSpace blend_space;
|
|
|
|
GimpLayerColorSpace composite_space;
|
|
|
|
GimpLayerCompositeMode composite_mode;
|
2016-10-22 04:54:10 +08:00
|
|
|
gdouble opacity;
|
2016-09-25 03:10:07 +08:00
|
|
|
GimpFillType fill_type;
|
2016-10-24 04:45:08 +08:00
|
|
|
gboolean lock_alpha;
|
|
|
|
gboolean rename_text_layers;
|
2016-09-25 03:10:07 +08:00
|
|
|
GimpLayerOptionsCallback callback;
|
|
|
|
gpointer user_data;
|
|
|
|
|
2017-01-30 20:24:35 +08:00
|
|
|
GtkWidget *mode_box;
|
2017-02-14 05:12:39 +08:00
|
|
|
GtkWidget *blend_space_combo;
|
|
|
|
GtkWidget *composite_space_combo;
|
|
|
|
GtkWidget *composite_mode_combo;
|
2016-09-25 03:10:07 +08:00
|
|
|
GtkWidget *size_se;
|
2016-10-22 04:54:10 +08:00
|
|
|
GtkWidget *offset_se;
|
2016-09-25 03:10:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-10-23 06:28:45 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2017-02-14 05:12:39 +08:00
|
|
|
static void layer_options_dialog_free (LayerOptionsDialog *private);
|
|
|
|
static void layer_options_dialog_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpItem *item,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *item_name,
|
|
|
|
gboolean item_visible,
|
|
|
|
GimpColorTag item_color_tag,
|
|
|
|
gboolean item_lock_content,
|
|
|
|
gboolean item_lock_position,
|
|
|
|
gpointer user_data);
|
2017-02-26 22:42:46 +08:00
|
|
|
static void
|
|
|
|
layer_options_dialog_update_mode_sensitivity (LayerOptionsDialog *private);
|
2017-02-14 05:12:39 +08:00
|
|
|
static void layer_options_dialog_mode_notify (GtkWidget *widget,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
LayerOptionsDialog *private);
|
|
|
|
static void layer_options_dialog_rename_toggled (GtkWidget *widget,
|
|
|
|
LayerOptionsDialog *private);
|
2004-10-23 06:28:45 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2016-09-25 03:10:07 +08:00
|
|
|
GtkWidget *
|
|
|
|
layer_options_dialog_new (GimpImage *image,
|
|
|
|
GimpLayer *layer,
|
|
|
|
GimpContext *context,
|
|
|
|
GtkWidget *parent,
|
|
|
|
const gchar *title,
|
|
|
|
const gchar *role,
|
|
|
|
const gchar *icon_name,
|
|
|
|
const gchar *desc,
|
|
|
|
const gchar *help_id,
|
|
|
|
const gchar *layer_name,
|
2017-01-09 06:00:19 +08:00
|
|
|
GimpLayerMode layer_mode,
|
2017-02-13 06:49:26 +08:00
|
|
|
GimpLayerColorSpace layer_blend_space,
|
|
|
|
GimpLayerColorSpace layer_composite_space,
|
|
|
|
GimpLayerCompositeMode layer_composite_mode,
|
2016-10-22 04:54:10 +08:00
|
|
|
gdouble layer_opacity,
|
2016-09-25 03:10:07 +08:00
|
|
|
GimpFillType layer_fill_type,
|
2016-10-26 22:51:56 +08:00
|
|
|
gboolean layer_visible,
|
2016-10-29 22:50:13 +08:00
|
|
|
GimpColorTag layer_color_tag,
|
2016-10-26 22:51:56 +08:00
|
|
|
gboolean layer_lock_content,
|
|
|
|
gboolean layer_lock_position,
|
|
|
|
gboolean layer_lock_alpha,
|
2016-09-25 03:10:07 +08:00
|
|
|
GimpLayerOptionsCallback callback,
|
|
|
|
gpointer user_data)
|
2004-10-23 06:28:45 +08:00
|
|
|
{
|
2017-02-17 18:20:53 +08:00
|
|
|
LayerOptionsDialog *private;
|
|
|
|
GtkWidget *dialog;
|
2018-05-03 01:12:02 +08:00
|
|
|
GtkWidget *grid;
|
2017-02-17 18:20:53 +08:00
|
|
|
GtkListStore *space_model;
|
|
|
|
GtkWidget *combo;
|
|
|
|
GtkWidget *scale;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkAdjustment *adjustment;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkWidget *button;
|
|
|
|
GimpLayerModeContext mode_context;
|
|
|
|
gdouble xres;
|
|
|
|
gdouble yres;
|
|
|
|
gint row = 0;
|
2004-10-23 06:28:45 +08:00
|
|
|
|
2006-09-01 19:26:54 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
|
|
|
g_return_val_if_fail (layer == NULL || GIMP_IS_LAYER (layer), NULL);
|
2006-10-15 02:15:41 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
2006-09-01 19:26:54 +08:00
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL);
|
|
|
|
|
2016-09-25 03:10:07 +08:00
|
|
|
private = g_slice_new0 (LayerOptionsDialog);
|
2004-10-23 06:28:45 +08:00
|
|
|
|
2016-10-24 04:45:08 +08:00
|
|
|
private->layer = layer;
|
|
|
|
private->mode = layer_mode;
|
2017-02-13 06:49:26 +08:00
|
|
|
private->blend_space = layer_blend_space;
|
|
|
|
private->composite_space = layer_composite_space;
|
|
|
|
private->composite_mode = layer_composite_mode;
|
2016-10-24 04:45:08 +08:00
|
|
|
private->opacity = layer_opacity * 100.0;
|
|
|
|
private->fill_type = layer_fill_type;
|
2016-10-26 22:51:56 +08:00
|
|
|
private->lock_alpha = layer_lock_alpha;
|
2016-10-24 04:45:08 +08:00
|
|
|
private->rename_text_layers = FALSE;
|
|
|
|
private->callback = callback;
|
|
|
|
private->user_data = user_data;
|
2004-10-23 06:28:45 +08:00
|
|
|
|
2016-10-26 22:51:56 +08:00
|
|
|
if (layer && gimp_item_is_text_layer (GIMP_ITEM (layer)))
|
|
|
|
private->rename_text_layers = GIMP_TEXT_LAYER (layer)->auto_rename;
|
|
|
|
|
|
|
|
dialog = item_options_dialog_new (image, GIMP_ITEM (layer), context,
|
|
|
|
parent, title, role,
|
|
|
|
icon_name, desc, help_id,
|
|
|
|
_("Layer _name:"),
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_TOOL_PAINTBRUSH,
|
2016-10-26 22:51:56 +08:00
|
|
|
_("Lock _pixels"),
|
|
|
|
_("Lock position and _size"),
|
|
|
|
layer_name,
|
|
|
|
layer_visible,
|
2016-10-29 22:50:13 +08:00
|
|
|
layer_color_tag,
|
2016-10-26 22:51:56 +08:00
|
|
|
layer_lock_content,
|
|
|
|
layer_lock_position,
|
|
|
|
layer_options_dialog_callback,
|
|
|
|
private);
|
2016-09-25 03:10:07 +08:00
|
|
|
|
|
|
|
g_object_weak_ref (G_OBJECT (dialog),
|
|
|
|
(GWeakNotify) layer_options_dialog_free, private);
|
|
|
|
|
2017-02-17 18:20:53 +08:00
|
|
|
if (! layer || gimp_viewable_get_children (GIMP_VIEWABLE (layer)) == NULL)
|
|
|
|
mode_context = GIMP_LAYER_MODE_CONTEXT_LAYER;
|
|
|
|
else
|
|
|
|
mode_context = GIMP_LAYER_MODE_CONTEXT_GROUP;
|
|
|
|
|
|
|
|
private->mode_box = gimp_layer_mode_box_new (mode_context);
|
2017-01-30 20:24:35 +08:00
|
|
|
item_options_dialog_add_widget (dialog, _("_Mode:"), private->mode_box);
|
|
|
|
gimp_layer_mode_box_set_mode (GIMP_LAYER_MODE_BOX (private->mode_box),
|
|
|
|
private->mode);
|
2007-12-27 01:33:41 +08:00
|
|
|
|
2017-02-14 05:12:39 +08:00
|
|
|
g_signal_connect (private->mode_box, "notify::layer-mode",
|
|
|
|
G_CALLBACK (layer_options_dialog_mode_notify),
|
|
|
|
private);
|
|
|
|
|
|
|
|
space_model =
|
|
|
|
gimp_enum_store_new_with_range (GIMP_TYPE_LAYER_COLOR_SPACE,
|
|
|
|
GIMP_LAYER_COLOR_SPACE_AUTO,
|
|
|
|
GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL);
|
|
|
|
|
|
|
|
private->blend_space_combo = combo =
|
|
|
|
gimp_enum_combo_box_new_with_model (GIMP_ENUM_STORE (space_model));
|
Missing mnemonics on several dialogs
paste as brush, paste as pattern, select to new brush, select to new pattern
fill selection outline, fill path, stroke selection, distort, rounded rectangle
indexed color conversion, merge visible layers, new guide, new guide (by percent)
image properties, newsprint, fractal explorer, sample colorize, new layer
metadata editor (just a button), spyroplus (only common buttons)
2019-09-05 20:44:17 +08:00
|
|
|
item_options_dialog_add_widget (dialog, _("_Blend space:"), combo);
|
2017-02-13 06:49:26 +08:00
|
|
|
gimp_enum_combo_box_set_icon_prefix (GIMP_ENUM_COMBO_BOX (combo),
|
|
|
|
"gimp-layer-color-space");
|
|
|
|
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
|
|
|
private->blend_space,
|
|
|
|
G_CALLBACK (gimp_int_combo_box_get_active),
|
2019-08-08 06:22:15 +08:00
|
|
|
&private->blend_space, NULL);
|
2017-02-13 06:49:26 +08:00
|
|
|
|
2017-02-14 05:12:39 +08:00
|
|
|
private->composite_space_combo = combo =
|
|
|
|
gimp_enum_combo_box_new_with_model (GIMP_ENUM_STORE (space_model));
|
Missing mnemonics on several dialogs
paste as brush, paste as pattern, select to new brush, select to new pattern
fill selection outline, fill path, stroke selection, distort, rounded rectangle
indexed color conversion, merge visible layers, new guide, new guide (by percent)
image properties, newsprint, fractal explorer, sample colorize, new layer
metadata editor (just a button), spyroplus (only common buttons)
2019-09-05 20:44:17 +08:00
|
|
|
item_options_dialog_add_widget (dialog, _("Compos_ite space:"), combo);
|
2017-02-13 06:49:26 +08:00
|
|
|
gimp_enum_combo_box_set_icon_prefix (GIMP_ENUM_COMBO_BOX (combo),
|
|
|
|
"gimp-layer-color-space");
|
|
|
|
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
|
|
|
private->composite_space,
|
|
|
|
G_CALLBACK (gimp_int_combo_box_get_active),
|
2019-08-08 06:22:15 +08:00
|
|
|
&private->composite_space, NULL);
|
2017-02-13 06:49:26 +08:00
|
|
|
|
2017-02-14 05:12:39 +08:00
|
|
|
g_object_unref (space_model);
|
|
|
|
|
|
|
|
private->composite_mode_combo = combo =
|
|
|
|
gimp_enum_combo_box_new (GIMP_TYPE_LAYER_COMPOSITE_MODE);
|
Missing mnemonics on several dialogs
paste as brush, paste as pattern, select to new brush, select to new pattern
fill selection outline, fill path, stroke selection, distort, rounded rectangle
indexed color conversion, merge visible layers, new guide, new guide (by percent)
image properties, newsprint, fractal explorer, sample colorize, new layer
metadata editor (just a button), spyroplus (only common buttons)
2019-09-05 20:44:17 +08:00
|
|
|
item_options_dialog_add_widget (dialog, _("Composite mo_de:"), combo);
|
2017-02-02 07:38:25 +08:00
|
|
|
gimp_enum_combo_box_set_icon_prefix (GIMP_ENUM_COMBO_BOX (combo),
|
|
|
|
"gimp-layer-composite");
|
|
|
|
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
2017-02-13 06:49:26 +08:00
|
|
|
private->composite_mode,
|
2017-02-02 07:38:25 +08:00
|
|
|
G_CALLBACK (gimp_int_combo_box_get_active),
|
2019-08-08 06:22:15 +08:00
|
|
|
&private->composite_mode, NULL);
|
2017-02-02 07:38:25 +08:00
|
|
|
|
2017-02-20 07:54:52 +08:00
|
|
|
/* set the sensitivity of above 3 menus */
|
2017-02-26 22:42:46 +08:00
|
|
|
layer_options_dialog_update_mode_sensitivity (private);
|
2017-02-20 07:54:52 +08:00
|
|
|
|
2018-06-25 00:15:16 +08:00
|
|
|
adjustment = gtk_adjustment_new (private->opacity, 0.0, 100.0,
|
|
|
|
1.0, 10.0, 0.0);
|
2016-10-22 04:54:10 +08:00
|
|
|
scale = gimp_spin_scale_new (adjustment, NULL, 1);
|
2016-10-26 22:51:56 +08:00
|
|
|
item_options_dialog_add_widget (dialog, _("_Opacity:"), scale);
|
2007-12-27 01:33:41 +08:00
|
|
|
|
2016-10-22 04:54:10 +08:00
|
|
|
g_signal_connect (adjustment, "value-changed",
|
|
|
|
G_CALLBACK (gimp_double_adjustment_update),
|
|
|
|
&private->opacity);
|
|
|
|
|
2018-05-03 01:12:02 +08:00
|
|
|
grid = item_options_dialog_get_grid (dialog, &row);
|
2016-10-26 22:51:56 +08:00
|
|
|
|
2016-10-22 04:54:10 +08:00
|
|
|
gimp_image_get_resolution (image, &xres, &yres);
|
|
|
|
|
|
|
|
if (! layer)
|
|
|
|
{
|
2004-10-23 06:28:45 +08:00
|
|
|
/* The size labels */
|
|
|
|
label = gtk_label_new (_("Width:"));
|
2016-09-09 01:11:20 +08:00
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
2018-05-03 01:12:02 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1);
|
2004-10-23 06:28:45 +08:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Height:"));
|
2016-09-09 01:11:20 +08:00
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
2018-05-03 01:12:02 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), label, 0, row + 1, 1, 1);
|
2004-10-23 06:28:45 +08:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* The size sizeentry */
|
2018-06-25 00:15:16 +08:00
|
|
|
adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 0);
|
2019-03-09 20:25:19 +08:00
|
|
|
spinbutton = gimp_spin_button_new (adjustment, 1.0, 2);
|
2014-06-22 04:39:37 +08:00
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2004-10-23 06:28:45 +08:00
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 10);
|
|
|
|
|
2016-09-25 03:10:07 +08:00
|
|
|
private->size_se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a",
|
2004-10-23 06:28:45 +08:00
|
|
|
TRUE, TRUE, FALSE, 10,
|
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
|
|
|
|
2016-09-25 03:10:07 +08:00
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (private->size_se),
|
2004-10-23 06:28:45 +08:00
|
|
|
GTK_SPIN_BUTTON (spinbutton), NULL);
|
2018-05-03 02:23:05 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (private->size_se), spinbutton, 1, 0, 1, 1);
|
2004-10-23 06:28:45 +08:00
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
2018-05-03 01:12:02 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), private->size_se, 1, row, 1, 2);
|
2016-09-25 03:10:07 +08:00
|
|
|
gtk_widget_show (private->size_se);
|
2004-10-23 06:28:45 +08:00
|
|
|
|
2016-09-25 03:10:07 +08:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->size_se),
|
2004-10-23 06:28:45 +08:00
|
|
|
GIMP_UNIT_PIXEL);
|
|
|
|
|
2016-09-25 03:10:07 +08:00
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0,
|
2007-12-27 01:33:41 +08:00
|
|
|
xres, FALSE);
|
2016-09-25 03:10:07 +08:00
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 1,
|
2007-12-27 01:33:41 +08:00
|
|
|
yres, FALSE);
|
2004-10-23 06:28:45 +08:00
|
|
|
|
2016-09-25 03:10:07 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se), 0,
|
2004-10-23 06:28:45 +08:00
|
|
|
GIMP_MIN_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE);
|
2016-09-25 03:10:07 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se), 1,
|
2004-10-23 06:28:45 +08:00
|
|
|
GIMP_MIN_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE);
|
|
|
|
|
2016-09-25 03:10:07 +08:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (private->size_se), 0,
|
2007-12-26 00:21:40 +08:00
|
|
|
0, gimp_image_get_width (image));
|
2016-09-25 03:10:07 +08:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (private->size_se), 1,
|
2007-12-26 00:21:40 +08:00
|
|
|
0, gimp_image_get_height (image));
|
2004-10-23 06:28:45 +08:00
|
|
|
|
2016-09-25 03:10:07 +08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->size_se), 0,
|
2007-12-26 00:21:40 +08:00
|
|
|
gimp_image_get_width (image));
|
2016-09-25 03:10:07 +08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->size_se), 1,
|
2007-12-26 00:21:40 +08:00
|
|
|
gimp_image_get_height (image));
|
2004-10-23 06:28:45 +08:00
|
|
|
|
2016-10-22 04:54:10 +08:00
|
|
|
row += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The offset labels */
|
|
|
|
label = gtk_label_new (_("Offset X:"));
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
2018-05-03 01:12:02 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), label, 0, row, 1, 1);
|
2016-10-22 04:54:10 +08:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Offset Y:"));
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
2018-05-03 01:12:02 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), label, 0, row + 1, 1, 1);
|
2016-10-22 04:54:10 +08:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* The offset sizeentry */
|
2018-06-25 00:15:16 +08:00
|
|
|
adjustment = gtk_adjustment_new (0, 1, 1, 1, 10, 0);
|
2019-03-09 20:25:19 +08:00
|
|
|
spinbutton = gimp_spin_button_new (adjustment, 1.0, 2);
|
2016-10-22 04:54:10 +08:00
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 10);
|
|
|
|
|
|
|
|
private->offset_se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a",
|
|
|
|
TRUE, TRUE, FALSE, 10,
|
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
|
|
|
|
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (private->offset_se),
|
|
|
|
GTK_SPIN_BUTTON (spinbutton), NULL);
|
2018-05-03 02:23:05 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (private->offset_se), spinbutton, 1, 0, 1, 1);
|
2016-10-22 04:54:10 +08:00
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
2018-05-03 01:12:02 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), private->offset_se, 1, row, 1, 2);
|
2016-10-22 04:54:10 +08:00
|
|
|
gtk_widget_show (private->offset_se);
|
|
|
|
|
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->offset_se),
|
|
|
|
GIMP_UNIT_PIXEL);
|
|
|
|
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->offset_se), 0,
|
|
|
|
xres, FALSE);
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->offset_se), 1,
|
|
|
|
yres, FALSE);
|
|
|
|
|
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->offset_se), 0,
|
|
|
|
-GIMP_MAX_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE);
|
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->offset_se), 1,
|
|
|
|
-GIMP_MAX_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE);
|
|
|
|
|
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (private->offset_se), 0,
|
|
|
|
0, gimp_image_get_width (image));
|
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (private->offset_se), 1,
|
|
|
|
0, gimp_image_get_height (image));
|
|
|
|
|
|
|
|
if (layer)
|
|
|
|
{
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->offset_se), 0,
|
|
|
|
gimp_item_get_offset_x (GIMP_ITEM (layer)));
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->offset_se), 1,
|
|
|
|
gimp_item_get_offset_y (GIMP_ITEM (layer)));
|
2004-10-23 06:28:45 +08:00
|
|
|
}
|
|
|
|
else
|
2016-10-22 04:54:10 +08:00
|
|
|
{
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->offset_se), 0, 0);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->offset_se), 1, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
row += 2;
|
|
|
|
|
|
|
|
if (! layer)
|
|
|
|
{
|
|
|
|
/* The fill type */
|
|
|
|
combo = gimp_enum_combo_box_new (GIMP_TYPE_FILL_TYPE);
|
2018-05-03 01:12:02 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++,
|
|
|
|
_("_Fill with:"), 0.0, 0.5,
|
|
|
|
combo, 1);
|
2016-10-22 04:54:10 +08:00
|
|
|
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
|
|
|
private->fill_type,
|
|
|
|
G_CALLBACK (gimp_int_combo_box_get_active),
|
2019-08-08 06:22:15 +08:00
|
|
|
&private->fill_type, NULL);
|
2016-10-22 04:54:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (layer)
|
2004-10-23 06:28:45 +08:00
|
|
|
{
|
2016-10-26 22:51:56 +08:00
|
|
|
GtkWidget *left_vbox = item_options_dialog_get_vbox (dialog);
|
|
|
|
GtkWidget *frame;
|
2013-04-17 02:29:18 +08:00
|
|
|
GimpContainer *filters;
|
|
|
|
GtkWidget *view;
|
|
|
|
|
2016-11-04 23:23:33 +08:00
|
|
|
frame = gimp_frame_new (_("Active Filters"));
|
2016-10-24 04:45:08 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (left_vbox), frame, TRUE, TRUE, 0);
|
2013-04-17 02:29:18 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
filters = gimp_drawable_get_filters (GIMP_DRAWABLE (layer));
|
|
|
|
|
|
|
|
view = gimp_container_tree_view_new (filters, context,
|
|
|
|
GIMP_VIEW_SIZE_SMALL, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), view);
|
|
|
|
gtk_widget_show (view);
|
2004-10-23 06:28:45 +08:00
|
|
|
}
|
|
|
|
|
2016-10-26 22:51:56 +08:00
|
|
|
button = item_options_dialog_get_lock_position (dialog);
|
2016-10-24 04:45:08 +08:00
|
|
|
|
|
|
|
if (private->size_se)
|
|
|
|
g_object_bind_property (G_OBJECT (button), "active",
|
|
|
|
G_OBJECT (private->size_se), "sensitive",
|
|
|
|
G_BINDING_SYNC_CREATE |
|
|
|
|
G_BINDING_INVERT_BOOLEAN);
|
|
|
|
|
|
|
|
g_object_bind_property (G_OBJECT (button), "active",
|
|
|
|
G_OBJECT (private->offset_se), "sensitive",
|
|
|
|
G_BINDING_SYNC_CREATE |
|
|
|
|
G_BINDING_INVERT_BOOLEAN);
|
|
|
|
|
2016-10-26 22:51:56 +08:00
|
|
|
button = item_options_dialog_add_switch (dialog,
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_TRANSPARENCY,
|
2016-10-26 22:51:56 +08:00
|
|
|
_("Lock _alpha"));
|
2016-10-24 04:45:08 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
|
|
|
private->lock_alpha);
|
|
|
|
g_signal_connect (button, "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&private->lock_alpha);
|
|
|
|
|
|
|
|
/* For text layers add a toggle to control "auto-rename" */
|
|
|
|
if (layer && gimp_item_is_text_layer (GIMP_ITEM (layer)))
|
|
|
|
{
|
2016-10-26 22:51:56 +08:00
|
|
|
button = item_options_dialog_add_switch (dialog,
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_TOOL_TEXT,
|
2016-10-26 22:51:56 +08:00
|
|
|
_("Set name from _text"));
|
2016-10-24 04:45:08 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
|
|
|
private->rename_text_layers);
|
|
|
|
g_signal_connect (button, "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&private->rename_text_layers);
|
|
|
|
|
|
|
|
g_signal_connect (button, "toggled",
|
2017-02-14 05:12:39 +08:00
|
|
|
G_CALLBACK (layer_options_dialog_rename_toggled),
|
2016-10-24 04:45:08 +08:00
|
|
|
private);
|
|
|
|
}
|
|
|
|
|
2016-09-25 03:10:07 +08:00
|
|
|
return dialog;
|
2004-10-23 06:28:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2016-10-24 04:45:08 +08:00
|
|
|
static void
|
|
|
|
layer_options_dialog_free (LayerOptionsDialog *private)
|
|
|
|
{
|
|
|
|
g_slice_free (LayerOptionsDialog, private);
|
|
|
|
}
|
|
|
|
|
2016-09-25 03:10:07 +08:00
|
|
|
static void
|
2016-10-29 22:50:13 +08:00
|
|
|
layer_options_dialog_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpItem *item,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *item_name,
|
|
|
|
gboolean item_visible,
|
|
|
|
GimpColorTag item_color_tag,
|
|
|
|
gboolean item_lock_content,
|
|
|
|
gboolean item_lock_position,
|
|
|
|
gpointer user_data)
|
2016-09-25 03:10:07 +08:00
|
|
|
{
|
2016-10-26 22:51:56 +08:00
|
|
|
LayerOptionsDialog *private = user_data;
|
|
|
|
gint width = 0;
|
|
|
|
gint height = 0;
|
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
2016-09-25 03:10:07 +08:00
|
|
|
|
2016-10-28 03:00:14 +08:00
|
|
|
if (private->size_se)
|
2016-10-26 22:51:56 +08:00
|
|
|
{
|
|
|
|
width =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se),
|
2016-10-22 04:54:10 +08:00
|
|
|
0));
|
2016-10-26 22:51:56 +08:00
|
|
|
height =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se),
|
2016-10-22 04:54:10 +08:00
|
|
|
1));
|
2016-09-25 03:10:07 +08:00
|
|
|
}
|
2016-10-26 22:51:56 +08:00
|
|
|
|
|
|
|
offset_x =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->offset_se),
|
|
|
|
0));
|
|
|
|
offset_y =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->offset_se),
|
|
|
|
1));
|
|
|
|
|
|
|
|
private->callback (dialog,
|
|
|
|
image,
|
|
|
|
GIMP_LAYER (item),
|
|
|
|
context,
|
|
|
|
item_name,
|
|
|
|
private->mode,
|
2017-02-13 06:49:26 +08:00
|
|
|
private->blend_space,
|
|
|
|
private->composite_space,
|
|
|
|
private->composite_mode,
|
2016-10-26 22:51:56 +08:00
|
|
|
private->opacity / 100.0,
|
|
|
|
private->fill_type,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
offset_x,
|
|
|
|
offset_y,
|
|
|
|
item_visible,
|
2016-10-29 22:50:13 +08:00
|
|
|
item_color_tag,
|
2016-10-26 22:51:56 +08:00
|
|
|
item_lock_content,
|
|
|
|
item_lock_position,
|
|
|
|
private->lock_alpha,
|
|
|
|
private->rename_text_layers,
|
|
|
|
private->user_data);
|
2016-09-25 03:10:07 +08:00
|
|
|
}
|
|
|
|
|
2017-02-26 22:42:46 +08:00
|
|
|
static void
|
|
|
|
layer_options_dialog_update_mode_sensitivity (LayerOptionsDialog *private)
|
|
|
|
{
|
|
|
|
gboolean mutable;
|
|
|
|
|
|
|
|
mutable = gimp_layer_mode_is_blend_space_mutable (private->mode);
|
|
|
|
gtk_widget_set_sensitive (private->blend_space_combo, mutable);
|
|
|
|
|
|
|
|
mutable = gimp_layer_mode_is_composite_space_mutable (private->mode);
|
|
|
|
gtk_widget_set_sensitive (private->composite_space_combo, mutable);
|
|
|
|
|
|
|
|
mutable = gimp_layer_mode_is_composite_mode_mutable (private->mode);
|
|
|
|
gtk_widget_set_sensitive (private->composite_mode_combo, mutable);
|
|
|
|
}
|
|
|
|
|
2004-10-23 06:28:45 +08:00
|
|
|
static void
|
2017-02-14 05:12:39 +08:00
|
|
|
layer_options_dialog_mode_notify (GtkWidget *widget,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
LayerOptionsDialog *private)
|
|
|
|
{
|
|
|
|
private->mode = gimp_layer_mode_box_get_mode (GIMP_LAYER_MODE_BOX (widget));
|
|
|
|
|
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (private->blend_space_combo),
|
|
|
|
GIMP_LAYER_COLOR_SPACE_AUTO);
|
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (private->composite_space_combo),
|
|
|
|
GIMP_LAYER_COLOR_SPACE_AUTO);
|
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (private->composite_mode_combo),
|
|
|
|
GIMP_LAYER_COMPOSITE_AUTO);
|
2017-02-26 22:42:46 +08:00
|
|
|
|
|
|
|
layer_options_dialog_update_mode_sensitivity (private);
|
2017-02-14 05:12:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
layer_options_dialog_rename_toggled (GtkWidget *widget,
|
|
|
|
LayerOptionsDialog *private)
|
2004-10-23 06:28:45 +08:00
|
|
|
{
|
2008-06-28 23:12:13 +08:00
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) &&
|
2016-09-25 03:10:07 +08:00
|
|
|
gimp_item_is_text_layer (GIMP_ITEM (private->layer)))
|
2004-10-23 06:28:45 +08:00
|
|
|
{
|
2016-09-25 03:10:07 +08:00
|
|
|
GimpTextLayer *text_layer = GIMP_TEXT_LAYER (private->layer);
|
2004-10-23 06:28:45 +08:00
|
|
|
GimpText *text = gimp_text_layer_get_text (text_layer);
|
|
|
|
|
|
|
|
if (text && text->text)
|
|
|
|
{
|
2016-10-26 22:51:56 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *name_entry;
|
|
|
|
gchar *name = gimp_utf8_strtrim (text->text, 30);
|
|
|
|
|
|
|
|
dialog = gtk_widget_get_toplevel (widget);
|
2004-10-23 06:28:45 +08:00
|
|
|
|
2016-10-26 22:51:56 +08:00
|
|
|
name_entry = item_options_dialog_get_name_entry (dialog);
|
|
|
|
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (name_entry), name);
|
2004-10-23 06:28:45 +08:00
|
|
|
|
|
|
|
g_free (name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|